| ÎļþÃû´Ó src/pages/productionManagement/productionReporting/index.vue ÐÞ¸Ä |
| | |
| | | required> |
| | | <u-input v-model="form.userName" |
| | | placeholder="è¯·éæ©ç产人" |
| | | readonly /> |
| | | readonly |
| | | @click="openProducerPicker" |
| | | suffix-icon="arrow-down" /> |
| | | </u-form-item> |
| | | </view> |
| | | <!-- 使ç¨FooterButtonsç»ä»¶ --> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from "vue"; |
| | | import { ref, nextTick } from "vue"; |
| | | import { onLoad } from "@dcloudio/uni-app"; |
| | | import FooterButtons from "@/components/FooterButtons.vue"; |
| | | import modal from "@/plugins/modal"; |
| | | |
| | | const showToast = message => { |
| | | uni.showToast({ |
| | |
| | | }; |
| | | import { addProductMain } from "@/api/productionManagement/productionReporting"; |
| | | import { getInfo } from "@/api/login"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user"; |
| | | |
| | | // 表åå¼ç¨ |
| | | const formRef = ref(); |
| | | |
| | | // è¡¨åæ°æ® |
| | | let form = ref({ |
| | | planQuantity: 0, |
| | | quantity: 0, |
| | | planQuantity: "", |
| | | quantity: "", |
| | | userName: "", |
| | | workOrderId: "", |
| | | reportWork: "", |
| | | productProcessRouteItemId: "", |
| | | userId: "", |
| | | productMainId: null, |
| | | schedulingUserId: "", |
| | | }); |
| | | let schedulingUserName = ref(""); |
| | | |
| | | // æ¥æéæ©å¨ç¶æ |
| | | const showEnterDatePicker = ref(false); |
| | | const enterDateValue = ref(Date.now()); |
| | | |
| | | // çäº§äººéæ©å¨ç¶æ |
| | | const showProducerPicker = ref(false); |
| | | const producerList = ref([]); |
| | | |
| | | // æå¼çäº§äººéæ©å¨ |
| | | const openProducerPicker = async () => { |
| | | if (producerList.value.length === 0) { |
| | | // 妿å表为空ï¼å
å è½½ç¨æ·å表 |
| | | try { |
| | | const res = await userListNoPageByTenantId(); |
| | | const users = res.data || []; |
| | | // 转æ¢ä¸º action-sheet éè¦çæ ¼å¼ |
| | | producerList.value = users.map(user => ({ |
| | | name: user.nickName || user.userName, |
| | | value: user.userId, |
| | | })); |
| | | } catch (error) { |
| | | console.error("å è½½ç¨æ·å表失败:", error); |
| | | showToast("å è½½ç¨æ·å表失败"); |
| | | return; |
| | | } |
| | | } |
| | | showProducerPicker.value = true; |
| | | }; |
| | | |
| | | // çäº§äººéæ©ç¡®è®¤ |
| | | const onProducerConfirm = e => { |
| | | form.value.schedulingUserId = e.value; |
| | | schedulingUserName.value = e.name; |
| | | form.value.userName = e.name; |
| | | form.value.userId = e.value; // åæ¶æ´æ° userId |
| | | showProducerPicker.value = false; |
| | | }; |
| | | |
| | |
| | | showToast("请è¾å
¥æ¬æ¬¡ç产æ°é"); |
| | | return; |
| | | } |
| | | if (form.value.quantity > form.value.planQuantity) { |
| | | if (!form.value.schedulingUserId) { |
| | | submitting.value = false; |
| | | showToast("è¯·éæ©ç产人"); |
| | | return; |
| | | } |
| | | // 转æ¢ä¸ºæ°åè¿è¡æ¯è¾ |
| | | const quantity = Number(form.value.quantity); |
| | | const planQuantity = Number(form.value.planQuantity); |
| | | if (quantity > planQuantity) { |
| | | submitting.value = false; |
| | | showToast("æ¬æ¬¡ç产æ°éä¸è½å¤§äºå¾
ç产æ°é"); |
| | | return; |
| | | } |
| | | console.log(form.value, "form.value"); |
| | | // åå¤æäº¤æ°æ®ï¼ç¡®ä¿æ°éåæ®µä¸ºæ°åç±»å |
| | | const submitData = { |
| | | ...form.value, |
| | | quantity: Number(form.value.quantity), |
| | | planQuantity: Number(form.value.planQuantity) || 0, |
| | | }; |
| | | console.log(submitData, "submitData"); |
| | | |
| | | addProductMain(form.value).then(res => { |
| | | addProductMain(submitData).then(res => { |
| | | if (res.code === 200) { |
| | | showToast("æ¥å·¥æå"); |
| | | submitting.value = false; |
| | |
| | | console.log(options, "options"); |
| | | try { |
| | | const orderRow = JSON.parse(options.orderRow); |
| | | console.log("æé çorderRow:", orderRow); |
| | | console.log(orderRow, "orderRow======########"); |
| | | form.value.planQuantity = orderRow.planQuantity; |
| | | form.value.quantity = orderRow.quantity; |
| | | form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId; |
| | | form.value.workOrderId = orderRow.id; |
| | | form.value.reportWork = orderRow.reportWork; |
| | | form.value.productMainId = orderRow.productMainId; |
| | | // ç¡®ä¿ 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; |
| | | }); |
| | | // ä½¿ç¨ nextTick ç¡®ä¿ DOM æ´æ° |
| | | nextTick(() => { |
| | | console.log("form.value after assignment:", form.value); |
| | | }); |
| | | } catch (error) { |
| | | modal.msgError("订åè§£æå¤±è´¥"); |
| | | console.error("订åè§£æå¤±è´¥:", error); |
| | | showToast("订åè§£æå¤±è´¥"); |
| | | goBack(); |
| | | return; |
| | | } |