| | |
| | | </el-tabs> |
| | | <!-- 操作按钮区 --> |
| | | <el-space> |
| | | <el-button type="danger" :icon="Delete">删除</el-button> |
| | | <!-- <el-button type="danger" :icon="Delete">删除</el-button>--> |
| | | <el-button type="info" plain :icon="Download">导出</el-button> |
| | | <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows">合并</el-button> |
| | | <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows('merge')">合并</el-button> |
| | | </el-space> |
| | | <div> |
| | | <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%"> |
| | | <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%" show-summary :summary-method="summarizeChildrenTable"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="序号" type="index" width="60" align="center" /> |
| | | <el-table-column prop="supplierName" label="供货商名称" width="180" sortable/> |
| | | <el-table-column prop="coal" label="煤种" sortable/> |
| | | <el-table-column prop="unit" label="单位" width="70"/> |
| | | <el-table-column prop="inventoryQuantity" label="库存数量" sortable min-width="110"/> |
| | | <el-table-column prop="priceIncludingTax" label="单价(含税)" sortable width="130"/> |
| | | <el-table-column prop="totalPriceIncludingTax" label="总价(含税)" width="130" /> |
| | | <el-table-column prop="costPerUnit" label="成本单价" /> |
| | | <el-table-column prop="priceIncludingTax" label="单价(含税)" sortable width="130"/> |
| | | <el-table-column prop="totalPriceIncludingTax" label="总价(含税)" width="130" /> |
| | | <el-table-column prop="priceExcludingTax" label="单价(不含税)" width="130" /> |
| | | <el-table-column prop="totalPriceExcludingTax" label="总价(不含税)" width="130" /> |
| | | <el-table-column prop="pendingReplenishment" label="待补库" width="130" /> |
| | | <el-table-column label="煤质" align="center" v-if="activeTab=== 'officialInventory'" width="600"> |
| | | <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/> |
| | | </el-table-column> |
| | | <el-table-column prop="registrantId" label="登记人" width="180"/> |
| | | <el-table-column prop="registrationDate" label="登记日期" width="180"/> |
| | | <el-table-column fixed="right" label="操作" min-width="60" align="center" v-if="activeTab !== 'officialInventory'"> |
| | | <el-table-column fixed="right" label="操作" min-width="60" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="reviewDia(scope.row)">审核</el-button> |
| | | <el-button link type="primary" size="small" @click="reviewDia(scope.row)" v-if="activeTab !== 'officialInventory'">审核</el-button> |
| | | <el-button link type="primary" size="small" @click="mergeRows('edit', scope.row)" v-else>编辑</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="成本单价" prop="costPerUnit"> |
| | | <el-input v-model="form.costPerUnit" placeholder="请输入成本单价" maxlength="30" /> |
| | | <el-form-item label="单价(不含税)" prop="priceExcludingTax"> |
| | | <el-input v-model="form.priceExcludingTax" placeholder="请输入成本单价" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="总价(不含税)" prop="totalPriceExcludingTax"> |
| | | <el-input v-model="form.totalPriceExcludingTax" placeholder="请输入成本单价" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="煤质方案" prop="qualityPlan"> |
| | | <el-select v-model="form.qualityPlan" placeholder="请选择" @change="coalPlanByIdList" clearable> |
| | |
| | | </el-dialog> |
| | | <!-- 合并数据弹框 --> |
| | | <el-dialog title="合并库存" v-model="mergeVisible" width="800px"> |
| | | <el-form :model="form" :rules="rules" ref="userRef" label-width="100px"> |
| | | <el-form :model="mergeForm" :rules="mergeRules" ref="mergeRef" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="供货商名称" prop="supplierName"> |
| | | <el-input v-model="form.supplierName" placeholder="请输入手机号码" maxlength="30" /> |
| | | <el-input v-model="mergeForm.supplierName" placeholder="请输入供货商名称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="煤种" prop="coal"> |
| | | <el-input v-model="form.coal" placeholder="请输入姓名" maxlength="30" /> |
| | | <el-input v-model="mergeForm.coal" placeholder="请输入煤种" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位" prop="unit"> |
| | | <el-input v-model="mergeForm.unit" placeholder="请输入单位" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="库存数量" prop="inventoryQuantity"> |
| | | <el-input v-model="mergeForm.inventoryQuantity" placeholder="请输入库存数量" :max="inventoryQuantity" type="number"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单价(含税)" prop="priceIncludingTax"> |
| | | <el-input v-model="form.priceIncludingTax" placeholder="请输入手机号码" maxlength="30" /> |
| | | <el-input v-model="mergeForm.priceIncludingTax" placeholder="请输入单价(含税)" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="总价(含税)" prop="totalPriceIncludingTax"> |
| | | <el-input v-model="form.totalPriceIncludingTax" placeholder="请输入手机号码" maxlength="30" /> |
| | | <el-input v-model="mergeForm.totalPriceIncludingTax" placeholder="请输入总价(含税)" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="成本单价" prop="costPerUnit"> |
| | | <el-input v-model="form.costPerUnit" placeholder="请输入姓名" maxlength="30" /> |
| | | <el-form-item label="单价(不含税)" prop="priceExcludingTax"> |
| | | <el-input v-model="mergeForm.priceExcludingTax" placeholder="请输入单价(不含税)" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="煤质" prop="userName"> |
| | | <el-input v-model="form.userName" placeholder="请输入手机号码" maxlength="30" /> |
| | | <el-form-item label="总价(不含税)" prop="totalPriceExcludingTax"> |
| | | <el-input v-model="mergeForm.totalPriceExcludingTax" placeholder="请输入总价(不含税)" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-divider></el-divider> |
| | | <el-row> |
| | | <el-col :span="12" v-for="item in filteredList" :key="item.id"> |
| | | <el-form-item :label="item.fieldName"> |
| | | <el-input v-model="mergeForm[item.fields]" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | coalPlanList, officialInventoryList, |
| | | pendingInventoryList |
| | | } from "@/api/warehouseManagement/index.js"; |
| | | import {editOfficial, merge} from "../../api/warehouseManagement/index.js"; |
| | | |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | const tableData = ref([]) |
| | | const selectedRows = ref([]) |
| | | const columns = ref([]) |
| | | const qualityPlanOption = ref([]) |
| | | const filteredList = ref([]) |
| | | const tableLoading = ref(false); |
| | |
| | | const pageNum = ref(1); |
| | | const pageSize = ref(10); |
| | | const inventoryQuantity = ref(0); |
| | | const count = ref(0); |
| | | const mean = ref(0); |
| | | const totalPrice = ref(0); |
| | | // 审核弹框 |
| | | const reviewVisible = ref(false); |
| | | // 合并弹框 |
| | | const mergeVisible = ref(false) |
| | | const operationType = ref('') |
| | | const data = reactive({ |
| | | form: { |
| | | supplierName: '', |
| | |
| | | inventoryQuantity: '', |
| | | priceIncludingTax: '', |
| | | totalPriceIncludingTax: '', |
| | | costPerUnit: '', |
| | | priceExcludingTax: '', |
| | | totalPriceExcludingTax: '', |
| | | qualityPlan: '', |
| | | pId: '', |
| | | }, |
| | | mergeForm: { |
| | | supplierName: '', |
| | | coal: '', |
| | | unit: '', |
| | | inventoryQuantity: '', |
| | | priceIncludingTax: '', |
| | | totalPriceIncludingTax: '', |
| | | priceExcludingTax: '', |
| | | totalPriceExcludingTax: '', |
| | | qualityPlan: '', |
| | | pId: '', |
| | | }, |
| | |
| | | coal: [{ required: true, message: "请输入煤种", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入单位", trigger: "blur" }], |
| | | qualityPlan: [{ required: true, message: "请选择", trigger: "change" }], |
| | | }, |
| | | mergeRules: { |
| | | supplierName: [{ required: true, message: "请输入供应商名称", trigger: "blur" }], |
| | | coal: [{ required: true, message: "请输入煤种", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入单位", trigger: "blur" }], |
| | | qualityPlan: [{ required: true, message: "请选择", trigger: "change" }], |
| | | } |
| | | }) |
| | | |
| | | const { form, rules } = toRefs(data) |
| | | const { form, rules, mergeForm, mergeRules } = toRefs(data) |
| | | // 当前标签 |
| | | const activeTab = ref("pendingInbound"); |
| | | const tabName = ref("pendingInbound"); |
| | |
| | | tableData.value = []; |
| | | getList(); |
| | | }; |
| | | const summarizeChildrenTable = (param) => { |
| | | return proxy.summarizeTable(param, ['inventoryQuantity', 'priceIncludingTax', 'totalPriceIncludingTax','priceExcludingTax','totalPriceExcludingTax']); |
| | | } |
| | | // 点击查询 |
| | | const handleQuery = () => { |
| | | pageNum.value = 1 |
| | |
| | | // 打开审核弹框 |
| | | const reviewDia = (row) => { |
| | | reviewVisible.value = true |
| | | filteredList.value = [] |
| | | form.value = {...row} |
| | | form.value.pId = row.id |
| | | inventoryQuantity.value = row.inventoryQuantity |
| | |
| | | }) |
| | | } |
| | | // 合并库存数据方法 |
| | | const mergeRows = () => { |
| | | if (selectedRows.value.length < 2) { |
| | | proxy.$modal.msgWarning('请至少选择两条数据') |
| | | return |
| | | const mergeRows = (type,row) => { |
| | | coalFieldListOption(); |
| | | mergeVisible.value = true; |
| | | operationType.value = type; |
| | | if (type === 'edit') { |
| | | mergeForm.value = {...row} |
| | | } else { |
| | | if (selectedRows.value.length < 2) { |
| | | proxy.$modal.msgWarning('请至少选择两条数据') |
| | | return |
| | | } |
| | | filteredList.value.forEach(item => { |
| | | mergeForm.value[item.fields] = '' |
| | | }) |
| | | const data = selectedRows.value |
| | | const selectedIds = selectedRows.value.map(row => row.id); |
| | | // 初始化合计和均值变量 |
| | | let totalInventory = 0; |
| | | let totalPriceIncludingTax = 0; |
| | | let totalPriceExcludingTax = 0; |
| | | let priceIncludingTaxSum = 0; |
| | | let priceExcludingTaxSum = 0; |
| | | // 遍历所有选中数据,累加计算 |
| | | data.forEach(row => { |
| | | totalInventory += parseFloat(row.inventoryQuantity) || 0; |
| | | priceIncludingTaxSum += parseFloat(row.priceIncludingTax) || 0; |
| | | totalPriceIncludingTax += parseFloat(row.totalPriceIncludingTax) || 0; |
| | | priceExcludingTaxSum += parseFloat(row.priceExcludingTax) || 0; |
| | | totalPriceExcludingTax += parseFloat(row.totalPriceExcludingTax) || 0; |
| | | }); |
| | | // 计算平均值并保留两位小数 |
| | | const avgPriceIncludingTax = Number((priceIncludingTaxSum / data.length).toFixed(2)); |
| | | const avgTotalPriceIncludingTax = Number((totalPriceIncludingTax / data.length).toFixed(2)); |
| | | const avgPriceExcludingTax = Number((priceExcludingTaxSum / data.length).toFixed(2)); |
| | | const avgTotalPriceExcludingTax = Number((totalPriceExcludingTax / data.length).toFixed(2)); |
| | | // 设置表单显示 |
| | | mergeForm.value.inventoryQuantity = totalInventory; |
| | | mergeForm.value.priceIncludingTax = avgPriceIncludingTax; |
| | | mergeForm.value.totalPriceIncludingTax = avgTotalPriceIncludingTax; |
| | | mergeForm.value.priceExcludingTax = avgPriceExcludingTax; |
| | | mergeForm.value.totalPriceExcludingTax = avgTotalPriceExcludingTax; |
| | | mergeForm.value.ids = selectedIds; |
| | | } |
| | | mergeVisible.value = true |
| | | } |
| | | // 提交合并表单 |
| | | const submitForm = () => { |
| | | |
| | | proxy.$refs.mergeRef.validate(valid => { |
| | | if (valid) { |
| | | delete mergeForm.value.createTime |
| | | delete mergeForm.value.updateTime |
| | | if (operationType.value === 'edit') { |
| | | mergeForm.value.fields = filteredList.value.reduce((acc, item) => { |
| | | const key = item.fields; |
| | | const value = mergeForm.value[key]; |
| | | // 判断是否有值(你可以根据需要修改判断条件) |
| | | if (value !== null && value !== undefined && value !== '') { |
| | | acc.push({ [key]: value }); |
| | | } |
| | | return acc; |
| | | }, []); |
| | | editOfficial(mergeForm.value).then(() => { |
| | | cancel() |
| | | proxy.$modal.msgSuccess('修改成功') |
| | | handleQuery() |
| | | }) |
| | | } else { |
| | | mergeForm.value.fields = filteredList.value.reduce((acc, item) => { |
| | | const key = item.fields; |
| | | const value = mergeForm.value[key]; |
| | | // 判断是否有值(你可以根据需要修改判断条件) |
| | | if (value !== null && value !== undefined && value !== '') { |
| | | acc.push({ [key]: value }); |
| | | } |
| | | return acc; |
| | | }, []); |
| | | merge(mergeForm.value).then(() => { |
| | | cancel() |
| | | proxy.$modal.msgSuccess('合并成功') |
| | | handleQuery() |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | // 关闭合并表单 |
| | | const cancel = () => { |
| | | proxy.$refs.mergeRef.resetFields(); |
| | | mergeVisible.value = false |
| | | } |
| | | // 提交审核表单 |