| | |
| | | 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" |
| | |
| | | <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" |
| | |
| | | ></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" |
| | |
| | | ></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 || "正在匹配车间..." }}</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" |
| | |
| | | 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> |
| | |
| | | show: false, |
| | | num: 1, |
| | | form: { |
| | | replace: "0", |
| | | // replace: "0", |
| | | productType: "", |
| | | licensePlate: "", |
| | | customerName1: "", |
| | |
| | | trigger: ["change"], |
| | | }, |
| | | ], |
| | | replace: [ |
| | | { |
| | | required: true, |
| | | message: "请选择是否替换二维码", |
| | | trigger: ["change", "blur"], |
| | | }, |
| | | ], |
| | | // replace: [ |
| | | // { |
| | | // required: true, |
| | | // message: "请选择是否替换二维码", |
| | | // trigger: ["change", "blur"], |
| | | // }, |
| | | // ], |
| | | licensePlate: [ |
| | | { |
| | | required: true, |
| | |
| | | selClientList: [], |
| | | selClientIndex1: null, |
| | | selClientIndex2: null, |
| | | // 生产车间 |
| | | // 生产车间(由产品类型自动带出,不可改) |
| | | workshopList: [], |
| | | workshopIndex: null, |
| | | // 司磅员 |
| | | weighmanList: [], |
| | | weighmanIndex: null, |
| | |
| | | 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); |
| | |
| | | onShow() { |
| | | // 重置表单数据 |
| | | this.form = { |
| | | replace: "0", |
| | | // replace: "0", |
| | | productType: "", |
| | | licensePlate: "", |
| | | customerName1: "", |
| | |
| | | }; |
| | | this.selClientIndex1 = null; |
| | | this.selClientIndex2 = null; |
| | | this.workshopIndex = null; |
| | | this.weighmanIndex = null; |
| | | this.checkboxList = this.checkboxList.map((item) => ({ |
| | | ...item, |
| | |
| | | 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); |
| | |
| | | }); |
| | | this.workshopList.push(obj); |
| | | }); |
| | | this.$nextTick(() => this.syncWorkshopFromProductType()); |
| | | } else { |
| | | uni.showToast({ |
| | | title: res.msg || "获取车间列表失败", |
| | |
| | | } |
| | | 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) { |
| | |
| | | confirm() {}, |
| | | |
| | | /** |
| | | * 产品类型变化时清空车间选择 |
| | | * 产品类型变化时按规则自动带出生产车间 |
| | | */ |
| | | handleProductTypeChange() { |
| | | this.workshopIndex = null; |
| | | this.form.workshop = ""; |
| | | this.syncWorkshopFromProductType(); |
| | | }, |
| | | // 提交按钮 |
| | | async submit() { |
| | |
| | | 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); |
| | |
| | | |
| | | // 客户名称验证 - 修改为至少有一个有值 |
| | | 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> |
| | |
| | | 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> |