| | |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <el-form :model="searchForm" :inline="true"> |
| | | <el-form-item label="销售订单号:"> |
| | | <el-input v-model="searchForm.salesContractNo" placeholder="请输入" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | | <el-form-item label="流水号:"> |
| | | <el-input v-model="searchForm.serialNo" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="车牌号:"> |
| | | <el-input v-model="searchForm.shippingCarNumber" placeholder="请输入" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | | <el-form-item label="车号:"> |
| | | <el-input v-model="searchForm.carNo" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="货名:"> |
| | | <el-input v-model="searchForm.goodsName" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="收货单位:"> |
| | | <el-input v-model="searchForm.receiveUnit" placeholder="请输入" clearable style="width: 200px" @change="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleQuery"> 搜索 </el-button> |
| | | <el-button type="primary" @click="handleQuery">搜索</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <div class="table_list"> |
| | | <div class="actions"> |
| | | <div></div> |
| | | <div /> |
| | | <div> |
| | | <el-button @click="handleOut">导出</el-button> |
| | | <el-button type="primary" plain @click="openImportDialog">导入</el-button> |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange" |
| | | :row-key="(row) => row.id" style="width: 100%" height="calc(100vh - 18.5em)"> |
| | | |
| | | <el-table |
| | | :data="tableData" |
| | | border |
| | | v-loading="tableLoading" |
| | | @selection-change="handleSelectionChange" |
| | | :row-key="(row) => row.id" |
| | | style="width: 100%" |
| | | height="calc(100vh - 21.5em)" |
| | | > |
| | | <el-table-column align="center" type="selection" width="55" /> |
| | | <el-table-column align="center" label="序号" type="index" width="60" /> |
| | | <el-table-column label="销售订单" prop="salesContractNo" show-overflow-tooltip /> |
| | | <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip /> |
| | | <el-table-column label="发货时间" prop="shippingDate" show-overflow-tooltip /> |
| | | <el-table-column label="发货车牌号" prop="shippingCarNumber" show-overflow-tooltip /> |
| | | <el-table-column fixed="right" label="操作" width="150" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button> |
| | | <el-button link type="danger" size="small" @click="handleDeleteSingle(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="流水号" prop="serialNo" show-overflow-tooltip min-width="120" /> |
| | | <el-table-column label="车号" prop="carNo" show-overflow-tooltip min-width="120" /> |
| | | <el-table-column label="发货单位" prop="shipUnit" show-overflow-tooltip min-width="140" /> |
| | | <el-table-column label="收货单位" prop="receiveUnit" show-overflow-tooltip min-width="140" /> |
| | | <el-table-column label="货名" prop="goodsName" show-overflow-tooltip min-width="120" /> |
| | | <el-table-column label="规格" prop="specification" show-overflow-tooltip min-width="120" /> |
| | | <el-table-column label="毛重" prop="grossWeight" show-overflow-tooltip min-width="100" /> |
| | | <el-table-column label="皮重" prop="tareWeight" show-overflow-tooltip min-width="100" /> |
| | | <el-table-column label="净重" prop="netWeight" show-overflow-tooltip min-width="100" /> |
| | | <el-table-column label="一次过磅时间" prop="firstWeighTime" show-overflow-tooltip min-width="180" /> |
| | | <el-table-column label="二次过磅时间" prop="secondWeighTime" show-overflow-tooltip min-width="180" /> |
| | | <el-table-column label="原发" prop="originalSender" show-overflow-tooltip min-width="100" /> |
| | | <el-table-column label="更新人" prop="updateBy" show-overflow-tooltip min-width="120" /> |
| | | </el-table> |
| | | <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" |
| | | :page="page.current" :limit="page.size" @pagination="paginationChange" /> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :page="page.current" |
| | | :limit="page.size" |
| | | @pagination="paginationChange" |
| | | /> |
| | | </div> |
| | | <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '新增发货台账' : '编辑发货台账'" width="50%" |
| | | @close="closeDia"> |
| | | <el-form :model="form" label-width="120px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="销售订单:" prop="salesContractNo"> |
| | | <el-select v-model="form.salesContractNo" placeholder="请选择" clearable filterable |
| | | @change="handleSalesOrderChange" style="width: 100%" :disabled="operationType === 'edit'"> |
| | | <el-option v-for="item in salesOrderOptions" :key="item.salesContractNo" |
| | | :label="item.salesContractNo" :value="item.salesContractNo"> |
| | | {{ item.salesContractNo + ' - ' + item.customerName }} |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="客户名称:" prop="customerName"> |
| | | <el-input v-model="form.customerName" placeholder="请输入" clearable :disabled="operationType === 'edit'" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="发货时间:" prop="shippingDate"> |
| | | <el-date-picker style="width: 100%" v-model="form.shippingDate" value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" type="date" placeholder="请选择" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="发货车牌号:" prop="shippingCarNumber"> |
| | | <el-input v-model="form.shippingCarNumber" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | </el-form> |
| | | |
| | | <el-dialog v-model="importUpload.open" :title="importUpload.title" width="500px" append-to-body> |
| | | <el-upload |
| | | ref="importUploadRef" |
| | | drag |
| | | :limit="1" |
| | | :action="importUpload.url" |
| | | :headers="importUpload.headers" |
| | | :before-upload="importUpload.beforeUpload" |
| | | :on-success="importUpload.onSuccess" |
| | | :on-error="importUpload.onError" |
| | | :auto-upload="false" |
| | | accept=".xlsx,.xls" |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text"> |
| | | 将文件拖到此处,或<em>点击上传</em> |
| | | </div> |
| | | <template #tip> |
| | | <div class="el-upload__tip">仅支持 xlsx/xls 文件</div> |
| | | </template> |
| | | </el-upload> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | <el-button type="primary" :loading="importUpload.isUploading" @click="submitImport">确定</el-button> |
| | | <el-button @click="importUpload.open = false">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | <script setup> |
| | | import pagination from "@/components/PIMTable/Pagination.vue"; |
| | | import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { |
| | | deliveryLedgerListPage, |
| | | addOrUpdateDeliveryLedger, |
| | | delDeliveryLedger, |
| | | } from "@/api/salesManagement/deliveryLedger.js"; |
| | | |
| | | import { getToken } from "@/utils/auth"; |
| | | import { weighbridgeLedgerListPage, delWeighbridgeLedger } from "@/api/salesManagement/deliveryLedger.js"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const tableLoading = ref(false); |
| | | const salesOrderOptions = ref([]); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | }); |
| | | const total = ref(0); |
| | | |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref(""); |
| | | const dialogFormVisible = ref(false); |
| | | const data = reactive({ |
| | | searchForm: { |
| | | salesContractNo: "", // 销售订单号 |
| | | shippingCarNumber: "", // 车牌号 |
| | | }, |
| | | form: { |
| | | id: null, |
| | | salesContractNo: "", |
| | | customerName: "", |
| | | shippingDate: "", |
| | | shippingCarNumber: "", |
| | | }, |
| | | rules: { |
| | | salesContractNo: [{ required: true, message: "请选择销售订单", trigger: "change" }], |
| | | customerName: [{ required: true, message: "请输入客户名称", trigger: "blur" }], |
| | | shippingDate: [{ required: true, message: "请选择发货时间", trigger: "change" }], |
| | | shippingCarNumber: [{ required: true, message: "请输入发货车牌号", trigger: "blur" }], |
| | | serialNo: "", |
| | | carNo: "", |
| | | goodsName: "", |
| | | receiveUnit: "", |
| | | }, |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | | const { searchForm } = toRefs(data); |
| | | |
| | | |
| | | const importUploadRef = ref(null); |
| | | const importUpload = reactive({ |
| | | title: "导入台账", |
| | | open: false, |
| | | isUploading: false, |
| | | url: import.meta.env.VITE_APP_BASE_API + "/sales/weighbridgeLedger/import", |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | beforeUpload: (file) => { |
| | | const isExcel = file.name.endsWith(".xlsx") || file.name.endsWith(".xls"); |
| | | if (!isExcel) { |
| | | proxy.$modal.msgError("上传文件只能是 xlsx/xls 格式"); |
| | | return false; |
| | | } |
| | | return true; |
| | | }, |
| | | onSuccess: (res) => { |
| | | importUpload.isUploading = false; |
| | | if (res?.code === 200) { |
| | | proxy.$modal.msgSuccess("导入成功"); |
| | | importUpload.open = false; |
| | | importUploadRef.value?.clearFiles(); |
| | | getList(); |
| | | return; |
| | | } |
| | | proxy.$modal.msgError(res?.msg || "导入失败"); |
| | | }, |
| | | onError: () => { |
| | | importUpload.isUploading = false; |
| | | proxy.$modal.msgError("导入失败,请重试"); |
| | | }, |
| | | }); |
| | | |
| | | // 查询列表 |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | deliveryLedgerListPage({ ...searchForm.value, ...page }) |
| | | weighbridgeLedgerListPage({ ...searchForm.value, ...page }) |
| | | .then((res) => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records || []; |
| | | total.value = res.data.total || 0; |
| | | tableData.value = res?.data?.records || res?.records || []; |
| | | total.value = res?.data?.total || res?.total || 0; |
| | | }) |
| | | .catch(() => { |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // 销售订单变化时自动填充客户名称 |
| | | const handleSalesOrderChange = (value) => { |
| | | const selectedOrder = salesOrderOptions.value.find(item => item.salesContractNo === value); |
| | | if (selectedOrder) { |
| | | form.value.customerName = selectedOrder.customerName; |
| | | } |
| | | }; |
| | | |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // 打开弹框 |
| | | const openForm = async (type, row) => { |
| | | operationType.value = type; |
| | | if (type === 'edit' && row) { |
| | | form.value = { |
| | | id: row.id ?? null, |
| | | salesContractNo: row.salesContractNo ?? "", |
| | | customerName: row.customerName ?? "", |
| | | shippingDate: row.shippingDate || getCurrentDate(), |
| | | shippingCarNumber: row.shippingCarNumber ?? "", |
| | | }; |
| | | } else { |
| | | form.value = { |
| | | id: null, |
| | | salesContractNo: "", |
| | | customerName: "", |
| | | shippingDate: getCurrentDate(), |
| | | shippingCarNumber: "", |
| | | }; |
| | | } |
| | | |
| | | dialogFormVisible.value = true; |
| | | }; |
| | | |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate((valid) => { |
| | | if (valid) { |
| | | const payload = { |
| | | id: form.value.id, |
| | | shippingDate: form.value.shippingDate, |
| | | shippingCarNumber: form.value.shippingCarNumber, |
| | | }; |
| | | addOrUpdateDeliveryLedger(payload).then((res) => { |
| | | proxy.$modal.msgSuccess("操作成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | }; |
| | | |
| | | // 导出 |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download("/shippingInfo/export", {}, "发货台账.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | // 批量删除 |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map((item) => item.id); |
| | | } else { |
| | | if (!selectedRows.value.length) { |
| | | proxy.$modal.msgWarning("请选择数据"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | const ids = selectedRows.value.map((item) => item.id); |
| | | proxy.$modal |
| | | .confirm("选中的内容将被删除,是否确认?") |
| | | .then(() => delWeighbridgeLedger(ids)) |
| | | .then(() => { |
| | | delDeliveryLedger(ids).then((res) => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | .catch(() => {}); |
| | | }; |
| | | |
| | | // 单个删除 |
| | | const handleDeleteSingle = (row) => { |
| | | ElMessageBox.confirm("此操作将删除该记录,是否确认?", "删除", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | delDeliveryLedger([row.id]).then((res) => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | const openImportDialog = () => { |
| | | importUpload.open = true; |
| | | importUploadRef.value?.clearFiles(); |
| | | }; |
| | | |
| | | // 获取当前日期并格式化为 YYYY-MM-DD |
| | | function getCurrentDate() { |
| | | const today = new Date(); |
| | | const year = today.getFullYear(); |
| | | const month = String(today.getMonth() + 1).padStart(2, "0"); |
| | | const day = String(today.getDate()).padStart(2, "0"); |
| | | return `${year}-${month}-${day}`; |
| | | } |
| | | const submitImport = () => { |
| | | if (!importUploadRef.value) return; |
| | | importUpload.isUploading = true; |
| | | importUploadRef.value.submit(); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getList(); |