فهرست منبع

refactor: 功能优化

yongCode 6 ماه پیش
والد
کامیت
0e8463acd0

+ 9 - 0
src/api/bussiness/index.js

@@ -35,6 +35,7 @@ export function queryToolDict(level,parentId) {
       params: {
         level,
         parentId,
+        pageSize: 65536
       },
     })
       .then((res) => {
@@ -81,6 +82,14 @@ export function listFileByBasisId(query) {
     params:query,
   });
 }
+// 根据基础信息id查询附件信息 (多类型查)
+export function listFileByBasisIdMulType(data) {
+  return request({
+    url: "/basis/detail/getListByType",
+    method: "post",
+    data,
+  });
+}
 
 // 给对应基础信息添加附件
 export function addFileByBasisId(data) {

+ 10 - 5
src/views/classification/hooks/useTable.js

@@ -1,4 +1,4 @@
-import { getToolDetailById, listFileByBasisId, toolDelete } from "@/api/bussiness";
+import { getToolDetailById, listFileByBasisIdMulType, toolDelete } from "@/api/bussiness";
 import { groupByKey } from "@/utils"
 // 数据表格的 hooks
 const useTable = (getList, updateTypeOneDict, reset, open, title,form,formLoading) => {
@@ -22,11 +22,17 @@ const useTable = (getList, updateTypeOneDict, reset, open, title,form,formLoadin
   };
 
   // 新增按钮操作
-  const handleAdd = () => {
+  const handleAdd = (row) => {
     reset();
     updateTypeOneDict();
     open.value = true;
     title.value = "添加分类";
+    if(row){
+      form.value = {
+        ...form.value,
+        parentId: row.id
+      }
+    }
   };
 
   // 点击表格上的修改按钮
@@ -45,13 +51,12 @@ const useTable = (getList, updateTypeOneDict, reset, open, title,form,formLoadin
     open.value = true;
     formLoading.value = true;
     // 获取附件数据
-    listFileByBasisId({
+    listFileByBasisIdMulType({
       basisId: row.id,
       delFlag: '0',
-      pageSize: 65536,
       informationType: 'sc,zl'
     }).then(res=>{
-      const allFiles = (res.rows || []).map(item => ({
+      const allFiles = (res.data || []).map(item => ({
         id: item.id,
         name: item.fileName,
         url: item.filePath,

+ 13 - 11
src/views/classification/index.vue

@@ -43,25 +43,31 @@
       <el-table-column label="描述" prop="describe" />
       <el-table-column
         label="操作"
-        width="180"
+        width="220"
         align="center"
         class-name="small-padding fixed-width"
       >
         <template #default="scope">
+          <el-button
+            v-if="scope.row.parentId === 0"
+            link
+            type="primary"
+            icon="Plus"
+            @click="handleAdd(scope.row,scope)"
+            >新增</el-button
+          >
           <el-button
             link
             type="primary"
             icon="Edit"
             @click="handleUpdate(scope.row)"
-            v-hasPermi="['system:post:edit']"
             >修改</el-button
           >
           <el-button
             link
-            type="primary"
+            type="danger"
             icon="Delete"
             @click="handleDelete(scope.row)"
-            v-hasPermi="['system:post:remove']"
             >删除</el-button
           >
         </template>
@@ -85,7 +91,7 @@
         <el-form-item label="分类名称" prop="toolName">
           <el-input v-model="form.toolName" placeholder="请输入分类名称" />
         </el-form-item>
-        <el-form-item label="所属分类" prop="parentId">
+        <el-form-item v-if="form.parentId" label="所属分类" prop="parentId">
           <el-select
             v-model="form.parentId"
             placeholder="请选择"
@@ -111,7 +117,7 @@
         <el-form-item
           label="使用手册"
           prop="manualFileList"
-          v-show="form.parentId"
+          v-if="form.parentId"
         >
           <FileUpload
             v-model="form.manualFileList"
@@ -122,7 +128,7 @@
         <el-form-item
           label="附件资料"
           prop="resourceFileList"
-          v-show="form.parentId"
+          v-if="form.parentId"
         >
           <FileUpload
             v-model="form.resourceFileList"
@@ -162,10 +168,6 @@ const levelOneDict = ref([]);
 // 获取一级分类字典
 const updateTypeOneDict = () => {
   queryToolDict("1").then((data) => {
-    data.unshift({
-      id: 0,
-      label: '顶层'
-    })
     levelOneDict.value = data;
   });
 };

+ 3 - 4
src/views/material/hooks/useTable.js

@@ -1,5 +1,5 @@
 import {
-  listFileByBasisId,
+  listFileByBasisIdMulType,
   getToolDetailById,
   queryToolDict,
   toolDelete,
@@ -71,15 +71,14 @@ const useTable = (
     open.value = true;
     formLoading.value = true;
     // 获取工具对应的附件
-    listFileByBasisId({
+    listFileByBasisIdMulType({
       basisId: row.id,
       delFlag: "0",
-      pageSize: 65536,
       informationType: 'sc,zl,syt'
     })
       .then((res) => {
         // 重新修改一下字段
-        const allFiles = (res.rows || []).map((item) => ({
+        const allFiles = (res.data || []).map((item) => ({
           id: item.id,
           name: item.fileName,
           url: item.filePath,

+ 26 - 10
src/views/material/index.vue

@@ -91,9 +91,10 @@
       @selection-change="handleSelectionChange"
     >
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="工具编号" align="center" prop="id" />
       <el-table-column label="工具品种" align="center" prop="toolName" />
       <el-table-column label="工具别名" align="center" prop="aliasName" />
+      <el-table-column label="大类" align="center" prop="ancestors" :formatter="(row)=>getTypeName(row,1)"/>
+      <el-table-column label="二级分类" align="center" prop="ancestors" :formatter="(row)=>getTypeName(row,2)"/>
       <el-table-column label="规格标准说明" align="center" prop="specifications" />
       <el-table-column label="举例" align="center" prop="example" />
       <el-table-column label="描述" align="center" prop="describe" />
@@ -115,13 +116,13 @@
           <el-button
             link
             type="primary"
-            icon="Edit"
+            icon="Memo"
             @click="handlePageToToolsMaterial(scope.row)"
             >物料管理</el-button
           >
           <el-button
             link
-            type="primary"
+            type="danger"
             icon="Delete"
             @click="handleDelete(scope.row)"
             >删除</el-button
@@ -256,13 +257,6 @@ import useSearchForm from "./hooks/useSearchForm.js";
 import useSubmitForm from "./hooks/useSubmitForm.js";
 import useTable from "./hooks/useTable.js";
 
-import {
-  listPost,
-  addPost,
-  delPost,
-  getPost,
-  updatePost,
-} from "@/api/system/post";
 import { listTools, queryToolDict } from "@/api/bussiness";
 
 const { proxy } = getCurrentInstance();
@@ -294,13 +288,35 @@ const getList = (params = {}) => {
 };
 // 大类的下拉选项
 const levelOneDict = ref([]);
+const levelTowDictAll = ref([])
 // 获取大类的下拉选项
 const updateTypeOneDict = () => {
   queryToolDict("1").then((data) => {
     levelOneDict.value = data || [];
   });
 };
+
+// 获取所有二级类别
+const updateTypeTwoDictAll = () => {
+  queryToolDict("2").then((data) => {
+    levelTowDictAll.value = data || [];
+  });
+};
 updateTypeOneDict();
+updateTypeTwoDictAll();
+// 根据类型获取对应类别的中文
+const getTypeName = (row,level) => {
+  const ancestorsList = row.ancestors.split(',');
+  const targetId = ancestorsList[level];
+  let target = null;
+  if(level === 1){
+    target = levelOneDict.value.find(item => +item.id === +targetId);
+  }else {
+    target = levelTowDictAll.value.find(item => +item.id === +targetId);
+  }
+  return target ? target.label : targetId
+}
+
 // 搜索表单
 const {
   queryParams,