| src/manifest.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/monofil.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/plate/edit.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/plate/form.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/plate/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/steelCore/form.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/steelCore/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/report/draw.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/report/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/wire/report/rawMaterial.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/wire/report/wire.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/manifest.json
@@ -2,7 +2,7 @@ "name" : "线缆上报", "appid" : "__UNI__F64E0A4", "description" : "", "versionName" : "1.0.8", "versionName" : "1.0.12", "versionCode" : "100", "transformPx" : false, /* 5+App特有相关 */ src/pages/production/twist/receive/monofil.vue
@@ -109,48 +109,52 @@ // let parseData = code.trim(); console.log("code:===========", JSON.parse(code.code)); console.log("id:=============", JSON.parse(code.code).id); const { data } = await TwistApi.getScarn({ outPutId: JSON.parse(code.code).id, }); try { const { data } = await TwistApi.getScarn({ outPutId: JSON.parse(code.code).id, }); // 检查是否已选择标签 if (!tab.value) { toast.error("请先选择一个层"); return; } // 找到当前选中的层 console.log("tab.value:===========2", tab.value); const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value); if (!currentLayer) { toast.error("未找到当前选中的层"); return; } // 检查当前层是否已存在该单丝 const exists = currentLayer.strandedWireDish?.some( (item: any) => item.monofilamentNumber === data.monofilamentNumber ); if (!exists) { const { id, outPutId, wireId, oneLength, ...rest } = data; const newItem = { wireId: paramsId.value, outputId: id, amount: oneLength, ongLength: oneLength, ...rest, }; // 添加到当前层的 strandedWireDish 中 if (!currentLayer.strandedWireDish) { currentLayer.strandedWireDish = []; // 检查是否已选择标签 if (!tab.value) { toast.error("请先选择一个层"); return; } currentLayer.strandedWireDish.push(newItem); // 刷新当前层的数据显示 getList(); } else { toast.error("该单丝已领用,请勿重复扫码"); // 找到当前选中的层 console.log("tab.value:===========2", tab.value); const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value); if (!currentLayer) { toast.error("未找到当前选中的层"); return; } // 检查当前层是否已存在该单丝 const exists = currentLayer.strandedWireDish?.some( (item: any) => item.monofilamentNumber === data.monofilamentNumber ); if (!exists) { const { id, outPutId, wireId, oneLength, ...rest } = data; const newItem = { wireId: paramsId.value, outputId: id, amount: oneLength, ongLength: oneLength, ...rest, }; // 添加到当前层的 strandedWireDish 中 if (!currentLayer.strandedWireDish) { currentLayer.strandedWireDish = []; } currentLayer.strandedWireDish.push(newItem); // 刷新当前层的数据显示 getList(); } else { toast.error("该单丝已领用,请勿重复扫码"); } } catch (error) { toast.error("二维码异常,请更换二维码!"); } }; src/pages/production/twist/receive/plate/edit.vue
@@ -1,7 +1,7 @@ <template> <view> <CardTitle title="绞线盘具领用" :hideAction="false" /> <PlateForm class="mx-4" /> <PlateForm ref="formRef" class="mx-4" /> <view class="footer"> <wd-button class="submit_btn" @@ -15,12 +15,48 @@ </wd-button> </view> </view> <wd-toast /> </template> <script lang="ts" setup> import CardTitle from "@/components/card-title/index.vue"; import PlateForm from "./form.vue"; import { useToast } from "wot-design-uni"; import { onLoad, onUnload } from "@dcloudio/uni-app"; const handleSubmit = () => {}; const formRef = ref(); const toast = useToast(); const handleSubmit = async () => { const success = await formRef.value.submitEdit(); if (success) { setTimeout(() => { uni.navigateBack(); }, 500); } }; // 接收列表页传递的数据 const receiveEditData = (data: any) => { console.log("receiveEditData 接收到的数据:", data); if (data && formRef.value) { // 确保 list 和 editId 都存在 if (data.list && data.editId) { formRef.value.setFormData(data.list, data.editId); } else { console.error("数据格式错误:", data); } } }; onLoad((options: any) => { // 监听数据传递事件 uni.$on("plateEditData", receiveEditData); }); onUnload(() => { // 页面卸载时移除监听 uni.$off("plateEditData", receiveEditData); }); </script> <style lang="scss" scoped> .footer { src/pages/production/twist/receive/plate/form.vue
@@ -1,13 +1,15 @@ <template> <wd-form ref="form" :model="model" class="relative form_box"> <wd-cell-group :border="true"> <wd-input v-model="model.diskMaterial" <wd-picker v-model="diskMaterialValue" :columns="diskMaterialOptions" label="盘具类型" label-width="100px" prop="diskMaterial" placeholder="请选择盘具类型" clearable placeholder="请输入盘具类型" @confirm="handleDiskMaterialChange" /> <wd-input v-model="model.model" @@ -41,7 +43,19 @@ <script setup lang="ts"> import useFormData from "@/hooks/useFormData"; import TwistApi from "@/api/product/twist"; import ManageApi from "@/api/product/manage"; import { useToast } from "wot-design-uni"; const props = defineProps({ mode: { type: String, default: "add", }, editData: { type: Object, default: null, }, }); const emits = defineEmits(["refresh"]); const paramsId = ref(); @@ -53,6 +67,43 @@ supplier: undefined, type: "盘具", }); // 用于编辑时存储完整列表数据和当前编辑ID const allListData = ref<any[]>([]); const editId = ref<number>(); // 盘具类型字典数据 const diskMaterialOptions = ref<Array<{ label: string; value: string }>>([]); const diskMaterialValue = ref(""); // 加载盘具类型字典数据 const loadDiskMaterialDict = async () => { try { const res = await ManageApi.dictAPI("disk_material"); if (res.data && Array.isArray(res.data)) { diskMaterialOptions.value = res.data.map((item: any) => ({ label: item.dictLabel || "", value: item.dictValue || "", })); } } catch (error) { console.error("加载盘具类型字典失败:", error); } }; // 处理盘具类型选择 const handleDiskMaterialChange = (val: any) => { model.diskMaterial = val.value; }; // 监听 model.diskMaterial 变化,同步选择器显示 watch( () => model.diskMaterial, (newValue) => { diskMaterialValue.value = newValue || ""; }, { immediate: true } ); const submit = async () => { const { code } = await TwistApi.addStrandedWireDish([ @@ -66,19 +117,113 @@ emits("refresh"); return true; } return false; }; // 编辑提交(也走新增接口,提交整个列表) const submitEdit = async (list?: any[], id?: number) => { const currentList = list || allListData.value; const currentId = id || editId.value; if (!currentId) { toast.error("缺少记录ID"); return false; } // 更新列表中对应的数据项 const updatedList = currentList.map((item) => { if (item.id === currentId) { // 保留原有数据,然后更新修改的字段 const updatedItem = { ...item, // 先保留原有的所有数据 diskMaterial: model.diskMaterial, model: model.model, amount: model.amount, supplier: model.supplier, type: model.type, }; return updatedItem; } return item; }); // 提交整个列表 const { code } = await TwistApi.addStrandedWireDish(updatedList); if (code == 200) { toast.success("更新成功"); return true; } return false; }; // 设置表单数据(用于编辑时回显) const setFormData = (list: any[], currentEditId: number) => { // 安全检查:确保list是数组 if (!Array.isArray(list)) { console.error("setFormData: list 参数不是数组", list); return; } // 存储完整列表数据 allListData.value = list; editId.value = currentEditId; // 找到当前编辑项并回显到表单 const currentItem = list.find((item) => item.id === currentEditId); if (currentItem) { model.diskMaterial = currentItem.diskMaterial; model.model = currentItem.model; model.amount = currentItem.amount; model.supplier = currentItem.supplier; model.type = currentItem.type || "盘具"; // 设置盘具类型的回显值 diskMaterialValue.value = currentItem.diskMaterial || ""; } }; onLoad((options: any) => { paramsId.value = options.id; }); onMounted(async () => { await loadDiskMaterialDict(); }); // 监听编辑数据变化,自动回显 watch( () => props.editData, (newData) => { if (newData && props.mode === "edit") { model.diskMaterial = newData.diskMaterial || ""; model.model = newData.model || ""; model.amount = newData.amount || ""; model.supplier = newData.supplier || ""; model.type = newData.type || "盘具"; diskMaterialValue.value = newData.diskMaterial || ""; } }, { immediate: true, deep: true } ); // 重置表单数据 const resetFormData = () => { model.diskMaterial = undefined; model.model = undefined; model.amount = undefined; model.supplier = undefined; model.type = "盘具"; diskMaterialValue.value = ""; }; defineExpose({ submit, submitEdit, setFormData, resetFormData, }); </script> <style lang="scss" scoped> .form_box { } .submit_btn { position: absolute; bottom: 0; src/pages/production/twist/receive/plate/index.vue
@@ -23,12 +23,24 @@ <ProductionCard :data="cardAttr" :value="item" color="#0D867F" /> </wd-card> </z-paging> <wd-popup v-model="dialog.visible" position="bottom" custom-class="yl-popup"> <wd-popup v-model="addDialog.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-button type="text" @click="cancelAdd">取消</wd-button> <wd-button type="text" @click="submitAdd">确定</wd-button> </view> <PlateForm ref="plateFormRef" @refresh="reloadList" /> <PlateForm ref="addFormRef" mode="add" @refresh="reloadList" /> </wd-popup> <wd-popup v-model="editDialog.visible" position="bottom" custom-class="yl-popup"> <view class="action px-3"> <wd-button type="text" @click="cancelEdit">取消</wd-button> <wd-button type="text" @click="submitEdit">确定</wd-button> </view> <PlateForm ref="editFormRef" mode="edit" :editData="editDialog.currentItem" @refresh="reloadList" /> </wd-popup> <wd-toast /> </view> @@ -39,16 +51,22 @@ import ProductionCard from "../../../components/ProductionCard.vue"; import { useToast } from "wot-design-uni"; import PlateForm from "./form.vue"; import { onLoad } from "@dcloudio/uni-app"; import { onLoad, onShow } from "@dcloudio/uni-app"; import ManageApi from "@/api/product/manage"; import zPaging from "@/components/z-paging/z-paging.vue"; const paramsId = ref(); const pagingRef = ref(); const plateFormRef = ref(); const addFormRef = ref(); const editFormRef = ref(); const toast = useToast(); const dialog = reactive({ const addDialog = reactive({ visible: false, }); const editDialog = reactive({ visible: false, currentItem: null as any, editId: undefined as number | undefined, }); const cardList = ref<any[]>([]); @@ -66,7 +84,6 @@ label: "数量", prop: "amount", }, {}, { label: "厂家", prop: "supplier", @@ -75,23 +92,49 @@ ]); const toEdit = (id: number) => { uni.navigateTo({ url: `/pages/production/twist/receive/plate/edit?id=${id}`, }); // 找到需要编辑的项 const itemToEdit = cardList.value.find((item) => item.id === id); if (itemToEdit) { editDialog.currentItem = itemToEdit; editDialog.editId = id; editDialog.visible = true; } }; const addReport = () => { dialog.visible = true; // 重置表单数据 if (addFormRef.value) { addFormRef.value.resetFormData(); } addDialog.visible = true; }; const submit = async () => { const submitAdd = async () => { toast.show("提交"); dialog.visible = !(await plateFormRef.value.submit()); const success = await addFormRef.value.submit(); if (success) { addDialog.visible = false; } }; const cancel = () => { const cancelAdd = () => { toast.show("取消"); dialog.visible = false; addDialog.visible = false; // 清空表单数据 addFormRef.value?.$refs?.form?.resetFields(); }; const submitEdit = async () => { const success = await editFormRef.value.submitEdit(cardList.value, editDialog.editId); if (success) { editDialog.visible = false; reloadList(); } }; const cancelEdit = () => { toast.show("取消"); editDialog.visible = false; }; const reloadList = () => { src/pages/production/twist/receive/steelCore/form.vue
@@ -50,6 +50,17 @@ import TwistApi from "@/api/product/twist"; import { useToast } from "wot-design-uni"; const props = defineProps({ mode: { type: String, default: "add", }, editData: { type: Object, default: null, }, }); const emits = defineEmits(["refresh"]); const paramsId = ref(); const editId = ref(); // 编辑时的ID @@ -81,19 +92,18 @@ }; // 编辑提交(也走新增接口,提交整个列表) const submitEdit = async () => { if (!editId.value) { const submitEdit = async (list?: any[], id?: number) => { const currentList = list || allListData.value; const currentId = id || editId.value; if (!currentId) { toast.error("缺少记录ID"); return false; } console.log("submitEdit - 编辑前的列表:", allListData.value); console.log("submitEdit - 当前表单数据:", model); console.log("submitEdit - 编辑的ID:", editId.value); // 更新列表中对应的数据项 const updatedList = allListData.value.map((item) => { if (item.id === editId.value) { const updatedList = currentList.map((item) => { if (item.id === currentId) { // 保留原有数据,然后更新修改的字段 const updatedItem = { ...item, // 先保留原有的所有数据 @@ -104,13 +114,10 @@ supplier: model.supplier, type: model.type, }; console.log("submitEdit - 更新后的项:", updatedItem); return updatedItem; } return item; }); console.log("submitEdit - 提交的完整列表:", updatedList); // 提交整个列表 const { code } = await TwistApi.addStrandedWireDish(updatedList); @@ -146,6 +153,32 @@ } }; // 监听编辑数据变化,自动回显 watch( () => props.editData, (newData) => { if (newData && props.mode === "edit") { model.model = newData.model || ""; model.monofilamentNumber = newData.monofilamentNumber || ""; model.amount = newData.amount || ""; model.weight = newData.weight || ""; model.supplier = newData.supplier || ""; model.type = newData.type || "钢芯"; } }, { immediate: true, deep: true } ); // 重置表单数据 const resetFormData = () => { model.model = undefined; model.monofilamentNumber = undefined; model.amount = undefined; model.weight = undefined; model.supplier = undefined; model.type = "钢芯"; }; onLoad((options: any) => { paramsId.value = options.id; }); @@ -154,6 +187,7 @@ submit, submitEdit, setFormData, resetFormData, }); </script> src/pages/production/twist/receive/steelCore/index.vue
@@ -23,15 +23,27 @@ <ProductionCard :data="cardAttr" :value="item" color="#0D867F" /> </wd-card> </z-paging> <wd-popup v-model="addDialog.visible" position="bottom" custom-class="yl-popup"> <view class="action px-3"> <wd-button type="text" @click="cancelAdd">取消</wd-button> <wd-button type="text" @click="submitAdd">确定</wd-button> </view> <SteelCore ref="addFormRef" mode="add" @refresh="reloadList" /> </wd-popup> <wd-popup v-model="editDialog.visible" position="bottom" custom-class="yl-popup"> <view class="action px-3"> <wd-button type="text" @click="cancelEdit">取消</wd-button> <wd-button type="text" @click="submitEdit">确定</wd-button> </view> <SteelCore ref="editFormRef" mode="edit" :editData="editDialog.currentItem" @refresh="reloadList" /> </wd-popup> <wd-toast /> </view> <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> </view> <SteelCore ref="steelCoreRef" @refresh="reloadList" /> </wd-popup> <wd-toast /> </template> <script setup lang="ts"> @@ -39,19 +51,24 @@ import ProductionCard from "../../../components/ProductionCard.vue"; import { useToast } from "wot-design-uni"; import SteelCore from "./form.vue"; import { onLoad, onShow } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app"; import ManageApi from "@/api/product/manage"; import zPaging from "@/components/z-paging/z-paging.vue"; const paramsId = ref(); const pagingRef = ref(); const steelCoreRef = ref(); const addFormRef = ref(); const editFormRef = ref(); const toast = useToast(); const dialog = reactive({ const addDialog = reactive({ visible: false, }); const editDialog = reactive({ visible: false, currentItem: null as any, editId: undefined as number | undefined, }); const cardList = ref<any[]>([]); const needRefresh = ref(false); // 标记是否需要刷新 const cardAttr = ref<any[]>([ { @@ -76,38 +93,44 @@ ]); const toEdit = (id: number) => { needRefresh.value = true; // 标记需要刷新 // 确保 cardList 是数组 const listData = Array.isArray(cardList.value) ? cardList.value : []; console.log("toEdit - 传递的列表数据:", listData, "编辑ID:", id); uni.navigateTo({ url: `/pages/production/twist/receive/steelCore/edit?id=${id}`, success: () => { // 页面跳转成功后发送事件传递完整列表数据和当前编辑ID uni.$emit("steelCoreEditData", { list: listData, editId: id, }); }, }); }; const addReport = () => { dialog.visible = true; }; const submit = async () => { const success = await steelCoreRef.value.submit(); if (success) { dialog.visible = false; const itemToEdit = cardList.value.find((item) => item.id === id); if (itemToEdit) { editDialog.currentItem = itemToEdit; editDialog.editId = id; editDialog.visible = true; } }; const cancel = () => { const addReport = () => { if (addFormRef.value) { addFormRef.value.resetFormData(); } addDialog.visible = true; }; const submitAdd = async () => { const success = await addFormRef.value.submit(); if (success) { addDialog.visible = false; } }; const cancelAdd = () => { toast.show("取消"); dialog.visible = false; addDialog.visible = false; }; const submitEdit = async () => { const success = await editFormRef.value.submitEdit(cardList.value, editDialog.editId); if (success) { editDialog.visible = false; reloadList(); } }; const cancelEdit = () => { toast.show("取消"); editDialog.visible = false; }; const getList = async () => { @@ -126,14 +149,6 @@ onLoad((options: any) => { paramsId.value = options.id; }); onShow(() => { // 从编辑页返回时刷新列表 if (needRefresh.value) { reloadList(); needRefresh.value = false; } }); </script> src/pages/production/twist/report/draw.vue
@@ -1,12 +1,12 @@ <template> <view class="draw-container"> <view class="header"> <text class="title">领用信息</text> <text class="title">领用自检</text> <wd-icon name="close" class="close-icon" @click="handleClose"></wd-icon> </view> <view class="content"> <wd-tabs v-model="activeTab" @change="handleTabChange"> <wd-tab title="原材料领用" name="material"> <wd-tab title="原材料领用自检" name="material"> <view class="form-section"> <template v-for="(item, index) in localMaterialData" :key="index"> <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> @@ -15,36 +15,43 @@ <wd-input v-model="item.model" :disabled="false" placeholder="请输入"></wd-input> </wd-form-item> <wd-form-item label="外观质量" prop="appearanceQuality" required> <wd-select-picker v-model="item.appearanceQuality" :columns="appearanceQualityOptions" placeholder="请选择" range-key="label" ></wd-select-picker> <view class="checkbox-group"> <wd-checkbox v-for="option in appearanceQualityOptions" :key="option.value" :modelValue=" Array.isArray(item.appearanceQuality) ? item.appearanceQuality.includes(String(option.value)) : false " shape="square" @change=" (val) => handleAppearanceQualityCheckbox(index, String(option.value), val) " > {{ option.label }} </wd-checkbox> </view> </wd-form-item> <wd-form-item label="直径" prop="diameter" required> <wd-form-item label="直径(mm)" prop="diameter" required> <wd-input v-model="item.dia" :disabled="false" placeholder="请输入"></wd-input> </wd-form-item> <wd-form-item label="长度" prop="length" required> <wd-form-item label="长度(m)" prop="length" required> <wd-input v-model="item.length" :disabled="false" placeholder="请输入"></wd-input> </wd-form-item> <wd-form-item label="卷绕紧密" prop="windingTightness" required> <wd-picker v-model="item.windingTightness" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="item.windingTightness" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="排列整齐" prop="arrangement" required> <wd-picker v-model="item.arrangement" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="item.arrangement" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="外层铝线离侧板边缘距离" prop="edgeDistance" required> <wd-form-item label="外层铝线离侧板边缘距离(mm)" prop="edgeDistance" required> <wd-input v-model="item.edgeDistance" :disabled="false" @@ -55,114 +62,116 @@ </template> </view> </wd-tab> <wd-tab title="钢芯领用" name="steel"> <wd-tab title="钢芯领用自检" name="steel"> <view class="form-section"> <template v-for="(item, index) in localSteelData" :key="index"> <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> <wd-form :model="item"> <wd-form-item label="规格型号" prop="model" required> <wd-input v-model="item.model" :disabled="false" placeholder="请输入"></wd-input> </wd-form-item> <wd-form-item label="绞向" prop="twistedDirection" required> <wd-input v-model="item.twistedDirection" :disabled="false" placeholder="请输入" ></wd-input> </wd-form-item> <wd-form-item label="外径" prop="outerDiameter" required> <wd-input v-model="item.outerDiameter" :disabled="false" placeholder="请输入" ></wd-input> </wd-form-item> <wd-form-item label="划伤" prop="scratch" required> <wd-picker v-model="item.scratch" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> </wd-form-item> <wd-form-item label="油污" prop="oilStain" required> <wd-picker v-model="item.oilStain" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> </wd-form-item> </wd-form> </template> <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"> <wd-tab title="盘具领用自检" name="reel"> <view class="form-section"> <wd-form :model="localReelData"> <wd-form-item label="螺母是否固定" prop="nutFixed" required> <wd-picker v-model="localReelData.nutFixed" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.nutFixed" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="侧板是否平直" prop="sidePlateFlat" required> <wd-picker v-model="localReelData.sidePlateFlat" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.sidePlateFlat" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="中心板是否平直" prop="centerPlateFlat" required> <wd-picker v-model="localReelData.centerPlateFlat" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.centerPlateFlat" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="涂漆质量" prop="paintQuality" required> <wd-picker v-model="localReelData.paintQuality" range-key="label" :columns="paintQualityOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.paintQuality" cell shape="dot"> <wd-radio v-for="option in paintQualityOptions" :key="option.value" :value="option.value" > {{ option.label }} </wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="毛刺裂纹扭折" prop="burrCrack" required> <wd-picker v-model="localReelData.burrCrack" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.burrCrack" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="锐角棱边倒钝" prop="edgeBlunt" required> <wd-picker v-model="localReelData.edgeBlunt" range-key="label" :columns="haveOrNotOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.edgeBlunt" cell shape="dot"> <wd-radio v-for="option in haveOrNotOptions" :key="option.value" :value="option.value" > {{ option.label }} </wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="木板是否发霉" prop="woodMold" required> <wd-picker v-model="localReelData.woodMold" range-key="label" :columns="trueOrFalseOptions" placeholder="请选择" ></wd-picker> <wd-radio-group v-model="localReelData.woodMold" cell shape="dot"> <wd-radio value="是">是</wd-radio> <wd-radio value="否">否</wd-radio> </wd-radio-group> </wd-form-item> <wd-form-item label="焊接质量" prop="weldQuality"> <wd-select-picker v-model="localReelData.weldQuality" range-key="label" :columns="weldQualityOptions" placeholder="请选择" ></wd-select-picker> <view class="checkbox-group"> <wd-checkbox v-for="option in weldQualityOptions" :key="option.value" :modelValue=" Array.isArray(localReelData.weldQuality) ? localReelData.weldQuality.includes(String(option.value)) : false " shape="square" @change="(val) => handleWeldQualityCheckbox(String(option.value), val)" > {{ option.label }} </wd-checkbox> </view> </wd-form-item> </wd-form> </view> @@ -176,7 +185,7 @@ </template> <script setup lang="ts"> import { ref, watch } from "vue"; import { ref, watch, nextTick } from "vue"; import { useToast } from "wot-design-uni"; import TwistApi from "@/api/product/twist"; import ManageApi from "@/api/product/manage"; @@ -184,7 +193,7 @@ // 定义TypeScript接口 interface MaterialData { model: string; appearanceQuality: string; appearanceQuality: string | string[]; dia: string; length: string; windingTightness: string; @@ -208,13 +217,13 @@ burrCrack: string; edgeBlunt: string; woodMold: string; weldQuality: string; weldQuality: string | string[]; } // 定义组件的props const props = defineProps<{ singleRegulationInfoArray: MaterialData[]; steelRegulationInfoArray: SteelData[]; steelRegulationInfo: SteelData; reelToolingInfo: ReelData; wireId: string; }>(); @@ -254,6 +263,121 @@ console.error("加载数据字典失败:", error); } }; // 存储每个原材料项的前一个外观质量值,用于比较变化 const previousAppearanceQuality = ref<Map<number, string[]>>(new Map()); // 处理外观质量下拉框的互斥选择逻辑 const handleAppearanceQualityChange = ( index: number, selectedValues: string[], allOptions: Array<{ label: string; value: string }> ): string[] => { // 如果没有选项数据,直接返回 if (!allOptions || allOptions.length === 0) { return selectedValues; } // 获取之前的值 const previousValues = previousAppearanceQuality.value.get(index) || []; // 查找"无外观问题"选项的值 const noIssueOption = allOptions.find( (item) => item.label === "无外观问题" || item.value === "无外观问题" ); if (!noIssueOption) { // 如果字典中没有"无外观问题"选项,直接返回 return selectedValues; } const noIssueValue = noIssueOption.value as string; // 检查当前选中值中是否包含"无外观问题" const hasNoIssue = selectedValues.includes(noIssueValue); // 检查之前是否包含"无外观问题" const hadNoIssue = previousValues.includes(noIssueValue); // 判断是否新选择了"无外观问题"(之前没有,现在有) const isNewlySelectedNoIssue = !hadNoIssue && hasNoIssue; // 判断是否移除了"无外观问题"(之前有,现在没有) const isRemovedNoIssue = hadNoIssue && !hasNoIssue; // 判断是否在"无外观问题"已选中的情况下选择了其他选项 const isSelectingOtherWithNoIssue = hadNoIssue && hasNoIssue && selectedValues.length > previousValues.length; let result: string[]; if (isNewlySelectedNoIssue) { // 如果新选择了"无外观问题",则只保留"无外观问题" result = [noIssueValue]; } else if (isSelectingOtherWithNoIssue) { // 如果"无外观问题"已经被选中,且新选择了其他选项,则移除"无外观问题" result = selectedValues.filter((val) => val !== noIssueValue); } else if (isRemovedNoIssue) { // 如果移除了"无外观问题",直接返回(已经是其他选项了) result = selectedValues; } else { result = selectedValues; } // 保存当前值作为下一次的前一个值 previousAppearanceQuality.value.set(index, result); return result; }; // 处理复选框的change事件 const handleAppearanceQualityCheckbox = ( index: number, optionValue: string | number, checked: boolean ) => { const currentValues = Array.isArray(localMaterialData.value[index].appearanceQuality) ? localMaterialData.value[index].appearanceQuality : []; let newValues: string[]; if (checked) { // 选中 newValues = [...(currentValues as string[]), optionValue as string]; } else { // 取消选中 newValues = (currentValues as string[]).filter((v) => v !== optionValue); } // 应用互斥逻辑 const result = handleAppearanceQualityChange( index, newValues, appearanceQualityOptions.value as Array<{ label: string; value: string }> ); // 更新值 localMaterialData.value[index].appearanceQuality = result; }; // 处理焊接质量复选框的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); } // 更新值 localReelData.value.weldQuality = newValues; }; const haveOrNotOptions = [ { label: "有", @@ -281,7 +405,13 @@ // 本地响应式数据,用于存储用户输入 const localMaterialData = ref<MaterialData[]>([]); const localSteelData = ref<SteelData[]>([]); const localSteelData = ref<SteelData>({ model: "", twistedDirection: "", outerDiameter: "", scratch: "", oilStain: "", }); const localReelData = ref<ReelData>({ nutFixed: "", sidePlateFlat: "", @@ -295,69 +425,160 @@ // 初始化本地数据 const initializeData = () => { // 查找"无外观问题"的值 const noIssueOption = appearanceQualityOptions.value.find( (item) => item.label === "无外观问题" || item.value === "无外观问题" ); const defaultAppearanceQuality = noIssueOption ? [noIssueOption.value as string] : []; // 初始化原材料数据 localMaterialData.value = props.singleRegulationInfoArray.length > 0 ? props.singleRegulationInfoArray.map((item) => ({ model: item.model || "", appearanceQuality: item.appearanceQuality || "", dia: item.dia || "", length: item.length || "", windingTightness: item.windingTightness || "", arrangement: item.arrangement || "", edgeDistance: item.edgeDistance || "", })) ? props.singleRegulationInfoArray.map((item, idx) => { // 处理外观质量数据,确保是数组格式 let initialQuality: string[] = []; if (item.appearanceQuality) { if (Array.isArray(item.appearanceQuality)) { initialQuality = item.appearanceQuality.map((v) => String(v)); } else if (typeof item.appearanceQuality === "string") { initialQuality = [item.appearanceQuality]; } } else { initialQuality = defaultAppearanceQuality; } // 初始化前一个值 previousAppearanceQuality.value.set(idx, initialQuality); return { model: item.model || "", appearanceQuality: initialQuality, dia: item.dia || "", length: item.length || "", windingTightness: item.windingTightness || "是", arrangement: item.arrangement || "是", edgeDistance: item.edgeDistance || "", }; }) : [ { model: "", appearanceQuality: "", appearanceQuality: defaultAppearanceQuality, dia: "", length: "", windingTightness: "", arrangement: "", windingTightness: "是", arrangement: "是", edgeDistance: "", }, ]; // 如果新建了第一条数据,初始化它的前一个值 if (localMaterialData.value.length > 0 && !previousAppearanceQuality.value.has(0)) { previousAppearanceQuality.value.set(0, defaultAppearanceQuality); } // 初始化钢芯数据 localSteelData.value = props.steelRegulationInfoArray.length > 0 ? props.steelRegulationInfoArray.map((item) => ({ model: item.model || "", twistedDirection: item.twistedDirection || "", outerDiameter: item.outerDiameter || "", scratch: item.scratch || "", oilStain: item.oilStain || "", })) : [ { model: "", twistedDirection: "", outerDiameter: "", scratch: "", oilStain: "", }, ]; props.steelRegulationInfo && Object.keys(props.steelRegulationInfo).length > 0 ? { model: props.steelRegulationInfo.model || "", twistedDirection: props.steelRegulationInfo.twistedDirection || "", outerDiameter: props.steelRegulationInfo.outerDiameter || "", scratch: props.steelRegulationInfo.scratch || "否", oilStain: props.steelRegulationInfo.oilStain || "否", } : { model: "", twistedDirection: "", outerDiameter: "", scratch: "否", oilStain: "否", }; // 初始化盘具数据 // 处理焊接质量默认值:如果为空则设置为"已磨光"和"已修平" let weldQualityValue: string[] = []; if ( Array.isArray(props.reelToolingInfo.weldQuality) && props.reelToolingInfo.weldQuality.length > 0 ) { weldQualityValue = props.reelToolingInfo.weldQuality.map((v) => String(v)); } else if ( props.reelToolingInfo.weldQuality && typeof props.reelToolingInfo.weldQuality === "string" ) { weldQualityValue = [props.reelToolingInfo.weldQuality as string]; } else { // 默认选择"已磨光"和"已修平" weldQualityValue = ["已磨光", "已修平"]; } localReelData.value = { nutFixed: props.reelToolingInfo.nutFixed || "", sidePlateFlat: props.reelToolingInfo.sidePlateFlat || "", centerPlateFlat: props.reelToolingInfo.centerPlateFlat || "", paintQuality: props.reelToolingInfo.paintQuality || "", burrCrack: props.reelToolingInfo.burrCrack || "", edgeBlunt: props.reelToolingInfo.edgeBlunt || "", woodMold: props.reelToolingInfo.woodMold || "", weldQuality: props.reelToolingInfo.weldQuality || "", nutFixed: props.reelToolingInfo.nutFixed || "是", sidePlateFlat: props.reelToolingInfo.sidePlateFlat || "是", centerPlateFlat: props.reelToolingInfo.centerPlateFlat || "是", paintQuality: props.reelToolingInfo.paintQuality || "完好", burrCrack: props.reelToolingInfo.burrCrack || "否", edgeBlunt: props.reelToolingInfo.edgeBlunt || "无", woodMold: props.reelToolingInfo.woodMold || "否", weldQuality: weldQualityValue, }; }; // 用于跟踪每个原材料项的初始外观质量值 const appearanceQualityWatchers = ref<Map<number, any>>(new Map()); // 初始化数据 initializeData(); // 为每个原材料项添加独立的外观质量监听器 const setupAppearanceQualityWatchers = () => { // 清除旧的监听器 appearanceQualityWatchers.value.forEach((stop) => stop()); appearanceQualityWatchers.value.clear(); // 为每个项添加新的监听器 localMaterialData.value.forEach((item, index) => { const stop = watch( () => item.appearanceQuality, (newValue, oldValue) => { const normalizedNewValue = Array.isArray(newValue) ? newValue : []; const normalizedOldValue = Array.isArray(oldValue) ? oldValue : []; // 应用互斥逻辑 const result = handleAppearanceQualityChange( index, normalizedNewValue, appearanceQualityOptions.value as Array<{ label: string; value: string }> ); // 如果值被修改了,异步更新,避免在监听中同步修改 if (JSON.stringify(result) !== JSON.stringify(normalizedNewValue)) { nextTick(() => { item.appearanceQuality = result; }); } }, { deep: true } ); appearanceQualityWatchers.value.set(index, stop); }); }; // 初始化监听器 setupAppearanceQualityWatchers(); // 监听props变化,更新本地数据 watch(() => props.singleRegulationInfoArray, initializeData, { deep: true }); watch(() => props.steelRegulationInfoArray, initializeData, { deep: true }); watch( () => props.singleRegulationInfoArray, () => { initializeData(); setupAppearanceQualityWatchers(); }, { deep: true } ); watch(() => props.steelRegulationInfo, initializeData, { deep: true }); watch(() => props.reelToolingInfo, initializeData, { deep: true }); const handleTabChange = (tabName: string) => { @@ -375,7 +596,7 @@ if ( activeTab.value === "material" || (!localMaterialData.value.length && !localSteelData.value.length && !Object.keys(localSteelData.value).length && !Object.keys(localReelData.value).length) ) { for (let i = 0; i < localMaterialData.value.length; i++) { @@ -406,26 +627,24 @@ if ( activeTab.value === "steel" || (!localMaterialData.value.length && !localSteelData.value.length && !Object.keys(localSteelData.value).length && !Object.keys(localReelData.value).length) ) { for (let i = 0; i < localSteelData.value.length; i++) { const item = localSteelData.value[i]; if ( !item.model || item.model === "" || !item.twistedDirection || item.twistedDirection === "" || !item.outerDiameter || item.outerDiameter === "" || !item.scratch || item.scratch === "" || !item.oilStain || item.oilStain === "" ) { toast.error(`钢芯第${i + 1}行存在必填项未填写`); return false; } const steel = localSteelData.value; if ( !steel.model || steel.model === "" || !steel.twistedDirection || steel.twistedDirection === "" || !steel.outerDiameter || steel.outerDiameter === "" || !steel.scratch || steel.scratch === "" || !steel.oilStain || steel.oilStain === "" ) { toast.error("钢芯数据存在必填项未填写"); return false; } } @@ -433,7 +652,7 @@ if ( activeTab.value === "reel" || (!localMaterialData.value.length && !localSteelData.value.length && !Object.keys(localSteelData.value).length && !Object.keys(localReelData.value).length) ) { const reel = localReelData.value; @@ -448,7 +667,7 @@ await TwistApi.addSingleDishInspection({ inspectResult: { singleRegulationInfoArray: localMaterialData.value, steelRegulationInfoArray: localSteelData.value, steelRegulationInfo: localSteelData.value, reelToolingInfo: localReelData.value, }, wireId: props.wireId, @@ -476,12 +695,14 @@ await loadDictData(); }); watch( () => [props.singleRegulationInfoArray, props.steelRegulationInfoArray, props.reelToolingInfo], () => [props.singleRegulationInfoArray, props.steelRegulationInfo, props.reelToolingInfo], () => { const hasMaterial = Array.isArray(props.singleRegulationInfoArray) && props.singleRegulationInfoArray.length > 0; const hasSteel = Array.isArray(props.steelRegulationInfoArray) && props.steelRegulationInfoArray.length > 0; props.steelRegulationInfo && typeof props.steelRegulationInfo === "object" && Object.keys(props.steelRegulationInfo).length > 0; const hasReel = props.reelToolingInfo && typeof props.reelToolingInfo === "object" && @@ -576,4 +797,14 @@ .submit-btn { width: 100%; } .checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; } :deep(.wd-checkbox) { margin-right: 0; } </style> src/pages/production/twist/report/index.vue
@@ -35,7 +35,7 @@ <wd-popup v-model="drawFormRef.visible" position="bottom" custom-class="yl-popup"> <Draw :single-regulation-info-array="drawData.singleRegulationInfoArray" :steel-regulation-info-array="drawData.steelRegulationInfoArray" :steel-regulation-info="drawData.steelRegulationInfo" :reel-tooling-info="drawData.reelToolingInfo" :wire-id="drawData.wireId" @close="handleDrawClose" @@ -73,8 +73,23 @@ }); const drawData = ref({ singleRegulationInfoArray: [], steelRegulationInfoArray: [], reelToolingInfo: {}, steelRegulationInfo: { model: "", twistedDirection: "", outerDiameter: "", scratch: "", oilStain: "", }, reelToolingInfo: { nutFixed: "", sidePlateFlat: "", centerPlateFlat: "", paintQuality: "", burrCrack: "", edgeBlunt: "", woodMold: "", weldQuality: "", }, wireId: "", }); @@ -117,8 +132,10 @@ }); }; const addReport = () => { const addReport = async () => { dialog.visible = true; // 打开新增弹窗时自动执行 // await showDrawPopup(); }; const submit = async () => { @@ -126,7 +143,7 @@ dialog.visible = !isSuccess; // 如果提交成功,关闭弹窗 if (isSuccess) { // 提交成功后执行 showDrawPopup(); // showDrawPopup(); } }; @@ -150,14 +167,13 @@ const { data } = await TwistApi.querySingleDishInspection({ id: paramsId.value, }); console.log("领用信息数据:", data); // 适配不同的数据结构返回格式 const responseData = data.data || data; if (responseData && responseData.singleWirePrePareInfoVo) { const info = responseData.singleWirePrePareInfoVo; drawData.value = { singleRegulationInfoArray: info.singleRegulationInfoArray || [], steelRegulationInfoArray: info.steelRegulationInfoArray || [], steelRegulationInfo: info.steelRegulationInfo || {}, reelToolingInfo: info.reelToolingInfo || {}, wireId: paramsId.value, }; @@ -165,7 +181,7 @@ drawFormRef.visible = true; toast.success("请填写领用信息!"); } else { toast.error("已存在领用信息,无需填报!"); // toast.error("已存在领用信息,无需填报!"); } } catch (error) { console.error("获取领用信息失败:", error); @@ -197,6 +213,7 @@ onLoad((options: any) => { paramsId.value = options.id; showDrawPopup(); }); </script> src/pages/production/wire/report/rawMaterial.vue
@@ -1,12 +1,12 @@ <template> <view class="draw-container"> <view class="header"> <text class="title">领用信息</text> <text class="title">领用自检</text> <wd-icon name="close" class="close-icon" @click="handleClose"></wd-icon> </view> <view class="content"> <wd-tabs v-model="activeTab" @change="handleTabChange"> <wd-tab title="原材料领用" name="reel"> <wd-tab title="原材料领用自检" name="reel"> <view class="form-section"> <wd-form :model="materialData"> <wd-form-item label="型号" prop="model" required> src/pages/production/wire/report/wire.vue
@@ -95,7 +95,7 @@ drawFormRef.visible = true; toast.success("请填写领用信息!"); } else { toast.error("已存在领用信息,无需填报!"); // toast.error("已存在领用信息,无需填报!"); } } catch (error) { console.error("获取领用信息失败:", error);