loulijun2021
2023-06-08 b77c699b4eb75980bcabba89018fdd3dd9ce91b4
1.递交
已修改1个文件
208 ■■■■■ 文件已修改
src/views/produceManager/productWarehouse.vue 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/produceManager/productWarehouse.vue
@@ -19,9 +19,9 @@
          <div style="font-size: 14px;margin-left: 5px;color: #a7a7a7">
            查询项
          </div>
          <div v-if="!isPermission" style="font-size: 14px;margin-left: 10px;color: red">
            当前用户在ERP系统中不存在或未授权,无法入库提交
          </div>
          <!--          <div v-if="!isPermission" style="font-size: 14px;margin-left: 10px;color: red">-->
          <!--            当前用户在ERP系统中不存在或未授权,无法入库提交-->
          <!--          </div>-->
        </div>
        <el-form
          ref="form"
@@ -745,7 +745,7 @@
      tableDataSummary: [], // 汇总表
      isPermission: true, // 是否有权限可提交
      // isPermission: true, // 是否有权限可提交
      userArr: [] // ERP人员数组
@@ -761,10 +761,7 @@
    this.getWareHouseSelect()
    this.getWorkShopSelect()
    this.getProductInHouseOrderCodeSearch()
    // this.getProductInHouseOrderSearch()
  },
  methods: {
    async getProductInHouseOrderCodeSearch() {
@@ -776,19 +773,13 @@
      const { data: res } = await ErpUserSelect()
      this.userArr = res
      if (!res.map(i => i.name).includes(getCookie('username'))) {
        this.isPermission = false
        await this.$alert('当前用户在ERP系统中不存在或未授权,无法入库提交', '提示', {
          confirmButtonText: '确定'
          // callback: action => {
          //   this.$message({
          //     type: 'info',
          //     message: `action: ${action}`
      // if (!res.map(i => i.name).includes(getCookie('username'))) {
      //   this.isPermission = false
      //
      //   await this.$alert('当前用户在ERP系统中不存在或未授权,无法入库提交', '提示', {
      //     confirmButtonText: '确定'
          //   })
          // }
        })
      }
    },
    // 单据类型改变
@@ -881,10 +872,6 @@
          this.tabClickIndex = row.index
          this.tabClickLabel = column.label
          break
        // case '判责金额(元)':
        //   this.tabClickIndex = row.index
        //   this.tabClickLabel = column.label
        //   break
        default:
          return
      }
@@ -907,66 +894,8 @@
    // tab点击
    tabClick(val) {
      // this.$nextTick(() => {
      //   this.$refs.tableDataRef.doLayout()
      // })
      // const stockcodeArr = [...new Set(this.multipleSelection.map(i => i.stockcode))]// 数组去重
      const partcodeArr = [...new Set(this.multipleSelection.map(i => i.partcode))]// 数组去重
      const newData = []
      // const Array2D = []
      //
      // stockcodeArr.forEach(i => {
      //   Array2D.push(this.multipleSelection.filter(j => j.stockcode === i))
      // })
      // Array2D.forEach(k => {
      //   const partcodeArr = [...new Set(k.map(j => j.partcode))]
      //   partcodeArr.forEach(i => {
      //     const t = k.find(j => j.partcode === i)
      //     let sum = 0
      //     const good_qty = k.filter(j => j.partcode === i).map(j => parseFloat(j.good_qty)).reduce((pre, curr) => {
      //       sum = pre + curr
      //       return sum
      //     })
      //     sum = 0
      //     const inhouseqty = k.filter(j => j.partcode === i).map(j => parseFloat(j.inhouseqty)).reduce((pre, curr) => {
      //       sum = pre + curr
      //       return sum
      //     })
      //     sum = 0
      //     const stinhouseqty = k.filter(j => j.partcode === i).map(j => parseFloat(j.stinhouseqty)).reduce((pre, curr) => {
      //       sum = pre + curr
      //       return sum
      //     })
      //     newData.push(
      //       {
      //         stockcode: t.stockcode,
      //         partcode: t.partcode,
      //         partname: t.partname,
      //         partspec: t.partspec,
      //         qty: t.qty,
      //         good_qty,
      //         inhouseqty,
      //         stinhouseqty,
      //         unitid: t.unitid,
      //         unitname: t.unitname,
      //         sourceVoucherDetailId: t.sbid,
      //         saleOrderDetailId: t.saleOrderDetailId,
      //         ManufactureOrderDetailId: t.sbid,
      //         stck_id: this.stockcodeArr.find(i => i.code === t.stockcode).id,
      //         SourceVoucherDetailIdByMergedFlow: t.sbid,
      //         materiel_code: t.partcode,
      //         warehouse: t.stockcode,
      //         materiel_id: t.materiel_id
      //       }
      //     )
      //   })
      // })
      // console.log(Array2D, 'Array2D')
      // console.log(newData, 'newData')
      partcodeArr.forEach(i => {
        const t = this.multipleSelection.find(j => j.partcode === i)
@@ -987,14 +916,6 @@
        })
        newData.push(
          {
            // partcode: i,
            // partname: t.partname,
            // partspec: t.partspec,
            // qty: t.qty,
            // good_qty,
            // inhouseqty,
            // stinhouseqty
            stockcode: t.stockcode,
            partcode: t.partcode,
            partname: t.partname,
@@ -1008,7 +929,7 @@
            sourceVoucherDetailId: t.sbid,
            saleOrderDetailId: t.saleOrderDetailId,
            ManufactureOrderDetailId: t.sbid,
            stck_id: t.stockcode ? this.stockcodeArr.find(i => i.code === t.stockcode).id : '/',
            stck_id: t.stockcode ? this.stockcodeArr.find(i => i.code === t.stockcode).id : '',
            SourceVoucherDetailIdByMergedFlow: t.sbid,
            materiel_code: t.partcode,
            warehouse: t.stockcode,
@@ -1017,7 +938,6 @@
          }
        )
      })
      // this.tableDataSummary = newData.flat()
      this.tableDataSummary = newData
    },
@@ -1032,8 +952,6 @@
      this.$store.state.app.buttonIsDisabled = true
      await this.tabClick()
      const openToken = await getTPlusToken() // 获取TPlus   token
      // const openToken =
      // 有源单
      if (this.form.documentType === 'Y') {
@@ -1166,13 +1084,13 @@
          const r1 = await ProductInHouseOrderSeave(data)
          if (r1.code === '200') {
            this.$message.success('入库成功!')
            this.$store.state.app.buttonIsDisabled = false
            await this.getProductInHouseOrderCodeSearch()
            await this.wkshopcodeChange(this.form.wkshopcode)
            this.tableDataDetail = []
            this.tableDataSummary = []
            this.multipleSelection = []
            this.form.stockcode = ''
            this.$store.state.app.buttonIsDisabled = false
          }
        } else {
          this.$message.error('入库失败!')
@@ -1243,7 +1161,7 @@
            hbillno: this.form.hbillno,
            incbit: this.form.incbit,
            wkshpcode: this.form.wkshopcode,
            sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : this.tableDataDetail[0].wo_id, // 下午把这个参数加上
            sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : this.tableDataDetail[0].wo_id,
            sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
            saleOrderId: this.tableDataDetail[0].saleOrderid,
            saleOrderCode: this.tableDataDetail[0].saleOrderCode,
@@ -1277,7 +1195,6 @@
              compositionQuantity: i.stinhouseqty + i.unitname,
              baseQuantity: i.stinhouseqty,
              sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
              // sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
              sourceVoucherCode: '',
              sourceVoucherDetailId: i.sourceVoucherDetailId,
              idsourcevouchertype: 69,
@@ -1310,7 +1227,6 @@
          const r1 = await ProductInHouseOrderSeave(data)
          if (r1.code === '200') {
            this.$message.success('入库成功!')
            this.$store.state.app.buttonIsDisabled = false
            await this.getProductInHouseOrderCodeSearch()
            await this.wkshopcodeChange(this.form.wkshopcode)
            this.tableDataDetail = []
@@ -1324,106 +1240,6 @@
          this.$store.state.app.buttonIsDisabled = false
        }
      }
    },
    // 入库提交
    submit2() {
      this.tabClick()
      this.$confirm('是否确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.multipleSelection.length === 0) {
          return this.$message.error('未选择产品!')
        }
        if (this.multipleSelection.find(i => !i.stockcode)) {
          return this.$message.error('明细里面有产品未填写仓库!')
        }
        this.multipleSelection.forEach(i => {
          i.stockname = this.stockcodeArr.find(j => j.code === i.stockcode).name
          i.id = this.stockcodeArr.find(j => j.code === i.stockcode).id
        })
        const head = {
          rightcode: '2064',
          hbillno: this.form.hbillno,
          incbit: this.form.incbit,
          wkshpcode: this.form.wkshopcode,
          sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
          sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
          saleOrderId: this.tableDataDetail[0].saleOrderid,
          saleOrderCode: this.tableDataDetail[0].saleOrderCode,
          rdDirectionFlag: 1,
          makerid: this.userArr.find(i => i.name === getCookie('username')).id,
          maker: getCookie('username'),
          accountingyear: new Date().getFullYear(),
          VoucherYear: new Date().getFullYear(),
          VoucherPeriod: new Date().getMonth() + 1,
          ManufactureOrderCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
          idbusitype: '03',
          iddepartment: this.WorkShopArr.find(i => i.code === this.form.wkshopcode).id,
          idrdstyle: 21,
          idwarehouse: '',
          voucherState: 181,
          idvouchertype: 15,
          voucherdate: handleDatetime(new Date().getTime()),
          madedate: handleDatetime(new Date().getTime()),
          createdtime: handleDatetime2(new Date().getTime()),
          DataSource: '56133',
          idsourcevouchertype: 69
        }
        const subsum = []
        this.tableDataSummary.forEach((i, index) => {
          subsum.push({
            code: index.toString().padStart(4, '0'),
            rownumber: index + 1,
            arrivalQuantity: i.qty,
            quantity: i.stinhouseqty,
            compositionQuantity: i.stinhouseqty + i.unitname,
            baseQuantity: i.stinhouseqty,
            sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
            sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
            sourceVoucherDetailId: i.sourceVoucherDetailId,
            idsourcevouchertype: 69,
            saleOrderId: this.tableDataDetail[0].saleOrderid,
            saleOrderCode: this.tableDataDetail[0].saleOrderCode,
            saleOrderDetailId: i.saleOrderDetailId,
            ManufactureOrderId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
            ManufactureOrderCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
            ManufactureOrderDetailId: i.ManufactureOrderDetailId,
            idbusiTypeByMergedFlow: 3,
            idinventory: i.materiel_id,
            idbaseunit: i.unitid,
            idunit: i.unitid,
            idwarehouse: i.stck_id,
            SourceVoucherIdByMergedFlow: this.tableDataDetail[0].mpoid,
            SourceVoucherCodeByMergedFlow: this.tableDataDetail[0].m_po,
            SourceVoucherDetailIdByMergedFlow: i.SourceVoucherDetailIdByMergedFlow,
            idsourceVoucherTypeByMergedFlow: 69,
            createdtime: handleDatetime2(new Date().getTime()),
            DataSource: '56133',
            materiel_code: i.materiel_code,
            warehouse: i.warehouse
          })
        })
        const data = {
          head, sub: this.multipleSelection, subsum
        }
        ProductInHouseOrderSeave(data).then(res => {
          if (res.code === '200') {
            this.$message.success('入库提交成功!')
            this.getProductInHouseOrderCodeSearch()
            this.wkshopcodeChange(this.form.wkshopcode)
            this.tableDataDetail = []
            this.tableDataSummary = []
            this.multipleSelection = []
          }
        })
      })
    },
    // 获取页面高度
    getHeight() {