From a66223eef2cc3c8a35ffa8aaef613008a3abdb31 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期五, 17 七月 2026 23:44:01 +0800
Subject: [PATCH] 优化盘点库存盘点
---
pages/wareHouse/nuclearScale/createwriteoffform.vue | 251 +++++++++++++++++++++++++++++++++----------------
1 files changed, 168 insertions(+), 83 deletions(-)
diff --git a/pages/wareHouse/nuclearScale/createwriteoffform.vue b/pages/wareHouse/nuclearScale/createwriteoffform.vue
index 9de5390..b221017 100644
--- a/pages/wareHouse/nuclearScale/createwriteoffform.vue
+++ b/pages/wareHouse/nuclearScale/createwriteoffform.vue
@@ -188,34 +188,20 @@
label="鐢熶骇杞﹂棿锛�"
:border-bottom="false"
prop="workshop"
- style="font-size: 16px; height: 40px"
+ class="workshop-form-item"
+ style="font-size: 16px"
>
- <picker
- class="item-one item-two"
- style="width: 100%; text-align: right; font-size: 16px"
- @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="鍙哥鍛橈細"
@@ -398,9 +384,8 @@
selClientList: [],
selClientIndex1: null,
selClientIndex2: null,
- // 鐢熶骇杞﹂棿
+ // 鐢熶骇杞﹂棿锛堢敱浜у搧绫诲瀷鑷姩甯﹀嚭锛屼笉鍙敼锛�
workshopList: [],
- workshopIndex: null,
// 鍙哥鍛�
weighmanList: [],
weighmanIndex: null,
@@ -410,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);
@@ -443,7 +455,6 @@
};
this.selClientIndex1 = null;
this.selClientIndex2 = null;
- this.workshopIndex = null;
this.weighmanIndex = null;
this.checkboxList = this.checkboxList.map((item) => ({
...item,
@@ -505,6 +516,7 @@
});
this.workshopList.push(obj);
});
+ this.$nextTick(() => this.syncWorkshopFromProductType());
} else {
uni.showToast({
title: res.msg || "鑾峰彇杞﹂棿鍒楄〃澶辫触",
@@ -521,20 +533,37 @@
});
},
+ /** 鏂版帴鍙d汉鍛樿閲屽鍚嶅彲鑳藉瓧娈典笉鍚岋紝缁熶竴鍙栧睍绀哄悕 */
+ staffRowDisplayName(row) {
+ if (!row || typeof row !== "object") return "";
+ return (
+ row.staffName ||
+ row.name ||
+ row.userName ||
+ row.nickName ||
+ row.realName ||
+ ""
+ );
+ },
+
/**
- * 鑾峰彇鍙夎溅宸ュ垪琛�
+ * 鑾峰彇鍙夎溅宸ュ垪琛紙鍙戣揣閮ㄩ棬锛�
*/
fetchForkliftOperators() {
this.$u.api
- .dictData({
- dictType: "forklift",
+ .NuclearScaleEntry.listStaff({
+ department: "鍙戣揣",
+ post: "鍙夎溅宸�",
})
.then((res) => {
- if (res.code === 0 && res.data.length > 0) {
- res.data.forEach((i) => {
+ const list = res?.data?.records || res?.data || [];
+ if (res.code === 0 && Array.isArray(list) && list.length > 0) {
+ list.forEach((i) => {
+ const name = this.staffRowDisplayName(i);
+ if (!name) return;
const obj = Object.assign({
- label: i.label,
- value: i.label,
+ label: name,
+ value: name,
});
this.checkboxList.push(obj);
});
@@ -555,19 +584,23 @@
},
/**
- * 鑾峰彇鍙哥鍛樺垪琛�
+ * 鑾峰彇鍙哥鍛樺垪琛紙鍙戣揣閮ㄩ棬锛�
*/
fetchWeighmen() {
this.$u.api
- .dictData({
- dictType: "weighing",
+ .NuclearScaleEntry.listStaff({
+ department: "鍙戣揣",
+ post: "鍙哥鍛�",
})
.then((res) => {
- if (res.code === 0 && res.data.length > 0) {
- res.data.forEach((i) => {
+ const list = res?.data?.records || res?.data || [];
+ if (res.code === 0 && Array.isArray(list) && list.length > 0) {
+ list.forEach((i) => {
+ const name = this.staffRowDisplayName(i);
+ if (!name) return;
const obj = Object.assign({
- label: i.label,
- value: i.label,
+ label: name,
+ value: name,
});
this.weighmanList.push(obj);
});
@@ -700,48 +733,49 @@
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;
}
+ 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);
+ }
+ });
+ this.form.workshop = uniq.join(",");
- const productType = this.form.productType;
- const selectedWorkshop = storage[e.target.value];
- console.log("閫夋嫨鐨勮溅闂�:", selectedWorkshop);
- // 妫�鏌ヤ骇鍝佺被鍨嬫槸鍚︿负閾滄潌(鍊间负TG01)
- if (productType === "TG01") {
- // 閾滄潌鍙兘閫夋嫨閾滄潌鐩稿叧杞﹂棿
- if (!selectedWorkshop.label.includes("閾滄潌")) {
- uni.showModal({
- title: "鎻愮ず",
- content: "閾滄潌浜у搧鍙兘閫夋嫨閾滄潌鐩稿叧杞﹂棿",
- showCancel: false,
+ // 鑻ュ瓧鍏稿凡鍔犺浇鍒欏仛涓�娆″瓨鍦ㄦ�ф彁绀猴紝閬垮厤閰嶇疆涓嶄竴鑷存椂鏃犳劅鐭�
+ 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;
- }
- } else {
- // 瀵间綋浜у搧涓嶈兘閫夋嫨閾滄潌杞﹂棿
- if (selectedWorkshop.label.includes("閾滄潌")) {
- uni.showModal({
- title: "鎻愮ず",
- content: "瀵间綋浜у搧涓嶈兘閫夋嫨閾滄潌杞﹂棿",
- showCancel: false,
- });
- return;
}
}
- if (selectedWorkshop.label.includes("鐩村彂") && productType !== "DT02") {
- uni.showModal({
- title: "鎻愮ず",
- content: "鐩村彂浜у搧鍙兘閫夋嫨瀵间綋2.6杞﹂棿",
- showCancel: false,
- });
- return;
- }
- this.workshopIndex = e.target.value;
- this.form.workshop = selectedWorkshop.value;
},
// 鍙哥鍛�
weighmanChange(e, storage) {
@@ -759,11 +793,10 @@
confirm() {},
/**
- * 浜у搧绫诲瀷鍙樺寲鏃舵竻绌鸿溅闂撮�夋嫨
+ * 浜у搧绫诲瀷鍙樺寲鏃舵寜瑙勫垯鑷姩甯﹀嚭鐢熶骇杞﹂棿
*/
handleProductTypeChange() {
- this.workshopIndex = null;
- this.form.workshop = "";
+ this.syncWorkshopFromProductType();
},
// 鎻愪氦鎸夐挳
async submit() {
@@ -945,4 +978,56 @@
// 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