From 409a6c46741422f0d6dc00acc38b5f7dc1f35e9f Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 24 九月 2026 10:53:07 +0800
Subject: [PATCH] feat: 现场需求前端改动

---
 src/views/equipmentManagement/measurementEquipment/components/calibrationDia.vue |  132 +++++++++++++++++++++++++++++++-------------
 1 files changed, 93 insertions(+), 39 deletions(-)

diff --git a/src/views/equipmentManagement/measurementEquipment/components/calibrationDia.vue b/src/views/equipmentManagement/measurementEquipment/components/calibrationDia.vue
index 923dd2c..85a8f4b 100644
--- a/src/views/equipmentManagement/measurementEquipment/components/calibrationDia.vue
+++ b/src/views/equipmentManagement/measurementEquipment/components/calibrationDia.vue
@@ -2,7 +2,7 @@
 	<div>
 		<el-dialog
 			v-model="dialogFormVisible"
-			title="璁¢噺鍣ㄥ叿"
+			:title="dialogTitle"
 			width="50%"
 			draggable
 			@close="closeDia"
@@ -14,7 +14,28 @@
 				:rules="rules"
 				ref="formRef"
 			>
-				<el-row :gutter="30">
+				<el-row :gutter="30" v-if="operationType === 'add'">
+					<el-col :span="24">
+						<el-form-item label="璁¢噺鍣ㄥ叿锛�" prop="measuringInstrumentLedgerId">
+							<el-select
+								v-model="form.measuringInstrumentLedgerId"
+								placeholder="璇烽�夋嫨璁¢噺鍣ㄥ叿"
+								filterable
+								clearable
+								style="width: 100%"
+								@change="handleInstrumentChange"
+							>
+								<el-option
+									v-for="item in instrumentOptions"
+									:key="item.id"
+									:label="`${item.code} - ${item.name}`"
+									:value="item.id"
+								/>
+							</el-select>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30" v-else>
 					<el-col :span="12">
 						<el-form-item label="璁¢噺鍣ㄥ叿缂栧彿锛�" prop="customerName">
 							<el-input
@@ -99,23 +120,6 @@
 						</el-form-item>
 					</el-col>
 				</el-row>
-<!--				<el-row :gutter="30">-->
-<!--					<el-col :span="24">-->
-<!--						<el-form-item label="闄勪欢鏉愭枡锛�" prop="remark">-->
-<!--							<el-upload v-model:file-list="fileList" :action="upload.url" multiple ref="fileUpload" auto-upload-->
-<!--												 :headers="upload.headers" :before-upload="handleBeforeUpload" :on-error="handleUploadError"-->
-<!--												 :on-success="handleUploadSuccess" :on-remove="handleRemove">-->
-<!--								<el-button type="primary" v-if="operationType !== 'view'">涓婁紶</el-button>-->
-<!--								<template #tip v-if="operationType !== 'view'">-->
-<!--									<div class="el-upload__tip">-->
-<!--										鏂囦欢鏍煎紡鏀寔-->
-<!--										doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z-->
-<!--									</div>-->
-<!--								</template>-->
-<!--							</el-upload>-->
-<!--						</el-form-item>-->
-<!--					</el-col>-->
-<!--				</el-row>-->
 			</el-form>
 			<template #footer>
 				<div class="dialog-footer">
@@ -128,13 +132,11 @@
 </template>
 
 <script setup>
-import {ref, reactive, toRefs, getCurrentInstance} from "vue";
+import {ref, reactive, toRefs, getCurrentInstance, computed} from "vue";
 import useUserStore from "@/store/modules/user.js";
 import {userListNoPageByTenantId} from "@/api/system/user.js";
-import {afterSalesServiceAdd, afterSalesServiceUpdate} from "@/api/customerService/index.js";
 import {getToken} from "@/utils/auth.js";
-import {ledgerRecordUpdate, ledgerRecordVerifying} from "@/api/equipmentManagement/calibration.js";
-import {delLedgerFile} from "@/api/salesManagement/salesLedger.js";
+import {ledgerRecordUpdate, ledgerRecordVerifying, ledgerOptions} from "@/api/equipmentManagement/calibration.js";
 import { getCurrentDate } from "@/utils/index.js";
 const { proxy } = getCurrentInstance()
 const emit = defineEmits(['close'])
@@ -142,10 +144,19 @@
 const operationType = ref('')
 const userStore = useUserStore();
 
+const dialogTitle = computed(() => {
+	if (operationType.value === 'add') return '鏂板鏍″噯'
+	if (operationType.value === 'verifying') return '璁¢噺鍣ㄥ叿妫�瀹�'
+	return '缂栬緫鏍″噯'
+})
+
 const data = reactive({
 	form: {
+		id: undefined,
+		measuringInstrumentLedgerId: undefined,
 		code: "",
 		name: "",
+		model: "",
 		valid: "",
 		recordDate: "",
 		userId: "",
@@ -153,6 +164,7 @@
     tempFileIds: []
 	},
 	rules: {
+		measuringInstrumentLedgerId: [{required: true, message: "璇烽�夋嫨璁¢噺鍣ㄥ叿", trigger: "change"}],
 		code: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
 		name: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
 		valid: [
@@ -188,6 +200,7 @@
 })
 const { form, rules } = toRefs(data);
 const userList = ref([])
+const instrumentOptions = ref([]);
 const fileList = ref([]);
 const upload = reactive({
 	// 涓婁紶鐨勫湴鍧�
@@ -196,34 +209,69 @@
 	headers: { Authorization: "Bearer " + getToken() },
 });
 
+// 鍔犺浇璁¢噺鍣ㄥ叿涓嬫媺锛堝綋鍓嶇鎴峰叏閮ㄨ閲忓櫒鍏凤級
+const loadInstrumentOptions = () => {
+	ledgerOptions().then((res) => {
+		instrumentOptions.value = res.data || [];
+	}).catch(() => {
+		instrumentOptions.value = [];
+	});
+};
+
+// 閫夋嫨璁¢噺鍣ㄥ叿鍚庡洖濉紪鍙�/鍚嶇О/璇佷功缂栧彿锛屽苟璁颁綇鍙拌处ID锛坴erifying 鐢� id 浣滀负鍙拌处ID锛�
+const handleInstrumentChange = (id) => {
+	const it = instrumentOptions.value.find(o => o.id === id);
+	if (it) {
+		form.value.id = it.id;
+		form.value.code = it.code;
+		form.value.name = it.name;
+		form.value.model = it.model;
+	} else {
+		form.value.id = undefined;
+		form.value.code = "";
+		form.value.name = "";
+		form.value.model = "";
+	}
+};
+
 // 鎵撳紑寮规
-const openDialog = (type, row) => {
-  console.log(row)
+const openDialog = (type, row = {}) => {
 	operationType.value = type;
 	dialogFormVisible.value = true;
 	userListNoPageByTenantId().then((res) => {
 		userList.value = res.data;
 	});
-  fileList.value = []
-	if(type !== "add"){
-	  form.value.tempFileIds = [];
-  }
+	fileList.value = [];
+	// 閲嶇疆琛ㄥ崟
+	form.value.id = undefined;
+	form.value.measuringInstrumentLedgerId = undefined;
+	form.value.code = "";
+	form.value.name = "";
+	form.value.model = "";
+	form.value.valid = "";
+	form.value.recordDate = "";
+	form.value.tempFileIds = [];
+
+	if (type === "add") {
+		loadInstrumentOptions();
+	}
 	if (type === "edit") {
+		form.value.id = row.id;
+		form.value.code = row.code;
+		form.value.name = row.name;
 		form.value.valid = row.valid;
 		form.value.recordDate = row.recordDate;
-    fileList.value = row.commonFiles;
+		fileList.value = row.commonFiles;
 	}
-	if(type === "add"){
-    fileList.value = row.commonFiles;
-  }
-	if(type === "verifying"){
+	if (type === "verifying") {
+		form.value.id = row.id;
+		form.value.code = row.code;
+		form.value.name = row.name;
+		form.value.model = row.model;
 		form.value.valid = row.valid;
 		form.value.recordDate = row.mostDate;
 	}
 
-	form.value.id = row.id;
-	form.value.code = row.code;
-	form.value.name = row.name;
 	form.value.userId = userStore.id;
 	form.value.entryDate = getCurrentDate();
 }
@@ -252,7 +300,13 @@
 const submitForm = () => {
 	proxy.$refs["formRef"].validate(valid => {
 		if (valid) {
-			if (operationType.value === "verifying") {
+			if (operationType.value === "add") {
+				// 鏂板鏍″噯锛氬鐢ㄦ瀹氭帴鍙o紝鍐欎竴鏉℃牎鍑嗚褰曞苟鍚屾鏇存柊鍙拌处妫�瀹氭棩鏈�/鏈夋晥鏈�
+				ledgerRecordVerifying(form.value).then(response => {
+					proxy.$modal.msgSuccess("鏂板鏍″噯鎴愬姛")
+					closeDia()
+				})
+			} else if (operationType.value === "verifying") {
 				ledgerRecordVerifying(form.value).then(response => {
 					proxy.$modal.msgSuccess("妫�瀹氭牎鍑嗘垚鍔�")
 					closeDia()
@@ -279,4 +333,4 @@
 
 <style scoped>
 
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3