charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/reportForm/inboundOutboundDetail/index.vue
@@ -4,33 +4,78 @@
      <SearchCommonView
        :add-title="'新建'"
        :showAdd="false"
        :placeholder="'请输入参考'"
        :placeholder="'请根据单号、产品、业务类型进行搜索'"
        :amount-view="false"
        :inputName="params.keyWord"
        :showDownload="true"
        @downloadClick="downHttpClick"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
      />
    </div>
    <div class="list-view">
      <TableCommonView
        ref="tableListRef"
        :table-list="tableList"
        @selTableCol="selTableCol"
        @tableRowClick="tableRowClick"
      ></TableCommonView>
      <div class="table">
        <TableCommonView
          ref="tableListRef"
          :table-list="tableList"
          @selTableCol="selTableCol"
          @tableRowClick="tableRowClick"
        >
          <template slot="tableButton">
            <el-table-column label="数量" prop='amount'>
              <el-table-column v-for="unit in unitList" :label="unit.name" prop='amount' min="90">
                <template slot-scope="scope">
                  {{getUnitValue(scope.row.amountMoreUnits,unit.name,scope.row.amount,scope.row.unit)}}
                </template>
              </el-table-column>
              <!--<el-table-column label="件" prop='amount' min="90">
                <template slot-scope="scope">
                  {{getUnitValue(scope.row.amountMoreUnits,'件',scope.row.amount,scope.row.unit)}}
                </template>
              </el-table-column>
              <el-table-column label="匹" prop='amount' min="90">
                <template slot-scope="scope">
                  {{getUnitValue(scope.row.amountMoreUnits,'匹',scope.row.amount,scope.row.unit)}}
                </template>
              </el-table-column>
              <el-table-column label="米数" prop='amount' min="90">
                <template slot-scope="scope">
                  {{getUnitValue(scope.row.amountMoreUnits,'米数',scope.row.amount,scope.row.unit)}}
                </template>
              </el-table-column>
              <el-table-column label="重量" prop='amount' min="90">
                <template slot-scope="scope">
                  {{getUnitValue(scope.row.beginMoreUnitsArr,'重量',scope.row.beginAmount,scope.row.unit)}}
                </template>
              </el-table-column>-->
          </el-table-column>
          </template>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    <!-- 编辑 -->
    <AddOverviewDialog v-if="editConfig.visible" :edit-common-config="editConfig" :add-name="this.$route.params.name" />
    <!-- 查看/编辑 -->
    <AddOverviewDialog
      v-if="editConfig.visible"
      :edit-common-config="editConfig"
      :add-name="this.$route.params.name"
    />
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getProductOperatonList } from "@/api/product/product"
import AddOverviewDialog from "@/views/overview/AddOverviewDialog"
import { getHistory,getOperationInfo } from "@/api/reportForm/inventoryRwport"
// import { getProductOperatonList } from "@/api/product/product"
import AddOverviewDialog from "@/views/overview/AddOverviewDialog"
import { getDataByType } from "@/api/data"
import { downloadHistory } from "@/api/downFile"
import FileSaver from 'file-saver'
import _ from 'lodash'
import { getUnitInfo } from "@/api/basic/standard";
export default {
  name: "InboundOutboundDetail",
  props: {},
@@ -39,6 +84,7 @@
  computed: {},
  data() {
    return {
        unitList:[],
      tableList: {},
      showcol: ["状态"],
      searchOptions: [],
@@ -52,15 +98,68 @@
        title: "新建",
        infomation: {}
      },
      productId: this.$route.params.id,
      productName: this.$route.params.name
      params: {},
      baseOperationTypeList:getDataByType("baseOperationTypeTwo"),
    }
  },
  created() {
    this.setTable()
    this.getData()
    console.log(this.$route.params)
    var paramsList = sessionStorage.getItem("paramsList")
    let params = {}
    if (paramsList) {
      params = JSON.parse(sessionStorage.getItem("paramsList"))
    } else {
      params = this.$route.params
      sessionStorage.setItem("paramsList", JSON.stringify(params))
    }
    this.params = params
    console.log(this.params,'====111')
    this.getData();
      this.getUnitInfo();
  },
  // 页面销毁之前
  beforeDestroy() {
    sessionStorage.removeItem("paramsList")
  },
  methods: {
      async getUnitInfo(){
          const { code,data }=await getUnitInfo();
          if(code===200){
              this.unitList=data;
          }
      },
      getUnitValue(list,val,num,unit){
          let  string='--'
          if(list){
              if(list.length>0){
                  for(let i in list){
                      if(list[i].unit==val){
                          string=list[i].amount
                          break;
                      }
                  }
              }
          }
          if(unit==val){
              string=num
          }
          return string
      },
     // 下载
     downHttpClick: _.debounce(function(){
      downloadHistory({
        keyWord:this.params.keyWord,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize,
          baseOperationType:1
      }).then(res => {
        if (res) {
          FileSaver.saveAs(res, '入库明细报表.xlsx');
          this.$message.success("下载成功!");
        }
      })
    }, 1000),
    setTable() {
      this.tableList = {
        tableInfomation: [],
@@ -82,10 +181,10 @@
      let tableColumn = [
        {
          label: "日期",
          prop: "operationDate",
          prop: "date",
          isShowColumn: true,
          default: true,
          date: true
          // date: true
        },
        {
          label: "单号",
@@ -100,18 +199,32 @@
          default: true
        },
        {
          label: "产品编码",
          prop: "productId",
          isShowColumn: true,
          default: true
        },
        {
          label: "业务类型",
          prop: "operationTypeName",
          isShowColumn: true,
          default: true,
          // conversion: true,
          // getStatus: this.getBaseOperationTypeList
        },
        {
          label: "从",
          prop: "from",
          prop: "fromLocation",
          isShowColumn: true,
          default: true
        },
        {
          label: "至",
          prop: "to",
          prop: "toLocation",
          isShowColumn: true,
          default: true
        },
        {
        /*{
          label: "数量",
          prop: "amount",
          isShowColumn: true,
@@ -120,6 +233,12 @@
        {
          label: "单位",
          prop: "unit",
          isShowColumn: true,
          default: true
        },*/
        {
          label: "重量",
          prop: "weight",
          isShowColumn: true,
          default: true
        },
@@ -135,7 +254,7 @@
        },
        {
          label: "完成者",
          prop: "admin",
          prop: "contactedName",
          isShowColumn: showcol.includes("完成者"),
          default: false
        }
@@ -146,65 +265,102 @@
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 请求数据
    async getData() {
      await getProductOperatonList({
        productId: this.productId,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        if (res.code === 200) {
          const list = res.data.map((item) => {
            return {
              ...item,
              from: item.fromLocation.name,
              to: item.toLocation.name,
              productName: this.productName
            }
          })
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.total
    getBaseOperationTypeList(val){
      let string = "--"
      if (val) {
        for (let i in this.baseOperationTypeList) {
          if (this.baseOperationTypeList[i].id == val) {
            return this.baseOperationTypeList[i].name
          }
        }
      })
      }
      return string
    },
    // 库存报表跳转请求数据
    async getData() {
      if (this.params.name === "报表") {
        await getHistory({
          keyWord:this.params.keyWord,
          produceId:this.params.produceId,
          unit:this.params.unit,
          productName:this.params.productName,
          page: this.pagerOptions.currPage,
          pageSize: this.pagerOptions.pageSize
        }).then((res) => {
          if (res.code === 200&&res.data) {
            res.data.map((item)=>{
                let dateObject = new Date(item.date);
                let formattedDateString = dateObject.toISOString().split('T')[0];
                item.date=formattedDateString
            })
            this.tableList.tableInfomation = res.data||[]
          }else{
            this.tableList.tableInfomation = res.data||[]
          }
          this.pagerOptions.totalCount = res.total
        })
      } else {
        await getHistory({
          baseOperationType:1,
          keyWord:this.params.keyWord,
          page: this.pagerOptions.currPage,
          pageSize: this.pagerOptions.pageSize
        }).then((res) => {
          if (res.code === 200&&res.data) {
            res.data.map((item)=>{
                if(item.status===""){
                  item.status=4
                }
                let dateObject = new Date(item.date);
                let formattedDateString = dateObject.toISOString().split('T')[0];
                item.date=formattedDateString
            })
            this.tableList.tableInfomation = res.data||[]
          }else{
            this.tableList.tableInfomation = res.data||[]
          }
          this.pagerOptions.totalCount = res.total
        })
      }
    },
    // 搜索
    getList(val) {
      console.log(val)
      this.params.keyWord=val;
      this.getData()
    },
    // 行点击
    tableRowClick(row) {
      console.log(row)
    async tableRowClick(row) {
      console.log(row,"看看row")
      // window.sessionStorage.sessionStorage.setItem('paramsData', {
      //   // name: "拼夕夕仓库-出库",
      //   workType: row.baseOperationType,
      //   id: row.operationId,
      //   // code: "PX"
      // });
      await getOperationInfo(row.operationId).then((res)=>{
          res.data.location=res.data.toLocation.id;
          res.data.toLocation=res.data.toLocation.id;
        res.data.details.forEach(item=>{
            item.toLocationId=item.toLocation.name;
        })
        this.editConfig.infomation = { ...res.data,workType:res.baseOperationType }
      })
      this.editConfig.visible = true
      this.editConfig.title = "查看"
      this.editConfig.infomation = { ...row }
    },
    // 新建
    addBtnClick() {
      this.editConfig.visible = true
      // this.editConfig.visible = true
      this.editConfig.title = "新建"
    },
    // 状态
    getStatus(val) {
      return val === 1 ? "草稿" : val === 3 ? "就绪" : "完成"
      return val === 1 ? "草稿" : val === 3 ? "就绪" : val===4?"完成":val===5?"已取消":" "
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
// .rightContent {
//   height: 100%;
//   background: #e6ecf2;
//   padding: 10px;
//   .top {
//     margin-bottom: 20px;
//     height: 60px;
//     background: #fff;
//     border-radius: 8px;
//   }
//   .list-view {
//     height: calc(100% - 120px);
//   }
// }
</style>
<style lang="scss" scoped></style>