From 35a28e272e903359a326f629db7a69bf49eaf2bb Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 23 十二月 2025 17:44:17 +0800
Subject: [PATCH] 工艺路线页面
---
/dev/null | 11 --
src/views/productionManagement/processRoute/index.vue | 37 ++++---
src/views/productionManagement/processRoute/New.vue | 106 ++++++++++++++++----
src/views/productionManagement/processRoute/Edit.vue | 116 ++++++++++++++++++----
4 files changed, 196 insertions(+), 74 deletions(-)
diff --git a/src/api/basicData/productModel.js b/src/api/basicData/productModel.js
deleted file mode 100644
index 97803d8..0000000
--- a/src/api/basicData/productModel.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// 浜у搧缁存姢椤甸潰鎺ュ彛
-import request from '@/utils/request'
-
-// 浜у搧鏍戞煡璇�
-export function list(query) {
- return request({
- url: '/basic/product/pageModel',
- method: 'get',
- params: query
- })
-}
diff --git a/src/views/productionManagement/processRoute/Edit.vue b/src/views/productionManagement/processRoute/Edit.vue
index df691cb..ad480a9 100644
--- a/src/views/productionManagement/processRoute/Edit.vue
+++ b/src/views/productionManagement/processRoute/Edit.vue
@@ -7,23 +7,36 @@
@close="closeModal"
>
<el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
- <el-form-item
- label="宸ュ簭鍚嶇О锛�"
- prop="name"
- :rules="[
- {
- required: true,
- message: '璇疯緭鍏ュ伐搴忓悕绉�',
- },
- {
- max: 100,
- message: '鏈�澶�100涓瓧绗�',
- }
- ]">
- <el-input v-model="formState.name" />
+ <el-form-item label="浜у搧澶х被锛�" prop="productId">
+ <el-tree-select
+ v-model="formState.productId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ style="width: 100%"
+ />
</el-form-item>
- <el-form-item label="澶囨敞" prop="remark">
- <el-input v-model="formState.remark" type="textarea" />
+
+ <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
+ <el-select
+ v-model="formState.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ >
+ <el-option
+ v-for="item in productModelsOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id"
+ />
+ </el-select>
+ </el-form-item>
+
+ <el-form-item label="澶囨敞" prop="description">
+ <el-input v-model="formState.description" type="textarea" />
</el-form-item>
</el-form>
<template #footer>
@@ -37,8 +50,9 @@
</template>
<script setup>
-import { ref, computed, getCurrentInstance } from "vue";
-import {update} from "@/api/productionManagement/productionProcess.js";
+import {ref, computed, getCurrentInstance, onMounted} from "vue";
+import {update} from "@/api/productionManagement/processRoute.js";
+import {modelList, productTreeList} from "@/api/basicData/product.js";
const props = defineProps({
visible: {
@@ -55,11 +69,7 @@
const emit = defineEmits(['update:visible', 'completed']);
// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
-const formState = ref({
- id: props.record.id,
- name: props.record.name,
- remark: props.record.remark,
-});
+const formState = ref({});
const isShow = computed({
get() {
@@ -71,10 +81,61 @@
});
let { proxy } = getCurrentInstance()
+const productModelsOptions = ref([])
+const productOptions = ref([])
const closeModal = () => {
isShow.value = false;
};
+
+const setFormData = () => {
+ formState.value = props.record
+}
+
+const getProductOptions = () => {
+ productTreeList().then((res) => {
+ productOptions.value = convertIdToValue(res);
+ });
+};
+const getModels = (value) => {
+ formState.value.productModelId = undefined;
+ productModelsOptions.value = [];
+ if (value) {
+ modelList({ id: value }).then((res) => {
+ productModelsOptions.value = res;
+ });
+ }
+};
+
+const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣鐨刲abel
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝鐩存帴杩斿洖锛堝凡缁忔槸label瀛楃涓诧級
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+
+function convertIdToValue(data) {
+ return data.map((item) => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+
+ return newItem;
+ });
+}
const handleSubmit = () => {
proxy.$refs["formRef"].validate(valid => {
@@ -95,4 +156,13 @@
handleSubmit,
isShow,
});
+
+
+onMounted(() => {
+ getProductOptions()
+ getModels(props.record.productId)
+ nextTick(() => {
+ setFormData()
+ });
+})
</script>
diff --git a/src/views/productionManagement/processRoute/New.vue b/src/views/productionManagement/processRoute/New.vue
index 76aeb01..5c56fd4 100644
--- a/src/views/productionManagement/processRoute/New.vue
+++ b/src/views/productionManagement/processRoute/New.vue
@@ -7,24 +7,34 @@
@close="closeModal"
>
<el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
- <el-form-item
- label="宸ュ簭鍚嶇О锛�"
- prop="name"
- :rules="[
- {
- required: true,
- message: '璇疯緭鍏ュ伐搴忓悕绉�',
- },
- {
- max: 100,
- message: '鏈�澶�100涓瓧绗�',
- }
- ]">
- <el-select v-model="formState.productModelId" placeholder="閫夋嫨闆朵欢" size="small">
- <el-option v-for="item in warehouse" :key="item.id" :label="item.label" :value="item.id">
- </el-option>
+ <el-form-item label="浜у搧澶х被锛�" prop="productId">
+ <el-tree-select
+ v-model="formState.productId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ style="width: 100%"
+ />
+ </el-form-item>
+
+ <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
+ <el-select
+ v-model="formState.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ >
+ <el-option
+ v-for="item in productModelsOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id"
+ />
</el-select>
</el-form-item>
+
<el-form-item label="澶囨敞" prop="description">
<el-input v-model="formState.description" type="textarea" />
</el-form-item>
@@ -41,7 +51,8 @@
<script setup>
import {ref, computed, getCurrentInstance, onMounted} from "vue";
-import {add} from "@/api/productionManagement/productionProcess.js";
+import {add} from "@/api/productionManagement/processRoute.js";
+import {modelList, productTreeList} from "@/api/basicData/product.js";
const props = defineProps({
visible: {
@@ -54,8 +65,9 @@
// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
const formState = ref({
- name: '',
- remark: '',
+ productId: undefined,
+ productModelId: undefined,
+ description: '',
});
const isShow = computed({
@@ -67,13 +79,62 @@
},
});
-const productModels = ref([])
+const productModelsOptions = ref([])
+const productOptions = ref([])
let { proxy } = getCurrentInstance()
const closeModal = () => {
isShow.value = false;
};
+
+const getProductOptions = () => {
+ productTreeList().then((res) => {
+ productOptions.value = convertIdToValue(res);
+ });
+};
+const getModels = (value) => {
+ formState.value.productId = undefined;
+ formState.value.productModelId = undefined;
+ productModelsOptions.value = [];
+
+ if (value) {
+ formState.value.productId = findNodeById(productOptions.value, value) || undefined;
+ modelList({ id: value }).then((res) => {
+ productModelsOptions.value = res;
+ });
+ }
+};
+
+const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣鐨刲abel
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝鐩存帴杩斿洖锛堝凡缁忔槸label瀛楃涓诧級
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+
+function convertIdToValue(data) {
+ return data.map((item) => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+
+ return newItem;
+ });
+}
const handleSubmit = () => {
proxy.$refs["formRef"].validate(valid => {
@@ -89,9 +150,6 @@
})
};
-const findProductModelOptions = () => {
-
-}
defineExpose({
closeModal,
@@ -100,6 +158,6 @@
});
onMounted(() => {
- findProductModelOptions()
+ getProductOptions()
})
</script>
diff --git a/src/views/productionManagement/processRoute/index.vue b/src/views/productionManagement/processRoute/index.vue
index 61b34e4..06a798d 100644
--- a/src/views/productionManagement/processRoute/index.vue
+++ b/src/views/productionManagement/processRoute/index.vue
@@ -52,15 +52,14 @@
const data = reactive({
searchForm: {
- name: "",
- no: "",
+ model: "",
},
});
const { searchForm } = toRefs(data);
const tableColumn = ref([
{
- label: "闆朵欢鍚嶇О",
- prop: "speculativeTradingName",
+ label: "瑙勬牸鍚嶇О",
+ prop: "model",
},
{
label: "鎻忚堪",
@@ -73,6 +72,13 @@
fixed: "right",
width: 280,
operation: [
+ {
+ name: "璇︽儏",
+ type: "text",
+ clickFun: (row) => {
+ showEditModal(row);
+ }
+ },
{
name: "缂栬緫",
type: "text",
@@ -139,18 +145,17 @@
// 鍒犻櫎
function handleDelete() {
- // const no = selectedRows.value.map((item) => item.no);
- // const ids = selectedRows.value.map((item) => item.id);
- // proxy.$modal
- // .confirm('鏄惁纭鍒犻櫎宸ュ簭缂栧彿涓�"' + no + '"鐨勬暟鎹」锛�')
- // .then(function () {
- // return del(ids);
- // })
- // .then(() => {
- // getList();
- // proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- // })
- // .catch(() => {});
+ const ids = selectedRows.value.map((item) => item.id);
+ proxy.$modal
+ .confirm('鏄惁纭鍒犻櫎宸插嬀閫夌殑鏁版嵁椤癸紵')
+ .then(function () {
+ return del(ids);
+ })
+ .then(() => {
+ getList();
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ })
+ .catch(() => {});
}
onMounted(() => {
--
Gitblit v1.9.3