| | |
| | | clearable |
| | | placeholder="请输入数量" |
| | | /> |
| | | <wd-input |
| | | <wd-picker |
| | | v-model="model.unit" |
| | | :columns="unitOptions" |
| | | label="单位" |
| | | label-width="100px" |
| | | prop="unit" |
| | | placeholder="请选择单位" |
| | | clearable |
| | | @confirm="handleUnitChange" |
| | | /> |
| | | <wd-picker |
| | | v-model="model.supplier" |
| | | :columns="supplierOptions" |
| | | label="厂家" |
| | | label-width="100px" |
| | | prop="supplier" |
| | | placeholder="请选择厂家" |
| | | clearable |
| | | placeholder="请输入厂家" |
| | | @confirm="handleSupplierChange" |
| | | /> |
| | | </wd-cell-group> |
| | | <wd-toast /> |
| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { onMounted, watch } from "vue"; |
| | | import useFormData from "@/hooks/useFormData"; |
| | | import TwistApi from "@/api/product/twist"; |
| | | import ManageApi from "@/api/product/manage"; |
| | |
| | | diskMaterial: undefined, // 盘具类型 |
| | | model: undefined, // 尺寸 |
| | | amount: undefined, // 数量 |
| | | unit: "只", // 单位,默认值为"只" |
| | | supplier: undefined, |
| | | type: "盘具", |
| | | }); |
| | |
| | | // 盘具类型字典数据 |
| | | const diskMaterialOptions = ref<Array<{ label: string; value: string }>>([]); |
| | | const diskMaterialValue = ref(""); |
| | | |
| | | // 单位字典数据 |
| | | const unitOptions = ref<Array<{ label: string; value: string }>>([]); |
| | | |
| | | // 厂家字典数据 |
| | | const supplierOptions = ref<Array<{ label: string; value: string }>>([]); |
| | | |
| | | // 加载盘具类型字典数据 |
| | | const loadDiskMaterialDict = async () => { |
| | |
| | | } |
| | | }; |
| | | |
| | | // 加载单位字典数据 |
| | | const loadUnitDict = async () => { |
| | | try { |
| | | const res = await ManageApi.dictAPI("technical_weight_unit"); |
| | | if (res.data && Array.isArray(res.data)) { |
| | | unitOptions.value = res.data.map((item: any) => ({ |
| | | label: item.dictLabel || "", |
| | | value: item.dictValue || "", |
| | | })); |
| | | // 设置默认值为"只",如果字典中有"只"选项 |
| | | const defaultOption = unitOptions.value.find( |
| | | (item) => item.label === "只" || item.value === "只" |
| | | ); |
| | | if (defaultOption && !model.unit) { |
| | | model.unit = defaultOption.value; |
| | | } |
| | | } |
| | | } catch (error) { |
| | | // 加载字典失败,静默处理 |
| | | } |
| | | }; |
| | | |
| | | // 加载厂家字典数据 |
| | | const loadSupplierDict = async () => { |
| | | try { |
| | | const res = await ManageApi.dictAPI("reel_factory"); |
| | | if (res.data && Array.isArray(res.data)) { |
| | | supplierOptions.value = res.data.map((item: any) => ({ |
| | | label: item.dictLabel || "", |
| | | value: item.dictValue || "", |
| | | })); |
| | | } |
| | | } catch (error) { |
| | | // 加载字典失败,静默处理 |
| | | } |
| | | }; |
| | | |
| | | // 处理盘具类型选择 |
| | | const handleDiskMaterialChange = (val: any) => { |
| | | model.diskMaterial = val.value; |
| | | }; |
| | | |
| | | // 处理单位选择 |
| | | const handleUnitChange = (val: any) => { |
| | | model.unit = val.value; |
| | | }; |
| | | |
| | | // 处理厂家选择 |
| | | const handleSupplierChange = (val: any) => { |
| | | model.supplier = val.value; |
| | | }; |
| | | |
| | | // 监听 model.diskMaterial 变化,同步选择器显示 |
| | |
| | | diskMaterial: model.diskMaterial, |
| | | model: model.model, |
| | | amount: model.amount, |
| | | unit: model.unit, |
| | | supplier: model.supplier, |
| | | type: model.type, |
| | | }; |
| | |
| | | model.diskMaterial = currentItem.diskMaterial; |
| | | model.model = currentItem.model; |
| | | model.amount = currentItem.amount; |
| | | model.unit = currentItem.unit || "只"; |
| | | model.supplier = currentItem.supplier; |
| | | model.type = currentItem.type || "盘具"; |
| | | // 设置盘具类型的回显值 |
| | |
| | | |
| | | onMounted(async () => { |
| | | await loadDiskMaterialDict(); |
| | | await loadUnitDict(); |
| | | await loadSupplierDict(); |
| | | }); |
| | | |
| | | // 监听编辑数据变化,自动回显 |
| | |
| | | model.diskMaterial = newData.diskMaterial || ""; |
| | | model.model = newData.model || ""; |
| | | model.amount = newData.amount || ""; |
| | | model.unit = newData.unit || "只"; |
| | | model.supplier = newData.supplier || ""; |
| | | model.type = newData.type || "盘具"; |
| | | diskMaterialValue.value = newData.diskMaterial || ""; |
| | |
| | | model.diskMaterial = undefined; |
| | | model.model = undefined; |
| | | model.amount = undefined; |
| | | model.unit = "只"; |
| | | model.supplier = undefined; |
| | | model.type = "盘具"; |
| | | diskMaterialValue.value = ""; |