小小儁爺
2025-10-31 b195295f2007d52f4a22e679f8ca591b042de27a
src/views/produce/productWarehouse.vue
@@ -32,6 +32,21 @@
        >
          <div class="elForm" style="display: flex;flex-direction: column;justify-content: flex-start">
            <div style="display: flex">
              <el-form-item label="单据类型" required style=" display: flex;">
                <el-select
                  v-model="form.issouceorder"
                  :popper-append-to-body="false"
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in issouceorderTypeArr"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="生产车间" required style=" display: flex;">
                <el-select
                  v-model="form.wkshopcode"
@@ -69,6 +84,10 @@
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                />
              </el-form-item>
            </div>
            <div style="display: flex">
              <el-form-item
                label="销售订单"
                style="display: flex;"
@@ -79,17 +98,26 @@
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                />
              </el-form-item>
            </div>
            <div style="display: flex">
              <el-form-item label="产品编码" style=" display: flex;">
                <el-input v-model="form.partcode" placeholder="请输入" :style="{minWidth:'100px',width:formItemWidth+'px'}" />
                <el-input
                  v-model="form.partcode"
                  placeholder="请输入"
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                />
              </el-form-item>
              <el-form-item label="产品名称" style=" display: flex;">
                <el-input v-model="form.partname" :style="{minWidth:'100px',width:formItemWidth+'px'}" placeholder="请输入" />
                <el-input
                  v-model="form.partname"
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                  placeholder="请输入"
                />
              </el-form-item>
              <el-form-item label="产品规格" style=" display: flex;">
                <el-input v-model="form.partspec" :style="{minWidth:'100px',width:formItemWidth+'px'}" placeholder="请输入" />
                <el-input
                  v-model="form.partspec"
                  :style="{minWidth:'100px',width:formItemWidth+'px'}"
                  placeholder="请输入"
                />
              </el-form-item>
            </div>
@@ -221,30 +249,15 @@
                  highlight-current-row
                  :header-cell-style="this.$headerCellStyle"
                  :cell-style="this.$cellStyle"
                  @row-click="rowClick"
                  @selection-change="handleSelectionChange"
                >
                  <!--                  @selection-change="handleSelectionChange"-->
                  <!--                  @cell-dblclick="cellDblclick"-->
                  <!--                  @cell-click="cellClick"-->
                  <!--                  <el-table-column-->
                  <!--                    type="selection"-->
                  <!--                    width="50"-->
                  <!--                    fixed-->
                  <!--                  />-->
                  <el-table-column
                    type="selection"
                    width="50"
                    fixed
                  >
                    <template slot-scope="{row}">
                      <el-radio
                        v-model="radioSelected"
                        :label="row.sbid"
                        style="color: transparent;padding-left: 10px;"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    type="index"
                    width="50"
@@ -585,8 +598,10 @@
import { PrentOrganizationNoCompany, WareHouse } from '@/api/GeneralBasicData'
import {
  DeptSelectData,
  ProductInHouseOrderCodeSearch,
  ProductInHouseOrderSearch, TProductInHouseOrderSpSeave
  ProductInHouseOrderSearch,
  InHouseOrderSpSeave
} from '@/api/WorkOrder'
import { TSecLocaTree } from '@/api/basicSettings'
import { getTPlusToken, handleDatetime, handleDatetime2 } from '@/utils/global'
@@ -613,6 +628,8 @@
        partname: '', // 产品名称
        partspec: '', // 规格型号
        issouceorder: 'Y', // 是否有源单
        deptno: '', // 入库部门
        saleOrderCode: '', // 销售订单
        stockcode: '' // 入库仓库
@@ -633,26 +650,33 @@
      buttonSize: '',
      formItemWidth: 0,
      radioSelected: ''
      issouceorderTypeArr: [
        { value: 'Y', label: '有源单' },
        { value: 'N', label: '无源单' }
      ]
    }
  },
  watch: {},
  created() {
  },
  mounted() {
  async mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.getPrentOrganizationNoCompany()
    this.getTSecLocaTree()
    this.getProductInHouseOrderCodeSearch()
    await this.getPrentOrganizationNoCompany()
    await this.getTSecLocaTree()
    await this.getProductInHouseOrderCodeSearch()
    // this.getDeptSelectData()
    // this.getProductInHouseOrderSearch()
  },
  methods: {
    // 获取入库部门
    async getDeptSelectData() {
      const { data: res } = await DeptSelectData()
      this.departmentArr = res
    },
    // 获取单据编号(入库单号)、流水号
    async getProductInHouseOrderCodeSearch() {
      const { data: res } = await ProductInHouseOrderCodeSearch({ rightcode: '0604' })
@@ -677,6 +701,7 @@
        return this.$message.info('生产车间不能为空!')
      }
      const data = {
        issouceorder: this.form.issouceorder,
        saleordercode: this.form.saleordercode, // 销售单号
        wkshopcode: this.form.wkshopcode, // 生产车间
        erpordercode: this.form.erpordercode, // 订单编号
@@ -710,42 +735,53 @@
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    //  行点击事件
    async rowClick(row, event, column) {
      this.radioSelected = row.sbid
      // const { data: res } = await SearchWorkStep({ wo_code: row.wo_code })
      // this.tableDataDetail = res
    },
    // 递交
    async  submit() {
      // usercode
      // console.log(localStorage.getItem('username'))
      if (this.multipleSelection.length === 0) {
        return this.$message.info('请先勾选单据!')
      }
      if (this.form.stockcode === '') {
        return this.$message.info('入库仓库不能为空!')
      }
      if (this.multipleSelection.find(i => i.stockid === '' || i.stockid === null)) {
        return this.$message.info('表格内入库仓库不能为空!')
      }
      this.$store.state.app.buttonIsDisabled = true
      const openToken = await getTPlusToken() // 获取TPlus   token
      const obj = this.tableDataDetail.find(i => i.sbid === this.radioSelected)
      // console.log(openToken)
      // 无源单
      if (!obj.saleOrderCode) {
        // const RDRecordDetails = []
        // this.tableDataSummary.forEach((i, index) => {
        //   RDRecordDetails.push({
        //     Code: index + 1, // 行号,从1开始自增长
        //     Inventory: {
        //       Code: i.materiel_code // 存货编码
        //     },
        //     BaseQuantity: i.stinhouseqty, // 主计量单位数量
      let res
      const a = 1
      if (openToken) {
        if (a === 2) {
          const RDRecordDetails = []
          this.multipleSelection.forEach((i, index) => {
            RDRecordDetails.push({
              Code: index + 1, // 行号,从1开始自增长
              Warehouse: {
                Code: i.stockcode
              },
              Inventory: {
                Code: i.partcode // 存货编码
              },
              BaseQuantity: i.stinhouseqty // 主计量单位数量
        //     SNObject: {
        //       SnAccountDetails: [
        //         {
        //           SNCode: index.toString().padStart(4, '0')
              //       SNCode: '00001'
              //     },
              //     {
              //       SNCode: '00002'
        //         }
        //       ]
        //     }
        //   })
        // })
        const data = {
            })
          })
          const D1 = {
          'dto': {
            'IsModifiedCode': true,
            'ExternalCode': this.form.hbillno,
@@ -760,34 +796,15 @@
            'Warehouse': {
              'Code': this.form.stockcode
            },
            // 'Department': {
            //   'Code': this.form.wkshopcode,
            //   'Name': this.WorkShopArr.find(i => i.code === this.form.wkshopcode).name
            // },
            'RDRecordDetails': [
              {
                Code: 1, // 行号,从1开始自增长
                Inventory: {
                  Code: obj.partcode // 存货编码
              'Department': {
                'Code': this.form.wkshopcode,
                'Name': this.WorkShopArr.find(i => i.torg_code === this.form.wkshopcode).torg_name
                },
                BaseQuantity: obj.stinhouseqty, // 主计量单位数量
                SNObject: {
                  SnAccountDetails: [
                    {
                      // SNCode: index.toString().padStart(4, '0')
                      SNCode: '0001'
                    }
                  ]
              'RDRecordDetails': RDRecordDetails
                }
              }
            ]
          }
        }
        console.log(JSON.parse(JSON.stringify(data)))
        const res = await axios.post(Vue.prototype.$chanjetBaseUrl + '/tplus/api/v2/productReceive/Create',
          data, {
          res = await axios.post(Vue.prototype.$chanjetBaseUrl + '/tplus/api/v2/productReceive/Create',
            D1, {
            headers: {
              'openToken': openToken,
              'appKey': Vue.prototype.$AppKey,
@@ -796,44 +813,88 @@
            }
          }
        )
        console.log(res)
        console.log(res.status)
      }
        // 目前都执行的这个
        if (a === 1) {
          const RDRecordDetails = []
          this.multipleSelection.forEach((i, index) => {
            RDRecordDetails.push({
              Code: index + 1, // 行号,从1开始自增长
              SourceVoucherId: i.mpoid ? i.mpoid : '', // 来源单据的单据ID
              BaseQuantity: i.stinhouseqty, // 主计量单位数量
              // SourceVoucherDetailId: i.sourceVoucherDetailId, // 来源单据的对应明细ID
              SourceVoucherDetailId: i.sbid ? i.sbid : '', // 来源单据的对应明细ID
              Inventory: {
                Code: i.partcode // 存货编码
    },
    // 递交
    async  submitBack() {
      // usercode
      // console.log(localStorage.getItem('username'))
      if (this.multipleSelection.length === 0) {
        return this.$message.info('请先勾选单据!')
              IdSourceVoucherType: i.sbid ? 69 : ''
            })
          })
          const D2 = {
            'dto': {
              'Warehouse': {
                'Code': this.form.stockcode// 仓库编码
              },
              'Code': this.form.hbillno, // 单据编码
              'IsModifiedCode': true,
              'BusiType': {
                'Code': '03'// 业务类型编码
              },
              'Department': {
                'Code': this.form.wkshopcode// 部门编码
              },
              'VoucherDate': handleDatetime(new Date().getTime()), // 单据日期
              'RdStyle': {
                'Code': '21'// 出库类别编码
              },
              'RDRecordDetails': RDRecordDetails,
              // 'Clerk': {
              //   'Code': this.userArr.find(i => i.name === getCookie('username')).code // 业务员code
              //   // 'Code': '001' // 业务员code
              //   // 'Name': getCookie('username')
              // },
              'ExternalCode': this.form.hbillno,
              'VoucherType': {
                'Code': 'ST1002'
      }
      if (this.form.stockcode === '') {
        return this.$message.info('入库仓库不能为空!')
      }
      if (this.multipleSelection.find(i => i.stockid === '' || i.stockid === null)) {
        return this.$message.info('表格内入库仓库不能为空!')
          }
          res = await axios.post(Vue.prototype.$chanjetBaseUrl + '/tplus/api/v2/ProductReceiveOpenApi/Create',
            D2, {
              headers: {
                'openToken': openToken,
                'appKey': Vue.prototype.$AppKey,
                'appSecret': Vue.prototype.$AppSecret,
                'Content-Type': 'application/json'
              }
            }
          )
      }
        // console.log(res)
        // console.log(res.data.code)
        // || res.data === null
        if (res.data.code === 0) {
      const TableDetailData = []
      this.multipleSelection.forEach((i, index) => {
        TableDetailData.push({
          'hbillno': this.form.hbillno, // 入库单号
          'wocode': i.wo_code, // 工单号
          'rownumber': (index + 1).toString(), // 行号
          'sourceVoucherId': i.mpoid.toString(), // 来源单据id
              'sourceVoucherId': i.mpoid ? i.mpoid.toString() : '', // 来源单据id
          'sourceVoucherCode': i.m_po, // 来源单据编号
          'SourceVoucherDetailId': i.sbid.toString(), // 来源单据明细id
              'SourceVoucherDetailId': i.sbid ? i.sbid.toString() : '', // 来源单据明细id
          'inbarcode': i.inbarcode, // 入库条码
          'idinventory': i.materiel_id.toString(), // 存货id
              'idinventory': i.materiel_id ? i.materiel_id.toString() : '', // 存货id
          'inventorycode': i.partcode, // 存货编码
          'idunit': i.unitid.toString(), // 计量单位id
              'idunit': i.unitid ? i.unitid.toString() : '', // 计量单位id
          'unitcode': i.unitcode, // 计量单位编码
          idwarehouse: i.stockid.toString(), // 仓库id
              idwarehouse: i.stockid, // 仓库id
          warehousecode: i.stockcode, // 仓库编码
          'saleOrderId': i.saleOrderid.toString(), // 销售单id
              'saleOrderId': i.saleOrderid ? i.saleOrderid.toString() : '', // 销售单id
          'saleOrderCode': i.saleOrderCode, // 销售单号
          'saleOrderDetailId': i.saleOrderDetailId.toString(), // 销售单明细id
              'saleOrderDetailId': i.saleOrderDetailId ? i.saleOrderDetailId.toString() : '', // 销售单明细id
          'qty': i.good_qty.toString(), // 入库数量
          'stepcode': i.step_code, // 工序编码
          'style': i.style, // 报工类型:B(自制) S(外协)
@@ -874,8 +935,9 @@
      }
      // console.log(JSON.stringify(data))
      this.$store.state.app.buttonIsDisabled = true
      const res = await TProductInHouseOrderSpSeave(data)
          // this.$store.state.app.buttonIsDisabled = true
          const res = await InHouseOrderSpSeave(data)
      this.$store.state.app.buttonIsDisabled = false
      if (res.code === '200') {
        this.$message.success('入库成功!')
@@ -886,9 +948,19 @@
        // await this.getProductInHouseOrderSearch()
        await this.getProductInHouseOrderCodeSearch()
      }
        } else {
          // console.log(res.data)
          this.$store.state.app.buttonIsDisabled = false
          this.$message.error(res.data.message)
        }
      } else {
        this.$store.state.app.buttonIsDisabled = false
      }
    },
    // 重置
    reset() {
      // this.form.issouceorder = 'Y'
      this.form.saleordercode = '' // 销售单号
      this.form.wkshopcode = '' // 生产车间
      this.form.erpordercode = ''// 订单编号
@@ -1058,14 +1130,6 @@
::v-deep .el-tabs__item {
  padding-right: 0;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0 0;
}
::v-deep .el-radio__label{
  display: none;
}
</style>
<style>