| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="filters" :inline="true"> |
| | | <el-form-item label="ç³è¯·åå·:"> |
| | | <el-input v-model="filters.invoiceApplicationNo" placeholder="请è¾å
¥ç³è¯·åå·" clearable style="width: 200px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="ä¾åºå:"> |
| | | <el-select v-model="filters.supplierId" placeholder="è¯·éæ©ä¾åºå" clearable filterable style="width: 200px;"> |
| | | <el-option |
| | | v-for="item in supplierList" |
| | | :key="item.id" |
| | | :label="item.supplierName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="å®¡æ ¸ç¶æ:"> |
| | | <el-select v-model="filters.status" placeholder="è¯·éæ©ç¶æ" clearable style="width: 150px;"> |
| | | <el-option label="å¾
å®¡æ ¸" :value="0" /> |
| | | <el-option label="å®¡æ ¸éè¿" :value="1" /> |
| | | <el-option label="å®¡æ ¸ä¸éè¿" :value="2" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="ç³è¯·æ¥æ:"> |
| | | <el-date-picker |
| | | v-model="filters.dateRange" |
| | | type="daterange" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | range-separator="è³" |
| | | start-placeholder="å¼å§æ¥æ" |
| | | end-placeholder="ç»ææ¥æ" |
| | | clearable |
| | | style="width: 240px;" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="onSearch">æç´¢</el-button> |
| | | <el-button @click="resetFilters">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="table_list"> |
| | | <div class="actions"> |
| | | <div></div> |
| | | <div> |
| | | <el-button type="primary" @click="add" icon="Plus">æ°å¢ç³è¯·</el-button> |
| | | <el-button @click="handleExport" icon="Download">导åº</el-button> |
| | | </div> |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | :column="columns" |
| | | :tableData="dataList" |
| | | :tableLoading="tableLoading" |
| | | isShowSummary |
| | | :summaryMethod="getSummaries" |
| | | :page="{ |
| | | current: pagination.currentPage, |
| | | size: pagination.pageSize, |
| | | total: pagination.total, |
| | | }" |
| | | @pagination="changePage" |
| | | > |
| | | <template #amount="{ row }"> |
| | | <span class="text-danger">Â¥{{ formatMoney(row.amount) }}</span> |
| | | </template> |
| | | <template #paymentMethod="{ row }"> |
| | | <el-tag>{{ getPaymentMethodLabel(row.paymentMethod) }}</el-tag> |
| | | </template> |
| | | <template #status="{ row }"> |
| | | <el-tag :type="getStatusType(row.status)">{{ getStatusLabel(row.status) }}</el-tag> |
| | | </template> |
| | | <template #operation="{ row }"> |
| | | <el-button type="primary" link @click="view(row)">æ¥ç</el-button> |
| | | <el-button type="primary" link @click="edit(row)" v-if="isPendingStatus(row.status)">ç¼è¾</el-button> |
| | | <el-button type="success" link @click="handleAudit(row)" v-if="isPendingStatus(row.status)">å®¡æ ¸</el-button> |
| | | <el-button type="warning" link @click="openPaymentDialog(row)" v-if="isApprovedStatus(row.status)">仿¬¾</el-button> |
| | | <el-button type="danger" link @click="handleDelete(row)" v-if="isPendingStatus(row.status)">å é¤</el-button> |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | | |
| | | <FormDialog |
| | | :title="dialogTitle" |
| | | v-model="dialogVisible" |
| | | width="800px" |
| | | :operation-type="isView ? 'detail' : ''" |
| | | @confirm="submitForm" |
| | | @cancel="closeDialog" |
| | | > |
| | | <el-form :model="form" :rules="rules" ref="formRef" label-width="120px"> |
| | | <el-row v-if="isView" :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å®¡æ ¸ç¶æ"> |
| | | <el-tag :type="getStatusType(form.status)">{{ getStatusLabel(form.status) }}</el-tag> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç³è¯·åå·" prop="invoiceApplicationNo"> |
| | | <el-input v-model="form.invoiceApplicationNo" placeholder="ä¿ååèªå¨çæ" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ä¾åºå" prop="supplierId"> |
| | | <el-select |
| | | v-model="form.supplierId" |
| | | placeholder="è¯·éæ©ä¾åºå" |
| | | style="width: 100%;" |
| | | filterable |
| | | :disabled="isEdit || isView" |
| | | @change="handleSupplierChange" |
| | | > |
| | | <el-option |
| | | v-for="item in supplierList" |
| | | :key="item.id" |
| | | :label="item.supplierName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å
³èå
¥åºå" prop="stockInRecordIds"> |
| | | <el-input |
| | | :model-value="inboundBatchDisplayText" |
| | | placeholder="请å
éæ©ä¾åºå" |
| | | readonly |
| | | :disabled="!form.supplierId || isEdit || isView" |
| | | class="inbound-batch-input" |
| | | @click="handleInboundInputClick" |
| | | > |
| | | <template v-if="!isEdit && !isView" #append> |
| | | <el-button |
| | | :disabled="!form.supplierId" |
| | | :loading="inboundBatchLoading" |
| | | @click.stop="openInboundSelectDialog" |
| | | > |
| | | éæ© |
| | | </el-button> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç³è¯·æ¥æ" prop="applyDate"> |
| | | <el-date-picker |
| | | v-model="form.applyDate" |
| | | type="date" |
| | | placeholder="éæ©æ¥æ" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å建æ¶é´" prop="createTime"> |
| | | <el-date-picker |
| | | v-model="formCreateTimeDate" |
| | | type="date" |
| | | placeholder="éæ©æ¥æ" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾éé¢" prop="paymentAmount"> |
| | | <el-input-number |
| | | v-model="form.paymentAmount" |
| | | :min="0" |
| | | :precision="2" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | placeholder="æ ¹æ®å
¥åºåèªå¨æ±æ»ï¼å¯ä¿®æ¹" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾æ¹å¼" prop="paymentMethod"> |
| | | <el-select |
| | | v-model="form.paymentMethod" |
| | | placeholder="è¯·éæ©ä»æ¬¾æ¹å¼" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | > |
| | | <el-option |
| | | v-for="item in checkout_payment" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="仿¬¾äºç±" prop="paymentContent"> |
| | | <el-input |
| | | v-model="form.paymentContent" |
| | | type="textarea" |
| | | :rows="3" |
| | | placeholder="请è¾å
¥ä»æ¬¾äºç±" |
| | | :disabled="isView" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请è¾å
¥å¤æ³¨" :disabled="isView" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template v-if="!isView" #footer> |
| | | <el-button type="primary" :loading="submitLoading" @click="submitForm">ç¡®å®</el-button> |
| | | <el-button @click="closeDialog">åæ¶</el-button> |
| | | </template> |
| | | </FormDialog> |
| | | |
| | | <FormDialog |
| | | title="仿¬¾" |
| | | v-model="paymentDialogVisible" |
| | | width="800px" |
| | | @confirm="submitPayment" |
| | | @cancel="paymentDialogVisible = false" |
| | | > |
| | | <el-form :model="paymentForm" :rules="paymentRules" ref="paymentFormRef" label-width="120px"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾åå·" prop="paymentNumber"> |
| | | <el-input v-model="paymentForm.paymentNumber" placeholder="ä¿ååèªå¨çæ" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å
³èç³è¯·å" prop="invoiceApplicationNo"> |
| | | <el-input v-model="paymentForm.invoiceApplicationNo" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ä¾åºå"> |
| | | <el-input v-model="paymentForm.supplierName" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾æ¥æ" prop="paymentDate"> |
| | | <el-date-picker |
| | | v-model="paymentForm.paymentDate" |
| | | type="date" |
| | | placeholder="éæ©æ¥æ" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%;" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å建æ¶é´" prop="createTime"> |
| | | <el-date-picker |
| | | v-model="paymentFormCreateTimeDate" |
| | | type="date" |
| | | placeholder="éæ©æ¥æ" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%;" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾éé¢" prop="paymentAmount"> |
| | | <el-input-number |
| | | v-model="paymentForm.paymentAmount" |
| | | :min="0" |
| | | :precision="2" |
| | | style="width: 100%;" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="仿¬¾æ¹å¼" prop="paymentMethod"> |
| | | <el-select v-model="paymentForm.paymentMethod" placeholder="è¯·éæ©ä»æ¬¾æ¹å¼" style="width: 100%;"> |
| | | <el-option |
| | | v-for="item in checkout_payment" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row v-if="isBankTransferPayment(paymentForm.paymentMethod)" :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="é¶è¡è´¦å·" prop="bankAccount"> |
| | | <el-input v-model="paymentForm.bankAccount" placeholder="é¶è¡è´¦å·" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="弿·è¡" prop="bankName"> |
| | | <el-input v-model="paymentForm.bankName" placeholder="弿·è¡" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="夿³¨" prop="remark"> |
| | | <el-input v-model="paymentForm.remark" type="textarea" :rows="3" placeholder="请è¾å
¥å¤æ³¨" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button type="primary" :loading="paymentSubmitLoading" @click="submitPayment">ç¡®å®</el-button> |
| | | <el-button @click="paymentDialogVisible = false">åæ¶</el-button> |
| | | </template> |
| | | </FormDialog> |
| | | |
| | | <el-dialog |
| | | v-model="inboundSelectVisible" |
| | | title="éæ©å
¥åºåå·" |
| | | width="1100px" |
| | | append-to-body |
| | | destroy-on-close |
| | | :close-on-click-modal="false" |
| | | @closed="handleInboundDialogClosed" |
| | | > |
| | | <el-table |
| | | ref="inboundTableRef" |
| | | v-loading="inboundBatchLoading" |
| | | :data="inboundBatchList" |
| | | row-key="id" |
| | | border |
| | | stripe |
| | | max-height="480" |
| | | @selection-change="handleInboundDialogSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column prop="inboundBatches" label="å
¥åºåå·" min-width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="supplierName" label="ä¾åºå" min-width="120" show-overflow-tooltip /> |
| | | <el-table-column prop="productName" label="产ååç§°" min-width="120" show-overflow-tooltip /> |
| | | <el-table-column prop="specificationModel" label="è§æ ¼åå·" min-width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="purchaseContractNumber" label="éè´è®¢åå·" min-width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="inboundDate" label="å
¥åºæ¥æ" width="110" align="center" /> |
| | | <el-table-column prop="inboundAmount" label="å
¥åºéé¢(å«ç¨)" width="120" align="right"> |
| | | <template #default="{ row }">Â¥{{ formatMoney(getInboundRowTaxInclusiveAmount(row)) }}</template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template #footer> |
| | | <el-button type="primary" @click="confirmInboundSelection">ç¡®å®</el-button> |
| | | <el-button @click="inboundSelectVisible = false">åæ¶</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, computed, onMounted, nextTick, getCurrentInstance } from "vue"; |
| | | import dayjs from "dayjs"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import FormDialog from "@/components/Dialog/FormDialog.vue"; |
| | | import { getOptions } from "@/api/procurementManagement/procurementLedger.js"; |
| | | import { |
| | | getInboundBatchesBySupplier, |
| | | addAccountPaymentApplication, |
| | | listPageAccountPaymentApplication, |
| | | updateAccountPaymentApplication, |
| | | auditAccountPaymentApplication, |
| | | deleteAccountPaymentApplication, |
| | | } from "@/api/financialManagement/accountPaymentApplication.js"; |
| | | import { addAccountPurchasePayment } from "@/api/financialManagement/accountPurchasePayment.js"; |
| | | |
| | | defineOptions({ |
| | | name: "仿¬¾ç³è¯·", |
| | | }); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { checkout_payment } = proxy.useDict("checkout_payment"); |
| | | |
| | | const filters = reactive({ |
| | | invoiceApplicationNo: "", |
| | | supplierId: "", |
| | | status: "", |
| | | dateRange: [], |
| | | }); |
| | | |
| | | const pagination = reactive({ |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | total: 0, |
| | | }); |
| | | |
| | | const columns = [ |
| | | { label: "ç³è¯·åå·", prop: "applyCode", width: "150" }, |
| | | { label: "ä¾åºå", prop: "supplierName", width: "180" }, |
| | | { label: "仿¬¾éé¢", prop: "amount", dataType: "slot", slot: "amount" }, |
| | | { label: "仿¬¾æ¹å¼", prop: "paymentMethod", dataType: "slot", slot: "paymentMethod", width: "120" }, |
| | | { label: "ç³è¯·æ¥æ", prop: "applyDate", width: "120" }, |
| | | { label: "ç¶æ", prop: "status", dataType: "slot", slot: "status", width: "100" }, |
| | | { label: "æä½", prop: "operation", dataType: "slot", slot: "operation", width: "260", fixed: "right" }, |
| | | ]; |
| | | |
| | | const dataList = ref([]); |
| | | const tableLoading = ref(false); |
| | | const dialogVisible = ref(false); |
| | | const dialogTitle = ref(""); |
| | | const formRef = ref(null); |
| | | const isEdit = ref(false); |
| | | const isView = ref(false); |
| | | const submitLoading = ref(false); |
| | | const currentId = ref(null); |
| | | const supplierList = ref([]); |
| | | |
| | | const inboundBatchList = ref([]); |
| | | const inboundBatchOptions = ref([]); |
| | | const inboundBatchLoading = ref(false); |
| | | const inboundSelectVisible = ref(false); |
| | | const inboundTableRef = ref(null); |
| | | const dialogInboundSelection = ref([]); |
| | | |
| | | const paymentDialogVisible = ref(false); |
| | | const paymentFormRef = ref(null); |
| | | const paymentSubmitLoading = ref(false); |
| | | |
| | | const paymentForm = reactive({ |
| | | paymentNumber: "", |
| | | invoiceApplicationNo: "", |
| | | supplierName: "", |
| | | supplierId: "", |
| | | accountPaymentApplicationId: null, |
| | | paymentDate: "", |
| | | paymentAmount: 0, |
| | | paymentMethod: "", |
| | | bankAccount: "", |
| | | bankName: "", |
| | | remark: "", |
| | | createTime: "", |
| | | }); |
| | | |
| | | const paymentRules = { |
| | | paymentDate: [{ required: true, message: "è¯·éæ©ä»æ¬¾æ¥æ", trigger: "change" }], |
| | | paymentAmount: [{ required: true, message: "请è¾å
¥ä»æ¬¾éé¢", trigger: "blur" }], |
| | | paymentMethod: [{ required: true, message: "è¯·éæ©ä»æ¬¾æ¹å¼", trigger: "change" }], |
| | | }; |
| | | |
| | | const STATUS_LABEL_MAP = { 0: "å¾
å®¡æ ¸", 1: "å®¡æ ¸éè¿", 2: "å®¡æ ¸ä¸éè¿" }; |
| | | const STATUS_TYPE_MAP = { 0: "warning", 1: "success", 2: "danger" }; |
| | | |
| | | const form = reactive({ |
| | | invoiceApplicationNo: "", |
| | | supplierId: "", |
| | | paymentAmount: 0, |
| | | paymentMethod: "", |
| | | applyDate: "", |
| | | paymentContent: "", |
| | | remark: "", |
| | | stockInRecordIds: [], |
| | | inboundBatches: "", |
| | | status: 0, |
| | | createTime: "", |
| | | }); |
| | | const formCreateTimeDate = computed({ |
| | | get: () => (form.createTime ? String(form.createTime).split(" ")[0] : ""), |
| | | set: (value) => { |
| | | form.createTime = value ? `${value} ${dayjs().format("HH:mm:ss")}` : ""; |
| | | }, |
| | | }); |
| | | const paymentFormCreateTimeDate = computed({ |
| | | get: () => (paymentForm.createTime ? String(paymentForm.createTime).split(" ")[0] : ""), |
| | | set: (value) => { |
| | | paymentForm.createTime = value ? `${value} ${dayjs().format("HH:mm:ss")}` : ""; |
| | | }, |
| | | }); |
| | | |
| | | const rules = { |
| | | supplierId: [{ required: true, message: "è¯·éæ©ä¾åºå", trigger: "change" }], |
| | | stockInRecordIds: [{ required: true, type: "array", min: 1, message: "è¯·éæ©å
³èå
¥åºå", trigger: "change" }], |
| | | paymentAmount: [{ required: true, message: "请è¾å
¥ä»æ¬¾éé¢", trigger: "blur" }], |
| | | paymentMethod: [{ required: true, message: "è¯·éæ©ä»æ¬¾æ¹å¼", trigger: "change" }], |
| | | applyDate: [{ required: true, message: "è¯·éæ©ç³è¯·æ¥æ", trigger: "change" }], |
| | | }; |
| | | |
| | | const getSummaries = ({ columns, data }) => { |
| | | const sums = []; |
| | | columns.forEach((col, index) => { |
| | | if (index === 0) { |
| | | sums[index] = "å计"; |
| | | } else if (col.property === "amount") { |
| | | const total = data.reduce((prev, cur) => { |
| | | const v = Number(cur.amount); |
| | | return prev + (isNaN(v) ? 0 : v); |
| | | }, 0); |
| | | sums[index] = total.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); |
| | | } else { |
| | | sums[index] = ""; |
| | | } |
| | | }); |
| | | return sums; |
| | | }; |
| | | |
| | | const formatMoney = (value) => { |
| | | if (value === undefined || value === null) return "0.00"; |
| | | return Number(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| | | }; |
| | | |
| | | const normalizeStatus = (status) => { |
| | | if (status === undefined || status === null || status === "") return 0; |
| | | const num = Number(status); |
| | | return Number.isNaN(num) ? 0 : num; |
| | | }; |
| | | |
| | | const isPendingStatus = (status) => normalizeStatus(status) === 0; |
| | | |
| | | const isApprovedStatus = (status) => normalizeStatus(status) === 1; |
| | | |
| | | const isBankTransferPayment = (method) => { |
| | | if (method === undefined || method === null || method === "") return false; |
| | | const item = checkout_payment.value?.find((m) => String(m.value) === String(method)); |
| | | if (item?.label?.includes("é¶è¡")) return true; |
| | | return String(method) === "bank_transfer" || String(method).toLowerCase().includes("bank"); |
| | | }; |
| | | |
| | | const getStatusLabel = (status) => STATUS_LABEL_MAP[normalizeStatus(status)] ?? "å¾
å®¡æ ¸"; |
| | | |
| | | const getStatusType = (status) => STATUS_TYPE_MAP[normalizeStatus(status)] ?? "warning"; |
| | | |
| | | const getPaymentMethodLabel = (value) => { |
| | | if (value === undefined || value === null || value === "") return "-"; |
| | | const item = checkout_payment.value?.find((m) => String(m.value) === String(value)); |
| | | return item?.label ?? value; |
| | | }; |
| | | |
| | | const getDefaultPaymentMethod = () => checkout_payment.value?.[0]?.value ?? ""; |
| | | |
| | | const parseStockInRecordIds = (value) => { |
| | | if (!value) return []; |
| | | if (Array.isArray(value)) return value; |
| | | return String(value) |
| | | .split(/[,ï¼]/) |
| | | .map((s) => s.trim()) |
| | | .filter(Boolean) |
| | | .map((s) => (/^\d+$/.test(s) ? Number(s) : s)); |
| | | }; |
| | | |
| | | const formatInboundBatches = (value) => { |
| | | if (value === undefined || value === null || value === "") return ""; |
| | | if (Array.isArray(value)) return value.filter(Boolean).join("ã"); |
| | | return String(value) |
| | | .split(/[,ï¼]/) |
| | | .map((s) => s.trim()) |
| | | .filter(Boolean) |
| | | .join("ã"); |
| | | }; |
| | | |
| | | const isSameInboundId = (a, b) => String(a) === String(b); |
| | | |
| | | const getInboundRowId = (row) => row?.id ?? row?.stockInRecordId; |
| | | |
| | | const getInboundRowTaxInclusiveAmount = (row) => |
| | | Number(row?.inboundAmount ?? row?.taxInclusivePrice ?? row?.totalAmount ?? row?.amount ?? 0); |
| | | |
| | | const normalizeInboundBatchOptions = (data) => { |
| | | const list = Array.isArray(data) ? data : []; |
| | | return list.map((item, index) => { |
| | | const label = |
| | | item.inboundBatches ?? item.batchNo ?? item.inboundNo ?? `å
¥åºå${index + 1}`; |
| | | const value = item.id ?? item.stockInRecordId ?? label; |
| | | return { |
| | | label: String(label), |
| | | value, |
| | | inboundAmount: getInboundRowTaxInclusiveAmount(item), |
| | | }; |
| | | }); |
| | | }; |
| | | |
| | | const syncPaymentAmount = () => { |
| | | const selected = form.stockInRecordIds || []; |
| | | let sum = inboundBatchOptions.value |
| | | .filter((opt) => selected.some((id) => isSameInboundId(id, opt.value))) |
| | | .reduce((acc, opt) => acc + (Number(opt.inboundAmount) || 0), 0); |
| | | |
| | | if (sum <= 0 && selected.length) { |
| | | sum = inboundBatchList.value |
| | | .filter((row) => selected.some((id) => isSameInboundId(id, getInboundRowId(row)))) |
| | | .reduce((acc, row) => acc + getInboundRowTaxInclusiveAmount(row), 0); |
| | | } |
| | | |
| | | form.paymentAmount = sum > 0 ? Number(sum.toFixed(2)) : 0; |
| | | }; |
| | | |
| | | const inboundBatchDisplayText = computed(() => { |
| | | if (form.inboundBatches) return form.inboundBatches; |
| | | const ids = form.stockInRecordIds || []; |
| | | if (!ids.length) return ""; |
| | | const labels = inboundBatchOptions.value |
| | | .filter((opt) => ids.some((id) => isSameInboundId(id, opt.value))) |
| | | .map((opt) => opt.label); |
| | | if (labels.length) return labels.join("ã"); |
| | | return ids.join("ã"); |
| | | }); |
| | | |
| | | const normalizeTableRow = (row) => ({ |
| | | ...row, |
| | | applyCode: row.invoiceApplicationNo ?? row.applyCode, |
| | | amount: row.paymentAmount ?? row.amount, |
| | | reason: row.paymentContent ?? row.reason, |
| | | status: normalizeStatus(row.status), |
| | | stockInRecordIds: row.stockInRecordIds ?? "", |
| | | inboundBatches: formatInboundBatches(row.inboundBatches), |
| | | }); |
| | | |
| | | const fillFormFromRow = (row) => { |
| | | const stockInRecordIds = parseStockInRecordIds(row.stockInRecordIds); |
| | | Object.assign(form, { |
| | | invoiceApplicationNo: row.invoiceApplicationNo ?? row.applyCode ?? "", |
| | | supplierId: row.supplierId, |
| | | paymentAmount: Number(row.paymentAmount ?? row.amount ?? 0), |
| | | paymentMethod: row.paymentMethod ?? getDefaultPaymentMethod(), |
| | | applyDate: row.applyDate ?? "", |
| | | paymentContent: row.paymentContent ?? row.reason ?? "", |
| | | remark: row.remark ?? "", |
| | | stockInRecordIds, |
| | | inboundBatches: formatInboundBatches(row.inboundBatches), |
| | | status: normalizeStatus(row.status), |
| | | createTime: row.createTime ?? "", |
| | | }); |
| | | }; |
| | | |
| | | const buildPayloadFromRow = (row, statusOverride) => ({ |
| | | id: row.id, |
| | | supplierId: row.supplierId, |
| | | stockInRecordIds: |
| | | typeof row.stockInRecordIds === "string" |
| | | ? row.stockInRecordIds |
| | | : (row.stockInRecordIds || []).join(","), |
| | | invoiceApplicationNo: row.invoiceApplicationNo ?? row.applyCode ?? "", |
| | | paymentMethod: row.paymentMethod, |
| | | paymentContent: row.paymentContent ?? row.reason ?? "", |
| | | applyDate: row.applyDate, |
| | | remark: row.remark ?? "", |
| | | status: statusOverride !== undefined ? statusOverride : normalizeStatus(row.status), |
| | | paymentAmount: Number(row.paymentAmount ?? row.amount ?? 0), |
| | | createTime: row.createTime, |
| | | }); |
| | | |
| | | const buildSubmitPayload = (forUpdate = false) => { |
| | | const payload = { |
| | | supplierId: form.supplierId, |
| | | stockInRecordIds: (form.stockInRecordIds || []).join(","), |
| | | invoiceApplicationNo: form.invoiceApplicationNo || "", |
| | | paymentMethod: form.paymentMethod, |
| | | paymentContent: form.paymentContent || "", |
| | | applyDate: form.applyDate, |
| | | remark: form.remark || "", |
| | | status: 0, |
| | | paymentAmount: form.paymentAmount, |
| | | createTime: form.createTime, |
| | | }; |
| | | if (forUpdate) { |
| | | payload.id = currentId.value; |
| | | } |
| | | return payload; |
| | | }; |
| | | |
| | | const getSupplierList = () => { |
| | | getOptions().then((res) => { |
| | | if (res.code === 200) { |
| | | supplierList.value = res.data ?? []; |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const appendFilterParams = (params) => { |
| | | if (filters.invoiceApplicationNo) { |
| | | params.invoiceApplicationNo = filters.invoiceApplicationNo; |
| | | } |
| | | if (filters.supplierId) { |
| | | params.supplierId = filters.supplierId; |
| | | } |
| | | if (filters.status !== "" && filters.status != null) { |
| | | params.status = filters.status; |
| | | } |
| | | if (filters.dateRange?.length === 2) { |
| | | params.startDate = filters.dateRange[0]; |
| | | params.endDate = filters.dateRange[1]; |
| | | } |
| | | return params; |
| | | }; |
| | | |
| | | const buildListParams = () => |
| | | appendFilterParams({ |
| | | current: pagination.currentPage, |
| | | size: pagination.pageSize, |
| | | }); |
| | | |
| | | const buildExportParams = () => appendFilterParams({}); |
| | | |
| | | const handleExport = () => { |
| | | proxy.download( |
| | | "/accountPaymentApplication/exportAccountPaymentApplication", |
| | | buildExportParams(), |
| | | `仿¬¾ç³è¯·_${Date.now()}.xlsx` |
| | | ); |
| | | }; |
| | | |
| | | const getTableData = () => { |
| | | tableLoading.value = true; |
| | | listPageAccountPaymentApplication(buildListParams()) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | dataList.value = (res.data?.records ?? []).map(normalizeTableRow); |
| | | pagination.total = res.data?.total ?? 0; |
| | | } else { |
| | | dataList.value = []; |
| | | pagination.total = 0; |
| | | ElMessage.error(res.msg || "æ¥è¯¢å¤±è´¥"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | dataList.value = []; |
| | | pagination.total = 0; |
| | | ElMessage.error("æ¥è¯¢å¤±è´¥"); |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | const onSearch = () => { |
| | | pagination.currentPage = 1; |
| | | getTableData(); |
| | | }; |
| | | |
| | | const resetFilters = () => { |
| | | filters.invoiceApplicationNo = ""; |
| | | filters.supplierId = ""; |
| | | filters.status = ""; |
| | | filters.dateRange = []; |
| | | pagination.currentPage = 1; |
| | | getTableData(); |
| | | }; |
| | | |
| | | const changePage = ({ page, limit }) => { |
| | | pagination.currentPage = page; |
| | | pagination.pageSize = limit; |
| | | getTableData(); |
| | | }; |
| | | |
| | | const closeDialog = () => { |
| | | dialogVisible.value = false; |
| | | isView.value = false; |
| | | isEdit.value = false; |
| | | inboundSelectVisible.value = false; |
| | | }; |
| | | |
| | | const resetForm = () => { |
| | | Object.assign(form, { |
| | | invoiceApplicationNo: "", |
| | | supplierId: "", |
| | | paymentAmount: 0, |
| | | paymentMethod: getDefaultPaymentMethod(), |
| | | applyDate: new Date().toISOString().split("T")[0], |
| | | paymentContent: "", |
| | | remark: "", |
| | | stockInRecordIds: [], |
| | | inboundBatches: "", |
| | | status: 0, |
| | | createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }); |
| | | inboundBatchList.value = []; |
| | | inboundBatchOptions.value = []; |
| | | }; |
| | | |
| | | const add = () => { |
| | | isEdit.value = false; |
| | | isView.value = false; |
| | | dialogTitle.value = "æ°å¢ä»æ¬¾ç³è¯·"; |
| | | resetForm(); |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | const edit = (row) => { |
| | | isEdit.value = true; |
| | | isView.value = false; |
| | | currentId.value = row.id; |
| | | dialogTitle.value = "ç¼è¾ä»æ¬¾ç³è¯·"; |
| | | fillFormFromRow(row); |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | const view = (row) => { |
| | | isView.value = true; |
| | | isEdit.value = false; |
| | | dialogTitle.value = "æ¥ç仿¬¾ç³è¯·"; |
| | | fillFormFromRow(row); |
| | | if (row.supplierId) { |
| | | loadInboundBatches(row.supplierId, true, false); |
| | | } |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | const submitAudit = (row, status) => { |
| | | auditAccountPaymentApplication(buildPayloadFromRow(row, status)) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | ElMessage.success(status === 1 ? "å®¡æ ¸éè¿" : "å®¡æ ¸ä¸éè¿"); |
| | | getTableData(); |
| | | } else { |
| | | ElMessage.error(res.msg || "å®¡æ ¸å¤±è´¥"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.error("å®¡æ ¸å¤±è´¥"); |
| | | }); |
| | | }; |
| | | |
| | | const handleAudit = (row) => { |
| | | ElMessageBox.confirm("è¯·éæ©å®¡æ ¸ç»æ", "仿¬¾ç³è¯·å®¡æ ¸", { |
| | | confirmButtonText: "å®¡æ ¸éè¿", |
| | | cancelButtonText: "å®¡æ ¸ä¸éè¿", |
| | | distinguishCancelAndClose: true, |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | submitAudit(row, 1); |
| | | }) |
| | | .catch((action) => { |
| | | if (action === "cancel") { |
| | | submitAudit(row, 2); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const openPaymentDialog = (row) => { |
| | | Object.assign(paymentForm, { |
| | | paymentNumber: "", |
| | | invoiceApplicationNo: row.invoiceApplicationNo ?? row.applyCode ?? "", |
| | | supplierName: row.supplierName ?? "", |
| | | supplierId: row.supplierId, |
| | | accountPaymentApplicationId: row.id, |
| | | paymentDate: new Date().toISOString().split("T")[0], |
| | | paymentAmount: Number(row.paymentAmount ?? row.amount ?? 0), |
| | | paymentMethod: row.paymentMethod ?? getDefaultPaymentMethod(), |
| | | bankAccount: row.bankAccountNum ?? row.bankAccount ?? "", |
| | | bankName: row.bankAccountName ?? row.bankName ?? "", |
| | | remark: "", |
| | | createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }); |
| | | paymentDialogVisible.value = true; |
| | | nextTick(() => { |
| | | paymentFormRef.value?.clearValidate(); |
| | | }); |
| | | }; |
| | | |
| | | const submitPayment = () => { |
| | | paymentFormRef.value?.validate((valid) => { |
| | | if (!valid) return; |
| | | paymentSubmitLoading.value = true; |
| | | addAccountPurchasePayment({ |
| | | accountPaymentApplicationId: paymentForm.accountPaymentApplicationId, |
| | | supplierId: paymentForm.supplierId, |
| | | paymentDate: paymentForm.paymentDate, |
| | | paymentMethod: paymentForm.paymentMethod, |
| | | paymentAmount: paymentForm.paymentAmount, |
| | | paymentNumber: paymentForm.paymentNumber || "", |
| | | remark: paymentForm.remark || "", |
| | | createTime: paymentForm.createTime, |
| | | }) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | ElMessage.success("仿¬¾æå"); |
| | | paymentDialogVisible.value = false; |
| | | getTableData(); |
| | | } else { |
| | | ElMessage.error(res.msg || "仿¬¾å¤±è´¥"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.error("仿¬¾å¤±è´¥"); |
| | | }) |
| | | .finally(() => { |
| | | paymentSubmitLoading.value = false; |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const handleDelete = (row) => { |
| | | ElMessageBox.confirm(`确认å é¤ç³è¯·åã${row.applyCode ?? row.invoiceApplicationNo}ãåï¼`, "æç¤º", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }).then(() => { |
| | | deleteAccountPaymentApplication([row.id]) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | ElMessage.success("å 餿å"); |
| | | getTableData(); |
| | | } else { |
| | | ElMessage.error(res.msg || "å é¤å¤±è´¥"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.error("å é¤å¤±è´¥"); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const submitForm = () => { |
| | | formRef.value?.validate((valid) => { |
| | | if (!valid) return; |
| | | submitLoading.value = true; |
| | | const request = isEdit.value |
| | | ? updateAccountPaymentApplication(buildSubmitPayload(true)) |
| | | : addAccountPaymentApplication(buildSubmitPayload(false)); |
| | | |
| | | request |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | ElMessage.success(isEdit.value ? "ç¼è¾æå" : "æ°å¢æå"); |
| | | closeDialog(); |
| | | pagination.currentPage = 1; |
| | | getTableData(); |
| | | } else { |
| | | ElMessage.error(res.msg || "ä¿å失败"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.error("ä¿å失败"); |
| | | }) |
| | | .finally(() => { |
| | | submitLoading.value = false; |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const ensureInboundOptionsForSelected = () => { |
| | | const ids = form.stockInRecordIds || []; |
| | | ids.forEach((id) => { |
| | | const exists = inboundBatchOptions.value.some((opt) => isSameInboundId(opt.value, id)); |
| | | if (exists) return; |
| | | const fromList = inboundBatchList.value.find((row) => isSameInboundId(getInboundRowId(row), id)); |
| | | if (fromList) { |
| | | const [option] = normalizeInboundBatchOptions([fromList]); |
| | | if (option) inboundBatchOptions.value.push(option); |
| | | return; |
| | | } |
| | | inboundBatchOptions.value.push({ |
| | | label: String(id), |
| | | value: id, |
| | | inboundAmount: 0, |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const restoreInboundTableSelection = () => { |
| | | nextTick(() => { |
| | | const table = inboundTableRef.value; |
| | | if (!table) return; |
| | | table.clearSelection(); |
| | | const selectedIds = new Set((form.stockInRecordIds || []).map((id) => String(id))); |
| | | inboundBatchList.value.forEach((row) => { |
| | | const rowId = getInboundRowId(row); |
| | | if (rowId !== undefined && rowId !== null && selectedIds.has(String(rowId))) { |
| | | table.toggleRowSelection(row, true); |
| | | } |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | const loadInboundBatches = (supplierId, keepSelected = false, syncAmount = true) => { |
| | | if (!supplierId) { |
| | | inboundBatchList.value = []; |
| | | inboundBatchOptions.value = []; |
| | | if (!keepSelected) { |
| | | form.stockInRecordIds = []; |
| | | form.inboundBatches = ""; |
| | | form.paymentAmount = 0; |
| | | } |
| | | return Promise.resolve(); |
| | | } |
| | | inboundBatchLoading.value = true; |
| | | return getInboundBatchesBySupplier({ supplierId }) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | const list = res.data?.records ?? res.data ?? []; |
| | | inboundBatchList.value = Array.isArray(list) ? list : []; |
| | | inboundBatchOptions.value = normalizeInboundBatchOptions(list); |
| | | } else { |
| | | inboundBatchList.value = []; |
| | | inboundBatchOptions.value = []; |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | inboundBatchList.value = []; |
| | | inboundBatchOptions.value = []; |
| | | }) |
| | | .finally(() => { |
| | | inboundBatchLoading.value = false; |
| | | if (keepSelected) { |
| | | ensureInboundOptionsForSelected(); |
| | | restoreInboundTableSelection(); |
| | | if (syncAmount && !isView.value) { |
| | | syncPaymentAmount(); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const handleSupplierChange = (supplierId) => { |
| | | form.stockInRecordIds = []; |
| | | form.inboundBatches = ""; |
| | | form.paymentAmount = 0; |
| | | loadInboundBatches(supplierId); |
| | | }; |
| | | |
| | | const handleInboundInputClick = () => { |
| | | if (isEdit.value || isView.value) return; |
| | | openInboundSelectDialog(); |
| | | }; |
| | | |
| | | const openInboundSelectDialog = () => { |
| | | if (!form.supplierId || isEdit.value || isView.value) return; |
| | | inboundSelectVisible.value = true; |
| | | loadInboundBatches(form.supplierId, true, false).then(() => { |
| | | restoreInboundTableSelection(); |
| | | }); |
| | | }; |
| | | |
| | | const handleInboundDialogSelectionChange = (selection) => { |
| | | dialogInboundSelection.value = selection; |
| | | }; |
| | | |
| | | const confirmInboundSelection = () => { |
| | | if (dialogInboundSelection.value.length === 0) { |
| | | ElMessage.warning("请è³å°éæ©ä¸æ¡å
¥åºå"); |
| | | return; |
| | | } |
| | | form.stockInRecordIds = dialogInboundSelection.value |
| | | .map((row) => getInboundRowId(row)) |
| | | .filter((id) => id !== undefined && id !== null); |
| | | form.inboundBatches = dialogInboundSelection.value |
| | | .map((row) => row.inboundBatches ?? row.batchNo ?? "") |
| | | .filter(Boolean) |
| | | .join("ã"); |
| | | dialogInboundSelection.value.forEach((row) => { |
| | | const [option] = normalizeInboundBatchOptions([row]); |
| | | if (option && !inboundBatchOptions.value.some((opt) => isSameInboundId(opt.value, option.value))) { |
| | | inboundBatchOptions.value.push(option); |
| | | } |
| | | }); |
| | | inboundSelectVisible.value = false; |
| | | syncPaymentAmount(); |
| | | formRef.value?.validateField("stockInRecordIds"); |
| | | }; |
| | | |
| | | const handleInboundDialogClosed = () => { |
| | | dialogInboundSelection.value = []; |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getSupplierList(); |
| | | getTableData(); |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .actions { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | margin-bottom: 15px; |
| | | } |
| | | |
| | | .text-danger { |
| | | color: #f56c6c; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .inbound-batch-input :deep(.el-input__wrapper) { |
| | | cursor: pointer; |
| | | } |
| | | </style> |