| src/api/product/twist.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/components/ProductionCard.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/components/MonofilCard.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/monofil.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/steelCore/edit.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/steelCore/form.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/production/twist/receive/steelCore/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | 
src/api/product/twist.ts
@@ -53,6 +53,15 @@ data: params, }); }, // 根据单丝编号查询 selectByMonofilamentNumber(params: { monofilamentNumber: string }) { return request<BaseResult<any>>({ url: "/strandedWire/selectByMonofilamentNumber", method: "GET", data: params, }); }, }; export default TwistApi; src/pages/production/components/ProductionCard.vue
@@ -1,8 +1,8 @@ <template> <wd-row> <wd-col v-for="(item, index) in data" :key="index" :span="item.span ?? 12" class="my-1"> <view class="flex justify-between w-full h-[20px]"> <view class="text-[#646874] pl-1">{{ item.label }}</view> <view class="flex w-full h-[20px]"> <view class="text-[#646874] pl-1 mr-3">{{ item.label }}</view> <view class="font-medium pr-1" :style="{ color: item.color ?? color }"> {{ value[item.prop] }} {{ value[item.unitProp] }} {{ item.unit }} </view> src/pages/production/twist/components/MonofilCard.vue
@@ -2,8 +2,8 @@ <wd-card> <wd-cell-group :border="true"> <wd-cell title="单丝编号" :value="data.monofilamentNumber" /> <wd-cell title="理论长度" :value="data.amount + ' (M)'" /> <wd-cell title="生产长度" :value="data.actuallyLength + ' (M)'" /> <wd-cell title="理论长度" :value="data.amount + ' (m)'" /> <wd-cell title="生产长度" :value="data.actuallyLength + ' (m)'" /> <wd-cell title="重量" :value="data.actuallyWeight + ' (kg)'" /> </wd-cell-group> </wd-card> src/pages/production/twist/receive/monofil.vue
@@ -11,16 +11,22 @@ <CardTitle title="单丝领用" :hideAction="false"> <template #action> <wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button> <wd-button type="icon" icon="add-circle" color="#0D867F" @click="openManualInput" ></wd-button> </template> </CardTitle> </template> <!-- <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" /> --> <wd-tabs v-model="tab" slidable="always"> <wd-tabs v-model="tab" slidable="always" class="tabs-container"> <block v-for="item in nodeList" :key="item"> <wd-tab :title="item.twistedLayer" :name="item.twistedLayer"> <view class="content"> <scroll-view class="content" scroll-y> <MonofilCard v-for="(m, i) in item.strandedWireDish" :key="i" :data="m" /> </view> </scroll-view> </wd-tab> </block> </wd-tabs> @@ -38,6 +44,32 @@ :nodeList="nodeList" @confirm="handleConfirmSave" /> <!-- 手动输入质量追溯号弹框 --> <wd-popup v-model="showManualInput" position="center" :close-on-click-modal="false"> <view class="manual-input-modal"> <view class="modal-header"> <text class="title">手动领用单丝</text> <wd-icon name="close" @click="closeManualInput" /> </view> <view class="modal-content"> <view class="input-label">单丝编号</view> <wd-input v-model="manualOutPutId" placeholder="请输入单丝编号" clearable @clear="manualOutPutId = ''" /> </view> <view class="modal-footer"> <wd-button @click="closeManualInput" type="default">取消</wd-button> <wd-button type="primary" @click="handleManualConfirm" custom-class="confirm-btn"> 确定 </wd-button> </view> </view> </wd-popup> <wd-toast /> </view> </template> @@ -61,6 +93,8 @@ const toast = useToast(); const tab = ref(""); const showStatisticsModal = ref(false); const showManualInput = ref(false); const manualOutPutId = ref(""); // 监听标签切换 watch(tab, () => { @@ -122,6 +156,76 @@ const openScan = () => { scanRef.value.triggerScan(); }; // 打开手动输入弹框 const openManualInput = () => { // 检查是否已选择标签 if (!tab.value) { toast.error("请先选择一个层"); return; } showManualInput.value = true; }; // 关闭手动输入弹框 const closeManualInput = () => { showManualInput.value = false; manualOutPutId.value = ""; }; // 手动输入确认 const handleManualConfirm = async () => { if (!manualOutPutId.value.trim()) { toast.error("请输入质量追溯号"); return; } try { const { data } = await TwistApi.selectByMonofilamentNumber({ monofilamentNumber: manualOutPutId.value.trim(), }); // 找到当前选中的层 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(); // 关闭弹框并清空输入 closeManualInput(); toast.success("添加成功"); } else { toast.error("该单丝已领用,请勿重复添加"); } } catch (error: any) { toast.error(error.msg || "查询失败"); } }; const getList = async () => { @@ -245,20 +349,112 @@ .list_box { height: calc(100vh - 100px); background: #f3f9f8; display: flex; flex-direction: column; } // 手动输入弹框样式 .manual-input-modal { width: 320px; background: #fff; border-radius: 12px; overflow: hidden; .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f0f0f0; .title { font-size: 18px; font-weight: 600; color: #333; } } .modal-content { padding: 20px; .input-label { font-size: 14px; color: #333; margin-bottom: 8px; font-weight: 500; } } .modal-footer { display: flex; gap: 12px; padding: 16px 20px; border-top: 1px solid #f0f0f0; } } :deep(.manual-input-modal .confirm-btn) { background-color: #0d867f !important; border-color: #0d867f !important; .wd-button__content { color: #fff !important; } } // tab容器样式 .tabs-container { height: calc(100vh - 200px); display: flex; flex-direction: column; } .content { height: calc(100vh - 280px); width: 100%; } :deep(.wd-button__content) { color: #0d867f; } :deep(.zp-paging-container) { background: transparent !important; flex: 1; display: flex; flex-direction: column; } :deep(.zp-paging-container-content) { background: transparent !important; flex: 1; display: flex; flex-direction: column; } :deep(.wd-tabs) { background: transparent !important; height: 100%; display: flex; flex-direction: column; overflow: hidden; } :deep(.wd-tabs__nav) { margin-bottom: 10px; flex-shrink: 0; position: sticky; top: 0; z-index: 10; background: #f3f9f8; } :deep(.wd-tabs__content) { flex: 1; overflow: visible; } :deep(.wd-tab__pane) { height: 100%; } :deep(.zp-paging-container-top) { flex-shrink: 0; } :deep(.zp-paging-container-bottom) { flex-shrink: 0; } </style> src/pages/production/twist/receive/steelCore/edit.vue
@@ -1,7 +1,7 @@ <template> <view> <CardTitle title="绞线盘具领用" :hideAction="false" /> <SteelCoreForm class="mx-4" /> <CardTitle title="绞线钢芯领用" :hideAction="false" /> <SteelCoreForm 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 SteelCoreForm 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("steelCoreEditData", receiveEditData); }); onUnload(() => { // 页面卸载时移除监听 uni.$off("steelCoreEditData", receiveEditData); }); </script> <style lang="scss" scoped> .footer { src/pages/production/twist/receive/steelCore/form.vue
@@ -26,10 +26,18 @@ placeholder="请输入长度" /> <wd-input v-model="model.manufacturers" v-model="model.weight" label="重量" label-width="100px" prop="weight" clearable placeholder="请输入重量" /> <wd-input v-model="model.supplier" label="厂家" label-width="100px" prop="manufacturers" prop="supplier" clearable placeholder="请输入厂家" /> @@ -44,15 +52,19 @@ const emits = defineEmits(["refresh"]); const paramsId = ref(); const editId = ref(); // 编辑时的ID const allListData = ref<any[]>([]); // 存储完整列表数据 const toast = useToast(); const { form: model } = useFormData({ model: undefined, // 规格型号 monofilamentNumber: undefined, // 样品编号 amount: undefined, // 数量 manufacturers: undefined, // 厂家 weight: undefined, // 重量 supplier: undefined, // 厂家 type: "钢芯", }); // 新增提交 const submit = async () => { const { code } = await TwistApi.addStrandedWireDish([ { @@ -65,6 +77,73 @@ emits("refresh"); return true; } return false; }; // 编辑提交(也走新增接口,提交整个列表) const submitEdit = async () => { if (!editId.value) { 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 updatedItem = { ...item, // 先保留原有的所有数据 model: model.model, monofilamentNumber: model.monofilamentNumber, amount: model.amount, weight: model.weight, supplier: model.supplier, type: model.type, }; console.log("submitEdit - 更新后的项:", updatedItem); return updatedItem; } return item; }); console.log("submitEdit - 提交的完整列表:", updatedList); // 提交整个列表 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.model = currentItem.model; model.monofilamentNumber = currentItem.monofilamentNumber; model.amount = currentItem.amount; model.weight = currentItem.weight; model.supplier = currentItem.supplier; model.type = currentItem.type || "钢芯"; } }; onLoad((options: any) => { @@ -73,12 +152,12 @@ defineExpose({ submit, submitEdit, setFormData, }); </script> <style lang="scss" scoped> .form_box { } .submit_btn { position: absolute; bottom: 0; src/pages/production/twist/receive/steelCore/index.vue
@@ -39,7 +39,7 @@ import ProductionCard from "../../../components/ProductionCard.vue"; import { useToast } from "wot-design-uni"; import SteelCore 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"; @@ -51,6 +51,7 @@ visible: false, }); const cardList = ref<any[]>([]); const needRefresh = ref(false); // 标记是否需要刷新 const cardAttr = ref<any[]>([ { @@ -63,6 +64,11 @@ unitProp: "unit", }, { label: "重量", prop: "weight", unitProp: "weightUnit", }, { label: "厂家", prop: "supplier", span: 16, @@ -70,8 +76,21 @@ ]); 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, }); }, }); }; @@ -80,7 +99,10 @@ }; const submit = async () => { dialog.visible = !(await steelCoreRef.value.submit()); const success = await steelCoreRef.value.submit(); if (success) { dialog.visible = false; } }; const cancel = () => { @@ -105,6 +127,14 @@ onLoad((options: any) => { paramsId.value = options.id; }); onShow(() => { // 从编辑页返回时刷新列表 if (needRefresh.value) { reloadList(); needRefresh.value = false; } }); </script> <style lang="scss" scoped>