CzRger 8 місяців тому
батько
коміт
7596e14d1e

+ 51 - 5
snowy-admin-web/src/views/yqyc/zero/enterprise-ledger/detail.vue

@@ -99,12 +99,28 @@
 					<a-row :gutter="16">
 						<a-col :span="8">
 							<a-form-item label="料件编码:" name="productCode">
-								<a-input v-model:value="bodyData.productCode" :disabled="isView" placeholder="请输入商品编码" allow-clear />
+								<a-select
+									v-model:value="bodyData.productCode"
+									placeholder="请选择料件编码"
+									style="width: 100%"
+									:filter-option="false"
+									:not-found-content="fetchingLj ? undefined : null"
+									:options="ljOptions"
+									:show-search="true"
+									@search="fetchLj"
+									@change="onChangeLj"
+									option-label-prop="value"
+									:disabled="isView"
+								>
+									<template v-if="fetchingLj" #notFoundContent>
+										<a-spin size="small" />
+									</template>
+								</a-select>
 							</a-form-item>
 						</a-col>
 						<a-col :span="8">
 							<a-form-item label="料件名称:" name="productName">
-								<a-input v-model:value="bodyData.productName" :disabled="isView" placeholder="请输入商品名称" allow-clear />
+								<a-input v-model:value="bodyData.productName" :disabled="true" placeholder="请选择料件编码" allow-clear />
 							</a-form-item>
 						</a-col>
 						<a-col :span="8">
@@ -129,12 +145,12 @@
 						</a-col>
 						<a-col :span="8">
 							<a-form-item label="法定计量单位:" name="legalUnit">
-								<a-select v-model:value="bodyData.legalUnit" :disabled="isView" placeholder="请输入法定计量单位" :options="legalUnitOptions" show-search allow-clear option-filter-prop="label"/>
+								<a-input v-model:value="bodyData.legalUnit" :disabled="true" placeholder="请选择料件编码" allow-clear/>
 							</a-form-item>
 						</a-col>
 						<a-col :span="8">
 							<a-form-item label="法定第二计量单位:" name="legalSecondUnit">
-								<a-select v-model:value="bodyData.legalSecondUnit" :disabled="isView" placeholder="请输入法定第二计量单位" :options="legalUnitOptions" show-search allow-clear option-filter-prop="label"/>
+								<a-input v-model:value="bodyData.legalSecondUnit" :disabled="true" placeholder="请选择料件编码" allow-clear/>
 							</a-form-item>
 						</a-col>
 						<a-col :span="8">
@@ -364,6 +380,7 @@
 									@search="fetchSp"
 									@change="onChangeSp"
 									option-label-prop="value"
+									:disabled="isView"
 								>
 									<template v-if="fetchingSp" #notFoundContent>
 										<a-spin size="small" />
@@ -565,6 +582,8 @@ const currencyOptions = ref([])
 const regionCodeOptions = ref([])
 const spOptions = ref([])
 const fetchingSp = ref(false)
+const ljOptions = ref([])
+const fetchingLj = ref(false)
 
 // 列表选择配置
 const bodyOptions = {
@@ -1311,7 +1330,34 @@ const onChangeSp = (val, obj) => {
 	productData.value.productName = obj.productName
 	productData.value.version = 1
 	productData.value.hsCode = val
-	productData.value.measurementUnit = obj.firstUnitCode + '-' + obj.firstUnitName
+	productData.value.measurementUnit = (obj.firstUnitCode || obj.firstUnitName) ? (obj.firstUnitCode + '-' + obj.firstUnitName) : ''
+}
+const fetchLj = debounce(value => {
+	lastFetchId += 1;
+	const fetchId = lastFetchId;
+	ljOptions.value = [];
+	fetchingLj.value = true;
+	qyRecordProductDictApi.qyRecordProductDictPage({
+		current: 1,
+		size: 10000,
+		productCode: value
+	}).then((res) => {
+		if (fetchId !== lastFetchId) {
+			return;
+		}
+		const arr = res.records.map(v => {
+			v.label = v.productName
+			v.value = v.productCode
+			return v
+		});
+		ljOptions.value = arr
+		fetchingLj.value = false
+	})
+}, 300);
+const onChangeLj = (val, obj) => {
+	bodyData.value.productName = obj.productName
+	bodyData.value.legalUnit = (obj.firstUnitCode || obj.firstUnitName) ? (obj.firstUnitCode + '-' + obj.firstUnitName) : ''
+	bodyData.value.legalSecondUnit = (obj.secondUnitCode || obj.secondUnitName) ? (obj.secondUnitCode + '-' + obj.secondUnitName) : ''
 }
 const onChangeSelfRate = () => {
 	setTimeout(() => {