| | |
| | | <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 /> |
| | |
| | | <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="供应商名称:" prop="salesContractNo"> |
| | | <el-input v-model="form.salesContractNo" placeholder="请输入" clearable /> |
| | | <el-form-item label="产品名称:" prop="productId"> |
| | | <el-select v-model="form.productId" placeholder="请选择" clearable> |
| | | <el-option v-for="item in productList" :key="item.id" :label="item.productName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="产品大类:" prop="salesman"> |
| | | <el-select v-model="form.salesman" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" |
| | | :value="item.nickName" /> |
| | | <el-form-item label="规格型号:" prop="productManageId"> |
| | | <el-select v-model="form.productManageId" placeholder="请选择" clearable> |
| | | <el-option v-for="item in productmodelList" :key="item.id" :label="item.model" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="规格型号:" prop="customerContractNo"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-form-item label="供应商名称:" prop="salesContractNo"> |
| | | <el-select v-model="form.supplierId" placeholder="请选择" clearable> |
| | | <el-option v-for="item in supplierLists" :key="item.id" :label="item.supplierName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="产品大类:" prop="salesman"> |
| | | <el-input v-model="form.productCategory" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位:" prop="customerId"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.unit" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <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-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="入库批次:" prop="entryPerson"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.inboundBatch" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="入库数量:" prop="customerContractNo"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.inboundQuantity" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税单价:" prop="customerId"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.taxInclusiveUnitPrice" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税总价:" prop="customerContractNo"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.taxInclusiveTotalPrice" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="税率:" prop="customerId"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.taxRate" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不含税总价:" prop="entryDate"> |
| | | <el-input v-model="form.customerContractNo" placeholder="请输入" clearable /> |
| | | <el-input v-model="form.taxExclusiveTotalPrice" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <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> |
| | |
| | | import useUserStore from '@/store/modules/user' |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import { |
| | | ledgerListPage, |
| | | customerList, |
| | | addOrUpdateSalesLedger, |
| | | getSalesLedgerWithProducts, delLedger |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import { |
| | | getStockInPage, |
| | | updateStockIn, |
| | | addSutockIn, |
| | | delStockIn, |
| | | exportStockIn |
| | | } from "@/api/inventoryManagement/stockIn.js"; |
| | | import {listSupplier} from "@/api/basicData/supplierManageFile.js"; |
| | | import {modelListPage, productTreeList} from "@/api/basicData/product.js"; |
| | | const userStore = useUserStore() |
| | | const { proxy } = getCurrentInstance() |
| | | const tableData = ref([]) |
| | | const productData = ref([]) |
| | | const selectedRows = ref([]) |
| | | const userList = ref([]) |
| | | const customerOption = ref([]) |
| | | const supplierLists = ref([]) |
| | | const productTree = ref([]); // 产品树数据 |
| | | const modelList = ref([]); // 规格型号列表 |
| | | const currentProductId = ref(null); // 当前选中的产品ID |
| | | const loading = ref(false); |
| | | const tableLoading = ref(false) |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | }) |
| | | const total = ref(0) |
| | | const fileList = ref([]) |
| | | // const fileList = ref([]) |
| | | |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref('') |
| | |
| | | supplierName: '', |
| | | }, |
| | | form: { |
| | | salesContractNo: '', |
| | | salesman: '', |
| | | customerContractNo: '', |
| | | customerId: '', |
| | | projectName: '', |
| | | entryPerson: '', |
| | | entryDate: '', |
| | | maintenanceTime: '', |
| | | productData: [], |
| | | executionDate: '' |
| | | productManageId: null, |
| | | 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" }], |
| | | productName: [{ required: true, message: "请选择", trigger: "change" }], |
| | | model: [{ 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) |
| | | // 3. 获取产品树方法 |
| | | const getProductTree = async () => { |
| | | try { |
| | | loading.value = true; |
| | | const res = await productTreeList(); |
| | | productTree.value = res.data; // 根据实际API返回结构调整 |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | }; |
| | | |
| | | // 4. 获取规格型号方法 |
| | | const getModelList = async (productId) => { |
| | | try { |
| | | loading.value = true; |
| | | const res = await modelListPage({ |
| | | id: productId, |
| | | current: 1, // 页码 |
| | | size: 10 // 每页条数 |
| | | }); |
| | | modelList.value = res.data.records; // 根据实际API返回结构调整 |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | }; |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | page.current = 1 |
| | | getList() |
| | | } |
| | | |
| | | const paginationChange = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList() |
| | | } |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true |
| | | getStockInPage({ ...searchForm.value, ...page }).then(res => { |
| | | tableLoading.value = false |
| | | tableData.value = res.data.records |
| | | tableData.value.map(item => { |
| | | item.children = [] |
| | | }) |
| | | total.value = res.total |
| | | ttotal.value = res.data.total |
| | | }).catch(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | } |
| | | const findNodeById = (nodes, productId) => { |
| | | for (let i = 0; i < nodes.length; i++) { |
| | | if (nodes[i].value === productId) { |
| | | return nodes[i].label; // 找到节点,返回该节点 |
| | | } |
| | | if (nodes[i].children && nodes[i].children.length > 0) { |
| | | const foundNode = findNodeById(nodes[i].children, productId); |
| | | if (foundNode) { |
| | | return foundNode.label; // 在子节点中找到,返回该节点 |
| | | } |
| | | } |
| | | } |
| | | return null; // 没有找到节点,返回null |
| | | const getProductTreeList = () => { |
| | | treeLoad.value = true; |
| | | productTreeList() |
| | | .then((res) => { |
| | | list.value = res; // 将返回的数据赋给list |
| | | list.value.forEach((a) => { |
| | | expandedKeys.value.push(a.label); // 默认展开所有节点 |
| | | }); |
| | | treeLoad.value = false; |
| | | }) |
| | | .catch((err) => { |
| | | treeLoad.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // 表格选择数据 |
| | | 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([]) |
| | |
| | | // 打开弹框 |
| | | const openForm = async (type, row) => { |
| | | operationType.value = type |
| | | form.value = {} |
| | | productData.value = [] |
| | | dialogFormVisible.value = true |
| | | 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 |
| | | }) |
| | | console.log('userList', userList.value) |
| | | |
| | | let supplierlists = await listSupplier() |
| | | supplierLists.value = supplierlists.data.records |
| | | console.log('supplierList', supplierLists.value) |
| | | |
| | | await getProductTree(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (type === 'add') { |
| | | // 新增时重置表单 |
| | | form.value = { |
| | | nickname: userStore.userId // 设置默认入库人为当前用户 |
| | | } |
| | | } else { |
| | | // 编辑时填充表单数据 |
| | | form.value = { ...row } |
| | | } |
| | | // 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 |
| | | } |
| | | } |
| | | |
| | | // 提交表单 |
| | | 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 |
| | | } |
| | | 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 => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | const apiMethod = operationType.value === 'add' ? addSutockIn : updateStockIn |
| | | apiMethod(form.value).then(res => { |
| | | proxy.$modal.msgSuccess(operationType.value === 'add' ? "新增成功" : "修改成功") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | proxy.download("/sales/ledger/export", {}, '入库台账.xlsx') |
| | | proxy.download("/stockin/export", {}, '入库台账.xlsx') |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | delLedger(ids).then(res => { |
| | | delStockIn(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | getList() |
| | | }) |