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 | 1336 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 1,011 insertions(+), 325 deletions(-)
diff --git a/pages/wareHouse/nuclearScale/createwriteoffform.vue b/pages/wareHouse/nuclearScale/createwriteoffform.vue
index 14963bf..b221017 100644
--- a/pages/wareHouse/nuclearScale/createwriteoffform.vue
+++ b/pages/wareHouse/nuclearScale/createwriteoffform.vue
@@ -1,347 +1,1033 @@
<template>
- <!-- 鏍哥褰曞叆 -->
- <div class="page">
- <view class="packing-registration-bg" />
- <u-navbar title="鏍哥褰曞叆" :background="background" :border-bottom="false" :title-bold="true" title-color="#000"
- back-icon-color="#000" />
- <u-form :model="form" ref="uForm" :label-width="200" :rules="rules" :error-type="['toast']" class="uForm">
- <u-form-item label="浜у搧绫诲瀷" :border-bottom="false" prop="value0">
- <u-radio-group v-model="form.value0">
- <u-radio name="瀵间綋">瀵间綋</u-radio>
- <u-radio name="閾滄潌">閾滄潌</u-radio>
- <u-radio name="瀵间綋2.6">瀵间綋2.6</u-radio>
- </u-radio-group>
- </u-form-item>
- <u-form-item label="鏇挎崲浜岀淮鐮�" :border-bottom="false" prop="value1">
- <u-radio-group v-model="form.value1">
- <u-radio name="1">鏄�</u-radio>
- <u-radio name="0">鍚�</u-radio>
- </u-radio-group>
- </u-form-item>
- <u-form-item label="杞︾墝鍙�" :border-bottom="false" prop="value2">
- <u-input v-model="form.value2" type="select" placeholder="璇疯緭鍏ヨ溅鐗屽彿" @click="lpn" />
- </u-form-item>
- <u-form-item label="瀹㈡埛鍚嶇О" :border-bottom="false" prop="value3">
- <picker class="item-one item-two" style="width: 100%; text-align: right"
- @change="locNoNumBindChange($event, locNoList)" :value="locNoNumIndex" :range="locNoList"
- range-key="label">
- <view>
- <text :style="{ color: locNoNumIndex == null ? '#a5abb4' : '#0c0c0c' }">{{
- locNoNumIndex == null
+ <!-- 鏍哥褰曞叆 -->
+ <div class="page">
+ <view class="packing-registration-bg" />
+ <u-navbar
+ title="鏍哥褰曞叆"
+ :background="background"
+ :border-bottom="false"
+ :title-bold="true"
+ title-color="#000"
+ back-icon-color="#000"
+ />
+ <u-form
+ :model="form"
+ ref="uForm"
+ :label-width="235"
+ labelAlign="left"
+ :rules="rules"
+ :error-type="['toast']"
+ class="uForm"
+ >
+ <u-form-item
+ label="浜у搧绫诲瀷锛�"
+ :border-bottom="false"
+ prop="productType"
+ style="font-size: 16px; height: 40px"
+ >
+ <u-radio-group
+ v-model="form.productType"
+ @change="handleProductTypeChange"
+ class="radio-group-large"
+ >
+ <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
+ label="鏇挎崲浜岀淮鐮侊細"
+ :border-bottom="false"
+ prop="replace"
+ style="font-size: small"
+ >
+ <u-radio-group v-model="form.replace" style="font-size: small">
+ <u-radio name="1">鏄�</u-radio>
+ <u-radio name="0">鍚�</u-radio>
+ </u-radio-group>
+ </u-form-item> -->
+ <u-form-item
+ label="杞︾墝鍙凤細"
+ :border-bottom="false"
+ prop="licensePlate"
+ 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: 16px; height: 40px"
+ >
+ <picker
+ class="item-one item-two"
+ style="width: 100%; font-size: 16px; text-align: right"
+ @change="selClientChange($event, selClientList, 'customerName1')"
+ :value="selClientIndex1"
+ :range="selClientList"
+ range-key="label"
+ >
+ <view>
+ <text
+ :style="{
+ color: selClientIndex1 == null ? '#a5abb4' : '#0c0c0c',
+ }"
+ >{{
+ selClientIndex1 == null
? "璇烽�夋嫨"
- : locNoList[locNoNumIndex].label
- }}</text>
- </view>
- </picker>
- <u-icon v-if="locNoNumIndex == null" name="arrow-right" color="#687792" size="28"></u-icon>
- </u-form-item>
- <u-form-item label="鍙戣揣閫氱煡鍗曞彿" :border-bottom="false" prop="value4">
- <u-input v-model="form.value4" placeholder="" disabled />
- </u-form-item>
- <u-form-item label="鐢熶骇杞﹂棿" :border-bottom="false" prop="value5">
- <picker class="item-one item-two" style="width: 100%; text-align: right"
- @change="locNoNumBindChange($event, locNoList)" :value="locNoNumIndex" :range="locNoList"
- range-key="label">
- <view>
- <text :style="{ color: locNoNumIndex == null ? '#a5abb4' : '#0c0c0c' }">{{
- locNoNumIndex == null
+ : selClientList[selClientIndex1].label
+ }}</text
+ >
+ </view>
+ </picker>
+ <u-icon
+ v-if="selClientIndex1 == null"
+ name="arrow-right"
+ color="#687792"
+ size="28"
+ ></u-icon>
+ </u-form-item>
+ <u-form-item
+ label="鍙戣揣閫氱煡鍗曞彿锛�"
+ :border-bottom="false"
+ prop="shippingNoticeNo1"
+ style="font-size: 16px; height: 40px"
+ :label-width="300"
+ >
+ <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: 16px; height: 40px"
+ >
+ <picker
+ class="item-one item-two"
+ style="width: 100%; font-size: 16px; text-align: right"
+ @change="selClientChange($event, selClientList, 'customerName2')"
+ :value="selClientIndex2"
+ :range="selClientList"
+ range-key="label"
+ >
+ <view>
+ <text
+ :style="{
+ color: selClientIndex2 == null ? '#a5abb4' : '#0c0c0c',
+ }"
+ >{{
+ selClientIndex2 == null
? "璇烽�夋嫨"
- : locNoList[locNoNumIndex].label
- }}</text>
- </view>
- </picker>
- <u-icon v-if="locNoNumIndex == null" name="arrow-right" color="#687792" size="28"></u-icon>
- </u-form-item>
- <u-form-item label="鍙哥鍛�" :border-bottom="false" prop="value6">
- <picker class="item-one item-two" style="width: 100%; text-align: right"
- @change="locNoNumBindChange($event, locNoList)" :value="locNoNumIndex" :range="locNoList"
- range-key="label">
- <view>
- <text :style="{ color: locNoNumIndex == null ? '#a5abb4' : '#0c0c0c' }">{{
- locNoNumIndex == null
+ : selClientList[selClientIndex2].label
+ }}</text
+ >
+ </view>
+ </picker>
+ <u-icon
+ v-if="selClientIndex2 == null"
+ name="arrow-right"
+ color="#687792"
+ size="28"
+ ></u-icon>
+ </u-form-item>
+ <u-form-item
+ label="鍙戣揣閫氱煡鍗曞彿锛�"
+ :border-bottom="false"
+ prop="shippingNoticeNo2"
+ style="font-size: 16px; height: 40px"
+ :label-width="300"
+ >
+ <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"
+ class="workshop-form-item"
+ style="font-size: 16px"
+ >
+ <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: 16px; height: 40px"
+ >
+ <picker
+ class="item-one item-two"
+ style="width: 100%; text-align: right; font-size: 16px"
+ @change="weighmanChange($event, weighmanList)"
+ :value="weighmanIndex"
+ :range="weighmanList"
+ range-key="label"
+ >
+ <view>
+ <text
+ :style="{ color: weighmanIndex == null ? '#a5abb4' : '#0c0c0c' }"
+ >{{
+ weighmanIndex == null
? "璇烽�夋嫨"
- : locNoList[locNoNumIndex].label
- }}</text>
- </view>
- </picker>
- <u-icon v-if="locNoNumIndex == null" name="arrow-right" color="#687792" size="28"></u-icon>
- </u-form-item>
- <u-form-item label="鍙夎溅宸�" :border-bottom="false" prop="value7">
- <u-input v-model="form.value7" type="select" placeholder="璇烽�夋嫨" @click="openForkliftDriverList" />
- </u-form-item>
- </u-form>
- <u-button type="primary" class="bottom-button1" @click="submit">鍒涘缓</u-button>
+ : weighmanList[weighmanIndex].label
+ }}</text
+ >
+ </view>
+ </picker>
+ <u-icon
+ v-if="weighmanIndex == null"
+ name="arrow-right"
+ color="#687792"
+ size="28"
+ ></u-icon>
+ </u-form-item>
+ <u-form-item
+ label="鍙夎溅宸ワ細"
+ :border-bottom="false"
+ prop="forkliftOperator"
+ 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>
+ </u-form>
+ <u-button type="primary" class="bottom-button1" @click="submit"
+ >鍒涘缓</u-button
+ >
- <!--杞︾墝鍙� -->
- <modalBg ref="modalBg" :confirm="confirm">
- <u-field v-model="form.value2" label="杞︾墝鍙凤細" placeholder="璇疯緭鍏�" :border-bottom="false">
- </u-field>
- </modalBg>
- <!-- 鍙夎溅宸� -->
- <u-modal v-model="showModal" title="" :show-cancel-button="true" :show-confirm-button="true"
- @confirm="confirmSelection" @cancel="cancel">
- <view class="popup-content">
- <view class="popup-header">
- <checkbox-group @change="checkboxChange">
- <label class="checkbox-item" v-for="(item, index) in checkboxList" :key="index">
- <checkbox :value="item.value" :checked="item.checked" />
- <text class="label">{{ item.label }}</text>
- </label>
- </checkbox-group>
- </view>
- </view>
- </u-modal>
- </div>
+ <!--杞︾墝鍙� -->
+ <modalBg ref="modalBg" :confirm="confirm">
+ <u-field
+ v-model="form.licensePlate"
+ label="杞︾墝鍙凤細"
+ placeholder="璇疯緭鍏�"
+ :border-bottom="false"
+ >
+ </u-field>
+ </modalBg>
+ <!-- 鍙夎溅宸� -->
+ <u-modal
+ v-model="showModal"
+ title=""
+ :show-cancel-button="true"
+ :show-confirm-button="true"
+ @confirm="confirmSelection"
+ @cancel="cancel"
+ >
+ <view class="popup-content" style="padding: 20rpx">
+ <scroll-view
+ scroll-y="true"
+ style="height: 400rpx; transform: translateZ(0)"
+ >
+ <view class="popup-header">
+ <checkbox-group @change="checkboxChange">
+ <label
+ class="checkbox-item"
+ v-for="(item, index) in checkboxList"
+ :key="index"
+ >
+ <checkbox :value="item.value" :checked="item.checked" />
+ <text class="label">{{ item.label }}</text>
+ </label>
+ </checkbox-group>
+ </view>
+ </scroll-view>
+ </view>
+ </u-modal>
+ </div>
</template>
<script>
- import modalBg from "@/components/modal/modal-bg.vue";
- import content_bg from "@/static/custom/packing/backBg.png";
- export default {
- components: {
- modalBg,
- },
- data() {
- return {
- checkboxList: [{
- label: "宸ヤ汉1",
- value: "a",
- checked: false,
- },
- {
- label: "宸ヤ汉2",
- value: "2",
- checked: false,
- },
- {
- label: "宸ヤ汉3",
- value: "3",
- checked: false,
- },
- {
- label: "宸ヤ汉4",
- value: "4",
- checked: false,
- },
- {
- label: "宸ヤ汉",
- value: "5",
- checked: false,
- },
- ],
- background: {
- backgroundImage: `url(${content_bg})`,
- backgroundAttachment: "fixed",
- backgroundSize: "100% auto",
- backgroundRepeat: "no-repeat",
- },
- show: false,
- num: 1,
- form: {
- value0: "",
- value1: "",
- value2: "",
- value3: "",
- value4: "111",
- value5: "",
- value6: "",
- value7: "",
- value8: "",
- },
- rules: {
- value0: [{
- required: true,
- message: "璇烽�夋嫨浜у搧绫诲瀷",
- trigger: ["change"],
- }, ],
- value1: [{
- required: true,
- message: "璇烽�夋嫨鏄惁鏇挎崲浜岀淮鐮�",
- trigger: ["change", "blur"],
- }, ],
- value2: [{
- required: true,
- message: "璇疯緭鍏ヨ溅鐗屽彿",
- trigger: ["change", "blur"],
- }, ],
- // value3: [
- // {
- // required: true,
- // message: "璇烽�夋嫨瀹㈡埛鍚嶇О",
- // trigger: ["change", "blur"],
- // },
- // ],
- value4: [{
- required: true,
- message: "璇疯緭鍏ュ彂璐ч�氱煡鍗曞彿",
- trigger: ["change"],
- }, ],
- value5: [{
- required: true,
- message: "璇烽�夋嫨鐢熶骇杞﹂棿",
- trigger: ["change"],
- }, ],
- value6: [{
- required: true,
- message: "璇烽�夋嫨鍙哥鍛�",
- trigger: ["change"],
- }, ],
- value7: [{
- type: "array",
- required: true,
- message: "璇疯嚦灏戦�夋嫨涓�涓弶杞﹀伐",
- trigger: ["change"],
- }, ],
- },
- locNoList: [{
- value: "0",
- label: "鍏徃1",
- },
- {
- value: "1",
- label: "鍏徃2",
- },
- {
- value: "2",
- label: "鍏徃3",
- },
- {
- value: "3",
- label: "鍏徃4",
- },
- {
- value: "4",
- label: "鍏徃5",
- },
- {
- value: "5",
- label: "鍏徃6",
- },
- ],
- locNoNumIndex: null,
- showModal: false,
- selectedItems: [],
- };
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- },
- onShow() {},
- methods: {
- // 澶嶉�夋鍙樺寲浜嬩欢
- checkboxChange(e) {
- const values = e.detail.value;
- this.checkboxList = this.checkboxList.map((item) => {
- return {
- ...item,
- checked: values.includes(item.value),
- };
- });
- },
+import modalBg from "@/components/modal/modal-bg.vue";
+import content_bg from "@/static/custom/packing/backBg.png";
+export default {
+ components: {
+ modalBg,
+ },
+ data() {
+ return {
+ checkboxList: [],
+ background: {
+ backgroundImage: `url(${content_bg})`,
+ backgroundAttachment: "fixed",
+ backgroundSize: "100% auto",
+ backgroundRepeat: "no-repeat",
+ },
+ show: false,
+ num: 1,
+ form: {
+ // replace: "0",
+ productType: "",
+ licensePlate: "",
+ customerName1: "",
+ shippingNoticeNo1: "",
+ customerName2: "",
+ shippingNoticeNo2: "",
+ workshop: "",
+ weighingOperator: "",
+ forkliftOperator: "",
+ },
+ rules: {
+ productType: [
+ {
+ required: true,
+ message: "璇烽�夋嫨浜у搧绫诲瀷",
+ trigger: ["change"],
+ },
+ ],
+ // replace: [
+ // {
+ // required: true,
+ // message: "璇烽�夋嫨鏄惁鏇挎崲浜岀淮鐮�",
+ // trigger: ["change", "blur"],
+ // },
+ // ],
+ licensePlate: [
+ {
+ required: true,
+ message: "璇疯緭鍏ヨ溅鐗屽彿",
+ trigger: ["change", "blur"],
+ },
+ ],
+ workshop: [
+ {
+ required: true,
+ message: "璇烽�夋嫨鐢熶骇杞﹂棿",
+ trigger: ["change"],
+ },
+ ],
+ weighingOperator: [
+ {
+ required: true,
+ message: "璇烽�夋嫨鍙哥鍛�",
+ trigger: ["change"],
+ },
+ ],
+ forkliftOperator: [
+ {
+ type: "string",
+ required: true,
+ message: "璇疯嚦灏戦�夋嫨涓�涓弶杞﹀伐",
+ trigger: ["change"],
+ },
+ ],
+ },
+ // 瀹㈡埛鍚嶇О
+ selClientList: [],
+ selClientIndex1: null,
+ selClientIndex2: null,
+ // 鐢熶骇杞﹂棿锛堢敱浜у搧绫诲瀷鑷姩甯﹀嚭锛屼笉鍙敼锛�
+ workshopList: [],
+ // 鍙哥鍛�
+ weighmanList: [],
+ weighmanIndex: null,
+ showModal: false,
+ selectedItems: [],
+ id1: "",
+ 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);
+ // 浠呭湪缁勪欢鍒濇鍔犺浇鏃惰幏鍙栨暟鎹�
+ if (this.selClientList.length === 0) {
+ this.fetchClients();
+ }
+ if (this.workshopList.length === 0) {
+ this.fetchWorkshops();
+ }
+ if (this.checkboxList.length === 0) {
+ this.fetchForkliftOperators();
+ }
+ if (this.weighmanList.length === 0) {
+ this.fetchWeighmen();
+ }
+ },
+ onShow() {
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ this.form = {
+ // replace: "0",
+ productType: "",
+ licensePlate: "",
+ customerName1: "",
+ shippingNoticeNo1: "",
+ customerName2: "",
+ shippingNoticeNo2: "",
+ workshop: "",
+ weighingOperator: "",
+ forkliftOperator: "",
+ };
+ this.selClientIndex1 = null;
+ this.selClientIndex2 = null;
+ this.weighmanIndex = null;
+ this.checkboxList = this.checkboxList.map((item) => ({
+ ...item,
+ checked: false,
+ }));
+ this.$refs.uForm && this.$refs.uForm.resetValidation();
+ },
+ methods: {
+ /**
+ * 鑾峰彇瀹㈡埛鍒楄〃
+ */
+ fetchClients() {
+ this.$u.api.NuclearScaleEntry.selClient()
+ .then((res) => {
+ console.log("瀹㈡埛鍚嶇О", res);
+ if (res.code === 0) {
+ res.data.forEach((i) => {
+ const obj = Object.assign({
+ 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);
+ });
+ } else {
+ uni.showToast({
+ title: res.msg || "鑾峰彇瀹㈡埛鍚嶇О澶辫触",
+ icon: "none",
+ });
+ }
+ })
+ .catch((err) => {
+ uni.showToast({
+ title: "缃戠粶閿欒锛岃幏鍙栧鎴峰悕绉板け璐�",
+ icon: "none",
+ });
+ console.error("鑾峰彇瀹㈡埛鍚嶇О閿欒:", err);
+ });
+ },
- // 纭閫夋嫨
- confirmSelection() {
- this.form.value7 = this.checkboxList
- .filter((item) => item.checked)
- .map((item) => item.label);
- },
- openForkliftDriverList() {
- this.showModal = true;
- },
- locNoNumBindChange(e, storage) {
- if (storage.length <= 0) {
- this.locNoNumIndex = null;
- return;
- }
- this.locNoNumIndex = e.target.value;
- this.form.value3 = storage[this.locNoNumIndex].label;
- },
- // 鎵撳紑寮规--鍚庨潰杩橀渶瑕佺洃鍚壂鐮佹灙鎵爜缁撴灉锛岃祴鍊肩粰鎶ュ伐鍗曞彿瀛楁锛岀劧鍚庢墦寮�寮规閫夋嫨璁㈠崟鍙风瓑鎿嶄綔
- lpn() {
- this.$refs.modalBg.open();
- },
- // 寮规淇濆瓨
- confirm() {
- console.log("淇濆瓨", this.form.value1);
- // 璇锋眰鎺ュ彛锛屾牴鎹伐鍗曞彿鏌ヨ鍏朵粬淇℃伅骞惰祴鍊�
- },
- // 鎻愪氦鎸夐挳
- submit() {
- if (!this.$refs.uForm.validate()) {
- console.log("1111");
- return;
- }
- if (this.form.value3 === "") {
- uni.showToast({
- title: "璇峰厛閫夋嫨瀹㈡埛鍚嶇О",
- icon: "none",
- });
- return;
- }
- },
- },
- };
+ /**
+ * 鑾峰彇杞﹂棿鍒楄〃
+ */
+ fetchWorkshops() {
+ this.$u.api
+ .dictData({
+ dictType: "workshop",
+ })
+ .then((res) => {
+ if (res.code === 0 && res.data.length > 0) {
+ res.data.forEach((i) => {
+ const obj = Object.assign({
+ label: i.label,
+ value: i.value,
+ });
+ this.workshopList.push(obj);
+ });
+ this.$nextTick(() => this.syncWorkshopFromProductType());
+ } else {
+ uni.showToast({
+ title: res.msg || "鑾峰彇杞﹂棿鍒楄〃澶辫触",
+ icon: "none",
+ });
+ }
+ })
+ .catch((err) => {
+ uni.showToast({
+ title: "缃戠粶閿欒锛岃幏鍙栬溅闂村垪琛ㄥけ璐�",
+ icon: "none",
+ });
+ console.error("鑾峰彇杞﹂棿鍒楄〃閿欒:", err);
+ });
+ },
+
+ /** 鏂版帴鍙d汉鍛樿閲屽鍚嶅彲鑳藉瓧娈典笉鍚岋紝缁熶竴鍙栧睍绀哄悕 */
+ staffRowDisplayName(row) {
+ if (!row || typeof row !== "object") return "";
+ return (
+ row.staffName ||
+ row.name ||
+ row.userName ||
+ row.nickName ||
+ row.realName ||
+ ""
+ );
+ },
+
+ /**
+ * 鑾峰彇鍙夎溅宸ュ垪琛紙鍙戣揣閮ㄩ棬锛�
+ */
+ fetchForkliftOperators() {
+ this.$u.api
+ .NuclearScaleEntry.listStaff({
+ department: "鍙戣揣",
+ post: "鍙夎溅宸�",
+ })
+ .then((res) => {
+ 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: name,
+ value: name,
+ });
+ this.checkboxList.push(obj);
+ });
+ } else {
+ uni.showToast({
+ title: res.msg || "鑾峰彇鍙夎溅宸ュ垪琛ㄥけ璐�",
+ icon: "none",
+ });
+ }
+ })
+ .catch((err) => {
+ uni.showToast({
+ title: "缃戠粶閿欒锛岃幏鍙栧弶杞﹀伐鍒楄〃澶辫触",
+ icon: "none",
+ });
+ console.error("鑾峰彇鍙夎溅宸ュ垪琛ㄩ敊璇�:", err);
+ });
+ },
+
+ /**
+ * 鑾峰彇鍙哥鍛樺垪琛紙鍙戣揣閮ㄩ棬锛�
+ */
+ fetchWeighmen() {
+ this.$u.api
+ .NuclearScaleEntry.listStaff({
+ department: "鍙戣揣",
+ post: "鍙哥鍛�",
+ })
+ .then((res) => {
+ 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: name,
+ value: name,
+ });
+ this.weighmanList.push(obj);
+ });
+ } else {
+ uni.showToast({
+ title: res.msg || "鑾峰彇鍙哥鍛樺垪琛ㄥけ璐�",
+ icon: "none",
+ });
+ }
+ })
+ .catch((err) => {
+ uni.showToast({
+ title: "缃戠粶閿欒锛岃幏鍙栧徃纾呭憳鍒楄〃澶辫触",
+ icon: "none",
+ });
+ console.error("鑾峰彇鍙哥鍛樺垪琛ㄩ敊璇�:", err);
+ });
+ },
+ // 澶嶉�夋鍙樺寲浜嬩欢
+ checkboxChange(e) {
+ const values = e.detail.value;
+ this.checkboxList = this.checkboxList.map((item) => {
+ return {
+ ...item,
+ checked: values.includes(item.value),
+ };
+ });
+ },
+
+ // 纭閫夋嫨
+ confirmSelection() {
+ // 灏嗛�変腑鐨勫弶杞﹀伐鏍囩鏁扮粍杞负浠ラ�楀彿鍒嗛殧鐨勫瓧绗︿覆
+ this.form.forkliftOperator = this.checkboxList
+ .filter((item) => item.checked)
+ .map((item) => item.label)
+ .join(",");
+ },
+ cancel() {},
+ openForkliftDriverList() {
+ this.showModal = true;
+ },
+ // 瀹㈡埛鍚嶇О
+ selClientChange(e, storage, code) {
+ if (storage.length <= 0) {
+ this.selClientIndex1 = null;
+ this.selClientIndex2 = null;
+ return;
+ }
+ const selectedIndex = e.target.value;
+ const selectedCustomer = storage[selectedIndex];
+ 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;
+ }
+ },
+ /**
+ * 鎸変骇鍝佺被鍨嬭嚜鍔ㄨ缃敓浜ц溅闂达紙鍥哄畾浼犲�硷紝鐢ㄦ埛涓嶅彲鏀癸級
+ */
+ 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(",");
+
+ // 鑻ュ瓧鍏稿凡鍔犺浇鍒欏仛涓�娆″瓨鍦ㄦ�ф彁绀猴紝閬垮厤閰嶇疆涓嶄竴鑷存椂鏃犳劅鐭�
+ 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",
+ });
+ }
+ }
+ },
+ // 鍙哥鍛�
+ weighmanChange(e, storage) {
+ if (storage.length <= 0) {
+ this.weighmanIndex = null;
+ return;
+ }
+ this.weighmanIndex = e.target.value;
+ this.form.weighingOperator = storage[this.weighmanIndex].label;
+ },
+ lpn() {
+ this.$refs.modalBg.open();
+ },
+ // 寮规淇濆瓨
+ confirm() {},
+
+ /**
+ * 浜у搧绫诲瀷鍙樺寲鏃舵寜瑙勫垯鑷姩甯﹀嚭鐢熶骇杞﹂棿
+ */
+ handleProductTypeChange() {
+ this.syncWorkshopFromProductType();
+ },
+ // 鎻愪氦鎸夐挳
+ async submit() {
+ if (this.isSubmitting) return;
+
+ try {
+ // 缁熶竴琛ㄥ崟楠岃瘉
+ if (!(await this.validateForm())) return;
+ // 鏋勫缓鎻愪氦鏁版嵁
+ // 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);
+
+ if (res.code === 0) {
+ this.$u.toast("鎻愪氦鎴愬姛");
+ uni.navigateBack();
+ } else {
+ uni.showToast({
+ title: res.msg || "鎻愪氦澶辫触锛氫笟鍔″鐞嗛敊璇�",
+ icon: "none",
+ });
+ console.error("涓氬姟閿欒:", res);
+ }
+ } catch (err) {
+ if (err.type === "validation") {
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ });
+ } else if (err.message.includes("Network Error")) {
+ uni.showToast({
+ title: "缃戠粶杩炴帴閿欒锛岃妫�鏌ョ綉缁滃悗閲嶈瘯",
+ icon: "none",
+ });
+ } else {
+ uni.showToast({
+ title: "绯荤粺閿欒锛岃绋嶅悗閲嶈瘯",
+ icon: "none",
+ });
+ }
+ console.error("鎻愪氦琛ㄥ崟閿欒:", err);
+ } finally {
+ this.isSubmitting = false;
+ }
+ },
+
+ // 缁熶竴琛ㄥ崟楠岃瘉
+ async validateForm() {
+ // 浣跨敤uView琛ㄥ崟楠岃瘉
+ if (!(await this.$refs.uForm.validate())) {
+ return false;
+ }
+
+ // 瀹㈡埛鍚嶇О楠岃瘉 - 淇敼涓鸿嚦灏戞湁涓�涓湁鍊�
+ if (!this.form.customerName1 && !this.form.customerName2) {
+ 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,
+ // });
+
+ // // 鏋勫缓瀹㈡埛鍒楄〃
+ // const customerList = [1, 2].map(createCustomerItem);
+
+ // return {
+ // customerList,
+ // };
+ // },
+ },
+};
</script>
<style lang="scss" scoped>
- @import "index.scss";
+@import "index.scss";
- /* 寮圭獥鏍峰紡 */
- .popup-content {
- padding: 30rpx;
- max-height: 70vh;
- overflow-y: auto;
- }
+/* 寮圭獥鏍峰紡 */
+.popup-content {
+ padding: 30rpx;
+ max-height: 70vh;
+ overflow-y: auto;
+}
- .popup-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-bottom: 20rpx;
- border-bottom: 1rpx solid #eee;
- margin-bottom: 20rpx;
- }
+.popup-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding-bottom: 20rpx;
+ border-bottom: 1rpx solid #eee;
+ margin-bottom: 20rpx;
+}
- .title {
- font-size: 32rpx;
- font-weight: bold;
- }
+.title {
+ font-size: 32rpx;
+ font-weight: bold;
+}
- .confirm-btn {
- color: #007aff;
- font-size: 28rpx;
- }
+.confirm-btn {
+ color: #007aff;
+ font-size: small;
+}
- /* 澶嶉�夋鏍峰紡 */
- .checkbox-item {
- width: 200px;
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- .label{
- position: relative;
- left: 130px;
- }
- }
+/* 澶嶉�夋鏍峰紡 */
+.checkbox-item {
+ width: 230px;
+ display: flex;
+ align-items: center;
+ padding: 20rpx 0;
+ border-bottom: 1rpx solid #f5f5f5;
+ background-color: #f8f9fa;
- .checkbox-item:last-child {
- border-bottom: none;
- }
+ .label {
+ position: relative;
+ left: 130px;
+ }
+}
- .checkbox-item .label {
- margin-left: 20rpx;
- }
+.checkbox-item:last-child {
+ border-bottom: none;
+}
- .item-one {
- font-size: 30rpx;
- color: #0c0c0c;
- margin-right: 6rpx;
- }
+.checkbox-item .label {
+ margin-left: 20rpx;
+}
- .item-two {
- font-size: 30rpx;
- color: #a5abb4;
- margin-right: 6rpx;
- }
+.item-one {
+ font-size: small;
+ color: #0c0c0c;
+ margin-right: 6rpx;
+}
+
+.item-two {
+ font-size: small;
+ 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