| .env.development | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/api/product/manage.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/api/product/twist.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/index/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/detail/twistDetail.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/list/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/report/draw.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/report/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/selfInspect/edit.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/selfInspect/form.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/selfInspect/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/utils/cache.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.env.development
@@ -9,11 +9,11 @@ # API åºç¡è·¯å¾ï¼å¼åç¯å¢ä¸ç请æ±åç¼ #VITE_APP_BASE_API = 'http://114.132.189.42:7002/mes' # VITE_APP_BASE_API = 'http://114.132.189.42:7002/mes' # VITE_APP_BASE_API = 'http://192.168.0.206:7002/mes' # é¹è£ VITE_APP_BASE_API = 'http://192.168.100.131:7002/mes' # VITE_APP_BASE_API = 'http://192.168.10.119:7002/mes' # é¹è£ # VITE_APP_BASE_API = 'http://192.168.100.131:7002/mes' # # API æå¡å¨ç URL #VITE_APP_API_URL = 'http://114.132.189.42:7002/mes' # VITE_APP_API_URL = 'http://114.132.189.42:7002/mes' VITE_APP_API_URL = 'http://192.168.100.131:7002/mes' # VITE_APP_API_URL = 'http://114.132.10.119:7002/mes' # VITE_APP_API_URL = 'http://192.168.100.131:7002/mes' # src/api/product/manage.ts
@@ -96,6 +96,15 @@ method: "GET", }); }, // è·åç产ç»è®¡ getProductStatistics(params: any) { return request<BaseResult<any>>({ url: "/app/getProductStatistics", method: "GET", data: params, }); }, }; export default ManageApi; src/api/product/twist.ts
@@ -97,6 +97,50 @@ method: "DELETE", }); }, // è·åç»çº¿èªæ£åºæ¬ä¿¡æ¯ getStrandedWireInspectionRecordStyleByWireId(params: { wireId: number | string }) { return request<BaseResult<any>>({ url: `/wireInspection/getStrandedWireInspectionRecordStyleByWireId`, method: "GET", data: params, }); }, // è·åç»çº¿èªæ£å表 getStrandedInspectionInfoByWireId(params: { wireId: number | string }) { return request<BaseResult<any>>({ url: `/wireInspection/getStrandedInspectionInfoByWireId`, method: "GET", data: params, }); }, // ä¿åç»çº¿èªæ£åºæ¬ä¿¡æ¯ saveStrandedWireInspectionFixedRecord(data: any) { return request<BaseResult<any>>({ url: `/wireInspection/saveStrandedWireInspectionFixedRecord`, method: "POST", data: data, }); }, // ä¿åç»çº¿èªæ£å·¥èºè®°å½ saveStrandedWireInspectionStructureRecord(data: any) { return request<BaseResult<any>>({ url: `/wireInspection/saveStrandedWireInspectionStructureRecord`, method: "POST", data: data, }); }, // å é¤ç»çº¿èªæ£å·¥èºè®°å½ deleteStrandedWireInspectionStructureRecord(id: number) { return request<BaseResult<any>>({ url: `/wireInspection/deleteStrandedWireInspectionStructureRecord/${id}`, method: "POST", }); }, }; export default TwistApi; src/pages.json
@@ -194,12 +194,6 @@ } }, { "path": "pages/production/wire/selfInspect/edit", "style": { "navigationBarTitleText": "ç¼è¾æä¸èªæ£" } }, { "path": "pages/production/wire/backman/index", "style": { "navigationBarTitleText": "æå·¥" @@ -257,12 +251,6 @@ "path": "pages/production/twist/selfInspect/index", "style": { "navigationBarTitleText": "ç»çº¿èªæ£" } }, { "path": "pages/production/twist/selfInspect/edit", "style": { "navigationBarTitleText": "ç»çº¿èªæ£ç¼è¾" } }, { @@ -333,4 +321,4 @@ } ] } } } src/pages/index/index.vue
@@ -93,6 +93,7 @@ import WorkerCallingCard from "@/components/worker-calling-card/index.vue"; import HomeApi from "@/api/home"; import { useUserStore } from "@/store/modules/user"; import { setTeamId, setPrepareId } from "@/utils/cache"; const visitStatsData = ref<VisitStatsVO>({ todayUvCount: 0, @@ -249,6 +250,16 @@ checkVersion(); const { data } = await HomeApi.getIndex(); // åå¨çç»IDåç产åå¤ID if (data) { if (data.team) { setTeamId(data.team); } if (data.prepareId) { setPrepareId(data.prepareId); } } // 夿æ¯å¦ä¸ºå·¡æ£åè§è² if (data.deviceGroupName == "æ¶æç»") { navList[1].show = true; src/pages/production/detail/twistDetail.vue
@@ -13,12 +13,7 @@ /> <view class="mx-3"> <wd-grid class="rounded-lg" clickable> <wd-grid-item icon="computer" link-type="navigateTo" :url="`/pages/production/twist/report/index?id=${paramsId}`" text="æ¥å·¥" /> <wd-grid-item icon="computer" @click="handleReportClick" text="æ¥å·¥" /> <!-- <wd-grid-item icon="chart" text="èªæ£" @@ -46,6 +41,8 @@ import { onLoad } from "@dcloudio/uni-app"; import ProductCard from "@/components/product_card/index.vue"; import TwistApi from "@/api/product/twist"; import { getPrepareId, setPrepareId } from "@/utils/cache"; import HomeApi from "@/api/home"; const paramsId = ref(); const cardData = reactive({ @@ -69,9 +66,49 @@ cardData.unAmount = data.unLength; }; onLoad((options: any) => { // è·åå¹¶ç¼åç产åå¤ID const initPrepareId = async () => { try { const { data } = await HomeApi.getIndex(); if (data && data.prepareId) { setPrepareId(data.prepareId); } } catch (error) { console.error("è·åç产åå¤ID失败:", error); } }; // å¤çæ¥å·¥ç¹å» const handleReportClick = () => { const prepareId = getPrepareId(); console.log("ç»çº¿è¡¨æ ¼æ¥å·¥æ£æ¥ - prepareIdå¼:", prepareId); // 妿prepareIdä¸ºç©ºææªå®ä¹ï¼è¯´æç产å夿ªå®æ if (!prepareId) { console.log("ç»çº¿è¡¨æ ¼æ¥å·¥é»æ¢ - ç产å夿ªå®æ"); uni.showModal({ title: "æç¤º", content: "请å¨çµèç«¯å®æç产åå¤ç¡®è®¤ï¼åè¿è¡æ¥å·¥æä½", showCancel: false, confirmText: "ç¡®å®", success: () => { // ç¨æ·ç¹å»ç¡®å®åï¼ä¸åä»»ä½æä½ }, }); return; } // 妿æ prepareIdï¼æ£å¸¸è·³è½¬ uni.navigateTo({ url: `/pages/production/twist/report/index?id=${paramsId.value}`, }); }; onLoad(async (options: any) => { paramsId.value = options.id; getDetailData(options.id); await getDetailData(options.id); // è·åå¹¶ç¼åç产åå¤ID await initPrepareId(); }); </script> src/pages/production/index.vue
@@ -4,7 +4,7 @@ <wd-col :span="21"> <wd-search v-model="searchKeyword" placeholder="请è¾å ¥è§æ ¼åå·" placeholder="请è¾å ¥" placeholder-left hide-cancel @search="handleSearch" @@ -24,18 +24,8 @@ :key="`wait-${searchKey}`" :api="ManageApi.getProductList" state="å¾ å®æ" :model="searchKeyword" :search="searchKeyword" @ok="changeWait" /> </wd-tab> <wd-tab :title="`é¨å宿(${total.partial})`" class="tab_bg"> <ProductList ref="partialRef" :key="`partial-${searchKey}`" :api="ManageApi.getProductList" state="é¨å宿" :model="searchKeyword" @ok="changePartial" /> </wd-tab> <wd-tab :title="`å·²ç产(${total.already})`" class="tab_bg"> @@ -44,7 +34,7 @@ :key="`already-${searchKey}`" :api="ManageApi.getProductList" state="已宿" :model="searchKeyword" :search="searchKeyword" @ok="changeAlready" /> </wd-tab> @@ -69,14 +59,12 @@ const toast = useToast(); const waitRef = ref(); const partialRef = ref(); const alreadyRef = ref(); const tab = ref<number>(0); const searchKeyword = ref(""); const searchKey = ref(0); const total = reactive({ wait: 0, partial: 0, already: 0, }); @@ -84,16 +72,31 @@ total.wait = num; }; const changePartial = (num: number) => { total.partial = num; }; const changeAlready = (num: number) => { total.already = num; }; // è·åç»è®¡æ°æ® const getStatistics = async () => { try { const params: any = {}; if (searchKeyword.value) { params.search = searchKeyword.value; } const { code, data } = await ManageApi.getProductStatistics(params); if (code === 200 && data) { total.wait = data["å¾ å®æ"] || 0; total.already = data["已宿"] || 0; } } catch (error) { console.error("è·åç»è®¡æ°æ®å¤±è´¥:", error); } }; const handleSearch = () => { searchKey.value++; // æç´¢æ¶æ´æ°ç»è®¡æ°æ® getStatistics(); }; const handleClear = () => { @@ -124,6 +127,8 @@ onMounted(() => { // å¼å¯å¹¿æçå¬äºä»¶ setupScanListener(); // è·åç»è®¡æ°æ® getStatistics(); console.log("æ¾ç¤º1"); }); onUnmounted(() => { src/pages/production/list/index.vue
@@ -51,7 +51,7 @@ type: String, default: "", }, model: { search: { type: String, default: "", }, @@ -80,8 +80,8 @@ current: pageNo, size: pageSize, }; if (props.model) { params.model = props.model; if (props.search) { params.search = props.search; } const { code, data } = await props.api(params); if (code == 200) { src/pages/production/twist/report/draw.vue
@@ -62,45 +62,6 @@ </template> </view> </wd-tab> <wd-tab title="è¯çº¿é¢ç¨èªæ£" name="steel"> <view class="form-section"> <wd-form :model="localSteelData"> <wd-form-item label="è§æ ¼åå·" prop="model" required> <wd-input v-model="localSteelData.model" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="ç»å" prop="twistedDirection" required> <wd-input v-model="localSteelData.twistedDirection" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="å¤å¾" prop="outerDiameter" required> <wd-input v-model="localSteelData.outerDiameter" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="å伤" prop="scratch" required> <wd-radio-group v-model="localSteelData.scratch" cell shape="dot"> <wd-radio value="æ¯">æ¯</wd-radio> <wd-radio value="å¦">å¦</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="油污" prop="oilStain" required> <wd-radio-group v-model="localSteelData.oilStain" cell shape="dot"> <wd-radio value="æ¯">æ¯</wd-radio> <wd-radio value="å¦">å¦</wd-radio> </wd-radio-group> </wd-form-item> </wd-form> </view> </wd-tab> <wd-tab title="çå ·é¢ç¨èªæ£" name="reel"> <view class="form-section"> <wd-form :model="localReelData"> @@ -163,7 +124,9 @@ :key="option.value" :modelValue=" Array.isArray(localReelData.weldQuality) ? localReelData.weldQuality.includes(String(option.value)) ? localReelData.weldQuality .map((v) => String(v)) .includes(String(option.value)) : false " shape="square" @@ -172,6 +135,45 @@ {{ option.label }} </wd-checkbox> </view> </wd-form-item> </wd-form> </view> </wd-tab> <wd-tab title="è¯çº¿é¢ç¨èªæ£" name="steel"> <view class="form-section"> <wd-form :model="localSteelData"> <wd-form-item label="è§æ ¼åå·" prop="model" required> <wd-input v-model="localSteelData.model" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="ç»å" prop="twistedDirection" required> <wd-input v-model="localSteelData.twistedDirection" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="å¤å¾" prop="outerDiameter" required> <wd-input v-model="localSteelData.outerDiameter" :disabled="false" placeholder="请è¾å ¥" ></wd-input> </wd-form-item> <wd-form-item label="å伤" prop="scratch" required> <wd-radio-group v-model="localSteelData.scratch" cell shape="dot"> <wd-radio value="æ¯">æ¯</wd-radio> <wd-radio value="å¦">å¦</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="油污" prop="oilStain" required> <wd-radio-group v-model="localSteelData.oilStain" cell shape="dot"> <wd-radio value="æ¯">æ¯</wd-radio> <wd-radio value="å¦">å¦</wd-radio> </wd-radio-group> </wd-form-item> </wd-form> </view> @@ -360,21 +362,29 @@ }; // å¤ççæ¥è´¨éå¤éæ¡çchangeäºä»¶ const handleWeldQualityCheckbox = (optionValue: string, checked: boolean) => { const currentValues = Array.isArray(localReelData.value.weldQuality) ? localReelData.value.weldQuality : []; let newValues: string[]; if (checked) { // éä¸ newValues = [...currentValues, optionValue]; } else { // åæ¶éä¸ newValues = currentValues.filter((v) => v !== optionValue); const handleWeldQualityCheckbox = (optionValue: string, checked: any) => { // ç¡®ä¿ weldQuality æ¯æ°ç» if (!Array.isArray(localReelData.value.weldQuality)) { localReelData.value.weldQuality = []; } // æ´æ°å¼ const currentValues = [...localReelData.value.weldQuality.map((v) => String(v))]; const optionValueStr = String(optionValue); // 夿å½åæ¯å¦å·²éä¸ const isCurrentlyChecked = currentValues.includes(optionValueStr); // æ ¹æ®å½åç¶æåæ¢ï¼å¦æå½åå·²éä¸ï¼ååæ¶éä¸ï¼å¦æå½åæªéä¸ï¼åéä¸ let newValues: string[]; if (isCurrentlyChecked) { // å½åå·²éä¸ï¼åæ¶éä¸ newValues = currentValues.filter((v) => v !== optionValueStr); } else { // å½åæªéä¸ï¼éä¸ newValues = [...currentValues, optionValueStr]; } // ç´æ¥æ´æ°å¼ localReelData.value.weldQuality = newValues; }; @@ -457,7 +467,7 @@ length: item.length || "", windingTightness: item.windingTightness || "æ¯", arrangement: item.arrangement || "æ¯", edgeDistance: item.edgeDistance || "", edgeDistance: item.edgeDistance || "25", }; }) : [ @@ -468,7 +478,7 @@ length: "", windingTightness: "æ¯", arrangement: "æ¯", edgeDistance: "", edgeDistance: "25", }, ]; @@ -510,7 +520,16 @@ weldQualityValue = [props.reelToolingInfo.weldQuality as string]; } else { // é»è®¤éæ©"已磨å "å"已修平" weldQualityValue = ["已磨å ", "已修平"]; // 妿åå ¸æ°æ®å·²å è½½ï¼ä½¿ç¨åå ¸ä¸çå®é å¼ï¼å¦å使ç¨å符串 if (weldQualityOptions.value.length > 0) { const defaultOptions = weldQualityOptions.value.filter( (opt) => opt.label === "已磨å " || opt.label === "已修平" ); weldQualityValue = defaultOptions.map((opt) => String(opt.value)); } else { // åå ¸æªå è½½æ¶ï¼ä½¿ç¨å符串ä½ä¸ºä¸´æ¶å¼ï¼åç»ä¼å¨åå ¸å è½½åéæ°åå§å weldQualityValue = ["已磨å ", "已修平"]; } } localReelData.value = { @@ -579,7 +598,8 @@ { deep: true } ); watch(() => props.steelRegulationInfo, initializeData, { deep: true }); watch(() => props.reelToolingInfo, initializeData, { deep: true }); // 注æï¼ä¸çå¬ props.reelToolingInfo çååï¼é¿å è¦çç¨æ·çæä½ // watch(() => props.reelToolingInfo, initializeData, { deep: true }); const handleTabChange = (tabName: string) => { activeTab.value = tabName; @@ -693,6 +713,23 @@ // å¨ç»ä»¶æè½½æ¶å¼æ¥å è½½æ°æ®åå ¸ onMounted(async () => { await loadDictData(); // åå ¸æ°æ®å è½½å®æåï¼éæ°åå§åæ°æ®ï¼ç¡®ä¿é»è®¤å¼è½æ£ç¡®å¹é // ä½åªåå§å weldQuality 妿å®è¿æ¯ç©ºæ°ç»æé»è®¤å¼ if ( !Array.isArray(localReelData.value.weldQuality) || localReelData.value.weldQuality.length === 0 || (localReelData.value.weldQuality.length === 2 && localReelData.value.weldQuality.includes("已磨å ") && localReelData.value.weldQuality.includes("已修平")) ) { // åªæå¨æ¯é»è®¤å¼æç©ºæ°ç»æ¶æéæ°åå§å const defaultOptions = weldQualityOptions.value.filter( (opt) => opt.label === "已磨å " || opt.label === "已修平" ); if (defaultOptions.length > 0) { localReelData.value.weldQuality = defaultOptions.map((opt) => String(opt.value)); } } }); watch( () => [props.singleRegulationInfoArray, props.steelRegulationInfo, props.reelToolingInfo], src/pages/production/twist/report/index.vue
@@ -2,7 +2,29 @@ <view class="list"> <z-paging ref="pagingRef" v-model="twistReportList" :fixed="false" @query="getTwistReportList"> <template #top> <CardTitle title="æ¥å·¥ä¿¡æ¯" :hideAction="true" :full="false" @action="addReport" /> <CardTitle title="æ¥å·¥ä¿¡æ¯" :hideAction="false" :full="false"> <template #action> <wd-button icon="chart" :round="false" size="small" plain style="margin-right: 10px" @click="handleSelfCheck" > èªæ£ </wd-button> <wd-button icon="file-add" :round="false" size="small" custom-class="add_btn" @click="addReport" > æ°å¢ </wd-button> </template> </CardTitle> </template> <wd-card v-for="item in twistReportList" :key="item.id" type="rectangle" custom-class="round"> <template #title> @@ -19,14 +41,6 @@ <template #footer> <wd-button size="small" plain style="margin-right: 10px" @click="toAttachment(item)"> éä»¶ </wd-button> <wd-button size="small" plain style="margin-right: 10px" @click="handleSelfCheck(item.id)" > èªæ£ </wd-button> <wd-button size="small" plain type="error" @click="handleDelete(item)">å é¤</wd-button> </template> @@ -68,7 +82,7 @@ import TwistApi from "@/api/product/twist"; import Draw from "./draw.vue"; import HomeApi from "@/api/home"; import { setTeamId, getTeamId } from "@/utils/cache"; import { setTeamId, getTeamId, setPrepareId } from "@/utils/cache"; const drawFormRef = reactive({ visible: false, @@ -149,24 +163,30 @@ const twistReportList = ref<any[]>([]); const teamId = ref<string | number | null>(null); // è·åå¹¶ç¼åçç»ID // è·åå¹¶ç¼åçç»IDåç产åå¤ID const initTeamId = async () => { // å å°è¯ä»ç¼åè·å const cachedTeamId = getTeamId(); if (cachedTeamId) { teamId.value = cachedTeamId; return; } // 妿ç¼å䏿²¡æï¼åè°ç¨æ¥å£è·å // è°ç¨æ¥å£è·åææ°æ°æ® try { const { data } = await HomeApi.getIndex(); if (data && data.team) { teamId.value = data.team; setTeamId(data.team); if (data) { // åå¨çç»ID if (data.team) { teamId.value = data.team; setTeamId(data.team); } // åå¨ç产åå¤ID if (data.prepareId) { setPrepareId(data.prepareId); } } } catch (error) { console.error("è·åçç»ID失败:", error); console.error("è·åæ°æ®å¤±è´¥:", error); } }; @@ -293,11 +313,10 @@ } }; const handleSelfCheck = (id: string) => { console.log("æ§è¡èªæ£æä½ï¼ID:", id); uni.showToast({ title: "èªæ£åè½å¼åä¸", icon: "none", const handleSelfCheck = () => { // 跳转å°èªæ£é¡µé¢ï¼ä¼ é wireId uni.navigateTo({ url: `/pages/production/twist/selfInspect/index?id=${paramsId.value}`, }); }; src/pages/production/twist/selfInspect/edit.vue
ÎļþÒÑɾ³ý src/pages/production/twist/selfInspect/form.vue
@@ -1,66 +1,369 @@ <template> <wd-form ref="form" :model="model" class="relative form_box"> <wd-cell-group :border="true"> <wd-input v-model="model.selfInspectName" label="èªæ£åç§°" label-width="100px" prop="selfInspectName" clearable placeholder="请è¾å ¥èªæ£åç§°" /> <wd-input v-model="model.unit" label="åä½" label-width="100px" prop="unit" clearable placeholder="请è¾å ¥åä½" /> <wd-input v-model="model.standard" label="æ åå¼" label-width="100px" prop="standard" clearable placeholder="请è¾å ¥æ åå¼" /> <wd-input v-model="model.selfInspectValue" label="èªæ£å¼" label-width="100px" prop="selfInspectValue" clearable placeholder="请è¾å ¥èªæ£å¼" /> <wd-input v-model="model.selfInspectResult" label="èªæ£ç»æ" label-width="100px" prop="selfInspectResult" clearable placeholder="请è¾å ¥èªæ£ç»æ" /> </wd-cell-group> </wd-form> <view class="form-container"> <wd-form ref="formRef" :model="formData"> <!-- ç»ææ£æ¥ --> <wd-row> <view style="margin: 10rpx"> <text class="title">ç»ææ£æ¥</text> </view> <wd-col :span="24"> <wd-form-item label="æåç»æ" prop="structureFormula" required> <wd-input v-model="formData.structureFormula" placeholder="请è¾å ¥æåç»æ" clearable :disabled="isViewMode" /> </wd-form-item> <wd-form-item label="è®°å½ä½ç½®" prop="recordPosition" required> <wd-select-picker v-model="formData.recordPosition" :columns="recordLocationColumns" type="radio" placeholder="è¯·éæ©è®°å½ä½ç½®" :clearable="false" :disabled="isViewMode" /> </wd-form-item> <wd-form-item label="ç»åå¤å¾(mm)" prop="twistedOuterDiameter" required> <wd-input v-model="formData.twistedOuterDiameter" placeholder="请è¾å ¥ç»åå¤å¾" clearable type="number" :disabled="isViewMode" /> </wd-form-item> </wd-col> </wd-row> <!-- ç»ææ åå¼å宿µ --> <wd-row v-if="structureItems.length > 0"> <view style="margin: 10rpx"> <text class="title">ç»ææ åå¼å宿µ</text> </view> <wd-col :span="24" v-for="(item, index) in structureItems" :key="index" style="padding-bottom: 10px" > <wd-form-item :label="item.structureName" label-width="180px" style="color: red" required /> <wd-form-item label="æ åå¼" prop="structureValue"> <text>{{ item.structureValue || "-" }}</text> </wd-form-item> <wd-form-item label="宿µæ ¹æ°" prop="actualValue1" required> <wd-input v-model="item.actualValue1" placeholder="请è¾å ¥æ ¹æ°" clearable type="number" :disabled="isViewMode" /> </wd-form-item> <wd-form-item label="宿µç´å¾" prop="actualValue2" required> <wd-input v-model="item.actualValue2" placeholder="请è¾å ¥ç´å¾" clearable type="number" :disabled="isViewMode" > <template #append>mm</template> </wd-input> </wd-form-item> </wd-col> </wd-row> <!-- ç»çº¿å·¥èºè´¨éæ§å¶ --> <wd-row v-if="twistItems.length > 0"> <view style="margin: 10rpx"> <text class="title">ç»çº¿å·¥èºè´¨éæ§å¶</text> </view> <wd-col :span="24" v-for="(item, index) in twistItems" :key="index" style="padding-bottom: 10px" > <wd-form-item :label="item.twistName" label-width="180px" style="color: red" required /> <wd-form-item label="ç»å" prop="direction" required> <wd-select-picker v-model="item.direction" :columns="twistDirectionColumns" type="radio" placeholder="è¯·éæ©ç»å" :clearable="false" :disabled="isViewMode" /> </wd-form-item> <wd-form-item label="èè·" prop="pitch" required> <wd-input v-model="item.pitch" placeholder="请è¾å ¥èè·" clearable type="number" :disabled="isViewMode" @input="updatePitchRatio(item)" > <template #append>mm</template> </wd-input> </wd-form-item> <wd-form-item label="è徿¯" prop="pitchRatio"> <text>{{ calculatePitchRatio(item.pitch, item.dia) }}</text> </wd-form-item> </wd-col> </wd-row> <!-- å¤è§åç»è®º --> <wd-row> <view style="margin: 10rpx"> <text class="title">å¤è§åç»è®º</text> </view> <wd-col :span="24"> <wd-form-item label="æåå¤è§" prop="productAppearance" required> <view v-if="!isViewMode" style="display: flex; flex-wrap: wrap; gap: 10px"> <wd-checkbox v-for="(opt, idx) in appearanceOptions" :key="idx" :value="opt.value" :modelValue="formData.productAppearance.includes(opt.value)" @click="handleAppearanceClick(opt.value)" style="width: 100px" > {{ opt.label }} </wd-checkbox> </view> <text v-else>{{ formatProductAppearance(formData.productAppearance) }}</text> </wd-form-item> <wd-form-item label="ç»è®º" prop="conclusion" required> <wd-radio-group v-model="formData.conclusion" inline class="conclusion-radio-group" :disabled="isViewMode" > <wd-radio value="åæ ¼" shape="dot">åæ ¼</wd-radio> <wd-radio value="ä¸åæ ¼" shape="dot">ä¸åæ ¼</wd-radio> </wd-radio-group> </wd-form-item> </wd-col> </wd-row> </wd-form> </view> </template> <script setup lang="ts"> import useFormData from "@/hooks/useFormData"; const { form: model } = useFormData({ selfInspectName: undefined, // èªæ£åç§° unit: undefined, // åä½ standard: undefined, // æ åå¼ selfInspectValue: undefined, // èªæ£å¼ selfInspectResult: undefined, // èªæ£å¼ import { ref, reactive, watch, computed } from "vue"; const props = defineProps({ formData: { type: Object, default: () => ({}), }, structureItems: { type: Array, default: () => [], }, twistItems: { type: Array, default: () => [], }, isViewMode: { type: Boolean, default: false, }, recordLocation: { type: Array, default: () => [], }, appearanceOptions: { type: Array, default: () => [], }, }); const emit = defineEmits(["update:formData", "update:structureItems", "update:twistItems"]); const formRef = ref(); // ç»åé项 const twistDirectionColumns = [ { label: "å·¦å", value: "å·¦å" }, { label: "å³å", value: "å³å" }, ]; // è®°å½ä½ç½®é项 const recordLocationColumns = computed(() => { return props.recordLocation.map((item: any) => ({ label: item.label, value: item.value, })); }); // 计ç®è徿¯ const calculatePitchRatio = (pitch: string, dia: string) => { if (!pitch || !dia) return "-"; const pitchNum = parseFloat(pitch); const diaNum = parseFloat(dia); if (isNaN(pitchNum) || isNaN(diaNum) || diaNum === 0) return "-"; return (pitchNum / diaNum).toFixed(2); }; // æ´æ°è徿¯ const updatePitchRatio = (item: any) => { item.pitchRatio = calculatePitchRatio(item.pitch, item.dia); emit("update:twistItems", [...props.twistItems]); }; // æ ¼å¼å产åå¤è§æ¾ç¤º const formatProductAppearance = (productAppearance: string[]) => { if (!productAppearance || productAppearance.length === 0) return "-"; return productAppearance.join("ã"); }; // å¤ç产åå¤è§éæ©çäºæ¥é»è¾ const handleAppearanceClick = (value: string) => { const currentValues = [...props.formData.productAppearance]; const isCurrentlyChecked = currentValues.includes(value); let newSelection: string[] = []; if (value === "æ å¤è§é®é¢") { if (isCurrentlyChecked) { newSelection = []; } else { newSelection = ["æ å¤è§é®é¢"]; } } else { if (isCurrentlyChecked) { newSelection = currentValues.filter((v) => v !== value); } else { const filteredValues = currentValues.filter((v) => v !== "æ å¤è§é®é¢"); newSelection = [...filteredValues, value]; } } emit("update:formData", { ...props.formData, productAppearance: newSelection, }); }; // 表åéªè¯ const validate = async () => { try { await formRef.value?.validate(); return true; } catch (error) { return false; } }; // éªè¯ç»æé¡¹ const validateStructureItems = () => { for (const item of props.structureItems) { if (!item.actualValue1) { return { valid: false, message: `${item.structureName}宿µæ ¹æ°ä¸ºå¿ 填项` }; } if (!item.actualValue2) { return { valid: false, message: `${item.structureName}宿µç´å¾ä¸ºå¿ 填项` }; } } return { valid: true }; }; // éªè¯ç»çº¿å·¥èºé¡¹ const validateTwistItems = () => { for (const item of props.twistItems) { if (!item.direction) { return { valid: false, message: `${item.twistName}ç»åä¸ºå¿ å¡«é¡¹` }; } if (!item.pitch) { return { valid: false, message: `${item.twistName}èè·ä¸ºå¿ 填项` }; } } return { valid: true }; }; // 宿´éªè¯ const validateAll = async () => { // åºç¡å段éªè¯ if (!props.formData.structureFormula) { return { valid: false, message: "æåç»æä¸ºå¿ å¡«é¡¹" }; } if (!props.formData.recordPosition) { return { valid: false, message: "è®°å½ä½ç½®ä¸ºå¿ 填项" }; } if (!props.formData.twistedOuterDiameter) { return { valid: false, message: "ç»åå¤å¾ä¸ºå¿ 填项" }; } if (!props.formData.productAppearance || props.formData.productAppearance.length === 0) { return { valid: false, message: "æåå¤è§ä¸ºå¿ 填项" }; } if (!props.formData.conclusion) { return { valid: false, message: "ç»è®ºä¸ºå¿ 填项" }; } // ç»æé¡¹éªè¯ const structureResult = validateStructureItems(); if (!structureResult.valid) { return structureResult; } // ç»çº¿å·¥èºé¡¹éªè¯ const twistResult = validateTwistItems(); if (!twistResult.valid) { return twistResult; } return { valid: true }; }; defineExpose({ validate, validateAll, }); </script> <style lang="scss" scoped> .form_box { .form-container { padding: 12px; max-height: 70vh; overflow-y: auto; } .submit_btn { .title { position: relative; margin-left: 10px; font-size: 14px; font-weight: 600; color: #0d867f; } .title::after { position: absolute; bottom: 0; width: 100%; content: ""; top: 4px; left: -10px; width: 3px; height: 14px; background: #0d867f; border-radius: 2px; } .conclusion-radio-group { display: flex; align-items: flex-start; gap: 20rpx; } :deep(.wd-form-item) { margin-bottom: 8rpx; } </style> src/pages/production/twist/selfInspect/index.vue
@@ -1,109 +1,697 @@ <template> <view class="list"> <z-paging ref="pagingRef" v-model="cardList" :fixed="false" @query="getList"> <template #top> <CardTitle title="ç»çº¿èªæ£" :hideAction="false" /> </template> <wd-card v-for="(item, index) in cardList" :key="index" type="rectangle" custom-class="round"> <template #title> <view class="flex justify-between"> <view> <wd-icon name="a-rootlist" color="#0D867F"></wd-icon> <text class="text-[#252525] ml-2 font-medium">{{ item.inspectionProject }}</text> </view> <view class="text-[#A8A8A8]" @click="toEdit">ç¼è¾</view> </view> </template> <ProductionCard :data="cardAttr" :value="item" color="#0D867F" /> </wd-card> </z-paging> <wd-popup v-model="dialog.visible" position="bottom" custom-class="yl-popup"> <view class="action px-3"> <wd-button type="text" @click="cancel">åæ¶</wd-button> <wd-button type="text" @click="submit">ç¡®å®</wd-button> <!-- åºæ¬ä¿¡æ¯æ¨¡å --> <wd-row> <view style="margin: 10rpx" class="flex justify-between items-center"> <text class="title">åºæ¬ä¿¡æ¯</text> <view class="flex gap-2"> <wd-button v-if="!isEdit" type="primary" size="small" icon="edit" @click="handleEdit"> ç¼è¾ </wd-button> <wd-button v-if="isEdit" type="info" size="small" icon="close" @click="handleCancel"> åæ¶ </wd-button> <wd-button v-if="isEdit" type="success" size="small" icon="check" @click="handleSave"> ä¿å </wd-button> </view> </view> <SelfInspectForm /> <wd-col :span="24"> <wd-form-item label="æ¥æ" prop="recordDate"> {{ formatDate(formData.recordDate) }} </wd-form-item> <wd-form-item label="æºå°" prop="deviceModel"> {{ formatValue(formData.deviceModel) }} </wd-form-item> <wd-form-item label="çæ¬¡" prop="workShift"> {{ formatValue(formData.workShift) }} </wd-form-item> <wd-form-item label="产åç±»å«" prop="productType"> {{ formatValue(formData.productType) }} </wd-form-item> <wd-form-item label="åå·è§æ ¼" prop="model"> {{ formatValue(formData.model) }} </wd-form-item> <wd-form-item label="ç产é¿åº¦" prop="actuallyLength"> {{ formatValue(formData.actuallyLength, "m") }} </wd-form-item> <wd-form-item label="æå线çå·" prop="systemNo"> {{ formatValue(formData.systemNo) }} </wd-form-item> <wd-form-item label="å¼ å设置" prop="tensionSetting"> <template v-if="isEdit"> <wd-input v-model="formData.tensionSetting" placeholder="请è¾å ¥å¼ å设置" clearable /> </template> <template v-else> {{ formatValue(formData.tensionSetting, "") }} </template> </wd-form-item> </wd-col> </wd-row> <!-- å·¥èºè®°å½æ¨¡å --> <wd-row> <view style="margin: 10rpx" class="flex justify-between items-center"> <text class="title">å·¥èºè®°å½</text> <wd-button v-if="!isEdit" type="primary" size="small" icon="file-add" @click="handleAddInspection" > æ·»å èªæ£ </wd-button> </view> <wd-col :span="24"> <wd-card v-for="(item, index) in inspectionList" :key="index" type="rectangle" custom-class="round" style="margin-bottom: 12px" > <template #title> <view class="flex justify-between"> <view> <text class="text-[#252525] font-medium"> è®°å½ä½ç½®: {{ getRecordPositionLabel( item.recordPosition || item.structureRecordResult?.recordPosition ) }} </text> </view> </view> </template> <view class="px-3 pb-3"> <view class="flex mb-2"> <text class="text-[#646874] mr-3">æåç»æ:</text> <text class="text-[#252525]"> {{ item.structureRecordResult?.inspectStructure?.structureFormula || item.structureFormula || "-" }} </text> </view> <view class="flex mb-2"> <text class="text-[#646874] mr-3">æåå¤è§:</text> <text class="text-[#252525]"> {{ getAppearanceLabel( item.structureRecordResult?.productAppearance || item.productAppearance ) }} </text> </view> <view class="flex mb-2"> <text class="text-[#646874] mr-3">ç»è®º:</text> <text class="text-[#252525]" :style="{ color: (item.structureRecordResult?.conclusion || item.conclusion) === 'åæ ¼' ? '#67C23A' : '#F56C6C', }" > {{ item.structureRecordResult?.conclusion || item.conclusion || "-" }} </text> </view> <view class="flex"> <text class="text-[#646874] mr-3">è®°å½äºº:</text> <text class="text-[#252525]">{{ item.createUserName || "-" }}</text> </view> </view> <template #footer> <view class="flex justify-end gap-2"> <wd-button size="small" plain @click="handleViewInspection(item, index)"> æ¥ç </wd-button> <wd-button v-if="!isEdit" size="small" plain type="primary" @click="handleEditInspection(item, index)" > ä¿®æ¹ </wd-button> <wd-button v-if="!isEdit" size="small" plain type="error" @click="handleDeleteInspection(index)" > å é¤ </wd-button> </view> </template> </wd-card> <view v-if="inspectionList.length === 0" class="text-center py-10 text-[#999]"> ææ å·¥èºè®°å½ </view> </wd-col> </wd-row> <!-- èªæ£å¼¹çª --> <wd-popup v-model="inspectionDialogVisible" position="bottom" custom-class="yl-popup" :close-on-click-modal="false" > <view class="action px-3"> <wd-button type="text" @click="inspectionDialogVisible = false">åæ¶</wd-button> <wd-button v-if="!isViewMode" type="text" @click="handleSaveInspection">ä¿å</wd-button> </view> <SelfInspectForm ref="inspectionFormRef" :form-data="inspectionForm" :structure-items="structureItems" :twist-items="twistItems" :is-view-mode="isViewMode" :record-location="recordLocation" :appearance-options="appearanceOptions" @update:form-data="(val) => Object.assign(inspectionForm, val)" @update:structure-items="(val) => (structureItems = val)" @update:twist-items="(val) => (twistItems = val)" /> </wd-popup> <wd-toast /> </view> </template> <script setup lang="ts"> import CardTitle from "@/components/card-title/index.vue"; import ProductionCard from "../../components/ProductionCard.vue"; import { useToast } from "wot-design-uni"; import SelfInspectForm from "./form.vue"; import TwistApi from "@/api/product/twist"; import ManageApi from "@/api/product/manage"; import { onLoad } from "@dcloudio/uni-app"; import { ref, reactive } from "vue"; const pagingRef = ref(); const paramsId = ref(); const paramsId = ref<string | number>(""); const toast = useToast(); const dialog = reactive({ visible: false, const isEdit = ref(false); const isViewMode = ref(false); const loading = ref(false); // åºæ¬ä¿¡æ¯è¡¨åæ°æ® const formData = reactive({ id: undefined as number | string | undefined, recordDate: "", deviceModel: "", workShift: "", productType: "", model: "", actuallyLength: "", systemNo: "", tensionSetting: "", createUserName: "", }); const cardAttr = ref<any[]>([ { label: "åä½", prop: "inspectionUnit", }, { label: "æ åå¼", prop: "standardValue", }, { label: "èªæ£å¼", prop: "inspectionItem", }, { label: "èªæ£ç»æ", prop: "inspectionResult", color: "#FF1E1E", }, ]); const cardList = ref<any[]>([]); // const addReport = () => { // dialog.visible = true; // }; // å·¥èºè®°å½å表 const inspectionList = ref<any[]>([]); const toEdit = () => { uni.navigateTo({ url: "/pages/production/twist/selfInspect/edit", // èªæ£å¼¹çª const inspectionDialogVisible = ref(false); const inspectionFormRef = ref(); const currentEditIndex = ref(-1); // èªæ£è¡¨åæ°æ® const inspectionForm = reactive({ recordPosition: "", structureFormula: "", productAppearance: ["æ å¤è§é®é¢"], conclusion: "åæ ¼", createUserName: "", twistedOuterDiameter: "", }); // ç»ææ£æ¥æ°æ® const structureItems = ref<any[]>([]); // ç»çº¿å·¥èºæ°æ® const twistItems = ref<any[]>([]); // åå¨ä»æ¥å£è·åçç»æå ¬å¼ const structureFormulaFromApi = ref(""); // åå ¸æ°æ® const recordLocation = ref<any>([]); const appearanceOptions = ref<Array<{ label: string; value: string }>>([]); // è·åå¤è§æ ç¾ const getAppearanceLabel = (value: string | string[]) => { if (Array.isArray(value)) { return value.join("ã") || "æ "; } else { return value || "æ "; } }; // è·åè®°å½ä½ç½®æ ç¾ const getRecordPositionLabel = (value: string) => { const option = recordLocation.value.find((item: any) => item.value === value); return option ? option.label : value || "-"; }; // æ ¼å¼åæ°å¼æ¾ç¤º const formatValue = (value: any, unit?: string) => { if (value === null || value === undefined || value === "") return "-"; return unit ? `${value}${unit}` : value; }; // æ ¼å¼åæ¥ææ¾ç¤º const formatDate = (date: string) => { if (!date) return "-"; return new Date(date).toLocaleDateString("zh-CN", { year: "numeric", month: "2-digit", day: "2-digit", }); }; const submit = () => { toast.show("æäº¤"); dialog.visible = false; // 计ç®è徿¯ const calculatePitchRatio = (pitch: string, dia: string) => { if (!pitch || !dia) return "-"; const pitchNum = parseFloat(pitch); const diaNum = parseFloat(dia); if (isNaN(pitchNum) || isNaN(diaNum) || diaNum === 0) return "-"; return (pitchNum / diaNum).toFixed(2); }; const cancel = () => { toast.show("åæ¶"); dialog.visible = false; // åå§åæ°æ® const getData = async () => { if (!paramsId.value) { console.warn("wireId ä¸åå¨"); return; } loading.value = true; try { // è·ååºæ¬ä¿¡æ¯ const { code, data } = await TwistApi.getStrandedWireInspectionRecordStyleByWireId({ wireId: paramsId.value, }); if (code === 200 && data) { // åæ¾æ°æ®å°è¡¨å if (data.fixedInfo) { Object.assign(formData, data.fixedInfo); } if (data.tensionSetting !== undefined) { formData.tensionSetting = data.tensionSetting; } // å¤çç»ææ£æ¥æ°æ® if (data.inspectStructure) { if (data.inspectStructure.structureFormula) { structureFormulaFromApi.value = data.inspectStructure.structureFormula; inspectionForm.structureFormula = data.inspectStructure.structureFormula; } if (data.inspectStructure.structureItems) { structureItems.value = data.inspectStructure.structureItems.map((item: any) => ({ ...item, actualValue1: "", actualValue2: "", })); } } // å¤çç»çº¿å·¥èºæ°æ® if (data.inspectTwist) { twistItems.value = data.inspectTwist.map((item: any) => ({ ...item, pitch: "", })); } } // è·åèªæ£åè¡¨æ°æ® await getInspectionList(); // è·ååå ¸æ°æ® await loadDictData(); } catch (error) { console.error("è·åèªæ£æ°æ®å¤±è´¥:", error); toast.error("è·åèªæ£æ°æ®å¤±è´¥"); } finally { loading.value = false; } }; const getList = async () => { const { data } = await ManageApi.getSelfInspection({ outPutId: paramsId.value, type: "ç»çº¿", // è·åèªæ£åè¡¨æ°æ® const getInspectionList = async () => { if (!paramsId.value) { console.warn("wireId ä¸åå¨"); return; } try { const { code, data } = await TwistApi.getStrandedInspectionInfoByWireId({ wireId: paramsId.value, }); if (code === 200 && data) { inspectionList.value = data.structureInfos || []; inspectionList.value = inspectionList.value.map((item: any) => { return { ...item.structureRecordResult, ...item, structureFormula: item.structureRecordResult?.inspectStructure?.structureFormula || item.structureFormula, }; }); } } catch (error) { console.error("è·åèªæ£å表失败:", error); } }; // å è½½åå ¸æ°æ® const loadDictData = async () => { try { // è®°å½ä½ç½®åå ¸ const recordLocationRes = await ManageApi.dictAPI("record_location"); if (recordLocationRes.data && Array.isArray(recordLocationRes.data)) { recordLocation.value = recordLocationRes.data.map((item: any) => ({ label: item.dictLabel || "", value: item.dictValue || "", })); } // å¤è§é项åå ¸ const appearanceRes = await ManageApi.dictAPI("draw_appearance_quality"); if (appearanceRes.data && Array.isArray(appearanceRes.data)) { appearanceOptions.value = appearanceRes.data.map((item: any) => ({ label: item.dictLabel || "", value: item.dictValue || "", })); } } catch (error) { console.error("å è½½åå ¸æ°æ®å¤±è´¥:", error); } }; // ä¿ååºæ¬ä¿¡æ¯ const handleSave = async () => { if (!formData.tensionSetting) { toast.warning("请è¾å ¥å¼ å设置"); return; } try { const submitData = { wireId: paramsId.value, strandedWireInspectionRecordId: formData.id, tensionSetting: formData.tensionSetting, }; const { code } = await TwistApi.saveStrandedWireInspectionFixedRecord(submitData); if (code === 200) { toast.success("ä¿åæå"); isEdit.value = false; await getData(); } else { toast.error("ä¿å失败"); } } catch (error) { console.error("ä¿å失败:", error); toast.error("ä¿å失败"); } }; // ç¼è¾ const handleEdit = () => { isEdit.value = true; }; // åæ¶ const handleCancel = () => { isEdit.value = false; getData(); }; // æ·»å èªæ£ const handleAddInspection = () => { currentEditIndex.value = -1; isViewMode.value = false; // æ¸ ç©ºè¡¨å Object.assign(inspectionForm, { recordPosition: "", structureFormula: structureFormulaFromApi.value || "", productAppearance: ["æ å¤è§é®é¢"], conclusion: "åæ ¼", createUserName: "", twistedOuterDiameter: "", }); pagingRef.value.complete(data); // éç½®ç»æé¡¹åç»çº¿å·¥èºæ°æ® if (structureItems.value.length > 0) { structureItems.value = structureItems.value.map((item: any) => { let defaultActualValue1 = ""; if (item.structureValue && typeof item.structureValue === "string") { const parts = item.structureValue.split("/"); if (parts.length > 0 && parts[0].trim()) { defaultActualValue1 = parts[0].trim(); } } return { ...item, actualValue1: defaultActualValue1, actualValue2: "", }; }); } if (twistItems.value.length > 0) { twistItems.value = twistItems.value.map((item: any) => ({ ...item, direction: item.direction || "", pitch: "", })); } inspectionDialogVisible.value = true; }; onLoad((options: any) => { // ç¼è¾èªæ£ const handleEditInspection = (row: any, index: number) => { currentEditIndex.value = index; isViewMode.value = false; const recordResult = row.structureRecordResult || {}; const inspectStructure = recordResult.inspectStructure || row.inspectStructure || {}; const inspectTwist = recordResult.inspectTwist || row.inspectTwist || []; // éç»è¡¨åæ°æ® Object.assign(inspectionForm, { recordPosition: recordResult.recordPosition || row.recordPosition || "", structureFormula: inspectStructure.structureFormula || row.structureFormula || "", productAppearance: recordResult.productAppearance || row.productAppearance || ["æ å¤è§é®é¢"], conclusion: recordResult.conclusion || row.conclusion || "åæ ¼", twistedOuterDiameter: recordResult.twistedOuterDiameter || inspectStructure.twistedOuterDiameter || row.twistedOuterDiameter || "", createUserName: row.createUserName || "", }); // éç»ç»æé¡¹æ°æ® if (inspectStructure.structureItems) { structureItems.value = inspectStructure.structureItems.map((item: any) => ({ ...item, actualValue1: item.actualValue1 || "", actualValue2: item.actualValue2 || "", })); } // éç»ç»çº¿å·¥èºæ°æ® if (inspectTwist.length > 0) { twistItems.value = inspectTwist.map((item: any) => ({ ...item, direction: item.direction || "", pitch: item.pitch || "", dia: item.dia || "", pitchRatio: item.pitchRatio || calculatePitchRatio(item.pitch, item.dia), })); } inspectionDialogVisible.value = true; }; // æ¥çèªæ£ const handleViewInspection = (row: any, index: number) => { currentEditIndex.value = index; isViewMode.value = true; const recordResult = row.structureRecordResult || {}; const inspectStructure = recordResult.inspectStructure || row.inspectStructure || {}; const inspectTwist = recordResult.inspectTwist || row.inspectTwist || []; Object.assign(inspectionForm, { recordPosition: recordResult.recordPosition || row.recordPosition || "", structureFormula: inspectStructure.structureFormula || row.structureFormula || "", productAppearance: recordResult.productAppearance || row.productAppearance || [], conclusion: recordResult.conclusion || row.conclusion || "åæ ¼", twistedOuterDiameter: recordResult.twistedOuterDiameter || inspectStructure.twistedOuterDiameter || row.twistedOuterDiameter || "", createUserName: row.createUserName || "", }); if (inspectStructure.structureItems) { structureItems.value = inspectStructure.structureItems.map((item: any) => ({ ...item, actualValue1: item.actualValue1 || "", actualValue2: item.actualValue2 || "", })); } if (inspectTwist.length > 0) { twistItems.value = inspectTwist.map((item: any) => ({ ...item, direction: item.direction || "", pitch: item.pitch || "", dia: item.dia || "", pitchRatio: item.pitchRatio || calculatePitchRatio(item.pitch, item.dia), })); } inspectionDialogVisible.value = true; }; // å é¤èªæ£ const handleDeleteInspection = async (index: number) => { const item = inspectionList.value[index]; if (!item || !item.id) { toast.error("å é¤å¤±è´¥ï¼è®°å½IDä¸åå¨"); return; } uni.showModal({ title: "æç¤º", content: "ç¡®å®è¦å é¤è¿æ¡å·¥èºè®°å½åï¼", success: async (res) => { if (res.confirm) { try { const { code } = await TwistApi.deleteStrandedWireInspectionStructureRecord(item.id); if (code === 200) { inspectionList.value.splice(index, 1); toast.success("å 餿å"); } else { toast.error("å é¤å¤±è´¥"); } } catch (error) { console.error("å é¤å·¥èºè®°å½å¤±è´¥:", error); toast.error("å é¤å¤±è´¥"); } } }, }); }; // ä¿åèªæ£ const handleSaveInspection = async () => { if (!inspectionFormRef.value) return; const result = await inspectionFormRef.value.validateAll(); if (!result.valid) { toast.warning(result.message || "è¯·å®æå¿ å¡«é¡¹"); return; } try { const submitData = { wireId: paramsId.value, strandedWireInspectionRecordId: formData.id, tensionSetting: formData.tensionSetting, recordPosition: inspectionForm.recordPosition, id: currentEditIndex.value >= 0 ? inspectionList.value[currentEditIndex.value].id : undefined, inspectionStructureResult: { twistedOuterDiameter: inspectionForm.twistedOuterDiameter, recordPosition: inspectionForm.recordPosition, inspectStructure: { structureFormula: inspectionForm.structureFormula, structureItems: structureItems.value.map((item: any) => ({ structureName: item.structureName, structureValue: item.structureValue, actualValue1: item.actualValue1, actualValue2: item.actualValue2, })), }, inspectTwist: twistItems.value.map((item: any) => ({ twistName: item.twistName, direction: item.direction, pitch: item.pitch, dia: item.dia, pitchRatio: calculatePitchRatio(item.pitch, item.dia), })), productAppearance: inspectionForm.productAppearance, conclusion: inspectionForm.conclusion, }, }; const { code } = await TwistApi.saveStrandedWireInspectionStructureRecord(submitData); if (code === 200) { toast.success(currentEditIndex.value >= 0 ? "ä¿®æ¹æå" : "æ·»å æå"); inspectionDialogVisible.value = false; await getInspectionList(); } else { toast.error("ä¿å失败"); } } catch (error) { console.error("ä¿åå·¥èºè®°å½å¤±è´¥:", error); toast.error("ä¿å失败"); } }; onLoad(async (options: any) => { paramsId.value = options.id; await getData(); }); </script> <style lang="scss" scoped> .list { height: calc(100vh - 120px); padding: 12px; background: #f3f9f8; min-height: 100vh; padding-bottom: 80px; } :deep() { .round { border-radius: 4px; } .title { position: relative; margin-left: 10px; font-size: 16px; font-weight: 500; color: #0d867f; } .title::after { position: absolute; content: ""; top: 4px; left: -10px; width: 4px; height: 16px; background: #0d867f; border-radius: 2px; } :deep() { .round { border-radius: 4px; } } src/utils/cache.ts
@@ -2,6 +2,7 @@ const USER_INFO_KEY = "user-info"; const DICT_KEY = "dict"; const TEAM_ID_KEY = "team-id"; const PREPARE_ID_KEY = "prepare-id"; import { type DictData } from "@/api/system/dict"; // 设置 token @@ -64,10 +65,26 @@ uni.removeStorageSync(TEAM_ID_KEY); } // 设置ç产åå¤ID export function setPrepareId(prepareId: string | number) { uni.setStorageSync(PREPARE_ID_KEY, prepareId); } // è·åç产åå¤ID export function getPrepareId(): string | number | null { return uni.getStorageSync(PREPARE_ID_KEY) || null; } // æ¸ é¤ç产åå¤ID export function clearPrepareId() { uni.removeStorageSync(PREPARE_ID_KEY); } // æ¸ é¤ææç¼åä¿¡æ¯ export function clearAll() { clearToken(); clearUserInfo(); clearDictCache(); clearTeamId(); clearPrepareId(); }