小小儁爺
2024-10-29 642ae743bc6009e4ae95e6e47831396ba54bcde7
src/views/produce/productWarehouse.vue
@@ -120,7 +120,7 @@
          <div class="elForm" style="justify-content: flex-start">
            <el-form-item label="单据日期" style=" display: flex;">
              <el-date-picker
                v-model="form.lm_date"
                v-model="form.hbdate"
                style="width: 200px"
                readonly
                type="date"
@@ -130,10 +130,11 @@
            <el-form-item label="单据编号" style=" display: flex;">
              <el-input
                v-model="form.hbillno"
                readonly
                placeholder="请输入"
                style="width: 200px"
              />
              <!--              readonly-->
            </el-form-item>
            <el-form-item label="入库仓库" required style=" display: flex;">
@@ -147,6 +148,23 @@
              >
                <el-option
                  v-for="item in stockcodeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="入库部门" required style=" display: flex;">
              <el-select
                v-model="form.deptno"
                :popper-append-to-body="false"
                filterable
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in departmentArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
@@ -549,8 +567,14 @@
<script>
import { PrentOrganizationNoCompany } from '@/api/GeneralBasicData'
import { ProductInHouseOrderSearch } from '@/api/WorkOrder'
import {
  DeptSelectData,
  ProductInHouseOrderCodeSearch,
  ProductInHouseOrderSearch,
  ProductInHouseOrderSeave
} from '@/api/WorkOrder'
import { TSecLocaTree } from '@/api/basicSettings'
import { handleDatetime, handleDatetime2 } from '@/utils/global'
export default {
  name: 'ProductWarehouse',
@@ -561,8 +585,8 @@
      tableHeight: 0,
      form: {
        hbillno: '', // 入库单号
        // incbit: '', // 流水号
        documentType: 'Y', // 单据类型
        incbit: '', // 流水号
        hbdate: new Date(), // 入库单日期
        saleordercode: '', // 销售单号
        wkshopcode: '', // 生产车间
@@ -572,6 +596,7 @@
        partname: '', // 产品名称
        partspec: '', // 规格型号
        deptno: '', // 入库部门
        saleOrderCode: '', // 销售订单
        stockcode: '' // 入库仓库
@@ -581,6 +606,7 @@
      multipleSelection: [],
      stockcodeArr: [], // 入库仓库数组
      WorkShopArr: [], // 生产车间数组
      departmentArr: [], // 入库部门
      tabClickIndex: null, // 点击的单元格
      tabClickLabel: '', // 当前点击的列名
@@ -598,10 +624,23 @@
    this.getPrentOrganizationNoCompany()
    this.getTSecLocaTree()
    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' })
      this.form.hbillno = res[0]
      this.form.incbit = res[1]
    },
    // 获取仓库信息
    async getTSecLocaTree() {
      const { data: res } = await TSecLocaTree()
@@ -637,12 +676,77 @@
    },
    // 复选框切换
    handleSelectionChange() {
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 递交
    submit() {
    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.form.deptno === '') {
        return this.$message.info('入库部门不能为空!')
      }
      const TableDetailData = []
      this.multipleSelection.forEach((i, index) => {
        TableDetailData.push({
          'hbillno': this.form.hbillno, // 入库单号
          'rownumber': (index + 1).toString(), // 行号
          'inbarcode': i.inbarcode, // 入库条码
          'mo_id': i.sbid.toString(), // 订单id(行号)
          'mo_no': i.m_po, // 订单号
          'wocode': i.wo_code, // 工单号
          'partcode': i.partcode, // 产品编码
          'unitcode': i.unitcode, // 单位编码
          'unit_rate': '1', // 单位换算率
          'stockcode': i.stockcode, // 仓库编码
          // 'qty': i.qty.toString(), // 入库数量
          'qty': i.good_qty.toString(), // 入库数量
          'price': '0', // 入库单价
          'saleid': i.saleOrderDetailId.toString(), // 销售单id(行号)
          'salecode': i.saleOrderCode, // 销售单号
          'status': '0', // 入库单状态:0(未审核) 1(已审核)
          'stepcode': i.step_code, // 工序编码
          'style': i.style// 报工类型:B(自制) S(外协)
        })
      })
      const data = {
        'rightcode': '0604', // 功能编号
        'incbit': this.form.incbit, // 流水号
        'TableData': [
          [
            {
              'hbillno': this.form.hbillno, // 入库单号
              'hbdate': handleDatetime(this.form.hbdate),
              'deptno': this.form.deptno, // 入库部门
              'storehouse_code': this.form.stockcode, // 仓库编码
              'status': '0', // 入库单状态:0(未审核) 1(已审核)
              'remark': '', // 备注
              'create_user': localStorage.getItem('username'), // 创建人员
              'create_date': handleDatetime2(new Date()),
              'check_user': '', // 审核人员
              'check_date': ''// 审核时间
            }
          ],
          TableDetailData// 表体
        ]
      }
      const res = await ProductInHouseOrderSeave(data)
      if (res.code === '200') {
        this.multipleSelection = []
        this.form.deptno = ''
        this.form.stockcode = ''
        await this.getProductInHouseOrderSearch()
        await this.getProductInHouseOrderCodeSearch()
      }
    },
    // 重置
    reset() {