Prechádzať zdrojové kódy

Merge branch 'product' of http://1.116.113.26:8088/zhuliu/xiaoshi_system into product

zhuliu 1 rok pred
rodič
commit
3dc03ae6d9

+ 2 - 0
src/api/index.js

@@ -27,6 +27,7 @@ import InvalidResponse from "./InvalidResponse";
 // 新系统新接口文件
 import event from "./newApi/event";
 import product from "./newApi/product";
+import framework from "./newApi/framework";
 
 export default {
   ...report,
@@ -54,4 +55,5 @@ export default {
 
   ...event,
   ...product,
+  ...framework,
 }

+ 3 - 3
src/api/newApi/event.js

@@ -23,9 +23,9 @@ export default {
   /**
   * 修改事件
   */
-  // eventUpdate(data) {
-  //  return axios.post('/v2/event/update', data)
-  // },
+  updateEvent(data) {
+   return axios.post('/xiaoshi/event/updateEvent', data)
+  },
   /**
   * 删除事件
   */

+ 10 - 0
src/api/newApi/framework.js

@@ -0,0 +1,10 @@
+import axios from '@/utils/axios'
+// 新系统架构新接口
+export default {
+  /**
+  * 新增架构
+  */
+  addTreeNode(data) {
+    return axios.post('/xiaoshi/treeNode/addTreeNode', data)
+  },
+}

+ 8 - 10
src/views/event/components/dialog/addEvent.vue

@@ -12,9 +12,8 @@
             </el-autocomplete>
           </el-form-item>
           <el-form-item label="所属客户" prop="clientId" v-if="userinfo.tenantType == 1" >
-          <!-- <el-form-item label="所属客户" prop="clientId"> -->
             <!-- <el-select v-model="formData[0].clientId" :disabled="(formData[0].id && !this.row) ? true : false" -->
-            <el-select v-model="formData[0].clientId" clearable
+            <el-select ref="select" v-model="formData[0].clientId" clearable
               style="width: 100%;" placeholder="请选择客户">
               <el-option
                 v-for="item in clientList"
@@ -35,7 +34,7 @@
           </el-form-item>
           <el-form-item label="事件场景" prop="scenarioId">
             <!-- <el-select v-model="formData[0].applicationScenarios[0]" :disabled="(formData[0].id && !this.row) ? true : false" -->
-            <el-select v-model="formData[0].scenarioId" 
+            <el-select ref="select2" v-model="formData[0].scenarioId" 
               style="width: 100%;" placeholder="请选择事件场景">
               <el-option
                 v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
@@ -191,9 +190,7 @@ export default {
       this.type = type
       if (data) {
         this.title = '编辑事件'
-        let form = JSON.parse(JSON.stringify(data))
-        this.$set(this.formData, 0, form)
-        // console.log(this.formData);
+        this.$set(this.formData, 0, data)
       } else {
         if (this.type == 1) {
           this.title='新增事件'
@@ -213,8 +210,9 @@ export default {
     },
     //关闭弹窗
     handleClose() {
-      if (this.type=='1') {
-        console.log(this.type);
+      if (this.type == '1') {
+        this.$refs.select.blur()
+        this.$refs.select2.blur()
         this.$refs.ruleForm.resetFields()
       }
       this.dialogVisible = false
@@ -285,11 +283,12 @@ export default {
     },
     //提交保存、编辑事件接口
     addInterface(forms) {
+      this.$emit('isAddEdit',forms)
       let formData = new FormData()
       // formData.append('file')//文件数据
       formData.append('event', JSON.stringify(forms[0]))
       if (forms[0].id) {//编辑
-        this.$api.eventEditEvent(formData).then(res => {
+        this.$api.updateEvent(formData).then(res => {
           if (res.code == 200) {
             this.$emit('isSuccess','编辑成功')
             this.$message.success('事件编辑成功')
@@ -372,7 +371,6 @@ export default {
     async querySearchQuestion(queryString, cb) {
       this.eventInput=queryString
       await this.questionEventList()
-      console.log(this.questionNameArr, cb);
       var records=[]
       this.questionNameArr.forEach(item => {
         item.value = item.name

+ 24 - 8
src/views/event/components/index.vue

@@ -48,6 +48,9 @@
             :groupBy='groupingValue'
             :groupingOption="groupingOption"
             :searchOption="searchOption"
+            :addEditData="addEditData"
+            :deleData="deleData"
+            @getData="getData"
           ></component>
         </div>
       </el-main>
@@ -65,7 +68,7 @@
       </el-footer>
     </el-container>
 
-    <addEvent ref="addEvent"  @isSuccess="handleSuccess"></addEvent>
+    <addEvent ref="addEvent"  @isSuccess="handleSuccess" @isAddEdit="isAddEdit"></addEvent>
     <fields ref="field"></fields>
   </div>
 </template>
@@ -126,7 +129,11 @@ export default {
       //场景
       scene:[],
       //表格全部栏位
-      fieldList:[],
+      fieldList: [],
+      // 分组时新增或编辑事件数组
+      addEditData: [],
+      // 分组时删除事件数组
+      deleData:[],
     };
   },
   watch: {},
@@ -145,13 +152,19 @@ export default {
         this.scene = response.data.ENTERPRISE_APPLICATION_SCENARIO  
       })
     },
+    // 分组时若删除当前分组最后一条数据时重新请求分组接口
+    getData(val) {
+      this.getGrouping()
+    },
+    // 子组件新增事件、编辑事件成功往孙组件table发送数据
+    isAddEdit(val) {
+      this.addEditData=val
+    },
     // 子组件新增事件成功
     handleSuccess(val) {
-      // console.log(val);
       this.queryParams.current = 1
       this.searchOption.searchQuery=''
       this.getList()
-      // this.isGrouping()
     },
     //显示视图?
     showViews() {
@@ -229,7 +242,9 @@ export default {
       this.$api.queryEvent(params).then(res => {
         if (res.code == 200) {
           this.tableData = res.data.data
-          this.total=res.data.total
+          if (!this.groupingValue) {
+            this.total=res.data.total
+          }
         }
       }).catch(err => {
         this.tableData = []
@@ -284,12 +299,11 @@ export default {
           this.$refs.field.open(this.fieldList)
           break;
       }
-      
     },
 
     //获取排序字段// 子组件table排序
     handleSort({ column, prop, order, str }) {
-      this.sort=[]
+      this.sort=[]//如需要多个字段排序,则不需要清空
       if (order == 'null') {
         return;
       }
@@ -336,19 +350,21 @@ export default {
           break;
         case 'cancel'://取消关联
           break;
-        case 'edit'://编辑事件,打开单件事件弹窗
+        case 'edit'://编辑事件,打开单件事件弹窗,1代表单个事件弹窗
           this.$refs.addEvent.open(row, 1)
           break;
       }
     },
     // 删除事件
     eventDelete(row) {
+      this.deleData=[]
       this.$confirm('此操作将删除该事件, 是否继续?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
         // 调用接口
+        this.deleData.push(row)
         let params = [ row.id ]
         this.$api.deleteEvent(params).then(res => {
           if (res.code == 200) {

+ 0 - 1
src/views/event/components/mixins/index.js

@@ -57,7 +57,6 @@ export default {
   methods: {
     // 点击名称等事件
     handleItem(row, key) {
-      // console.log(row,key);
       let path = {}
       let router=this.$router.resolve({
         path: '',

+ 10 - 2
src/views/event/components/view/mergeTable.vue

@@ -4,7 +4,7 @@
       <el-table-column type="expand">
         <template slot-scope="props">
           <div style="padding: 10px;height: 340px;">
-            <Table  :column="column"  @option="handleOption" :row="{row:props.row,groupBy:groupBy,searchOption:searchOption}"/>
+            <Table  :column="column"  @option="handleOption" :row="{row:props.row,groupBy:groupBy,searchOption:searchOption,}" :addEditData="addEditData" :deleData="deleData" @getData="getData"/>
           </div>
         </template>
       </el-table-column>
@@ -25,6 +25,10 @@ import Table from "./table";
 
 export default {
   props: {
+    // 分组时删除事件数组
+    deleData:Array,
+    // 分组时新增或编辑事件数组
+    addEditData:Array,
     // 检索条件
     searchOption: {
       type: Object,
@@ -112,6 +116,10 @@ export default {
     
   },
   methods: {
+    // 分组时若删除当前分组最后一条数据时重新请求分组接口
+    getData(val) {
+      this.$emit('getData',val)
+    },
     // 排序
     sortChange({ column, prop, order }) {
       let str='1'
@@ -123,7 +131,7 @@ export default {
     },
     //打开展开行获取数据并保存起来
     expandChange(row, expandedRows) {
-      
+
     }
   }
 }

+ 34 - 18
src/views/event/components/view/table.vue

@@ -106,7 +106,9 @@ export default {
         ]
       }
     },
-    row: null
+    row: null,
+    editData:null,
+    addEditData:null,
   },
   data() {
     return {
@@ -125,14 +127,35 @@ export default {
     };
   },
   watch: {
-
+    // 分组时新增或编辑事件处理
+    'addEditData'(val) {
+      let a = this.tableData.findIndex(item => {
+        return item.id == val[0].id
+      })
+      if (a != -1) {
+        this.$set(this.tableData,[a],val[0])
+      } else {
+        this.$set(this.tableData, [this.tableData.length], val[0])
+      }
+    },
+    'deleData'(val) {
+      let a = this.tableData.findIndex(item => {
+        return item.id == val[0].id
+      })
+      if (a != -1) {
+        this.tableData.splice(a, 1)
+        // 分组时若删除当前分组最后一条数据时重新请求分组接口
+        if (this.tableData.length==0) {
+          this.$emit('getData',true)
+        }
+      }
+    },
   },
   mounted() {
     if (!this.row) {
       this.disabled = true
     } else {
       this.disabled = false
-      // this.getList()
     }
   },
   methods: {
@@ -140,21 +163,14 @@ export default {
       if (!this.row) return;
       if (this.params.current * this.params.size >= this.params.total) {
         this.isMore = true
-        if (!this.row.searchOption) {
-          this.disabled = true
-        }
+        this.disabled = true
         setTimeout(() => {
           this.isMore = false;
           this.isFlag = false
         }, 1000)
       }
       if (this.disabled) return;
-      if (!this.row.searchOption) {
-        this.params.current += 1
-      } else {
-        this.params.current = 1
-        this.tableData=[]
-      }
+      this.params.current += 1
       let params = {
         ...this.params,
         ...this.row.searchOption,//检索条件
@@ -166,14 +182,12 @@ export default {
       this.isFlag = true;
       this.$api.queryEvent(params).then(res => {
         if (res.code == 200) {
-          this.tableData = this.tableData.concat(res.data.data)
+          this.tableData.push(...res.data.data)
           this.params.total = res.data.total
         }
       }).catch(err => {
-        this.tableData = []
       })
       setTimeout(() => {
-
         this.isMore = false;
         this.isFlag = false
       }, 1000)
@@ -185,6 +199,7 @@ export default {
     },
     // 排序方法
     handleSort({ column, prop, order }) {
+      this.sort=[]//如需要多个字段排序,则不需要清空
       if (order == 'null') {
         return;
       }
@@ -203,7 +218,9 @@ export default {
         params.orderType = orderType[order]
         this.sort.push(params)
       }
-      this.getList()
+      this.params.current = 0
+      this.disabled = false
+      this.tableData.splice(0)
     },
     // 数据处理
     getColumnData(row, key) {
@@ -213,8 +230,7 @@ export default {
         } else {
           return '--'
         }
-      }
-      else if (key == 'eventDate') {
+      }else if (key == 'eventDate') {
         if (row.eventDate) {
           return row.eventDate.slice(0, 10)
         } else {

+ 62 - 23
src/views/product/components/dialog/classifyNode.vue

@@ -1,18 +1,18 @@
 <template>
-  <!-- 新增/编辑分类节点 -->
+  <!-- 新增/编辑架构分类节点 -->
   <div class="classifyNode">
     <el-dialog :title="title" :visible.sync="dialogVisible" :before-close="handleClose" width="600px" :close-on-click-modal="false">
       <el-form :model="form" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
-        <el-form-item label="所属产品名称" prop="productName">
-          <el-input v-model="form.productName" disabled placeholder="请输入所属产品名称"></el-input>
+        <el-form-item label="所属产品名称" prop="name">
+          <el-input v-model="form.name" disabled placeholder="请输入所属产品名称"></el-input>
         </el-form-item>
-        <el-form-item label="所属架构" prop="parentPath">
-          <el-select v-model="value" placeholder="请输入所属产品架构" :disabled="form.isAppend==1" style="width: 100%;">
+        <el-form-item label="所属架构" >
+          <el-select v-model="form.parent_id" placeholder="请输入所属产品架构" style="width: 100%;">
             <el-option
               v-for="item in options"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
+              :key="item.parent_id"
+              :label="item.path"
+              :value="item.parent_id">
             </el-option>
           </el-select>
         </el-form-item>
@@ -50,6 +50,9 @@
 
 <script>
 export default {
+  props: {
+    treeDataPath:Array
+  },
   data() {
     return {
       // 分类节点弹窗title
@@ -58,46 +61,80 @@ export default {
       dialogVisible: false,
       // 分类节点表单数据
       form: {},
+      // 文件数组
+      file:[],
       // 分类节点表单字段校验
       rules: {
-        productName: [ { required: true, message: '请输入所属产品名称', trigger: 'blur' },],
+        name: [ { required: true, message: '请输入所属产品名称', trigger: 'blur' },],
         classifyName: [ { required: true, message: '请输入产品架构名称', trigger: 'blur' },],
       },
       // 所属架构选择的数据源
-      options: [],
-      // 所属架构选择的值
-      value:'/',
+      options: [
+        {parent_id:0,path:'/'}
+      ],
     }
   },
   mounted() {
 
   },
   methods: {
-    open(row) {
-      this.form=JSON.parse(JSON.stringify(row))
-      if (this.form.isAppend == 1) {
-        this.title='新增产品架构'
+    open(data, productName) {
+      if (data) {
+        this.form = JSON.parse(JSON.stringify(data))
+        this.title = '编辑产品架构'
         if (this.form.pathName) {
           this.value=this.form.pathName
-        } else {
-          this.value='/'
-        }
+        } 
       } else {
-        this.title = '编辑产品架构'
+        this.title='新增产品架构'
         if (this.form.pathName) {
           this.value=this.form.pathName
-        } 
-        // this.options=路径数据
+        } else {
+          this.form.parent_id=0
+        }
       }
+      // this.options=this.treeDataPath
+      this.form.name = productName
+      // console.log(this.form,productName);
       this.dialogVisible=true
     },
     // 图片变化的change事件
-    handleChange(){},
+    handleChange() {
+      this.$set(this.form,'pictures', [{url:file.url}])
+      this.file=[file.raw]
+    },
     // 弹窗确定提交 
     submit() { 
+     
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
+          let formData = new FormData()
+          if (this.file.length>0) {
+            formData.append('files',this.file)
+          }
+          this.form.type = 1//类型:1产品类别,2产品,3技术分类,4自定义树
+          let arr=this.options.filter(item => {
+            return item.parent_id == this.form.parent_id
+          })
+          this.form.path = arr[0].path
+          console.log(this.form);
+          formData.append('productCategory', JSON.stringify(this.form))
+          // return
+          if (this.form.id) {// 编辑
+            this.$api.edit(formData).then(res => {
+              if (res.code == 200) {
+                this.$message.success('编辑成功')
+              }
+            })
+          } else {//新增
+            this.$api.addTreeNode(formData).then(res => {
+              if (res.code == 200) {
+                this.$message.success('新增成功')
+              }
+            })
+          }
           this.handleClose()
+
         } else {
           
         }
@@ -105,6 +142,8 @@ export default {
     },
     // 关闭
     handleClose() {
+      this.$refs.ruleForm.resetFields()
+      this.form={}
       this.dialogVisible=false
     },
   },

+ 17 - 1
src/views/product/components/framework/index.vue

@@ -1,7 +1,7 @@
 <template>
   <!-- 架构 -->
   <div>
-    <viewIndex style="height: 100%;"></viewIndex>
+    <viewIndex style="height: 100%;" :row="row"></viewIndex>
   </div>
 </template>
 
@@ -11,6 +11,22 @@ export default {
   components: {
     viewIndex
   },
+  data() {
+    return {
+      
+    }
+  },
+  computed: {
+    row() {
+      return JSON.parse(this.$route.query.row)
+    },
+  },
+  mounted() {
+    
+  },
+  methods: {
+    
+  },
 }
 </script>
 

+ 98 - 17
src/views/product/components/framework/viewIndex.vue

@@ -1,11 +1,10 @@
 <template>
   <!-- 架构主页面 -->
   <div class="framework">
-
     <el-container>
       <el-header>
         <div>
-          <p style="margin-left: 10px;">产品名称:Header</p>
+          <p style="margin-left: 10px;">产品名称:{{ row.productName }}</p>
         </div>
       </el-header>
       <el-container>
@@ -16,7 +15,7 @@
             <el-button type="primary" size="small" @click="handleAppend">新增分类节点</el-button>
           </div>
           <div>
-            <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick">
+            <el-tree ref="tree" :data="treeData" :props="defaultProps" @node-click="handleNodeClick" :default-expanded-keys="expandedKeys">
               <!-- <el-tree ref="tree" :data="treeData" :props="treeProps" :current-node-key="parentId" @node-click="handleNodeClick" node-key="id" :default-checked-keys="expandedKeys" :highlight-current="true" :default-expanded-keys="expandedKeys" :expand-on-click-node="false"> -->
               <span class="custom-tree-node" slot-scope="{ node, data }">
                 <span>{{ node.label }}</span>
@@ -58,7 +57,7 @@
       </el-container>
     </el-container>
 
-    <classifyNode ref="classifyNode"></classifyNode>
+    <classifyNode ref="classifyNode" :treeDataPath="treeDataPath"></classifyNode>
   </div>
 </template>
 
@@ -66,6 +65,9 @@
 import frameworkTable from './view/table.vue'
 import classifyNode from '../dialog/classifyNode.vue';
 export default {
+  props: {
+    row:Object,
+  },
   components: {
     frameworkTable,
     classifyNode
@@ -170,10 +172,13 @@ export default {
         }
 
       ],
+      // 树形组件的显示及其子级
       defaultProps: {
         children: 'children',
         label: 'structureName'
       },
+      // 架构路径数组
+      treeDataPath:[],
       // 查询架构表格数据字段
       queryParams: {
         current: 1,
@@ -209,57 +214,133 @@ export default {
           "createTime": "2023-05-11 17:28:06"
         }
       ],
+      expandedKeys:[],
     }
   },
   mounted() {
-
+    // 请求数据(左侧tree)
+    // this.getList()
+    // 请求架构路径
+    // this.getPath()
   },
   methods: {
+    handleNode() {//请求新数据后保持刷新前所点击的节点高亮并展开
+      this.expandedKeys = []
+      if (sessionStorage.getItem('parentId')) {
+        this.parentId = JSON.parse(sessionStorage.getItem('parentId'))
+        this.expandedKeys.push(this.parentId)
+        this.$nextTick(() => {
+          this.$refs.tree.setCurrentKey(this.parentId)
+          this.queryParams.structureId = this.parentId
+          this.getList()
+        })
+      }
+    },
     // 子组件传来的值
     handleOption({ val, row }) {
       console.log(val, row);
       switch (val) {
         case '0'://编辑
-          row.isAppend=2
-          this.$refs.classifyNode.open(row)
+          this.$refs.classifyNode.open(row,this.row.productName)
+          break;
+        case '1'://预览图片
+          
+          break;
+        case '2'://删除
+          this.deleNode(row)
           break;
       
         default:
           break;
       }
     },
+    // 删除
+    deleNode(row) {
+      this.$confirm('此操作将删除当前节点及其下属节点, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        // 调用接口
+        this.deleData.push(row)
+        let params = [ row.id ]
+        this.$api.deleteEvent(params).then(res => {
+          if (res.code == 200) {
+            this.getList()
+            this.$message.success('删除该当前分类节点及所属子级分类节点成功!');
+          }
+        })
+      }).catch(() => {
+        this.$message.info('已取消删除');
+      });
+    },
     // 按钮新增分类节点/树节点新增
     handleAppend() {
-      this.$refs.classifyNode.open({isAppend:1})
+      // console.log(this.row);
+      this.$refs.classifyNode.open(null,this.row.productName)
     },
     // 根据产品名称查询产品
     handleQuery() {
-      
+      this.getList()
     },
+    // 树节点上的新增
     append(data, node) {
-      data.isAppend = 1
-      this.$refs.classifyNode.open(data)
+      this.$refs.classifyNode.open(data,this.row.productName)
       // console.log(data, node);
     },
-    // 树节点编辑
+    // 树节点上的编辑
     edit(data, node) {
-      data.isAppend = 2
-      this.$refs.classifyNode.open(data)
+      this.$refs.classifyNode.open(data,this.row.productName)
       // console.log(data, node);
     },
-    // 树节点删除
+    // 树节点上的删除
     remove(data, node) {
+      this.deleNode(data)
       // console.log(data, node);
     },
     // 树节点点击事件
     handleNodeClick(data, node) { 
       // console.log(data, node);
       if (data.children && data.children.length>0) {
-        this.tableData=data.children
+        this.tableData = data.children
+        this.handleCurrent(data.children)
       }
     },
+    // 请求数据(tree)
+    getList() {
+      let params = {
+        productName:this.productName,//事件名称
+      }
+      this.$api.queryList(params).then(res => {
+        if (res.code == 200 ) {
+          this.treeData = res.data
+          this.tableData = res.data.children
+          this.handleCurrent(res.data.children)
+        }
+      })
+    },
+    // 请求架构路径
+    getPath() {
+      let params = {
+        
+      }
+      this.$api.path(params).then(res => {
+        if (res.code == 200 ) {
+          this.treeDataPath = res.data
+        }
+      })
+    },
     // 分页
-    handleCurrentChange(val) { },
+    handleCurrentChange(val) { 
+      this.queryParams.current = val;
+    },
+    // 分页处理
+    handleCurrent(nodeData) {
+      this.total=nodeData.length
+      let start = this.queryParams.size * (this.queryParams.current - 1)
+      let end =this.queryParams.size * this.queryParams.current
+      this.tableData = nodeData.slice(start, end)
+    },
   },
 }
 </script>

+ 1 - 1
src/views/product/components/view/categoryTable.vue

@@ -125,7 +125,7 @@ export default {
       let router = this.$router.resolve({
         path: '/frameworkIndex',
         query: {
-          
+          row:JSON.stringify(row)
         }
       })
       window.open(router.href,'_blank')