From ee6f8c315926a871f11a96a69702efcef4d0b49f Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 26 五月 2025 13:49:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
src/views/basicData/product/index.vue | 184 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 154 insertions(+), 30 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 0275185..dba78e3 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -14,9 +14,10 @@
<el-button type="primary" @click="openProDia('add')" style="margin-left: 10px">鏂板浜у搧</el-button>
</div>
<div>
- <el-tree ref="tree" v-loading="treeLoad" :data="list"
+ <el-tree ref="tree" v-loading="treeLoad" :data="list" @node-click="handleNodeClick"
+ :expand-on-click-node="false"
:default-expanded-keys="expandedKeys" :draggable="true" :filter-node-method="filterNode"
- :props="{ children: 'children', label: 'label' }" highlight-current node-key="label"
+ :props="{ children: 'children', label: 'label' }" highlight-current node-key="id"
style="height: calc(100vh - 190px);overflow-y: scroll;scrollbar-width: none;">
<template #default="{ node, data }">
<div class="custom-tree-node">
@@ -43,13 +44,13 @@
</div>
<div class="right">
<div style="margin-bottom: 10px">
- <el-button type="primary" @click="modelDia = true">鏂板瑙勬牸鍨嬪彿</el-button>
+ <el-button type="primary" @click="openModelDia('add')">鏂板瑙勬牸鍨嬪彿</el-button>
<el-button type="danger" @click="handleDelete" style="margin-left: 10px" plain>鍒犻櫎</el-button>
</div>
<PIMTable :column="tableColumn" :tableData="tableData" :page="page" :isSelection="true" :handleSelectionChange="handleSelectionChange"
:tableLoading="tableLoading" @pagination="pagination" :total="total"></PIMTable>
</div>
- <el-dialog :visible.sync="productDia" title="浜у搧" width="400px">
+ <el-dialog v-model="productDia" title="浜у搧" width="400px">
<el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
<el-row :gutter="30">
<el-col :span="24">
@@ -66,17 +67,52 @@
</div>
</template>
</el-dialog>
+ <el-dialog v-model="modelDia" title="浜у搧" width="400px">
+ <el-form :model="modelForm" label-width="140px" label-position="top" :rules="modelRules" ref="modelFormRef">
+ <el-row>
+ <el-col :span="24">
+ <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
+ <el-input v-model="modelForm.model" placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�" clearable/>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row>
+ <el-col :span="24">
+ <el-form-item label="鍗曚綅锛�" prop="unit">
+ <el-input v-model="modelForm.unit" placeholder="璇疯緭鍏ュ崟浣�" clearable/>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitModelForm">纭</el-button>
+ <el-button @click="closeProDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
</div>
</template>
<script setup>
import {ref} from "vue";
-import {listCustomer} from "@/api/basicData/customerFile.js";
import {ElMessageBox} from "element-plus";
-import {productTreeList} from "@/api/basicData/product.js";
+import {
+ addOrEditProduct,
+ addOrEditProductModel,
+ delProduct, delProductModel,
+ modelList,
+ productTreeList
+} from "@/api/basicData/product.js";
const { proxy } = getCurrentInstance()
+const productDia = ref(false)
+const modelDia = ref(false)
+const modelOperationType = ref('')
const search = ref('')
+const currentId = ref('')
+const currentParentId = ref('')
+const operationType = ref('')
const treeLoad = ref(false)
const list = ref([])
const expandedKeys = ref([])
@@ -87,7 +123,7 @@
},
{
label: '鍗曚綅',
- prop: 'model',
+ prop: 'unit',
},
{
dataType: "action",
@@ -98,7 +134,7 @@
name: "缂栬緫",
type: "text",
clickFun: (row) => {
- openForm('edit', row);
+ openModelDia('edit', row);
},
},
],
@@ -112,17 +148,24 @@
current: 1,
size: 10,
})
-const productDia = ref(false)
-const modelDia = ref(false)
const data = reactive({
form: {
productName: '',
},
rules: {
productName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ },
+ modelForm: {
+ model: '',
+ unit: '',
+ },
+ modelRules: {
+ model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
}
})
-const { form, rules } = toRefs(data)
+const { form, rules, modelForm, modelRules } = toRefs(data)
+// 鏌ヨ浜у搧鏍�
const getProductTreeList = () => {
treeLoad.value = true;
productTreeList().then(res => {
@@ -135,27 +178,122 @@
treeLoad.value = false;
})
}
+// 杩囨护浜у搧鏍�
const searchFilter = () => {
proxy.$refs.tree.filter(search.value);
}
+// 鎵撳紑浜у搧寮规
const openProDia = (type, data) => {
+ operationType.value = type;
productDia.value = true
- console.log('openEditDia', data)
+ form.value.productName = ''
+ if (type === 'edit') {
+ form.value.productName = data.productName
+ }
}
+// 鎵撳紑瑙勬牸鍨嬪彿寮规
+const openModelDia = (type, data) => {
+ modelOperationType.value = type;
+ modelDia.value = true
+ modelForm.value.model = ''
+ modelForm.value.model = ''
+ modelForm.value.id = ''
+ if (type === 'edit') {
+ modelForm.value = {...data}
+ }
+}
+// 鎻愪氦浜у搧鍚嶇О淇敼
const submitForm = () => {
+ proxy.$refs.formRef.validate(valid => {
+ if (valid) {
+ if (operationType.value === 'add') {
+ form.value.parentId = currentId.value
+ form.value.id = ''
+ } else {
+ form.value.id = currentId.value
+ form.value.parentId = ''
+ }
+ addOrEditProduct(form.value).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛")
+ closeProDia()
+ getProductTreeList()
+ })
+ }
+ })
}
+// 鍏抽棴浜у搧寮规
const closeProDia = () => {
proxy.$refs.formRef.resetFields();
productDia.value = false;
}
-const remove = (value) => {
+// 鍒犻櫎浜у搧
+const remove = (node, data) => {
+ let ids = []
+ ids.push(data.id)
+ ElMessageBox.confirm(
+ '閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�',
+ '鍒犻櫎鎻愮ず', {
+ confirmButtonText: '纭',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }
+ ).then(() => {
+ tableLoading.value = true
+ delProduct(ids).then(res => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+ getProductTreeList()
+ }).finally(() => {
+ tableLoading.value = false
+ })
+ }).catch(() => {
+ proxy.$modal.msg("宸插彇娑�")
+ })
+}
+// 閫夋嫨浜у搧
+const handleNodeClick = (val, node, el) => {
+ currentId.value = val.id
+ currentParentId.value = val.parentId
+ getModelList()
+}
+
+// 鎻愪氦瑙勬牸鍨嬪彿淇敼
+const submitModelForm = () => {
+ proxy.$refs.modelFormRef.validate(valid => {
+ if (valid) {
+ modelForm.value.productId = currentId.value
+ addOrEditProductModel(modelForm.value).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛")
+ closeModelDia()
+ getModelList()
+ })
+ }
+ })
+}
+// 鍏抽棴浜у搧寮规
+const closeModelDia = () => {
+ proxy.$refs.modelFormRef.resetFields();
+ modelDia.value = false;
}
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
selectedRows.value = selection
}
-// 鍒犻櫎
+
+// 鏌ヨ瑙勬牸鍨嬪彿
+const pagination = ({ current, limit }) => {
+ page.current = current;
+ page.size = limit;
+ getModelList()
+}
+const getModelList = () => {
+ tableLoading.value = true
+ modelList({id: currentId.value}).then(res => {
+ tableLoading.value = false
+ tableData.value = res
+ })
+}
+// 鍒犻櫎瑙勬牸鍨嬪彿
const handleDelete = () => {
let ids = []
if (selectedRows.value.length > 0) {
@@ -173,28 +311,14 @@
}
).then(() => {
tableLoading.value = true
- delCustomer(ids).then(res => {
+ delProductModel(ids).then(res => {
proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
- getList()
+ getModelList()
}).finally(() => {
tableLoading.value = false
})
}).catch(() => {
proxy.$modal.msg("宸插彇娑�")
- })
-}
-// 鏌ヨ瑙勬牸鍨嬪彿
-const pagination = ({ current, limit }) => {
- page.current = current;
- page.size = limit;
- getList()
-}
-const getList = () => {
- tableLoading.value = true
- listCustomer({...searchForm.value, ...page}).then(res => {
- tableLoading.value = false
- tableData.value = res.rows
- total.value = res.total
})
}
// 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
--
Gitblit v1.9.3