From a08c9f3200771297065583e2bc53bbc721e853d7 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 13 四月 2026 15:29:07 +0800
Subject: [PATCH] 优化车间选择逻辑,改为根据产品类型固定传值设置车间,并增加缺失编码提示
---
pages/wareHouse/nuclearScale/createwriteoffform.vue | 472 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 338 insertions(+), 134 deletions(-)
diff --git a/pages/wareHouse/nuclearScale/createwriteoffform.vue b/pages/wareHouse/nuclearScale/createwriteoffform.vue
index 2a2b921..8611bad 100644
--- a/pages/wareHouse/nuclearScale/createwriteoffform.vue
+++ b/pages/wareHouse/nuclearScale/createwriteoffform.vue
@@ -23,19 +23,20 @@
label="浜у搧绫诲瀷锛�"
:border-bottom="false"
prop="productType"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<u-radio-group
v-model="form.productType"
@change="handleProductTypeChange"
- style="font-size: small"
+ class="radio-group-large"
>
- <u-radio name="DT01">瀵间綋</u-radio>
- <u-radio name="TG01">閾滄潌</u-radio>
- <u-radio name="DT02">瀵间綋2.6</u-radio>
+ <u-radio name="DT01" class="radio-large">瀵间綋</u-radio>
+ <u-radio name="TG01" class="radio-large">閾滄潌</u-radio>
+ <u-radio name="DT02" class="radio-large">瀵间綋2.6</u-radio>
+ <!-- <u-radio name="ZF01" class="radio-large">鐩村彂</u-radio> -->
</u-radio-group>
</u-form-item>
- <u-form-item
+ <!-- <u-form-item
label="鏇挎崲浜岀淮鐮侊細"
:border-bottom="false"
prop="replace"
@@ -45,29 +46,39 @@
<u-radio name="1">鏄�</u-radio>
<u-radio name="0">鍚�</u-radio>
</u-radio-group>
- </u-form-item>
+ </u-form-item> -->
<u-form-item
label="杞︾墝鍙凤細"
:border-bottom="false"
prop="licensePlate"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<u-input
v-model="form.licensePlate"
type="select"
placeholder="璇疯緭鍏ヨ溅鐗屽彿"
@click="lpn"
+ :custom-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ :input-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
/>
</u-form-item>
<u-form-item
label="瀹㈡埛鍚嶇О1锛�"
:border-bottom="false"
prop="customerName1"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<picker
class="item-one item-two"
- style="width: 100%; text-align: right"
+ style="width: 100%; font-size: 16px; text-align: right"
@change="selClientChange($event, selClientList, 'customerName1')"
:value="selClientIndex1"
:range="selClientList"
@@ -94,23 +105,37 @@
></u-icon>
</u-form-item>
<u-form-item
- label="鍙戣揣閫氱煡鍗曞彿1锛�"
+ label="鍙戣揣閫氱煡鍗曞彿锛�"
:border-bottom="false"
prop="shippingNoticeNo1"
- style="font-size: small"
- :label-width="245"
+ style="font-size: 16px; height: 40px"
+ :label-width="300"
>
- <u-input v-model="form.shippingNoticeNo1" placeholder="" disabled />
+ <u-input
+ v-model="form.shippingNoticeNo1"
+ placeholder=""
+ disabled
+ :custom-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ :input-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ />
</u-form-item>
<u-form-item
label="瀹㈡埛鍚嶇О2锛�"
:border-bottom="false"
prop="customerName2"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<picker
class="item-one item-two"
- style="width: 100%; text-align: right"
+ style="width: 100%; font-size: 16px; text-align: right"
@change="selClientChange($event, selClientList, 'customerName2')"
:value="selClientIndex2"
:range="selClientList"
@@ -137,56 +162,56 @@
></u-icon>
</u-form-item>
<u-form-item
- label="鍙戣揣閫氱煡鍗曞彿2锛�"
+ label="鍙戣揣閫氱煡鍗曞彿锛�"
:border-bottom="false"
prop="shippingNoticeNo2"
- style="font-size: small"
- :label-width="245"
+ style="font-size: 16px; height: 40px"
+ :label-width="300"
>
- <u-input v-model="form.shippingNoticeNo2" placeholder="" disabled />
+ <u-input
+ v-model="form.shippingNoticeNo2"
+ placeholder=""
+ disabled
+ :custom-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ :input-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ />
</u-form-item>
<u-form-item
label="鐢熶骇杞﹂棿锛�"
:border-bottom="false"
prop="workshop"
- style="font-size: small"
+ class="workshop-form-item"
+ style="font-size: 16px"
>
- <picker
- class="item-one item-two"
- style="width: 100%; text-align: right"
- @change="workshopChange($event, workshopList)"
- :value="workshopIndex"
- :range="workshopList"
- range-key="label"
- :disabled="!form.productType"
- >
- <view>
- <text
- :style="{ color: workshopIndex == null ? '#a5abb4' : '#0c0c0c' }"
- >{{
- workshopIndex == null
- ? "璇烽�夋嫨"
- : workshopList[workshopIndex].label
- }}</text
- >
- </view>
- </picker>
- <u-icon
- v-if="workshopIndex == null"
- name="arrow-right"
- color="#687792"
- size="28"
- ></u-icon>
+ <view class="workshop-field-body">
+ <text v-if="!form.productType" class="workshop-field-text is-placeholder"
+ >璇峰厛閫夋嫨浜у搧绫诲瀷</text
+ >
+ <text
+ v-else
+ class="workshop-field-text"
+ :class="{ 'is-placeholder': !workshopDisplayText }"
+ >{{ workshopDisplayText || "姝e湪鍖归厤杞﹂棿..." }}</text
+ >
+ </view>
</u-form-item>
<u-form-item
label="鍙哥鍛橈細"
:border-bottom="false"
prop="weighingOperator"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<picker
class="item-one item-two"
- style="width: 100%; text-align: right"
+ style="width: 100%; text-align: right; font-size: 16px"
@change="weighmanChange($event, weighmanList)"
:value="weighmanIndex"
:range="weighmanList"
@@ -214,12 +239,22 @@
label="鍙夎溅宸ワ細"
:border-bottom="false"
prop="forkliftOperator"
- style="font-size: small"
+ style="font-size: 16px; height: 40px"
>
<u-input
v-model="form.forkliftOperator"
type="select"
placeholder="璇烽�夋嫨"
+ :custom-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
+ :input-style="{
+ fontSize: '16px',
+ height: '40px',
+ lineHeight: '40px',
+ }"
@click="openForkliftDriverList"
/>
</u-form-item>
@@ -289,7 +324,7 @@
show: false,
num: 1,
form: {
- replace: "0",
+ // replace: "0",
productType: "",
licensePlate: "",
customerName1: "",
@@ -308,13 +343,13 @@
trigger: ["change"],
},
],
- replace: [
- {
- required: true,
- message: "璇烽�夋嫨鏄惁鏇挎崲浜岀淮鐮�",
- trigger: ["change", "blur"],
- },
- ],
+ // replace: [
+ // {
+ // required: true,
+ // message: "璇烽�夋嫨鏄惁鏇挎崲浜岀淮鐮�",
+ // trigger: ["change", "blur"],
+ // },
+ // ],
licensePlate: [
{
required: true,
@@ -349,9 +384,8 @@
selClientList: [],
selClientIndex1: null,
selClientIndex2: null,
- // 鐢熶骇杞﹂棿
+ // 鐢熶骇杞﹂棿锛堢敱浜у搧绫诲瀷鑷姩甯﹀嚭锛屼笉鍙敼锛�
workshopList: [],
- workshopIndex: null,
// 鍙哥鍛�
weighmanList: [],
weighmanIndex: null,
@@ -361,6 +395,33 @@
id2: "",
isSubmitting: false,
};
+ },
+ computed: {
+ workshopDisplayText() {
+ const raw = this.form.workshop;
+ if (!raw) return "";
+ const values = String(raw)
+ .split(",")
+ .map((s) => s.trim())
+ .filter(Boolean);
+ const labels = values.map((v) => {
+ const w = this.workshopList.find(
+ (x) => String(x.value) === String(v)
+ );
+ return w ? w.label : v;
+ });
+ return labels.join("銆�");
+ },
+ },
+ watch: {
+ workshopList: {
+ handler(list) {
+ if (list && list.length && this.form.productType) {
+ this.$nextTick(() => this.syncWorkshopFromProductType());
+ }
+ },
+ deep: true,
+ },
},
onReady() {
this.$refs.uForm.setRules(this.rules);
@@ -381,7 +442,7 @@
onShow() {
// 閲嶇疆琛ㄥ崟鏁版嵁
this.form = {
- replace: "0",
+ // replace: "0",
productType: "",
licensePlate: "",
customerName1: "",
@@ -394,7 +455,6 @@
};
this.selClientIndex1 = null;
this.selClientIndex2 = null;
- this.workshopIndex = null;
this.weighmanIndex = null;
this.checkboxList = this.checkboxList.map((item) => ({
...item,
@@ -416,6 +476,9 @@
label: i.customerName,
value: i.customerName,
shippingNoticeNo: i.shippingNoticeNo,
+ receiverAddress: i.receiverAddress,
+ contactPerson: i.contactPerson,
+ contactPhone: i.contactPhone,
id: i.id,
});
this.selClientList.push(obj);
@@ -453,6 +516,7 @@
});
this.workshopList.push(obj);
});
+ this.$nextTick(() => this.syncWorkshopFromProductType());
} else {
uni.showToast({
title: res.msg || "鑾峰彇杞﹂棿鍒楄〃澶辫触",
@@ -566,71 +630,131 @@
}
const selectedIndex = e.target.value;
const selectedCustomer = storage[selectedIndex];
-
- // // 妫�鏌ユ槸鍚﹂�夋嫨浜嗙浉鍚岀殑瀹㈡埛
- // if (code === "customerName1" && this.selClientIndex2 === selectedIndex) {
- // uni.showToast({
- // title: "涓嶈兘閫夋嫨鐩稿悓鐨勫鎴�",
- // icon: "none",
- // });
- // return;
- // }
- // if (code === "customerName2" && this.selClientIndex1 === selectedIndex) {
- // uni.showToast({
- // title: "涓嶈兘閫夋嫨鐩稿悓鐨勫鎴�",
- // icon: "none",
- // });
- // return;
- // }
-
+ console.log("selectedCustomer", selectedCustomer);
+ console.log("selectedIndex", selectedIndex);
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗙浉鍚岀殑瀹㈡埛
+ if (code === "customerName1" && this.selClientIndex2 === selectedIndex) {
+ uni.showToast({
+ title: "涓嶈兘閫夋嫨鐩稿悓鐨勫鎴�",
+ icon: "none",
+ });
+ return;
+ }
+ if (code === "customerName2" && this.selClientIndex1 === selectedIndex) {
+ uni.showToast({
+ title: "涓嶈兘閫夋嫨鐩稿悓鐨勫鎴�",
+ icon: "none",
+ });
+ return;
+ }
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗鎴峰悕绉扮浉鍚岀殑瀹㈡埛
+ if (code === "customerName1" && this.selClientIndex2 !== null) {
+ const otherCustomer = storage[this.selClientIndex2];
+ if (selectedCustomer.label === otherCustomer.label) {
+ uni.showToast({
+ title: "涓嶈兘閫夋嫨瀹㈡埛鍚嶇О鐩稿悓鐨勫鎴�",
+ icon: "none",
+ });
+ return;
+ }
+ }
+ if (code === "customerName2" && this.selClientIndex1 !== null) {
+ const otherCustomer = storage[this.selClientIndex1];
+ if (selectedCustomer.label === otherCustomer.label) {
+ uni.showToast({
+ title: "涓嶈兘閫夋嫨瀹㈡埛鍚嶇О鐩稿悓鐨勫鎴�",
+ icon: "none",
+ });
+ return;
+ }
+ }
+ // 妫�鏌ヤ笉鍚屽鎴风殑鏀惰揣鍦板潃銆佽仈绯讳汉銆佽仈绯荤數璇濇槸鍚︾浉鍚�
+ if (code === "customerName1" && this.selClientIndex2 !== null) {
+ const otherCustomer = storage[this.selClientIndex2];
+ if (
+ selectedCustomer.receiverAddress !== otherCustomer.receiverAddress ||
+ selectedCustomer.contactPerson !== otherCustomer.contactPerson ||
+ selectedCustomer.contactPhone !== otherCustomer.contactPhone
+ ) {
+ uni.showToast({
+ title: "涓や釜瀹㈡埛鐨勬敹璐у湴鍧�銆佽仈绯讳汉鎴栬仈绯荤數璇濅笉鐩稿悓锛屼笉鑳藉悓鏃堕�夋嫨",
+ icon: "none",
+ });
+ return;
+ }
+ }
+ if (code === "customerName2" && this.selClientIndex1 !== null) {
+ const otherCustomer = storage[this.selClientIndex1];
+ if (
+ selectedCustomer.receiverAddress !== otherCustomer.receiverAddress ||
+ selectedCustomer.contactPerson !== otherCustomer.contactPerson ||
+ selectedCustomer.contactPhone !== otherCustomer.contactPhone
+ ) {
+ uni.showToast({
+ title: "涓や釜瀹㈡埛鐨勬敹璐у湴鍧�銆佽仈绯讳汉鎴栬仈绯荤數璇濅笉鐩稿悓锛屼笉鑳藉悓鏃堕�夋嫨",
+ icon: "none",
+ });
+ return;
+ }
+ }
if (code === "customerName2") {
this.selClientIndex2 = selectedIndex;
this.form.customerName2 = selectedCustomer.label;
this.form.shippingNoticeNo2 = selectedCustomer.shippingNoticeNo;
+ this.form.customerNo2 = selectedCustomer.customerNo;
this.id2 = selectedCustomer.id;
}
if (code === "customerName1") {
this.selClientIndex1 = selectedIndex;
this.form.customerName1 = selectedCustomer.label;
this.form.shippingNoticeNo1 = selectedCustomer.shippingNoticeNo;
+ this.form.customerNo1 = selectedCustomer.customerNo;
this.id1 = selectedCustomer.id;
}
},
- // 鐢熶骇杞﹂棿
- workshopChange(e, storage) {
- if (storage.length <= 0) {
- this.workshopIndex = null;
+ /**
+ * 鎸変骇鍝佺被鍨嬭嚜鍔ㄨ缃敓浜ц溅闂达紙鍥哄畾浼犲�硷紝鐢ㄦ埛涓嶅彲鏀癸級
+ */
+ syncWorkshopFromProductType() {
+ const pt = this.form.productType;
+ if (!pt) {
+ this.form.workshop = "";
return;
}
-
- const productType = this.form.productType;
- const selectedWorkshop = storage[e.target.value];
-
- // 妫�鏌ヤ骇鍝佺被鍨嬫槸鍚︿负閾滄潌(鍊间负TG01)
- if (productType === "TG01") {
- // 閾滄潌鍙兘閫夋嫨閾滄潌鐩稿叧杞﹂棿
- if (!selectedWorkshop.label.includes("閾滄潌")) {
- uni.showModal({
- title: "鎻愮ず",
- content: "閾滄潌浜у搧鍙兘閫夋嫨閾滄潌鐩稿叧杞﹂棿",
- showCancel: false,
- });
- return;
+ if (pt === "TG01") {
+ this.setWorkshopByValues(["CT01", "ZF01"]);
+ return;
+ }
+ if (pt === "DT01") {
+ this.setWorkshopByValues(["CD01", "CY01", "ZF01"]);
+ return;
+ }
+ if (pt === "DT02") {
+ this.setWorkshopByValues(["CD01", "CY01", "ZF01"]);
+ }
+ },
+ setWorkshopByValues(requiredValues) {
+ const uniq = [];
+ const seen = new Set();
+ requiredValues.forEach((value) => {
+ if (!seen.has(value)) {
+ seen.add(value);
+ uniq.push(value);
}
- } else {
- // 瀵间綋浜у搧涓嶈兘閫夋嫨閾滄潌杞﹂棿
- if (selectedWorkshop.label.includes("閾滄潌")) {
- uni.showModal({
- title: "鎻愮ず",
- content: "瀵间綋浜у搧涓嶈兘閫夋嫨閾滄潌杞﹂棿",
- showCancel: false,
+ });
+ this.form.workshop = uniq.join(",");
+
+ // 鑻ュ瓧鍏稿凡鍔犺浇鍒欏仛涓�娆″瓨鍦ㄦ�ф彁绀猴紝閬垮厤閰嶇疆涓嶄竴鑷存椂鏃犳劅鐭�
+ if (this.workshopList.length) {
+ const dictValues = new Set(this.workshopList.map((x) => String(x.value)));
+ const missing = uniq.filter((v) => !dictValues.has(String(v)));
+ if (missing.length) {
+ uni.showToast({
+ title: `杞﹂棿瀛楀吀缂哄皯缂栫爜锛�${missing.join("銆�")}`,
+ icon: "none",
});
- return;
}
}
-
- this.workshopIndex = e.target.value;
- this.form.workshop = selectedWorkshop.label;
},
// 鍙哥鍛�
weighmanChange(e, storage) {
@@ -648,11 +772,10 @@
confirm() {},
/**
- * 浜у搧绫诲瀷鍙樺寲鏃舵竻绌鸿溅闂撮�夋嫨
+ * 浜у搧绫诲瀷鍙樺寲鏃舵寜瑙勫垯鑷姩甯﹀嚭鐢熶骇杞﹂棿
*/
handleProductTypeChange() {
- this.workshopIndex = null;
- this.form.workshop = "";
+ this.syncWorkshopFromProductType();
},
// 鎻愪氦鎸夐挳
async submit() {
@@ -661,9 +784,21 @@
try {
// 缁熶竴琛ㄥ崟楠岃瘉
if (!(await this.validateForm())) return;
- // 绉婚櫎鍐椾綑鐨勯獙璇佷唬鐮�
// 鏋勫缓鎻愪氦鏁版嵁
- const submitData = this.buildSubmitData().customerList;
+ // const submitData = this.buildSubmitData().customerList;
+ const submitData = {
+ customerName1: this.form.customerName1,
+ shippingNoticeNo1: this.form.shippingNoticeNo1,
+ customerName2: this.form.customerName2,
+ shippingNoticeNo2: this.form.shippingNoticeNo2,
+ customerNo1: this.form.customerNo1,
+ customerNo2: this.form.customerNo2,
+ productType: this.form.productType,
+ licensePlate: this.form.licensePlate,
+ workshop: this.form.workshop,
+ weighingOperator: this.form.weighingOperator,
+ forkliftOperator: this.form.forkliftOperator,
+ };
console.log("鎻愪氦鐨勬暟鎹�", submitData);
this.isSubmitting = true;
const res = await this.$u.api.NuclearScaleEntry.createMain(submitData);
@@ -710,34 +845,37 @@
// 瀹㈡埛鍚嶇О楠岃瘉 - 淇敼涓鸿嚦灏戞湁涓�涓湁鍊�
if (!this.form.customerName1 && !this.form.customerName2) {
- throw { type: "validation", message: "璇疯嚦灏戦�夋嫨涓�涓鎴峰悕绉�" };
+ throw {
+ type: "validation",
+ message: "璇疯嚦灏戦�夋嫨涓�涓鎴峰悕绉�",
+ };
}
return true;
},
- // 鏋勫缓鎻愪氦鏁版嵁
- buildSubmitData() {
- // 鍒涘缓瀹㈡埛鏁版嵁鐨勮緟鍔╁嚱鏁�
- const createCustomerItem = (customerIndex) => ({
- customerName: this.form[`customerName${customerIndex}`],
- shippingNoticeNo: this.form[`shippingNoticeNo${customerIndex}`],
- shippingNoticeId: this[`id${customerIndex}`],
- replace: this.form.replace,
- productType: this.form.productType,
- licensePlate: this.form.licensePlate,
- workshop: this.form.workshop,
- weighingOperator: this.form.weighingOperator,
- forkliftOperator: this.form.forkliftOperator,
- });
+ // // 鏋勫缓鎻愪氦鏁版嵁
+ // buildSubmitData() {
+ // // 鍒涘缓瀹㈡埛鏁版嵁鐨勮緟鍔╁嚱鏁�
+ // const createCustomerItem = (customerIndex) => ({
+ // customerName: this.form[`customerName${customerIndex}`],
+ // shippingNoticeNo: this.form[`shippingNoticeNo${customerIndex}`],
+ // shippingNoticeId: this[`id${customerIndex}`],
+ // replace: this.form.replace,
+ // productType: this.form.productType,
+ // licensePlate: this.form.licensePlate,
+ // workshop: this.form.workshop,
+ // weighingOperator: this.form.weighingOperator,
+ // forkliftOperator: this.form.forkliftOperator,
+ // });
- // 鏋勫缓瀹㈡埛鍒楄〃
- const customerList = [1, 2].map(createCustomerItem);
+ // // 鏋勫缓瀹㈡埛鍒楄〃
+ // const customerList = [1, 2].map(createCustomerItem);
- return {
- customerList,
- };
- },
+ // return {
+ // customerList,
+ // };
+ // },
},
};
</script>
@@ -805,4 +943,70 @@
color: #a5abb4;
margin-right: 6rpx;
}
+
+/* 浜у搧绫诲瀷鍗曢�夌粍鏍峰紡 */
+.radio-group-large {
+ font-size: 16px !important;
+ height: 40px !important;
+ display: flex;
+ align-items: center;
+}
+
+.radio-large {
+ font-size: 15px !important;
+ // margin-right: 5px;
+ transform: scale(1.2);
+}
+
+/* 鐢熶骇杞﹂棿澶氳灞曠ず锛岄伩鍏嶅浐瀹氶珮搴︽尋鍘嬭鐩栦笅涓�琛� */
+::v-deep .workshop-form-item.u-form-item {
+ height: auto !important;
+ min-height: 40px;
+ line-height: 1.45 !important;
+ align-items: stretch;
+}
+
+::v-deep .workshop-form-item .u-form-item__body {
+ align-items: flex-start;
+}
+
+::v-deep .workshop-form-item .u-form-item--left {
+ align-items: flex-start;
+ padding-top: 4px;
+}
+
+::v-deep .workshop-form-item .u-form-item--left__content,
+::v-deep .workshop-form-item .u-form-item--left__content__label {
+ align-items: flex-start;
+}
+
+::v-deep .workshop-form-item .u-form-item--right__content {
+ align-items: flex-start;
+}
+
+::v-deep .workshop-form-item .u-form-item--right__content__slot {
+ align-items: flex-start !important;
+}
+
+.workshop-field-body {
+ width: 100%;
+ box-sizing: border-box;
+ padding: 4px 0 6px;
+ text-align: right;
+}
+
+.workshop-field-text {
+ display: block;
+ width: 100%;
+ font-size: 16px;
+ line-height: 1.45;
+ color: #0c0c0c;
+ text-align: right;
+ word-break: break-word;
+ white-space: normal;
+}
+
+.workshop-field-text.is-placeholder {
+ color: #a5abb4;
+}
</style>
\ No newline at end of file
--
Gitblit v1.9.3