| | |
| | | suffix-icon="arrow-down" /> |
| | | </u-form-item> |
| | | </view> |
| | | <!-- 卿忰åºå --> |
| | | <view class="form-section" |
| | | v-if="params.length > 0"> |
| | | <view class="section-title">å·¥åºåæ°</view> |
| | | <u-form-item v-for="param in params" |
| | | :key="param.id" |
| | | :label="param.paramName" |
| | | :label-width="110" |
| | | :required="param.required === '1'"> |
| | | <!-- æ°åç±»å --> |
| | | <template v-if="param.paramType == '1'"> |
| | | <u-input v-model="form.paramGroups[param.id]" |
| | | type="number" |
| | | :placeholder="'请è¾å
¥' + param.paramName" |
| | | :key="param.id" /> |
| | | <text v-if="param.unit && param.unit != '/'" |
| | | class="param-unit">{{ param.unit }}</text> |
| | | </template> |
| | | <!-- ææ¬ç±»å --> |
| | | <template v-else-if="param.paramType == '2'"> |
| | | <u-input v-model="form.paramGroups[param.id]" |
| | | :placeholder="'请è¾å
¥' + param.paramName" |
| | | :key="param.id" /> |
| | | <text v-if="param.unit && param.unit != '/'" |
| | | class="param-unit">{{ param.unit }}</text> |
| | | </template> |
| | | <!-- éæ©ç±»å --> |
| | | <template v-else-if="param.paramType == '3'"> |
| | | <u-input v-model="form.paramGroups[param.id]" |
| | | readonly |
| | | :placeholder="'è¯·éæ©' + param.paramName" |
| | | @click="openParamSelect(param)" |
| | | suffix-icon="arrow-down" /> |
| | | </template> |
| | | <!-- æ¥æç±»å --> |
| | | <template v-else-if="param.paramType == '4'"> |
| | | <u-input v-model="form.paramGroups[param.id]" |
| | | readonly |
| | | :placeholder="'è¯·éæ©' + param.paramName" |
| | | @click="openDateParamPicker(param)" |
| | | suffix-icon="arrow-down" /> |
| | | <text v-if="param.unit && param.unit != '/'" |
| | | class="param-unit">{{ param.unit }}</text> |
| | | </template> |
| | | <!-- é»è®¤ææ¬ --> |
| | | <template v-else> |
| | | <u-input v-model="form.paramGroups[param.id]" |
| | | :placeholder="'请è¾å
¥' + param.paramName" |
| | | :key="param.id" /> |
| | | </template> |
| | | </u-form-item> |
| | | </view> |
| | | <!-- 使ç¨FooterButtonsç»ä»¶ --> |
| | | <FooterButtons @cancel="goBack" |
| | | @confirm="submitForm" |
| | |
| | | title="éæ©ç产人" |
| | | @select="onProducerConfirm" |
| | | @close="showProducerPicker = false" /> |
| | | <!-- åæ°éæ©å¨ --> |
| | | <up-action-sheet :show="showParamSelect" |
| | | :actions="paramOptions" |
| | | :title="currentParam?.paramName || 'éæ©'" |
| | | @select="onParamConfirm" |
| | | @close="showParamSelect = false" /> |
| | | <!-- æ¥æéæ©å¨ --> |
| | | <up-datetime-picker :show="showDatePicker" |
| | | v-model="datePickerValue" |
| | | :mode="datePickerMode" |
| | | @confirm="onDateConfirm" |
| | | @cancel="showDatePicker = false" /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import { addProductMain } from "@/api/productionManagement/productionReporting"; |
| | | import { getInfo } from "@/api/login"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user"; |
| | | import { findProcessParamListOrder } from "@/api/productionManagement/productProcessRoute.js"; |
| | | import { getDicts } from "@/api/system/dict/data"; |
| | | import { formatDateToYMD, parseTime } from "@/utils/ruoyi"; |
| | | |
| | | // 表åå¼ç¨ |
| | | const formRef = ref(); |
| | | |
| | | // è¡¨åæ°æ® |
| | | let form = ref({ |
| | | planQuantity: "", |
| | | quantity: "", |
| | |
| | | productProcessRouteItemId: "", |
| | | userId: "", |
| | | schedulingUserId: "", |
| | | reportWork: "", |
| | | productMainId: null, |
| | | productionOrderRoutingOperationId: "", |
| | | productionOrderId: "", |
| | | paramGroups: {}, |
| | | }); |
| | | |
| | | // çäº§äººéæ©å¨ç¶æ |
| | | const showProducerPicker = ref(false); |
| | | const producerList = ref([]); |
| | | |
| | | // æå¼çäº§äººéæ©å¨ |
| | | const params = ref([]); |
| | | const dictOptions = ref({}); |
| | | const showParamSelect = ref(false); |
| | | const currentParam = ref(null); |
| | | const paramOptions = ref([]); |
| | | |
| | | const showDatePicker = ref(false); |
| | | const datePickerValue = ref(Date.now()); |
| | | const datePickerMode = ref("date"); |
| | | const currentDateParam = ref(null); |
| | | |
| | | 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, |
| | |
| | | showProducerPicker.value = true; |
| | | }; |
| | | |
| | | // çäº§äººéæ©ç¡®è®¤ |
| | | const onProducerConfirm = e => { |
| | | form.value.schedulingUserId = e.value; |
| | | form.value.userName = e.name; |
| | | form.value.userId = e.value; // åæ¶æ´æ° userId |
| | | form.value.userId = e.value; |
| | | showProducerPicker.value = false; |
| | | }; |
| | | |
| | | // æäº¤ç¶æ |
| | | const openParamSelect = async param => { |
| | | currentParam.value = param; |
| | | if (param.paramType == "3" && param.paramFormat) { |
| | | const options = await getDictOptions(param.paramFormat); |
| | | paramOptions.value = options.map(opt => ({ |
| | | name: opt.dictLabel, |
| | | value: opt.dictLabel, |
| | | })); |
| | | } |
| | | showParamSelect.value = true; |
| | | }; |
| | | |
| | | const onParamConfirm = e => { |
| | | if (currentParam.value) { |
| | | form.value.paramGroups[currentParam.value.id] = e.value; |
| | | } |
| | | showParamSelect.value = false; |
| | | }; |
| | | |
| | | const openDateParamPicker = param => { |
| | | currentDateParam.value = param; |
| | | const currentValue = form.value.paramGroups[param.id]; |
| | | datePickerValue.value = currentValue |
| | | ? new Date(currentValue).getTime() |
| | | : Date.now(); |
| | | // åç
§ PC 端é»è¾ï¼å¦ææ ¼å¼æ¯ yyyy-MM-dd å为 date 模å¼ï¼å¦å为 datetime æ¨¡å¼ |
| | | datePickerMode.value = |
| | | param.paramFormat === "yyyy-MM-dd" ? "date" : "datetime"; |
| | | showDatePicker.value = true; |
| | | }; |
| | | |
| | | const onDateConfirm = e => { |
| | | if (currentDateParam.value) { |
| | | const format = |
| | | currentDateParam.value.paramFormat === "yyyy-MM-dd" |
| | | ? "{y}-{m}-{d}" |
| | | : "{y}-{m}-{d} {h}:{i}:{s}"; |
| | | form.value.paramGroups[currentDateParam.value.id] = parseTime( |
| | | e.value, |
| | | format |
| | | ); |
| | | } |
| | | showDatePicker.value = false; |
| | | }; |
| | | |
| | | const getDictOptions = async dictType => { |
| | | if (!dictType) return []; |
| | | if (dictOptions.value[dictType]) return dictOptions.value[dictType]; |
| | | try { |
| | | const res = await getDicts(dictType); |
| | | if (res.code === 200) { |
| | | dictOptions.value[dictType] = res.data; |
| | | return res.data; |
| | | } |
| | | return []; |
| | | } catch (error) { |
| | | console.error("è·ååå
¸æ°æ®å¤±è´¥:", error); |
| | | return []; |
| | | } |
| | | }; |
| | | |
| | | const loadParams = (productionOrderRoutingOperationId, productionOrderId) => { |
| | | findProcessParamListOrder({ |
| | | productionOrderRoutingOperationId, |
| | | productionOrderId, |
| | | }) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | console.log(res.data, "res.data========"); |
| | | |
| | | const paramList = res.data || []; |
| | | params.value = paramList; |
| | | form.value.paramGroups = {}; |
| | | paramList.forEach(param => { |
| | | if (!form.value.paramGroups[param.id]) { |
| | | form.value.paramGroups[param.id] = ""; |
| | | } |
| | | if (param.paramType == "3" && param.paramFormat) { |
| | | getDictOptions(param.paramFormat); |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | console.error("è·åå·¥åºåæ°å¤±è´¥:", err); |
| | | }); |
| | | }; |
| | | |
| | | const submitting = ref(false); |
| | | |
| | | // è¿åä¸ä¸é¡µ |
| | | const goBack = () => { |
| | | uni.navigateBack(); |
| | | }; |
| | | // æäº¤è¡¨å |
| | | |
| | | const submitForm = async () => { |
| | | submitting.value = true; |
| | | // æ ¡éªè¡¨å |
| | | |
| | | if (!form.value.quantity) { |
| | | submitting.value = false; |
| | | showToast("请è¾å
¥æ¬æ¬¡ç产æ°é"); |
| | | return; |
| | | } |
| | | |
| | | if (!form.value.schedulingUserId) { |
| | | submitting.value = false; |
| | | showToast("è¯·éæ©ç产人"); |
| | | return; |
| | | } |
| | | // 转æ¢ä¸ºæ°åè¿è¡æ¯è¾ |
| | | |
| | | const quantity = Number(form.value.quantity) || 0; |
| | | const scrapQty = Number(form.value.scrapQty) || 0; |
| | | const planQuantity = Number(form.value.planQuantity); |
| | | // éªè¯ç产æ°éåæ¥åºæ°éçåä¸è½è¶
è¿å¾
ç产æ°é |
| | | |
| | | if (quantity <= 0) { |
| | | submitting.value = false; |
| | | showToast("æ¬æ¬¡ç产æ°éå¿
须大äº0"); |
| | | return; |
| | | } |
| | | |
| | | if (quantity + scrapQty > planQuantity) { |
| | | submitting.value = false; |
| | | showToast("ç产æ°éåæ¥åºæ°éçåä¸è½è¶
è¿å¾
ç产æ°é"); |
| | | return; |
| | | } |
| | | if (quantity > planQuantity) { |
| | | |
| | | if (scrapQty < 0) { |
| | | submitting.value = false; |
| | | showToast("æ¬æ¬¡ç产æ°éä¸è½å¤§äºå¾
ç产æ°é"); |
| | | showToast("æ¥åºæ°éä¸è½å°äº0"); |
| | | return; |
| | | } |
| | | // åå¤æäº¤æ°æ®ï¼ç¡®ä¿æ°éåæ®µä¸ºæ°åç±»å |
| | | |
| | | if (scrapQty > quantity) { |
| | | submitting.value = false; |
| | | showToast("æ¥åºæ°éä¸è½å¤§äºæ¬æ¬¡ç产æ°é"); |
| | | return; |
| | | } |
| | | |
| | | const productionOperationParamList = params.value.map(param => ({ |
| | | ...param, |
| | | inputValue: form.value.paramGroups[param.id] ?? "", |
| | | })); |
| | | |
| | | const submitData = { |
| | | ...form.value, |
| | | quantity: Number(form.value.quantity), |
| | | scrapQty: Number(form.value.scrapQty) || 0, |
| | | planQuantity: Number(form.value.planQuantity) || 0, |
| | | quantity: quantity, |
| | | scrapQty: scrapQty, |
| | | userId: form.value.userId, |
| | | userName: form.value.userName, |
| | | productionOperationTaskId: form.value.workOrderId, |
| | | productProcessRouteItemId: form.value.productProcessRouteItemId, |
| | | reportWork: form.value.reportWork, |
| | | productMainId: form.value.productMainId, |
| | | productionOrderRoutingOperationId: |
| | | form.value.productionOrderRoutingOperationId, |
| | | productionOrderId: form.value.productionOrderId, |
| | | productionOperationParamList: productionOperationParamList, |
| | | }; |
| | | |
| | | console.log(submitData, "submitData"); |
| | | |
| | | addProductMain(submitData).then(res => { |
| | | addProductMain(submitData) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | showToast("æ¥å·¥æå"); |
| | | submitting.value = false; |
| | |
| | | showToast(res.msg || "æ¥å·¥å¤±è´¥"); |
| | | submitting.value = false; |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | showToast("æ¥å·¥å¤±è´¥"); |
| | | submitting.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // 页é¢å è½½æ¶åå§åæ°æ® |
| | | 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.userName = res.user.nickName || res.user.userName; |
| | | form.value.schedulingUserId = res.user.userId; |
| | | }); |
| | | return; |
| | | } |
| | | try { |
| | | const orderRow = JSON.parse(options.orderRow); |
| | | const orderRow = JSON.parse(decodeURIComponent(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.planQuantity = |
| | | orderRow.planQuantity != null ? String(orderRow.planQuantity) : ""; |
| | | form.value.productProcessRouteItemId = |
| | | orderRow.productProcessRouteItemId || ""; |
| | | form.value.workOrderId = orderRow.id || ""; |
| | | form.value.reportWork = orderRow.reportWork || ""; |
| | | form.value.productMainId = orderRow.productMainId || null; |
| | | form.value.productionOrderRoutingOperationId = |
| | | orderRow.productionOrderRoutingOperationId || ""; |
| | | form.value.productionOrderId = orderRow.productionOrderId || ""; |
| | | |
| | | getInfo().then(res => { |
| | | // é»è®¤ä½¿ç¨å½åç»å½ç¨æ·ï¼ä½å
è®¸ç¨æ·ä¿®æ¹ |
| | | form.value.userId = res.user.userId; |
| | | form.value.userName = res.user.userName; |
| | | form.value.userName = res.user.nickName || res.user.userName; |
| | | form.value.schedulingUserId = res.user.userId; |
| | | }); |
| | | // ä½¿ç¨ nextTick ç¡®ä¿ DOM æ´æ° |
| | | console.log(orderRow, "orderRow====="); |
| | | |
| | | if ( |
| | | orderRow.productionOrderRoutingOperationId && |
| | | orderRow.productionOrderId |
| | | ) { |
| | | nextTick(() => { |
| | | loadParams( |
| | | orderRow.productionOrderRoutingOperationId, |
| | | orderRow.productionOrderId |
| | | ); |
| | | }); |
| | | } |
| | | |
| | | nextTick(() => { |
| | | console.log("form.value after assignment:", form.value); |
| | | }); |
| | |
| | | console.error("订åè§£æå¤±è´¥:", error); |
| | | showToast("订åè§£æå¤±è´¥"); |
| | | goBack(); |
| | | return; |
| | | } |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | @import "@/static/scss/form-common.scss"; |
| | | |
| | | .form-section { |
| | | background: #fff; |
| | | margin-bottom: 12px; |
| | | padding: 0 16px; |
| | | } |
| | | |
| | | .section-title { |
| | | font-size: 28rpx; |
| | | font-weight: bold; |
| | | color: #303133; |
| | | padding: 24rpx 0 16rpx; |
| | | border-bottom: 1px solid #f0f0f0; |
| | | } |
| | | |
| | | .param-unit { |
| | | margin-left: 8rpx; |
| | | color: #909399; |
| | | font-size: 24rpx; |
| | | } |
| | | </style> |
| | | |
| | | |