| src/api/basicData/productModel.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/views/productionManagement/processRoute/Edit.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/views/productionManagement/processRoute/New.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/views/productionManagement/processRoute/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/api/basicData/productModel.js
ÎļþÒÑɾ³ý 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; // æ¾å°èç¹ï¼è¿å该èç¹çlabel } if (nodes[i].children && nodes[i].children.length > 0) { const foundNode = findNodeById(nodes[i].children, productId); if (foundNode) { return foundNode; // å¨åèç¹ä¸æ¾å°ï¼ç´æ¥è¿åï¼å·²ç»æ¯labelåç¬¦ä¸²ï¼ } } } return null; // æ²¡ææ¾å°èç¹ï¼è¿ånull }; 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> 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; // æ¾å°èç¹ï¼è¿å该èç¹çlabel } if (nodes[i].children && nodes[i].children.length > 0) { const foundNode = findNodeById(nodes[i].children, productId); if (foundNode) { return foundNode; // å¨åèç¹ä¸æ¾å°ï¼ç´æ¥è¿åï¼å·²ç»æ¯labelåç¬¦ä¸²ï¼ } } } return null; // æ²¡ææ¾å°èç¹ï¼è¿ånull }; 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> 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(() => {