wangyi
2025-11-27 fdccbcb18a3216ec53b47e0f04cd71a1605c8e58
src/views/sell/Kf_ICStockBillMainList/Kf_ICStockBillMainListEdit.vue
@@ -352,6 +352,7 @@
import Dept from '@/views/component/dept'
import Warehouse from '@/views/component/warehouse'
import Material from '@/views/component/material'
import dayjs from 'dayjs'
export default {
  name: 'SellOutBill',
@@ -461,6 +462,9 @@
      } 
      else if (this.OperationType == 3 || this.copyType == 1) { 
        this.handleUpdate()
      }
      else if(this.OperationType == 2){
        this.handleCopy()
      }
      else if (this.OperationType == 4) {
        this.zzSelDis = true
@@ -768,6 +772,141 @@
      });
    },
    //#endregion
     //#region 复制页面初始化
    handleCopy() {
      // 检查必要参数
      if (!this.linterid) {
        this.$modal.msgError("复制失败:缺少源数据ID");
        this.formShow = true;
        this.formLoading = false;
        return;
      }
      if (!this.baseURL) {
        this.$modal.msgError("复制失败:接口地址未配置");
        this.formShow = true;
        this.formLoading = false;
        return;
      }
      this.reset()
      let rowHmainid = this.linterid
      console.log("开始复制,参数:", { HInterID: rowHmainid })
      // 添加请求超时设置
      axios.get(this.baseURL + "Kf_ICStockBackBill/getEditInitData", {
        params: { 'HInterID': rowHmainid },
        timeout: 10000 // 10秒超时
      }).then(response => {
        console.log("复制接口完整响应:", response)
        if (!response.data) {
          throw new Error("响应数据为空")
        }
        if (response.data.count == 1) {
          // 原有的复制逻辑
          var result = response.data
          var data = response.data.data[0]
          console.log("复制获取的数据:", data)
          // 获取新单号
          this.getHBillNo()
          // 复制主表数据
          this.form.BillType = data.HSourceBillType
          this.form.HInterID = 0
          this.form.HDate = dayjs(new Date()).format("YYYY-MM-DD")
          this.form.HMaker = sessionStorage["HUserName"] || "当前用户"
          this.form.HChecker = ""
          this.form.HMakeDate = dayjs(new Date()).format("YYYY-MM-DD")
          this.form.HCheckDate = ""
          this.form.HCloseMan = ""
          this.form.HDeleteMan = ""
          this.form.HCloseDate = ""
          this.form.HDeleteDate = ""
          // 复制业务数据...
          this.form.HEmpID = data.HEmpID
          this.form.HEmpName = data.业务员
          this.form.HDeptID = data.HDeptID
          this.form.HDeptName = data.部门
          this.form.HSupID = data.HSupID
          this.form.HSupName = data.供应商
          this.form.HInvoiceBillNo = (data.发票编号 || "") + "_COPY"
          this.form.HWHID = data.主表仓库ID
          this.form.HWHName = data.主表仓库
          this.form.HSecManagerID = data.HSecManagerID
          this.form.HSecManagerName = data.验收员
          this.form.HRemark = (data.表头备注 || "") + " (复制)"
          this.form.HOrgID = data.HOrgID
          this.form.HSTOCKORGID = data.HOrgID
          this.form.HOWNERID = data.HOrgID
          // 复制子表数据...
          this.editData = [] // 清空原有数据
          for (var i = 0; i < result.data.length; i++) {
            this.editData.push({
              "HMaterID": result.data[i].HMaterID,
              "物料代码": result.data[i].物料代码,
              "物料名称": result.data[i].物料名称,
              "规格型号": result.data[i].规格型号,
              "HUnitID": result.data[i].HUnitID,
              "计量单位": result.data[i].计量单位,
              "HQtyMust": result.data[i].应收数量,
              "HQty": result.data[i].实收数量,
              "HRemark": (result.data[i].表体备注 || "") + " (复制)",
              "HPrice": result.data[i].单价,
              "HMoney": result.data[i].金额,
              "HOrderPrice": result.data[i].采购金额,
              "HWHID": result.data[i].HWHID,
              "收料仓库": result.data[i].收料仓库,
              "HSPID": result.data[i].HSPID,
              "仓位名称": result.data[i].仓位名称,
              "HBatchNo": result.data[i].批次,
              "HSourceBillNo": result.data[i].源单单号,
              "HSourceBillType": result.data[i].源单类型,
              "HSourceInterID": result.data[i].源单主内码,
              "HSourceEntryID": result.data[i].源单子内码,
              "HTaxRate": result.data[i].税率,
              "HTaxPrice": result.data[i].含税单价,
              "HlineTotal": result.data[i].含税金额,
              "HStatus": "创建"
            })
          }
          this.subDisabled = false
          this.$modal.msgSuccess("数据复制成功!")
          this.formShow = true
          this.formLoading = false
        } else {
          this.$modal.msgError("复制失败:未找到对应的源数据")
          this.formShow = true
          this.formLoading = false
        }
      }).catch(error => {
        let errorMsg = "复制数据失败! ";
        if (error.response) {
          // 服务器响应错误
          errorMsg += `服务器错误: ${error.response.status} - ${error.response.data || ''}`;
        } else if (error.request) {
          // 请求发送失败
          errorMsg += "网络错误,请检查网络连接";
        } else {
          // 其他错误
          errorMsg += error.message;
        }
        console.error("复制详细错误:", error)
        this.$modal.msgError(errorMsg)
        this.$nextTick(() => {
          this.formShow = true
          this.formLoading = false
        })
      })
    },
    //#endregion
    //#region 列设置
    handleRowHide() {