From e446a0f0d95283a1c2c44a1f4ef7ac512fdf11ca Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 22 一月 2026 13:37:55 +0800
Subject: [PATCH] 湟水峡 1.发货分开类型货车和快递
---
src/views/salesManagement/salesLedger/index.vue | 424 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 309 insertions(+), 115 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index b4215b5..41aaf1a 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -6,16 +6,8 @@
<el-input v-model="searchForm.customerName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
@change="handleQuery" />
</el-form-item>
- <el-form-item label="瀹㈡埛鍚堝悓鍙凤細">
- <el-input v-model="searchForm.customerContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
- @change="handleQuery" />
- </el-form-item>
<el-form-item label="閿�鍞悎鍚屽彿锛�">
<el-input v-model="searchForm.salesContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
- @change="handleQuery" />
- </el-form-item>
- <el-form-item label="椤圭洰鍚嶇О锛�">
- <el-input v-model="searchForm.projectName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
@change="handleQuery" />
</el-form-item>
<el-form-item label="褰曞叆鏃ユ湡锛�">
@@ -64,30 +56,43 @@
</el-table-column>
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
<el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" width="180" show-overflow-tooltip />
- <el-table-column label="瀹㈡埛鍚堝悓鍙�" prop="customerContractNo" width="180" show-overflow-tooltip />
<el-table-column label="瀹㈡埛鍚嶇О" prop="customerName" width="300" show-overflow-tooltip />
<el-table-column label="涓氬姟鍛�" prop="salesman" width="100" show-overflow-tooltip />
- <el-table-column label="椤圭洰鍚嶇О" prop="projectName" width="180" show-overflow-tooltip />
<el-table-column label="浠樻鏂瑰紡" prop="paymentMethod" show-overflow-tooltip />
<el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" width="220" show-overflow-tooltip
:formatter="formattedNumber" />
<el-table-column label="褰曞叆浜�" prop="entryPersonName" width="100" show-overflow-tooltip />
<el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" width="120" show-overflow-tooltip />
<el-table-column label="绛捐鏃ユ湡" prop="executionDate" width="120" show-overflow-tooltip />
- <el-table-column fixed="right" label="鎿嶄綔" min-width="200" align="center">
+ <el-table-column label="鍙戣揣鐘舵��" prop="shippingStatus" width="140" align="center" show-overflow-tooltip />
+ <el-table-column label="鍙戣揣鏃ユ湡" prop="shippingDate" width="140" align="center" show-overflow-tooltip />
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="140" align="center">
<template #default="scope">
- <el-button link type="primary" size="small" :disabled="scope.row.invoiceTotal>0 || scope.row.entryPersonName !== userStore.nickName" @click="openForm('edit', scope.row)">缂栬緫</el-button>
-<!-- <el-button link type="primary" size="small" @click="openForm('view', scope.row)">璇︽儏</el-button>-->
+ <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">缂栬緫</el-button>
<el-button link type="primary" size="small" @click="downLoadFile(scope.row)">闄勪欢</el-button>
- <el-button link type="primary" size="small" @click="openDeliveryForm(scope.row)">鍙戣揣</el-button>
+ <el-button
+ link
+ type="primary"
+ size="small"
+ @click="openDeliveryForm(scope.row)"
+ :disabled="scope.row.shippingStatus === '宸插彂璐�'"
+ >
+ 鍙戣揣
+ </el-button>
</template>
</el-table-column>
</el-table>
<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="70%"
- @close="closeDia">
+ <FormDialog
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板閿�鍞彴璐﹂〉闈�' : '缂栬緫閿�鍞彴璐﹂〉闈�'"
+ :width="'70%'"
+ :operation-type="operationType"
+ @close="closeDia"
+ @confirm="submitForm"
+ @cancel="closeDia">
<el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
<el-row :gutter="30">
<el-col :span="12">
@@ -97,7 +102,9 @@
</el-col>
<el-col :span="12">
<el-form-item label="涓氬姟鍛橈細" prop="salesman">
- <el-select v-model="form.salesman" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
+ <el-select v-model="form.salesman"
+ filterable
+ :reserve-keyword="false" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
<el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
:value="item.nickName" />
</el-select>
@@ -106,26 +113,14 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="瀹㈡埛鍚堝悓鍙凤細" prop="customerContractNo">
- <el-input v-model="form.customerContractNo" placeholder="璇疯緭鍏�" clearable :disabled="operationType === 'view'"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
<el-form-item label="瀹㈡埛鍚嶇О锛�" prop="customerId">
- <el-select v-model="form.customerId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
+ <el-select v-model="form.customerId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'" filterable>
<el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.id">
{{
- item.customerName + "鈥斺��" + item.taxpayerIdentificationNumber
+ item.customerName+'-'+item.customerType
}}
</el-option>
</el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="椤圭洰鍚嶇О锛�" prop="projectName">
- <el-input v-model="form.projectName" placeholder="璇疯緭鍏�" clearable :disabled="operationType === 'view'" />
</el-form-item>
</el-col>
<el-col :span="12">
@@ -138,7 +133,10 @@
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="褰曞叆浜猴細" prop="entryPerson">
- <el-select v-model="form.entryPerson" placeholder="璇烽�夋嫨" clearable @change="changs" disabled>
+ <el-select v-model="form.entryPerson"
+ filterable
+ default-first-option
+ :reserve-keyword="false" placeholder="璇烽�夋嫨" clearable @change="changs">
<el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" />
</el-select>
</el-form-item>
@@ -154,14 +152,6 @@
<el-col :span="12">
<el-form-item label="浠樻鏂瑰紡">
<el-input v-model="form.paymentMethod" placeholder="璇疯緭鍏�" clearable :disabled="operationType === 'view'" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鏄惁寮�绁�" prop="isInvoice">
- <el-select v-model="form.isInvoice" placeholder="璇烽�夋嫨" clearable>
- <el-option label="鏄�" value="1" />
- <el-option label="鍚�" value="2" />
- </el-select>
</el-form-item>
</el-col>
</el-row>
@@ -220,7 +210,7 @@
<el-button @click="closeDia">鍙栨秷</el-button>
</div>
</template>
- </el-dialog>
+ </FormDialog>
<el-dialog v-model="productFormVisible" :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'" width="40%"
@close="closeProductDia">
<el-form :model="productForm" label-width="140px" label-position="top" :rules="productRules" ref="productFormRef">
@@ -331,7 +321,7 @@
<div v-for="(item, index) in printData" :key="index" class="print-page">
<div class="delivery-note">
<div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
+ <div class="company-name">闈掓捣婀熸按宄″啘涓氬彂灞曟湁闄愬叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
@@ -342,17 +332,20 @@
<span class="value">{{ formatDate(item.createTime) }}</span>
</div>
<div>
-
- <span class="label">瀹㈡埛鍚嶇О锛�</span>
- <span class="value">{{ item.customerName || '寮犵埍鏈�' }}</span>
+ <span class="label">鍙戣揣杞︾墝鍙凤細</span>
+ <span class="value">{{ item.shippingCarNumber }}</span>
</div>
</div>
<div class="info-row">
+ <div>
+ <span class="label">瀹㈡埛鍚嶇О锛�</span>
+ <span class="value">{{ item.customerName || '寮犵埍鏈�' }}</span>
+ </div>
<span class="label">鍗曞彿锛�</span>
<span class="value">{{ item.salesContractNo }}</span>
</div>
</div>
-
+
<div class="table-section">
<table class="product-table">
<thead>
@@ -390,7 +383,7 @@
</tfoot>
</table>
</div>
-
+
<div class="footer-section">
<div class="footer-row">
<div class="footer-item">
@@ -432,6 +425,21 @@
<el-form :model="deliveryForm" label-width="120px" label-position="top" :rules="deliveryRules" ref="deliveryFormRef">
<el-row :gutter="30">
<el-col :span="24">
+ <el-form-item label="鍙戣揣绫诲瀷锛�" prop="type">
+ <el-select
+ v-model="deliveryForm.type"
+ placeholder="璇烽�夋嫨鍙戣揣绫诲瀷"
+ style="width: 100%"
+ @change="handleShippingTypeChange"
+ >
+ <el-option label="璐ц溅" value="璐ц溅" />
+ <el-option label="蹇��" value="蹇��" />
+ </el-select>
+ </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%"
@@ -446,7 +454,7 @@
</el-col>
</el-row>
<el-row :gutter="30">
- <el-col :span="24">
+ <el-col :span="24" v-if="deliveryForm.type === '璐ц溅'">
<el-form-item label="鍙戣揣杞︾墝鍙凤細" prop="shippingCarNumber">
<el-input
v-model="deliveryForm.shippingCarNumber"
@@ -455,7 +463,56 @@
/>
</el-form-item>
</el-col>
+ <el-col :span="24" v-else>
+ <el-form-item label="蹇�掑叕鍙革細" prop="expressCompany">
+ <el-input
+ v-model="deliveryForm.expressCompany"
+ placeholder="璇疯緭鍏ュ揩閫掑叕鍙�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
</el-row>
+ <el-row :gutter="30" v-if="deliveryForm.type === '蹇��'">
+ <el-col :span="24">
+ <el-form-item label="蹇�掑崟鍙凤細" prop="expressNumber">
+ <el-input
+ v-model="deliveryForm.expressNumber"
+ placeholder="璇疯緭鍏ュ揩閫掑崟鍙�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="24">
+ <el-form-item label="鍙戣揣鍥剧墖锛�">
+ <el-upload
+ v-model:file-list="deliveryFileList"
+ :action="upload.url"
+ multiple
+ ref="deliveryFileUpload"
+ auto-upload
+ :headers="upload.headers"
+ :data="{ type: 9 }"
+ :before-upload="handleDeliveryBeforeUpload"
+ :on-error="handleDeliveryUploadError"
+ :on-success="handleDeliveryUploadSuccess"
+ :on-remove="handleDeliveryRemove"
+ list-type="picture-card"
+ :limit="9"
+ accept="image/png,image/jpeg,image/jpg"
+ >
+ <el-icon class="avatar-uploader-icon"><Plus /></el-icon>
+ <template #tip>
+ <div class="el-upload__tip">
+ 鏀寔 jpg銆乯peg銆乸ng 鏍煎紡锛屾渶澶氫笂浼� 9 寮狅紝鍗曞紶澶у皬涓嶈秴杩� 10MB
+ </div>
+ </template>
+ </el-upload>
+ </el-form-item>
+ </el-col>
+ </el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
@@ -471,26 +528,31 @@
<script setup>
import { getToken } from "@/utils/auth";
import pagination from "@/components/PIMTable/Pagination.vue";
-import {onMounted, ref} from "vue";
+import {onMounted, ref, getCurrentInstance} from "vue";
import { addShippingInfo } from "@/api/salesManagement/deliveryLedger.js";
-import { ElMessageBox } from "element-plus";
+import { ElMessageBox, ElMessage } from "element-plus";
+import { UploadFilled, Plus } from "@element-plus/icons-vue";
import useUserStore from "@/store/modules/user";
import { userListNoPage } from "@/api/system/user.js";
-import FileList from "./fileList.vue";
+import FileList from '@/views/salesManagement/salesLedger/fileList.vue';
+import FormDialog from '@/components/Dialog/FormDialog.vue';
+import { getQuotationList } from "@/api/salesManagement/salesQuotation.js";
import {
- ledgerListPage,
- productList,
- customerList,
- addOrUpdateSalesLedger,
- getSalesLedgerWithProducts,
- delLedger,
- addOrUpdateSalesLedgerProduct,
- delProduct,
- delLedgerFile,
+ ledgerListPage,
+ productList,
+ customerList,
+ addOrUpdateSalesLedger,
+ getSalesLedgerWithProducts,
+ delLedger,
+ addOrUpdateSalesLedgerProduct,
+ delProduct,
+ delLedgerFile, getProductInventory,
} from "@/api/salesManagement/salesLedger.js";
+import { getQuotationDetail } from "@/api/salesManagement/salesQuotation.js";
import { modelList, productTreeList } from "@/api/basicData/product.js";
import useFormData from "@/hooks/useFormData.js";
import dayjs from "dayjs";
+import { getCurrentDate } from "@/utils/index.js";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
@@ -509,6 +571,7 @@
});
const total = ref(0);
const fileList = ref([]);
+const deliveryFileList = ref([]);
// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
const operationType = ref("");
@@ -516,10 +579,8 @@
const data = reactive({
searchForm: {
customerName: "", // 瀹㈡埛鍚嶇О
- customerContractNo: "", // 瀹㈡埛鍚堝悓缂栧彿
salesContractNo: "", // 閿�鍞悎鍚岀紪鍙�
productCategory: "", // 浜у搧澶х被
- projectName: "", // 椤圭洰鍚嶇О
entryDate: null, // 褰曞叆鏃ユ湡
entryDateStart: undefined,
entryDateEnd: undefined,
@@ -527,28 +588,20 @@
form: {
salesContractNo: "",
salesman: "",
- customerContractNo: "",
customerId: "",
- projectName: "",
entryPerson: "",
entryDate: "",
maintenanceTime: "",
productData: [],
executionDate: "",
paymentMethod: "",
- isInvoice:"",
},
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" }],
- isInvoice: [{ required: true, message: "璇烽�夋嫨", trigger: "change"}],
},
});
const { form, rules } = toRefs(data);
@@ -608,15 +661,25 @@
const currentDeliveryRow = ref(null);
const deliveryFormData = reactive({
deliveryForm: {
+ type: "璐ц溅", // 璐ц溅, 蹇��
shippingDate: "",
shippingCarNumber: "",
+ expressCompany: "",
+ expressNumber: "", // 蹇�掑崟鍙�
+ shippingImages: "", // 鍙戣揣鍥剧墖锛屽涓敤閫楀彿鍒嗛殧
},
deliveryRules: {
+ type: [
+ { required: true, message: "璇烽�夋嫨鍙戣揣绫诲瀷", trigger: "change" }
+ ],
shippingDate: [
{ required: true, message: "璇烽�夋嫨鍙戣揣鏃ユ湡", trigger: "change" }
],
shippingCarNumber: [
- { required: true, message: "璇疯緭鍏ュ彂璐ц溅鐗屽彿", trigger: "blur" }
+ { validator: (_, value, callback) => validateShippingCarNumber(value, callback), trigger: "blur" }
+ ],
+ expressCompany: [
+ { validator: (_, value, callback) => validateExpressCompany(value, callback), trigger: "blur" }
],
},
});
@@ -636,7 +699,11 @@
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
const handleQuery = () => {
- page.current = 1;
+ // 鍙湁鍦ㄧ偣鍑绘悳绱㈡寜閽椂鎵嶉噸缃〉鐮佸埌绗竴椤�
+ // 閬垮厤琛ㄥ崟瀛楁change浜嬩欢骞叉壈鍒嗛〉
+ if (arguments.length === 0) {
+ page.current = 1;
+ }
expandedRowKeys.value = [];
getList();
};
@@ -663,8 +730,12 @@
};
// 鑾峰彇浜у搧澶х被tree鏁版嵁
const getProductOptions = () => {
- productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
+ // 杩斿洖 Promise锛屼究浜庡湪缂栬緫浜у搧鏃剁瓑寰呭姞杞藉畬鎴�
+ return productTreeList().then((res) => {
+ // 鍏煎鎺ュ彛杩斿洖 { data: [] } 鎴栫洿鎺ヨ繑鍥炴暟缁�
+ const list = Array.isArray(res) ? res : (res?.data ?? []);
+ productOptions.value = convertIdToValue(list);
+ return productOptions.value;
});
};
const formattedNumber = (row, column, cellValue) => {
@@ -683,6 +754,7 @@
if (index !== -1) {
productForm.value.specificationModel = modelOptions.value[index].model;
productForm.value.unit = modelOptions.value[index].unit;
+ fetchQuotationPrice();
} else {
productForm.value.specificationModel = null;
productForm.value.unit = null;
@@ -702,6 +774,29 @@
}
return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
};
+// 鏍规嵁鎶ヤ环鎺ュ彛鍥炲~鍗曚环
+const fetchQuotationPrice = async () => {
+ // 闇�瑕佸鎴风被鍨嬨�佷骇鍝佸悕绉般�佽鏍�
+ const customer = customerOption.value.find((c) => c.id === form.value.customerId);
+ const customerType = customer?.customerType || customer?.type;
+ const productName = productForm.value.productCategory;
+ const specification = productForm.value.specificationModel;
+
+ try {
+ const { data } = await getQuotationDetail({
+ type: customerType,
+ productName,
+ specification,
+ });
+ const price = data;
+ if (price !== null && price !== undefined) {
+ productForm.value.taxInclusiveUnitPrice = Number(price);
+ mathNum(); // 閲嶆柊璁$畻鎬讳环
+ }
+ } catch (error) {
+ console.error("鑾峰彇鎶ヤ环鍗曚环澶辫触", error);
+ }
+};
function convertIdToValue(data) {
return data.map((item) => {
const { id, children, ...rest } = item;
@@ -715,6 +810,19 @@
return newItem;
});
+}
+// 鏍规嵁鍚嶇О鍙嶆煡浜у搧澶х被 id锛屼究浜庝粎瀛樺悕绉版椂鐨勫弽鏄�
+function findNodeIdByLabel(nodes, label) {
+ if (!label) return null;
+ for (let i = 0; i < nodes.length; i++) {
+ const node = nodes[i];
+ if (node.label === label) return node.value;
+ if (node.children && node.children.length > 0) {
+ const found = findNodeIdByLabel(node.children, label);
+ if (found !== null && found !== undefined) return found;
+ }
+ }
+ return null;
}
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
@@ -772,7 +880,12 @@
customerOption.value = res;
});
form.value.entryPerson = userStore.id;
- if (type !== "add") {
+ if (type === "add") {
+ // 鏂板鏃惰缃綍鍏ユ棩鏈熶负褰撳ぉ
+ form.value.entryDate = getCurrentDate();
+ // 绛捐鏃ユ湡榛樿涓哄綋澶�
+ form.value.executionDate = getCurrentDate();
+ } else {
currentId.value = row.id;
getSalesLedgerWithProducts({ id: row.id, type: 1 }).then((res) => {
form.value = { ...res };
@@ -829,6 +942,47 @@
});
}
}
+// 鍙戣揣鍥剧墖涓婁紶鍓嶆牎妫�
+function handleDeliveryBeforeUpload(file) {
+ // 鏍℃鏂囦欢绫诲瀷
+ const isImage = file.type === 'image/png' || file.type === 'image/jpeg' || file.type === 'image/jpg';
+ if (!isImage) {
+ proxy.$modal.msgError("鍙兘涓婁紶 jpg銆乯peg銆乸ng 鏍煎紡鐨勫浘鐗�!");
+ return false;
+ }
+ // 鏍℃鏂囦欢澶у皬
+ const isLt10M = file.size / 1024 / 1024 < 10;
+ if (!isLt10M) {
+ proxy.$modal.msgError("涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 10MB!");
+ return false;
+ }
+ proxy.$modal.loading("姝e湪涓婁紶鍥剧墖锛岃绋嶅��...");
+ return true;
+}
+// 鍙戣揣鍥剧墖涓婁紶澶辫触
+function handleDeliveryUploadError(err) {
+ proxy.$modal.msgError("涓婁紶鍥剧墖澶辫触");
+ proxy.$modal.closeLoading();
+}
+// 鍙戣揣鍥剧墖涓婁紶鎴愬姛鍥炶皟
+function handleDeliveryUploadSuccess(res, file, uploadFiles) {
+ proxy.$modal.closeLoading();
+ if (res.code === 200) {
+ file.tempId = res.data.tempId;
+ proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+ } else {
+ proxy.$modal.msgError(res.msg);
+ proxy.$refs.deliveryFileUpload.handleRemove(file);
+ }
+}
+// 绉婚櫎鍙戣揣鍥剧墖
+function handleDeliveryRemove(file) {
+ // 浠庢枃浠跺垪琛ㄤ腑绉婚櫎
+ const index = deliveryFileList.value.findIndex(item => item.uid === file.uid);
+ if (index > -1) {
+ deliveryFileList.value.splice(index, 1);
+ }
+}
// 鎻愪氦琛ㄥ崟
const submitForm = () => {
proxy.$refs["formRef"].validate((valid) => {
@@ -862,13 +1016,40 @@
const productIndex = ref(0);
// 鎵撳紑浜у搧寮规
-const openProductForm = (type, row,index) => {
+const openProductForm = async (type, row, index) => {
productOperationType.value = type;
productForm.value = {};
proxy.resetForm("productFormRef");
+ // 鏂板銆佺紪杈戦兘闇�鍏堝姞杞戒骇鍝佹爲锛屽惁鍒� el-tree-select 鏃犳暟鎹�
+ try {
+ await getProductOptions();
+ } catch (e) {
+ console.error("鍔犺浇浜у搧鏍戝け璐�", e);
+ }
if (type === "edit") {
productForm.value = { ...row };
productIndex.value = index;
+ // 缂栬緫鏃舵牴鎹骇鍝佸ぇ绫诲悕绉板弽鏌� tree 鑺傜偣 id锛屽苟鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
+ try {
+ const options = productOptions.value && productOptions.value.length > 0
+ ? productOptions.value
+ : await getProductOptions();
+ const categoryId = findNodeIdByLabel(options, productForm.value.productCategory);
+ if (categoryId) {
+ const models = await modelList({ id: categoryId });
+ modelOptions.value = models || [];
+ // 鏍规嵁褰撳墠瑙勬牸鍨嬪彿鍚嶇О鍙嶆煡骞惰缃� productModelId锛屼究浜庝笅鎷夋鏄剧ず宸查�夊��
+ const currentModel = (modelOptions.value || []).find(
+ (m) => m.model === productForm.value.specificationModel
+ );
+ if (currentModel) {
+ productForm.value.productModelId = currentModel.id;
+ }
+ }
+ } catch (e) {
+ // 鍔犺浇澶辫触鏃朵繚鎸佸彲缂栬緫锛屼笉涓柇寮圭獥
+ console.error("鍔犺浇浜у搧瑙勬牸鍨嬪彿澶辫触", e);
+ }
}
productFormVisible.value = true;
getProductOptions();
@@ -1183,7 +1364,7 @@
<div class="print-page">
<div class="delivery-note">
<div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
+ <div class="company-name">闈掓捣婀熸按宄″啘涓氬彂灞曟湁闄愬叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
@@ -1312,15 +1493,6 @@
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
};
-// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
-function getCurrentDate() {
- const today = new Date();
- const year = today.getFullYear();
- const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
- const day = String(today.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
-}
-
// 璁$畻浜у搧鎬绘暟閲�
const getTotalQuantity = (products) => {
if (!products || products.length === 0) return '0';
@@ -1356,6 +1528,20 @@
return total.toFixed(2);
};
+// 鍙戣揣绫诲瀷鏍¢獙锛氳揣杞︽椂瑕佹眰杞︾墝锛屽揩閫掓椂瑕佹眰蹇�掑叕鍙�
+const validateShippingCarNumber = (value, callback) => {
+ if (deliveryForm.value.type === "璐ц溅") {
+ if (!value) return callback(new Error("璇疯緭鍏ュ彂璐ц溅鐗屽彿"));
+ }
+ callback();
+};
+const validateExpressCompany = (value, callback) => {
+ if (deliveryForm.value.type === "蹇��") {
+ if (!value) return callback(new Error("璇疯緭鍏ュ揩閫掑叕鍙�"));
+ }
+ callback();
+};
+
const mathNum = () => {
console.log("productForm.value", productForm.value);
if (!productForm.value.taxInclusiveUnitPrice) {
@@ -1386,6 +1572,7 @@
const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
+ const taxRate = Number(productForm.value.taxRate) || 0;
if (!totalPrice || !quantity || quantity <= 0) {
return;
@@ -1397,17 +1584,10 @@
productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- // if (productForm.value.taxRate) {
- // productForm.value.taxExclusiveTotalPrice =
- // proxy.calculateTaxExclusiveTotalPrice(
- // totalPrice,
- // productForm.value.taxRate
- // );
- // }
productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
totalPrice,
- productForm.value.taxRate
+ taxRate
);
isCalculating.value = false;
@@ -1423,7 +1603,7 @@
const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
- const taxRate = productForm.value.taxRate?parseFloat(productForm.value.taxRate):0;
+ const taxRate = Number(productForm.value.taxRate) || 0;
// if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
// return;
@@ -1455,6 +1635,7 @@
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
+ const taxRate = Number(productForm.value.taxRate) || 0;
if (!quantity || quantity <= 0 || !unitPrice) {
return;
@@ -1466,17 +1647,10 @@
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- // if (productForm.value.taxRate) {
- // productForm.value.taxExclusiveTotalPrice =
- // proxy.calculateTaxExclusiveTotalPrice(
- // productForm.value.taxInclusiveTotalPrice,
- // productForm.value.taxRate
- // );
- // }
productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ taxRate
);
isCalculating.value = false;
@@ -1492,6 +1666,7 @@
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
+ const taxRate = Number(productForm.value.taxRate) || 0;
if (!quantity || quantity <= 0 || !unitPrice) {
return;
@@ -1503,17 +1678,10 @@
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- // if (productForm.value.taxRate) {
- // productForm.value.taxExclusiveTotalPrice =
- // proxy.calculateTaxExclusiveTotalPrice(
- // productForm.value.taxInclusiveTotalPrice,
- // productForm.value.taxRate
- // );
- // }
productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ taxRate
);
isCalculating.value = false;
@@ -1528,7 +1696,7 @@
if (isCalculating.value) return;
const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
- const taxRate = parseFloat(productForm.value.taxRate);
+ const taxRate = Number(productForm.value.taxRate) || 0;
// if (!inclusiveTotalPrice || !taxRate) {
// return;
@@ -1562,22 +1730,35 @@
// 鎵撳紑鍙戣揣寮规
const openDeliveryForm = (row) => {
- currentDeliveryRow.value = row;
+ currentDeliveryRow.value = row;
deliveryForm.value = {
+ type: "璐ц溅",
shippingDate: getCurrentDate(),
shippingCarNumber: "",
+ expressCompany: "",
+ expressNumber: "", // 鍒濆鍖栧揩閫掑崟鍙蜂负绌�
+ shippingImages: "", // 鍒濆鍖栧浘鐗囦负绌�
};
- deliveryFormVisible.value = true;
+ deliveryFileList.value = []; // 鍒濆鍖栨枃浠跺垪琛ㄤ负绌�
+ deliveryFormVisible.value = true;
};
// 鎻愪氦鍙戣揣琛ㄥ崟
const submitDelivery = () => {
proxy.$refs["deliveryFormRef"].validate((valid) => {
if (valid) {
+ let tempFileIds = [];
+ if (deliveryFileList.value !== null && deliveryFileList.value.length > 0) {
+ tempFileIds = deliveryFileList.value.map((item) => item.tempId);
+ }
addShippingInfo({
salesLedgerId: currentDeliveryRow.value.id,
+ type: deliveryForm.value.type,
shippingDate: deliveryForm.value.shippingDate,
- shippingCarNumber: deliveryForm.value.shippingCarNumber,
+ shippingCarNumber: deliveryForm.value.type === "璐ц溅" ? deliveryForm.value.shippingCarNumber : "",
+ expressCompany: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressCompany : "",
+ expressNumber: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressNumber : "",
+ tempFileIds: tempFileIds,
})
.then(() => {
proxy.$modal.msgSuccess("鍙戣揣鎴愬姛");
@@ -1594,10 +1775,23 @@
// 鍏抽棴鍙戣揣寮规
const closeDeliveryDia = () => {
proxy.resetForm("deliveryFormRef");
+ deliveryFileList.value = []; // 娓呯┖鏂囦欢鍒楄〃
+ deliveryForm.value.shippingImages = ""; // 娓呯┖鍥剧墖
+ deliveryForm.value.expressNumber = ""; // 娓呯┖蹇�掑崟鍙�
deliveryFormVisible.value = false;
currentDeliveryRow.value = null;
};
+// 鍙戣揣绫诲瀷鍒囨崲鏃舵竻绌哄搴斿瓧娈�
+const handleShippingTypeChange = (val) => {
+ if (val === "璐ц溅") {
+ deliveryForm.value.expressCompany = "";
+ deliveryForm.value.expressNumber = "";
+ } else {
+ deliveryForm.value.shippingCarNumber = "";
+ }
+};
+
onMounted(() => {
getList();
});
--
Gitblit v1.9.3