From 8cc901ed214f3885b34a07d0520fbcfd50063439 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 14:30:39 +0800
Subject: [PATCH] fix: 完成绞线自检,生产确认等功能新增
---
src/pages/production/twist/selfInspect/form.vue | 413 +++++++++++++--
src/pages.json | 14
src/pages/production/list/index.vue | 6
src/api/product/manage.ts | 9
src/pages/index/index.vue | 11
src/pages/production/twist/report/draw.vue | 151 +++--
.env.development | 8
/dev/null | 31 -
src/pages/production/twist/report/index.vue | 63 +
src/api/product/twist.ts | 44 +
src/pages/production/detail/twistDetail.vue | 53 +
src/pages/production/twist/selfInspect/index.vue | 730 ++++++++++++++++++++++++--
src/pages/production/index.vue | 43
src/utils/cache.ts | 17
14 files changed, 1,310 insertions(+), 283 deletions(-)
diff --git a/.env.development b/.env.development
index 09e5628..ebd9627 100644
--- a/.env.development
+++ b/.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' #
diff --git a/src/api/product/manage.ts b/src/api/product/manage.ts
index bdbc5aa..34dd68a 100644
--- a/src/api/product/manage.ts
+++ b/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;
diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index 086f1d3..378c77f 100644
--- a/src/api/product/twist.ts
+++ b/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;
diff --git a/src/pages.json b/src/pages.json
index 6841877..dfc8cb7 100644
--- a/src/pages.json
+++ b/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 @@
}
]
}
-}
\ No newline at end of file
+}
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 46174fc..747bfa2 100644
--- a/src/pages/index/index.vue
+++ b/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鍜岀敓浜у噯澶嘔D
+ if (data) {
+ if (data.team) {
+ setTeamId(data.team);
+ }
+ if (data.prepareId) {
+ setPrepareId(data.prepareId);
+ }
+ }
+
// 鍒ゆ柇鏄惁涓哄贰妫�鍛樿鑹�
if (data.deviceGroupName == "鏃舵晥缁�") {
navList[1].show = true;
diff --git a/src/pages/production/detail/twistDetail.vue b/src/pages/production/detail/twistDetail.vue
index fede20a..b63840d 100644
--- a/src/pages/production/detail/twistDetail.vue
+++ b/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) => {
+// 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+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);
+ // 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+ await initPrepareId();
});
</script>
diff --git a/src/pages/production/index.vue b/src/pages/production/index.vue
index 1fbe803..73d3f94 100644
--- a/src/pages/production/index.vue
+++ b/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(() => {
diff --git a/src/pages/production/list/index.vue b/src/pages/production/list/index.vue
index 79b8d0e..6f4eb01 100644
--- a/src/pages/production/list/index.vue
+++ b/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) {
diff --git a/src/pages/production/twist/report/draw.vue b/src/pages/production/twist/report/draw.vue
index b8e2a1e..b148266 100644
--- a/src/pages/production/twist/report/draw.vue
+++ b/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 @@
};
// 澶勭悊鐒婃帴璐ㄩ噺澶嶉�夋鐨刢hange浜嬩欢
-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();
+ // 瀛楀吀鏁版嵁鍔犺浇瀹屾垚鍚庯紝閲嶆柊鍒濆鍖栨暟鎹紝纭繚榛樿鍊艰兘姝g‘鍖归厤
+ // 浣嗗彧鍒濆鍖� 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],
diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index b9244b1..c1b3b25 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/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);
-// 鑾峰彇骞剁紦瀛樼彮缁処D
+// 鑾峰彇骞剁紦瀛樼彮缁処D鍜岀敓浜у噯澶嘔D
const initTeamId = async () => {
// 鍏堝皾璇曚粠缂撳瓨鑾峰彇
const cachedTeamId = getTeamId();
if (cachedTeamId) {
teamId.value = cachedTeamId;
- return;
}
- // 濡傛灉缂撳瓨涓病鏈夛紝鍒欒皟鐢ㄦ帴鍙h幏鍙�
+ // 璋冪敤鎺ュ彛鑾峰彇鏈�鏂版暟鎹�
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("鎵ц鑷鎿嶄綔锛孖D:", id);
- uni.showToast({
- title: "鑷鍔熻兘寮�鍙戜腑",
- icon: "none",
+const handleSelfCheck = () => {
+ // 璺宠浆鍒拌嚜妫�椤甸潰锛屼紶閫� wireId
+ uni.navigateTo({
+ url: `/pages/production/twist/selfInspect/index?id=${paramsId.value}`,
});
};
diff --git a/src/pages/production/twist/selfInspect/edit.vue b/src/pages/production/twist/selfInspect/edit.vue
deleted file mode 100644
index c9ebfec..0000000
--- a/src/pages/production/twist/selfInspect/edit.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-<template>
- <view>
- <CardTitle title="缂栬緫鑷" :hideAction="false" />
- <BackmanForm class="mx-4" />
- <view class="footer">
- <wd-button
- class="submit_btn"
- type="primary"
- size="large"
- block
- :round="false"
- @click="handleSubmit"
- >
- 淇濆瓨
- </wd-button>
- </view>
- </view>
-</template>
-
-<script setup lang="ts">
-import CardTitle from "@/components/card-title/index.vue";
-import BackmanForm from "./form.vue";
-
-const handleSubmit = () => {};
-</script>
-
-<style lang="scss" scoped>
-.footer {
- margin: 20px 16px 0 16px;
-}
-</style>
diff --git a/src/pages/production/twist/selfInspect/form.vue b/src/pages/production/twist/selfInspect/form.vue
index 6402db7..5f9d84b 100644
--- a/src/pages/production/twist/selfInspect/form.vue
+++ b/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>
diff --git a/src/pages/production/twist/selfInspect/index.vue b/src/pages/production/twist/selfInspect/index.vue
index 9d524c2..7e35f3f 100644
--- a/src/pages/production/twist/selfInspect/index.vue
+++ b/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[]>([]);
+
+// 瀛樺偍浠庢帴鍙h幏鍙栫殑缁撴瀯鍏紡
+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("鍒犻櫎澶辫触锛氳褰旾D涓嶅瓨鍦�");
+ 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;
}
}
diff --git a/src/utils/cache.ts b/src/utils/cache.ts
index ed9ab16..b136531 100644
--- a/src/utils/cache.ts
+++ b/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();
}
--
Gitblit v1.9.3