| | |
| | | placeholder="请输入" |
| | | type="number" /> |
| | | </u-form-item> |
| | | <u-form-item label="班组信息" |
| | | prop="schedulingUserId" |
| | | <!-- 班组信息和审核人 --> |
| | | <u-form-item v-for="(item, key) in pickerFields" |
| | | :key="key" |
| | | :label="item.label" |
| | | :prop="key + '.name'" |
| | | required> |
| | | <u-input v-model="form.userName" |
| | | placeholder="请选择生产人" |
| | | <u-input v-model="form[key].name" |
| | | :placeholder="form[key].name ? '已选择: ' + form[key].name : '请选择' + item.label" |
| | | readonly |
| | | @click="openProducerPicker" |
| | | @click="openProducerPicker(key)" |
| | | suffix-icon="arrow-down" /> |
| | | </u-form-item> |
| | | </view> |
| | |
| | | const formRef = ref(); |
| | | |
| | | // 表单数据 |
| | | let form = ref({ |
| | | const form = ref({ |
| | | planQuantity: "", |
| | | quantity: "", |
| | | scrapQty: "", |
| | | userName: "", |
| | | workOrderId: "", |
| | | productProcessRouteItemId: "", |
| | | userId: "", |
| | | schedulingUserId: "", |
| | | userId: { value: "", name: "" }, // 班组信息 |
| | | auditUserId: { value: "", name: "" }, // 审核人 |
| | | }); |
| | | |
| | | // 这里的字段配置用于模版循环 |
| | | const pickerFields = { |
| | | userId: { label: "班组信息" }, |
| | | auditUserId: { label: "审核人" }, |
| | | }; |
| | | |
| | | // 生产人选择器状态 |
| | | const showProducerPicker = ref(false); |
| | | const producerList = ref([]); |
| | | const currentField = ref(""); // 当前选择的字段 |
| | | |
| | | // 打开生产人选择器 |
| | | const openProducerPicker = async () => { |
| | | const openProducerPicker = async (field) => { |
| | | if (producerList.value.length === 0) { |
| | | // 如果列表为空,先加载用户列表 |
| | | try { |
| | |
| | | const users = res.data || []; |
| | | // 转换为 action-sheet 需要的格式 |
| | | producerList.value = users.map(user => ({ |
| | | name: user.nickName || user.userName, |
| | | name: user.nickName || "", |
| | | value: user.userId, |
| | | })); |
| | | } catch (error) { |
| | |
| | | } |
| | | } |
| | | showProducerPicker.value = true; |
| | | currentField.value = field; // 保存当前字段 |
| | | }; |
| | | |
| | | // 生产人选择确认 |
| | | const onProducerConfirm = e => { |
| | | form.value.schedulingUserId = e.value; |
| | | form.value.userName = e.name; |
| | | form.value.userId = e.value; // 同时更新 userId |
| | | if (currentField.value && form.value[currentField.value]) { |
| | | form.value[currentField.value].value = e.value; |
| | | form.value[currentField.value].name = e.name ; |
| | | } |
| | | showProducerPicker.value = false; |
| | | }; |
| | | |
| | |
| | | showToast("请输入本次生产数量"); |
| | | return; |
| | | } |
| | | if (!form.value.schedulingUserId) { |
| | | if (!form.value.userId.value) { |
| | | submitting.value = false; |
| | | showToast("请选择生产人"); |
| | | showToast("请选择班组信息"); |
| | | return; |
| | | } |
| | | if (!form.value.auditUserId.value) { |
| | | submitting.value = false; |
| | | showToast("请选择审核人"); |
| | | return; |
| | | } |
| | | // 转换为数字进行比较 |
| | |
| | | quantity: Number(form.value.quantity), |
| | | scrapQty: Number(form.value.scrapQty) || 0, |
| | | planQuantity: Number(form.value.planQuantity) || 0, |
| | | userId: form.value.userId.value, |
| | | auditUserId: form.value.auditUserId.value, |
| | | schedulingUserId: form.value.userId.value, // 兼容旧字段 |
| | | }; |
| | | console.log(submitData, "submitData"); |
| | | |
| | |
| | | |
| | | // 页面加载时初始化数据 |
| | | onLoad(options => { |
| | | console.log(options, "options"); |
| | | // 如果没有 orderRow 参数,说明是从首页直接跳转,需要用户手动选择订单 |
| | | if (!options.orderRow) { |
| | | console.log("从首页跳转,无订单数据"); |
| | | getInfo().then(res => { |
| | | // 默认使用当前登录用户 |
| | | form.value.userId = res.user.userId; |
| | | form.value.userName = res.user.userName; |
| | | form.value.schedulingUserId = res.user.userId; |
| | | }); |
| | | return; |
| | | } |
| | | try { |
| | | const orderRow = JSON.parse(options.orderRow); |
| | | console.log("构造的orderRow:", orderRow); |
| | | console.log(orderRow, "orderRow======########"); |
| | | // 确保 planQuantity 转换为字符串,以便在 u-input 中正确显示 |
| | | form.value.planQuantity = orderRow.planQuantity != null ? String(orderRow.planQuantity) : ""; |
| | | form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId || ""; |
| | | form.value.workOrderId = orderRow.id || ""; |
| | | getInfo().then(res => { |
| | | // 默认使用当前登录用户,但允许用户修改 |
| | | form.value.userId = res.user.userId; |
| | | form.value.userName = res.user.userName; |
| | | form.value.schedulingUserId = res.user.userId; |
| | | form.value.userId.value = res.user.userId; |
| | | form.value.userId.name = res.user.nickName; |
| | | }); |
| | | // 使用 nextTick 确保 DOM 更新 |
| | | nextTick(() => { |