lishenao
9 天以前 d50a93ffd0baa588ad4650b7584b608cdc761990
src/views/inventoryManagement/issueManagement/index.vue
@@ -22,8 +22,8 @@
        <el-table-column label="入库时间" prop="inboundTime" width="100" show-overflow-tooltip />
        <el-table-column label="入库批次" prop="inboundBatch" width="160" show-overflow-tooltip />
        <el-table-column label="供应商名称" prop="supplierName" width="160" show-overflow-tooltip />
        <el-table-column label="产品大类" prop="productCategory" width="100" show-overflow-tooltip />
        <el-table-column label="规格型号" prop="specificationModel" width="160" show-overflow-tooltip />
        <el-table-column label="产品大类" prop="productName" width="100" show-overflow-tooltip />
        <el-table-column label="规格型号" prop="model" width="160" show-overflow-tooltip />
        <el-table-column label="单位" prop="unit" width="70" show-overflow-tooltip />
        <el-table-column label="入库数量" prop="inboundQuantity" width="90" show-overflow-tooltip />
        <el-table-column label="含税单价" prop="taxInclusiveUnitPrice" width="100" show-overflow-tooltip />
@@ -43,14 +43,14 @@
    <el-dialog v-model="dialogFormVisible" :title="'新增出库'" width="40%" @close="closeDia">
      <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
        <el-form-item label="出库数量:" prop="salesContractNo">
          <el-input v-model="form.salesContractNo" placeholder="请输入" clearable />
          <el-input v-model="form.inboundQuantity" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="出库日期:" prop="projectName">
          <el-date-picker style="width: 100%" v-model="form.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
          <el-date-picker style="width: 100%" v-model="form.inboundTime" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
            type="date" placeholder="请选择" clearable />
        </el-form-item>
        <el-form-item label="出库人:" prop="entryPerson">
          <el-select v-model="form.entryPerson" placeholder="请选择" clearable>
          <el-select v-model="form.nickName" placeholder="请选择" clearable>
            <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" />
          </el-select>
        </el-form-item>
@@ -78,12 +78,11 @@
  getSalesLedgerWithProducts, delLedger
} from "@/api/salesManagement/salesLedger.js";
import {
  getStockOutPage,
  addStockOut,
  updateStockOut,
  delStockOut,
  exportStockOut
} from "@/api/inventoryManagement/stockOut.js";
  getStockManagePage,
    delStockManage,
    stockOut
} from "@/api/inventoryManagement/stockManage.js";
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const tableData = ref([])
@@ -106,25 +105,33 @@
    supplierName: '',
  },
  form: {
    salesContractNo: '',
    salesman: '',
    customerContractNo: '',
    customerId: '',
    projectName: '',
    entryPerson: '',
    entryDate: '',
    maintenanceTime: '',
    productData: [],
    executionDate: ''
    supplierId: null,
    productId: null,
    userId: null,
    supplierName: '',
    productName: '',
    model: '',
    unit: '',
    inboundTime: '',
    inboundBatch: '',
    inboundQuantity: '',
    taxInclusiveUnitPrice: '',
    taxInclusiveTotalPrice: '',
    taxRate: '',
    taxExclusiveTotalPrice: '',
    nickName: '',
  },
  rules: {
    salesman: [{ required: true, message: "请选择", trigger: "change" }],
    customerContractNo: [{ required: true, message: "请输入", trigger: "blur" }],
    customerId: [{ required: true, message: "请选择", trigger: "change" }],
    projectName: [{ required: true, message: "请输入", trigger: "blur" }],
    entryPerson: [{ required: true, message: "请选择", trigger: "change" }],
    entryDate: [{ required: true, message: "请选择", trigger: "change" }],
    executionDate: [{ required: true, message: "请选择", trigger: "change" }],
    supplierName: [{ required: true, message: "请输入", trigger: "blur" }],
    productCategory: [{ required: true, message: "请选择", trigger: "change" }],
    specificationModel: [{ required: true, message: "请输入", trigger: "blur" }],
    unit: [{ required: true, message: "请输入", trigger: "blur" }],
    inboundTime: [{ required: true, message: "请选择", trigger: "change" }],
    inboundBatch: [{ required: true, message: "请输入", trigger: "blur" }],
    inboundQuantity: [{ required: true, message: "请输入", trigger: "blur" }],
    taxInclusiveUnitPrice: [{ required: true, message: "请输入", trigger: "blur" }],
    taxRate: [{ required: true, message: "请输入", trigger: "blur" }],
    nickname: [{ required: true, message: "请选择", trigger: "change" }]
  }
})
const { searchForm, form, rules } = toRefs(data)
@@ -142,13 +149,10 @@
}
const getList = () => {
  tableLoading.value = true
  getStockOutPage({ ...searchForm.value, ...page }).then(res => {
  getStockManagePage({ ...searchForm.value, ...page }).then(res => {
    tableLoading.value = false
    tableData.value = res.data.records
    tableData.value.map(item => {
      item.children = []
    })
    total.value = res.total
    console.log('res', res.data.records)
  }).catch(() => {
    tableLoading.value = false
  })
@@ -171,7 +175,7 @@
const handleSelectionChange = (selection) => {
  // 过滤掉子数据
  selectedRows.value = selection.filter(item => item.children !== undefined);
  selectedRows.value = selection.filter(item => item.id);
  console.log('selection', selectedRows.value)
}
const expandedRowKeys = ref([])
@@ -180,57 +184,47 @@
const summarizeMainTable = (param) => {
  return proxy.summarizeTable(param, ['contractAmount', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice']);
};
const currentRowId = ref(null) // 新增:存储当前操作的行ID
// 打开弹框
const openForm = async (row) => {
  // form.value = {}
  // productData.value = []
  // let userLists = await userListNoPage()
  // userList.value = userLists.data
  // customerList().then(res => {
  //   customerOption.value = res
  // })
  // console.log('userStore.id', userStore.id)
  // form.value.entryPerson = userStore.id
  // if (type === 'edit') {
  //   currentId.value = row.id;
  //   getSalesLedgerWithProducts({ id: row.id, type: 1 }).then(res => {
  //     form.value = { ...res }
  //     form.value.entryPerson = Number(res.entryPerson)
  //     productData.value = form.value.productData
  //     fileList.value = form.value.salesLedgerFiles
  //   })
  // }
  // let userAll = await userStore.getInfo()
  // userList.value.forEach(element => {
  //   if(userAll.user.nickName === element.nickName && userAll.user.userName === element.userName) {
  //     form.value.entryPerson = userAll.user.userId // 设置默认业务员为当前用户
  //   }
  // });
  // form.value.entryDate = getCurrentDate() // 设置默认录入日期为当前日期
  dialogFormVisible.value = true
  currentRowId.value = row.id
  form.value = {}
  // 初始化表单数据
  form.value = {
    inboundQuantity: '', // 出库数量清空
    inboundTime: getCurrentDate(), // 默认当前日期
    nickName: '', // 默认当前用户
  }
  console.log('form',form.value)
  // 加载用户列表
  try {
    const userLists = await userListNoPage()
    userList.value = userLists.data
  } catch (error) {
    console.error('加载用户列表失败:', error)
  }
}
// 提交表单
const submitForm = () => {
  proxy.$refs["formRef"].validate(valid => {
    if (valid) {
      if (productData.value.length > 0) {
        form.value.productData = proxy.HaveJson(productData.value)
      } else {
        proxy.$modal.msgWarning('请添加产品信息')
        return
    if (valid && currentRowId.value) {
      const outData = {
        id: currentRowId.value, // 原始记录ID
        outQuantity: form.value.inboundQuantity, // 出库数量
        outTime: form.value.inboundTime, // 出库时间
        userId: form.value.userId // 操作人
      }
      let tempFileIds = []
      if (fileList.value.length > 0) {
        tempFileIds = fileList.value.map(item => item.tempId)
      }
      form.value.tempFileIds = tempFileIds
      form.value.type = 1
      addOrUpdateSalesLedger(form.value).then(res => {
      stockOut(outData).then(res => {
        proxy.$modal.msgSuccess("提交成功")
        closeDia()
        getList()
      }).catch(err => {
        proxy.$modal.msgError("出库失败")
      })
    }
  })
@@ -251,7 +245,7 @@
    type: 'warning',
  }
  ).then(() => {
    proxy.download("/sales/ledger/export", {}, '入库台账.xlsx')
    proxy.download("/stockmanagement/export", {}, '入库台账.xlsx')
  }).catch(() => {
    proxy.$modal.msg("已取消")
  })
@@ -273,7 +267,7 @@
    type: 'warning',
  }
  ).then(() => {
    delLedger(ids).then(res => {
    delStockManage(ids).then(res => {
      proxy.$modal.msgSuccess("删除成功")
      getList()
    })