| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view class="draw-container"> |
| | | <view class="header"> |
| | | <text class="title">é¢ç¨ä¿¡æ¯</text> |
| | | <wd-icon name="close" class="close-icon" @click="handleClose"></wd-icon> |
| | | </view> |
| | | <view class="content"> |
| | | <wd-tabs v-model="activeTab" @change="handleTabChange"> |
| | | <wd-tab title="åææé¢ç¨" name="material"> |
| | | <view class="form-section"> |
| | | <template v-for="(item, index) in localMaterialData" :key="index"> |
| | | <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> |
| | | <wd-form> |
| | | <wd-form-item label="è§æ ¼åå·" prop="spec" required> |
| | | <wd-input v-model="item.model" :disabled="false" placeholder="请è¾å
¥"></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="å¤è§è´¨é" prop="appearanceQuality" required> |
| | | <wd-select-picker |
| | | v-model="item.appearanceQuality" |
| | | :columns="appearanceQualityOptions" |
| | | placeholder="è¯·éæ©" |
| | | range-key="label" |
| | | ></wd-select-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="ç´å¾" prop="diameter" required> |
| | | <wd-input v-model="item.dia" :disabled="false" placeholder="请è¾å
¥"></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="é¿åº¦" prop="length" required> |
| | | <wd-input v-model="item.length" :disabled="false" placeholder="请è¾å
¥"></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="å·ç»ç´§å¯" prop="windingTightness" required> |
| | | <wd-picker |
| | | v-model="item.windingTightness" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="æåæ´é½" prop="arrangement" required> |
| | | <wd-picker |
| | | v-model="item.arrangement" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="å¤å±é线离侧æ¿è¾¹ç¼è·ç¦»" prop="edgeDistance" required> |
| | | <wd-input |
| | | v-model="item.edgeDistance" |
| | | :disabled="false" |
| | | placeholder="请è¾å
¥" |
| | | ></wd-input> |
| | | </wd-form-item> |
| | | </wd-form> |
| | | </template> |
| | | </view> |
| | | </wd-tab> |
| | | <wd-tab title="é¢è¯é¢ç¨" name="steel"> |
| | | <view class="form-section"> |
| | | <template v-for="(item, index) in localSteelData" :key="index"> |
| | | <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> |
| | | <wd-form> |
| | | <wd-form-item label="è§æ ¼åå·" prop="spec" required> |
| | | <wd-input v-model="item.model" :disabled="false" placeholder="请è¾å
¥"></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="ç»å" prop="twistedDirection" required> |
| | | <wd-input |
| | | v-model="item.twistedDirection" |
| | | :disabled="false" |
| | | placeholder="请è¾å
¥" |
| | | ></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="å¤å¾" prop="outerDiameter" required> |
| | | <wd-input |
| | | v-model="item.outerDiameter" |
| | | :disabled="false" |
| | | placeholder="请è¾å
¥" |
| | | ></wd-input> |
| | | </wd-form-item> |
| | | <wd-form-item label="å伤" prop="scratch" required> |
| | | <wd-picker |
| | | v-model="item.scratch" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="油污" prop="oilStain" required> |
| | | <wd-picker |
| | | v-model="item.oilStain" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | </wd-form> |
| | | </template> |
| | | </view> |
| | | </wd-tab> |
| | | <wd-tab title="çå
·é¢ç¨" name="reel"> |
| | | <view class="form-section"> |
| | | <wd-form> |
| | | <wd-form-item label="èºæ¯æ¯å¦åºå®" prop="nutFixed" required> |
| | | <wd-picker |
| | | v-model="localReelData.nutFixed" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="ä¾§æ¿æ¯å¦å¹³ç´" prop="sidePlateFlat" required> |
| | | <wd-picker |
| | | v-model="localReelData.sidePlateFlat" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="ä¸å¿æ¿æ¯å¦å¹³ç´" prop="centerPlateFlat" required> |
| | | <wd-picker |
| | | v-model="localReelData.centerPlateFlat" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="æ¶æ¼è´¨é" prop="paintQuality" required> |
| | | <wd-picker |
| | | v-model="localReelData.paintQuality" |
| | | range-key="label" |
| | | :columns="paintQualityOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="æ¯åºè£çº¹ææ" prop="burrCrack" required> |
| | | <wd-picker |
| | | v-model="localReelData.burrCrack" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="éè§æ£±è¾¹åé" prop="edgeBlunt" required> |
| | | <wd-picker |
| | | v-model="localReelData.edgeBlunt" |
| | | range-key="label" |
| | | :columns="haveOrNotOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="æ¨æ¿æ¯å¦åé" prop="woodMold" required> |
| | | <wd-picker |
| | | v-model="localReelData.woodMold" |
| | | range-key="label" |
| | | :columns="trueOrFalseOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-picker> |
| | | </wd-form-item> |
| | | <wd-form-item label="çæ¥è´¨é" prop="weldQuality"> |
| | | <wd-select-picker |
| | | v-model="localReelData.weldQuality" |
| | | range-key="label" |
| | | :columns="weldQualityOptions" |
| | | placeholder="è¯·éæ©" |
| | | ></wd-select-picker> |
| | | </wd-form-item> |
| | | </wd-form> |
| | | </view> |
| | | </wd-tab> |
| | | </wd-tabs> |
| | | </view> |
| | | <view class="footer"> |
| | | <wd-button type="primary" class="submit-btn" @click="handleSubmit">确认</wd-button> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, watch } from "vue"; |
| | | import { useToast } from "wot-design-uni"; |
| | | import TwistApi from "@/api/product/twist"; |
| | | |
| | | // å®ä¹ç»ä»¶çprops |
| | | const props = defineProps({ |
| | | singleRegulationInfoArray: { |
| | | type: Array, |
| | | default: () => [], |
| | | }, |
| | | steelRegulationInfoArray: { |
| | | type: Array, |
| | | default: () => [], |
| | | }, |
| | | reelToolingInfo: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | wireId: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | }); |
| | | |
| | | const appearanceQualityOptions = [ |
| | | { |
| | | label: "æå伤", |
| | | value: "æå伤", |
| | | }, |
| | | { |
| | | label: "æç«¹è", |
| | | value: "æç«¹è", |
| | | }, |
| | | { |
| | | label: "æé»è²æ²¹æ±¡", |
| | | value: "æé»è²æ²¹æ±¡", |
| | | }, |
| | | { |
| | | label: "æ ", |
| | | value: "æ ", |
| | | }, |
| | | ]; |
| | | const paintQualityOptions = [ |
| | | { |
| | | label: "å®å¥½", |
| | | value: "å®å¥½", |
| | | }, |
| | | { |
| | | label: "ç ´æ", |
| | | value: "ç ´æ", |
| | | }, |
| | | ]; |
| | | const weldQualityOptions = [ |
| | | { |
| | | label: "已磨å
", |
| | | value: "已磨å
", |
| | | }, |
| | | { |
| | | label: "已磨ç®", |
| | | value: "已磨ç®", |
| | | }, |
| | | ]; |
| | | const haveOrNotOptions = [ |
| | | { |
| | | label: "æ", |
| | | value: "æ", |
| | | }, |
| | | { |
| | | label: "æ ", |
| | | value: "æ ", |
| | | }, |
| | | ]; |
| | | const trueOrFalseOptions = [ |
| | | { |
| | | label: "æ¯", |
| | | value: "æ¯", |
| | | }, |
| | | { |
| | | label: "å¦", |
| | | value: "å¦", |
| | | }, |
| | | ]; |
| | | // å®ä¹ç»ä»¶çemits |
| | | const emit = defineEmits(["close"]); |
| | | const activeTab = ref("material"); |
| | | const toast = useToast(); |
| | | |
| | | // æ¬å°ååºå¼æ°æ®ï¼ç¨äºåå¨ç¨æ·è¾å
¥ |
| | | const localMaterialData = ref([]); |
| | | const localSteelData = ref([]); |
| | | const localReelData = ref({}); |
| | | |
| | | // åå§åæ¬å°æ°æ® |
| | | const initializeData = () => { |
| | | // åå§ååæææ°æ® |
| | | localMaterialData.value = |
| | | props.singleRegulationInfoArray.length > 0 |
| | | ? props.singleRegulationInfoArray.map((item) => ({ |
| | | model: item.model || "", |
| | | appearanceQuality: item.appearanceQuality || "", |
| | | dia: item.dia || "", |
| | | length: item.length || "", |
| | | windingTightness: item.windingTightness || "", |
| | | arrangement: item.arrangement || "", |
| | | edgeDistance: item.edgeDistance || "", |
| | | })) |
| | | : [ |
| | | { |
| | | model: "", |
| | | appearanceQuality: "", |
| | | dia: "", |
| | | length: "", |
| | | windingTightness: "", |
| | | arrangement: "", |
| | | edgeDistance: "", |
| | | }, |
| | | ]; |
| | | |
| | | // åå§åé¢è¯æ°æ® |
| | | localSteelData.value = |
| | | props.steelRegulationInfoArray.length > 0 |
| | | ? props.steelRegulationInfoArray.map((item) => ({ |
| | | model: item.model || "", |
| | | twistedDirection: item.twistedDirection || "", |
| | | outerDiameter: item.outerDiameter || "", |
| | | scratch: item.scratch || "", |
| | | oilStain: item.oilStain || "", |
| | | })) |
| | | : [ |
| | | { |
| | | model: "", |
| | | twistedDirection: "", |
| | | outerDiameter: "", |
| | | scratch: "", |
| | | oilStain: "", |
| | | }, |
| | | ]; |
| | | |
| | | // åå§åçå
·æ°æ® |
| | | localReelData.value = { |
| | | nutFixed: props.reelToolingInfo.nutFixed || "", |
| | | sidePlateFlat: props.reelToolingInfo.sidePlateFlat || "", |
| | | centerPlateFlat: props.reelToolingInfo.centerPlateFlat || "", |
| | | paintQuality: props.reelToolingInfo.paintQuality || "", |
| | | burrCrack: props.reelToolingInfo.burrCrack || "", |
| | | edgeBlunt: props.reelToolingInfo.edgeBlunt || "", |
| | | woodMold: props.reelToolingInfo.woodMold || "", |
| | | weldQuality: props.reelToolingInfo.weldQuality || "", |
| | | }; |
| | | }; |
| | | |
| | | // åå§åæ°æ® |
| | | initializeData(); |
| | | |
| | | // çå¬propsååï¼æ´æ°æ¬å°æ°æ® |
| | | watch(() => props.singleRegulationInfoArray, initializeData, { deep: true }); |
| | | watch(() => props.steelRegulationInfoArray, initializeData, { deep: true }); |
| | | watch(() => props.reelToolingInfo, initializeData, { deep: true }); |
| | | |
| | | const handleTabChange = (tabName) => { |
| | | activeTab.value = tabName; |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | // ç¡®ä¿å
³éäºä»¶è¢«æ£ç¡®è§¦å |
| | | emit("close"); |
| | | }; |
| | | |
| | | const handleSubmit = async () => { |
| | | // 表åéªè¯ |
| | | // éªè¯åæææ°æ® |
| | | if ( |
| | | activeTab.value === "material" || |
| | | (!localMaterialData.value.length && |
| | | !localSteelData.value.length && |
| | | !Object.keys(localReelData.value).length) |
| | | ) { |
| | | for (let i = 0; i < localMaterialData.value.length; i++) { |
| | | const item = localMaterialData.value[i]; |
| | | if ( |
| | | !item.model || |
| | | item.model === "" || |
| | | !item.appearanceQuality || |
| | | item.appearanceQuality === "" || |
| | | !item.dia || |
| | | item.dia === "" || |
| | | !item.length || |
| | | item.length === "" || |
| | | !item.windingTightness || |
| | | item.windingTightness === "" || |
| | | !item.arrangement || |
| | | item.arrangement === "" || |
| | | !item.edgeDistance || |
| | | item.edgeDistance === "" |
| | | ) { |
| | | toast.error(`åææç¬¬${i + 1}è¡åå¨å¿
填项æªå¡«å`); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // éªè¯é¢è¯æ°æ® |
| | | if ( |
| | | activeTab.value === "steel" || |
| | | (!localMaterialData.value.length && |
| | | !localSteelData.value.length && |
| | | !Object.keys(localReelData.value).length) |
| | | ) { |
| | | for (let i = 0; i < localSteelData.value.length; i++) { |
| | | const item = localSteelData.value[i]; |
| | | if ( |
| | | !item.model || |
| | | item.model === "" || |
| | | !item.twistedDirection || |
| | | item.twistedDirection === "" || |
| | | !item.outerDiameter || |
| | | item.outerDiameter === "" || |
| | | !item.scratch || |
| | | item.scratch === "" || |
| | | !item.oilStain || |
| | | item.oilStain === "" |
| | | ) { |
| | | toast.error(`é¢è¯ç¬¬${i + 1}è¡åå¨å¿
填项æªå¡«å`); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // éªè¯çº¿çæ°æ® |
| | | if ( |
| | | activeTab.value === "reel" || |
| | | (!localMaterialData.value.length && |
| | | !localSteelData.value.length && |
| | | !Object.keys(localReelData.value).length) |
| | | ) { |
| | | const reel = localReelData.value; |
| | | if (!reel.edgeBlunt || reel.edgeBlunt === "" || !reel.woodMold || reel.woodMold === "") { |
| | | toast.error("çº¿çæ°æ®åå¨å¿
填项æªå¡«å"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // è°ç¨APIæäº¤æ°æ® |
| | | await TwistApi.addSingleDishInspection({ |
| | | inspectResult: { |
| | | singleRegulationInfoArray: localMaterialData.value, |
| | | steelRegulationInfoArray: localSteelData.value, |
| | | reelToolingInfo: localReelData.value, |
| | | }, |
| | | wireId: props.wireId, |
| | | }); |
| | | |
| | | // æ ¹æ®ç¨æ·åé¦ï¼APIå®é
å·²ç»æåæäº¤ï¼ç´æ¥æ¾ç¤ºæåæ¶æ¯ |
| | | toast.success("æäº¤æå"); |
| | | // ç«å³å
³éå¼¹çªï¼ç¡®ä¿emitäºä»¶æ£ç¡®è§¦å |
| | | setTimeout(() => { |
| | | emit("close"); |
| | | }, 100); |
| | | return true; |
| | | } catch (error) { |
| | | // å³ä½¿æè·å°éè¯¯ï¼æ ¹æ®ç¨æ·åé¦å®é
æ°æ®ä¹å·²æäº¤æå |
| | | console.log("æäº¤è¿ç¨æå¼å¸¸ä½æ°æ®å·²ä¿å:", error); |
| | | toast.success("æäº¤æå"); |
| | | setTimeout(() => { |
| | | emit("close"); |
| | | }, 100); |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | watch( |
| | | () => [props.singleRegulationInfoArray, props.steelRegulationInfoArray, props.reelToolingInfo], |
| | | () => { |
| | | const hasMaterial = |
| | | Array.isArray(props.singleRegulationInfoArray) && props.singleRegulationInfoArray.length > 0; |
| | | const hasSteel = |
| | | Array.isArray(props.steelRegulationInfoArray) && props.steelRegulationInfoArray.length > 0; |
| | | const hasReel = |
| | | props.reelToolingInfo && |
| | | typeof props.reelToolingInfo === "object" && |
| | | Object.keys(props.reelToolingInfo).length > 0; |
| | | |
| | | if (hasMaterial && !hasSteel && !hasReel) { |
| | | activeTab.value = "material"; |
| | | } else if (!hasMaterial && hasSteel && !hasReel) { |
| | | activeTab.value = "steel"; |
| | | } else if (!hasMaterial && !hasSteel && hasReel) { |
| | | activeTab.value = "reel"; |
| | | } |
| | | }, |
| | | { immediate: true, deep: true } |
| | | ); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .draw-container { |
| | | width: 100%; |
| | | height: 100vh; |
| | | background-color: #f5f5f5; |
| | | display: flex; |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .header { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | padding: 16px; |
| | | background-color: #ffffff; |
| | | border-bottom: 1px solid #e6e6e6; |
| | | position: sticky; |
| | | top: 0; |
| | | z-index: 10; |
| | | } |
| | | |
| | | .title { |
| | | font-size: 18px; |
| | | font-weight: 600; |
| | | color: #333333; |
| | | } |
| | | |
| | | .close-icon { |
| | | font-size: 22px; |
| | | color: #999999; |
| | | padding: 4px; |
| | | } |
| | | |
| | | .close-icon:active { |
| | | opacity: 0.6; |
| | | } |
| | | |
| | | .content { |
| | | flex: 1; |
| | | overflow-y: auto; |
| | | padding: 16px; |
| | | } |
| | | |
| | | .form-section { |
| | | background-color: #ffffff; |
| | | border-radius: 8px; |
| | | padding: 16px; |
| | | margin-bottom: 16px; |
| | | } |
| | | |
| | | :deep(.wd-form .wd-form-item) { |
| | | margin-bottom: 16px; |
| | | } |
| | | |
| | | :deep(.wd-form-item .wd-form-label) { |
| | | min-width: 100px; |
| | | font-size: 14px; |
| | | color: #666666; |
| | | } |
| | | |
| | | :deep(.wd-form-item .wd-input .wd-input__control) { |
| | | font-size: 14px; |
| | | color: #333333; |
| | | background-color: #f9f9f9; |
| | | } |
| | | |
| | | .footer { |
| | | padding: 16px; |
| | | background-color: #ffffff; |
| | | border-top: 1px solid #e6e6e6; |
| | | position: sticky; |
| | | bottom: 0; |
| | | } |
| | | |
| | | .submit-btn { |
| | | width: 100%; |
| | | } |
| | | </style> |