Explorar el Código

版本新增注册

zhuliu hace 10 meses
padre
commit
e1c0cac807

+ 30 - 0
src/utils/common.js

@@ -2,6 +2,36 @@
 import { Message } from 'element-ui'
 import Config from '@/config'
 export default {
+   /**
+   * 防抖
+   * @param {Function} func 
+   * @param {Number} duration 
+   * @returns 
+   */
+   debounce(func, duration = 500) {
+    let timer;
+    return () => {
+      clearTimeout(timer)
+      timer = setTimeout(func, duration)
+    }
+  },
+  /**
+   * 节流
+   * @param {Function} func 
+   * @param {Number} delay 
+   * @returns 
+   */
+  throttle(func, delay = 2000) {
+    let flag = true
+    return () => {
+      if (!flag) return;
+      flag = false;
+      setTimeout(() => {
+        func()
+        flag = true
+      }, delay)
+    }
+  },
   //查看文件
   getFile(guid) {
     if(!guid){

+ 3 - 1
src/utils/model/index.js

@@ -3,11 +3,13 @@
 import myInput from './input/index.vue'
 import myUpload from './upload/index.vue'
 import myTooltip from './tooltip/index.vue'
+import valueInput from './valueInput'
 
 var models = {
   myInput,
   myUpload,
-  myTooltip
+  myTooltip,
+  valueInput
 }
 export default {
   install(Vue) {

+ 34 - 0
src/utils/model/valueInput/index.vue

@@ -0,0 +1,34 @@
+<template>
+  <components :is="component" v-model="newValue" v-bind="$attrs" v-on="$listeners"></components>
+</template> 
+
+<script>
+export default {
+  components: {},
+  props: {
+    value:{
+
+    },
+    component:{
+        type:String,
+        default:"el-input"
+    }
+  },
+  data() {
+    return {
+        newValue:this.value,
+    };
+  },
+  watch: {
+    value(){
+        this.newValue = this.value
+    }
+  },
+  computed: {},
+  created() {},
+  mounted() {},
+  methods: {},
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 2 - 2
src/views/backStageManage/application/vision/components/form/function.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" label-position="left">
-      <el-form-item label="所属功能" prop="function">
+      <el-form-item label="所属功能" prop="function" v-if="ruleForm.function">
         <el-input v-model="ruleForm.last" placeholder="所属功能" :disabled="true"></el-input>
       </el-form-item>
       <el-form-item label="所属应用" prop="apply">
@@ -42,7 +42,7 @@ export default {
         ruleForm:this.form,
         rules: {
             name: [{ required: true, message: '请输入功能名称', trigger: 'blur' },],
-            apply: [{ required: true, message: '请选择所属应用', trigger: 'change' },],
+            apply: [{ required: true, message: '请选择所属应用', trigger: 'blur' },],
             sign: [{ required: true, message: '请输入功能标识', trigger: 'blur' },],
         },
     };

+ 30 - 3
src/views/backStageManage/application/vision/components/functionTable.vue

@@ -13,10 +13,11 @@
         >
             <el-table-column type="index" align="center" width="50px">
                 <template slot-scope="scope">
-                    <div>
-                        <el-checkbox-group v-model="checkList">
+                    <div v-if="reload">
+                        <!-- <el-checkbox-group v-model="checkList">
                             <el-checkbox :label="scope.row.id" @change="(value)=>changeCheck(value,scope.row)">{{ "" }}</el-checkbox>
-                        </el-checkbox-group>
+                        </el-checkbox-group> -->
+                        <value-input component="el-checkbox" :value="(scope.row.isSelect == 1 || (defaultChecked && scope.row.isSelect === undefined))?true:false"  @change="(value)=>changeCheck(value,scope.row)"></value-input>
                     </div>
                 </template>
             </el-table-column>
@@ -64,6 +65,14 @@ export default {
         loading:{
             type:Boolean,
             default:false
+        },
+        reload:{
+            type:Boolean,
+            default:true,
+        },
+        defaultChecked:{
+            type:Boolean,
+            default:false,
         }
     },
     data() {
@@ -88,6 +97,24 @@ export default {
 };
 </script>
 <style lang="scss">
+.indeterminate .el-checkbox__input .el-checkbox__inner {
+  background-color: #409eff !important;
+  border-color: #409eff !important;
+  color: #fff !important;
+}
+
+.indeterminate .el-checkbox__input.is-checked .el-checkbox__inner::after {
+  transform: scale(0.5);
+}
+
+.indeterminate .el-checkbox__input .el-checkbox__inner {
+  background-color: #f2f6fc;
+  border-color: #dcdfe6;
+}
+.indeterminate .el-checkbox__input .el-checkbox__inner::after {
+  border-color: #c0c4cc !important;
+  background-color: #c0c4cc;
+}
 .indeterminate .el-checkbox__input .el-checkbox__inner::after {
   content: "";
   position: absolute;

+ 45 - 2
src/views/backStageManage/application/vision/components/mixins/functionData.js

@@ -8,9 +8,13 @@ export default{
     data() {
         return {
             addType:'',
-            originFunction:null
+            originFunction:null,
         }
     },
+    created() {
+    },
+    mounted() {
+    },
     methods: {
         addFunction(type,form={}){
             this.addType = type
@@ -21,10 +25,49 @@ export default{
                 sign:form.sign,
                 function: form.id || 0,
                 functionType:1,
-                last:form.path == 0?form.name:(row.last+'/'+form.name)
+                last:form.path?(form.last+'/'+form.name):form.name
             }
             this.$refs.addFunctionDialog.open(ruleForm)
         },
         getNewFunction(value){},
+         //获取代码
+         getCode(row,type){
+            var data = row.functionCodes
+            if(!data || data.length == 0){
+                data = [
+                    {
+                        authType:type,
+                        code:'' 
+                    }
+                ]
+                this.$set(row,'functionCodes',data)
+                return ''
+            }
+            var obj = data.find(item=>{
+                return item.authType == type
+            })
+            if(obj){
+                return obj.code
+            }
+            return ''
+        },
+        //改变代码
+        setCodeList_code(row,value,type){
+            row.operateType = this.model == 'edit'?3:1
+            var data = row.functionCodes
+            var obj = data.find(item=>{
+                return item.authType == type
+            })
+            if(!obj){
+                obj = {
+                    authType:type,
+                    code :value
+                }
+                data.push(obj)
+                return 
+            }
+            obj.code = value
+
+        },
     },
 }

+ 25 - 14
src/views/backStageManage/application/vision/components/mixins/treeChecked.js

@@ -10,17 +10,19 @@ export default{
             
             function selectAllChildrens(data) {
                 data.forEach((item) => {
+                    // let index = that.checkList.findIndex(i =>{
+                    //     return i == item.id
+                    // })
                     if(checked){
                         that.$set(item,'isSelect',1)
-                        that.checkList.push(item.id)  
+                        // if(index == -1){
+                        //     that.checkList.push(item.id) 
+                        // }
                     }else{
-                        let index = that.checkList.findIndex(i =>{
-                            return i == item.id
-                        })
-                        if(index !=-1 ){
-                            that.$set(item,'isSelect',2)
-                            that.checkList.splice(index,1)
-                        }
+                        that.$set(item,'isSelect',2)
+                        // if(index !=-1 ){
+                        //     that.checkList.splice(index,1)
+                        // }
                     }
                     
                   if (item.children && item.children.length) {
@@ -81,20 +83,28 @@ export default{
                     })
                 ) {
                     that.$set(item,'isSelect',1)
+                    // let index = that.checkList.findIndex(i=>i == item.id)
+                    // if(index == -1){
+                    //     that.checkList.push(item.id)
+                    // }
                 } else if (
                     selectStatuaArr.every((selectItem) => {
                     return 2 == selectItem;
                     })
                 ) {
                     that.$set(item,'isSelect',2)
-                    let index = that.checkList.findIndex(i =>{
-                        return i == item.id
-                    })
-                    if(index != -1){
-                        that.checkList.splice(index,1)
-                    }
+                    // let index = that.checkList.findIndex(i =>{
+                    //     return i == item.id
+                    // })
+                    // if(index != -1){
+                    //     that.checkList.splice(index,1)
+                    // }
                 } else {
                     that.$set(item,'isSelect','')
+                    // let index = that.checkList.findIndex(i=>i == item.id)
+                    // if(index == -1){
+                    //     that.checkList.push(item.id)
+                    // }
                 }
                 //则还有父级
                 if(item.parentId!=0) {
@@ -113,6 +123,7 @@ export default{
             } else if(levelSataus == 3) {
               operateLastLeve(row);
             }
+            // this.$forceUpdate()
         },
         rowClassNameFun({ row }) {
             if (row.isSelect ==='') {

+ 0 - 134
src/views/backStageManage/application/vision/components/treeChecked.js

@@ -1,134 +0,0 @@
-export default{
-    methods: {
-        changeCheck(checked,row){
-            let that = this;
-            if(checked){
-                that.$set(row,'isSelect',1)
-            }else{
-                that.$set(row,'isSelect',2)
-            }
-            
-            function selectAllChildrens(data) {
-                data.forEach((item) => {
-                    let index = that.checkList.findIndex(i =>{
-                        return i == item.id
-                    })
-                    if(checked){
-                        that.$set(item,'isSelect',1)
-                        if(index == -1){
-                            that.checkList.push(item.id) 
-                        }
-                    }else{
-                        that.$set(item,'isSelect',2)
-                        if(index !=-1 ){
-                            that.checkList.splice(index,1)
-                        }
-                    }
-                    
-                  if (item.children && item.children.length) {
-                    selectAllChildrens(item.children);
-                  }
-                });
-            }
-    
-            function getSelectStatus(selectStatuaArr, data) {
-                data.forEach((childrenItem) => {
-                    selectStatuaArr.push(childrenItem.isSelect)
-                    if (childrenItem.children && childrenItem.children.length) {
-                        getSelectStatus(selectStatuaArr, childrenItem.children);
-                    }
-                });
-                return selectStatuaArr;
-            }
-            function getLevelStatus(row) {
-                //如果当前节点的parantId =0 并且有子节点,则为1
-                //如果当前节点的parantId !=0 并且子节点没有子节点 则为3
-                if (row.parentId == 0) {
-                    if (row.children && row.children.length) {
-                        return 1;
-                    }else{
-                        return 4;
-                    }
-                } else {
-                    if (!row.children || !row.children.length) {
-                        return 3;
-                    } else {
-                        return 2;
-                    }
-                }
-            }
-            let result = {};
-            //获取明确的节点
-            function getExplicitNode(data,parentId) {
-                for(var i = 0;i<data.length;i++){
-                    var item = data[i]
-                    if(item.id == parentId) {
-                        result = item;
-                        return result;
-                    }
-                    if(item.children && item.children.length) {
-                        getExplicitNode(item.children,parentId);
-                    }
-                }
-                return {}
-            }
-            function operateLastLeve(row) {
-                //操作的是子节点  1、获取父节点  2、判断子节点选中个数,如果全部选中则父节点设为选中状态,如果都不选中,则为不选中状态,如果部分选择,则设为不明确状态
-                let selectStatuaArr = [];
-                let item = getExplicitNode(that.tableData.children,row.parentId);
-                selectStatuaArr = getSelectStatus(selectStatuaArr, item.children);
-                if (
-                    selectStatuaArr.every((selectItem) => {
-                        return 1 == selectItem || selectItem === undefined;
-                    })
-                ) {
-                    that.$set(item,'isSelect',1)
-                    let index = that.checkList.findIndex(i=>i == item.id)
-                    if(index == -1){
-                        that.checkList.push(item.id)
-                    }
-                } else if (
-                    selectStatuaArr.every((selectItem) => {
-                    return 2 == selectItem;
-                    })
-                ) {
-                    that.$set(item,'isSelect',2)
-                    let index = that.checkList.findIndex(i =>{
-                        return i == item.id
-                    })
-                    if(index != -1){
-                        that.checkList.splice(index,1)
-                    }
-                } else {
-                    that.$set(item,'isSelect','')
-                    let index = that.checkList.findIndex(i=>i == item.id)
-                    if(index == -1){
-                        that.checkList.push(item.id)
-                    }
-                }
-                //则还有父级
-                if(item.parentId!=0) {
-                    operateLastLeve(item)
-                }
-            }
-            //判断操作的是子级点复选框还是父级点复选框,如果是父级点,则控制子级点的全选和不全选
-      
-            // 1、只是父级 2、既是子集,又是父级 3、只是子级
-            let levelSataus = getLevelStatus(row);
-            if (levelSataus == 1) {
-              selectAllChildrens(row.children);
-            } else if (levelSataus == 2) {
-              selectAllChildrens(row.children);
-              operateLastLeve(row);
-            } else if(levelSataus == 3) {
-              operateLastLeve(row);
-            }
-        },
-        rowClassNameFun({ row }) {
-            if (row.isSelect ==='') {
-              return "indeterminate";
-            }
-          },
-      
-    },
-}

+ 93 - 67
src/views/backStageManage/application/vision/components/versionForm.vue

@@ -24,18 +24,18 @@
             <div style="height: 500px;" >
                 <p style="display:flex;align-items:center;justify-content:space-between">
                     选择功能:
-                    <el-button type="primary" size="small" @click="addFunction(1,this.form)">添加功能</el-button>
+                    <el-button type="primary" size="small" @click="addFunction(1,form)">添加功能</el-button>
                 </p>
-                <funTable ref="functionTable" :applyId="form.applyId" :tableData="tableData" :loading="loading" :checkFunctions="checkFunctions">
+                <funTable ref="functionTable" :tableData="tableData" :loading="loading" :reload="reload" :defaultChecked="true">
                     <template slot="column">
                         <el-table-column label="授权代码" align="center">
                             <template slot-scope="scope">
-                                <el-input v-if="!scope.row.children || scope.row.children == 0" type="textarea" :value="getCode(scope.row.id,'code1')" @change="(val)=>setCodeList_code(scope.row.id,val,'code1')"></el-input>
+                                <value-input v-if="!scope.row.children || scope.row.children == 0" type="textarea" :value="getCode(scope.row,2)" @change="(val)=>setCodeList_code(scope.row,val,2)"></value-input>
                             </template>
                         </el-table-column>
                         <el-table-column label="代码" align="center">
                             <template slot-scope="scope">
-                                <el-input v-if="!scope.row.children || scope.row.children == 0" type="textarea" :value="getCode(scope.row.id,'code1')" @change="(val)=>setCodeList_code(scope.row.id,val,'code2')"></el-input>
+                                <value-input v-if="!scope.row.children || scope.row.children == 0" type="textarea" :value="getCode(scope.row,1)" @change="(val)=>setCodeList_code(scope.row,val,1)"></value-input>
                             </template>
                         </el-table-column>
                         <el-table-column label="操作" align="center" width="100px">
@@ -108,6 +108,7 @@ export default {
             },
             total:0,
             loading:false,
+            reload:true,
         };
     },
     watch: {
@@ -125,24 +126,10 @@ export default {
         async init(){
             if(this.model == 'add'){
                 this.resetForm()
-                await this.getList()
-                this.getFunctionId(this.tableData.children,[])
             }else if(this.model == 'edit'){
-                //查询数据并检验
                 this.getById()
             }
-        },
-        getFunctionId(data,checkData=[]){
-            for(var i = 0;i<data.length;i++){
-                checkData.push(data[i].id)
-                if(data[i].children && data[i].children.length>0){
-                    this.getFunctionId(data[i].children,checkData)
-                }
-            }
-            this.checkFunctions = checkData
-            this.$nextTick(()=>{
-                this.checkFunctions_back_up = [...checkData]
-            })
+            await this.getList()
         },
         //查询数据并校验
         getById(){
@@ -156,53 +143,36 @@ export default {
             this.$api.getVersionById(params).then(response=>{
                 if(response.code == 200){
                     this.form = response.data.records
-                    this.getList()
-                    this.getCodeList()
                 }
             }).catch(error=>{
                 this.resetForm()
             })
         },
-        //获取代码集合
-        getCodeList(){
-            if(!this.form.id){
-                return 
-            }
-            this.codeList = []
-        },
-        //获取代码
-        getCode(funId,field){
-            var index = this.codeList.findIndex(item=>{
-                return item.id == funId
-            })
-            if(index!=-1){
-                return this.codeList[index][field]
-            }
-            return ''
-        },
-        //改变代码
-        setCodeList_code(funId,value,field){
-            var index1 = this.checkFunctions.indexOf(funId)
-            if(index1 ==-1){
-                this.checkFunctions.push(funId)
-            }
-            var index = this.codeList.findIndex(item=>{
-                return item.id == funId
-            })
-            if(index!=-1){
-                this.codeList[index][field] = value
-            }else{
-                var obj = {
-                    id:funId,
-                }
-                obj[field] = value
-                this.codeList.push(obj)
-            }
-        },
         //重置表单
         resetForm(){
             this.form = Object.assign({}, currentForm)
             this.$refs['form'].resetFields();
+            this.reload = false
+            this.$nextTick(()=>{
+                this.reload = true
+            })
+        },
+        //获取所有的功能及代码
+        getAllFunCode(data,funCode){
+            for(var i = 0;i<data.length;i++){
+                if(data[i].isSelect != 2){
+                    funCode.push(
+                        {
+                            functionId:data[i].id,
+                            operateType:data[i].operateType,
+                            functionCodes:data[i].functionCodes
+                        }
+                    )
+                }
+                if(data[i].children && data[i].children.length){
+                    this.getAllFunCode(data[i].children,funCode)
+                }
+            }
         },
         /** 提交按钮 */
         submitForm: function() {
@@ -213,10 +183,9 @@ export default {
                         return
                     }
                     this.form.fileGuid = fileGuids.length>0?fileGuids[0]:''
-                    this.form.assoFunctionCodeDTO = this.codeList.filter(item=>{
-                        return this.checkFunctions.indexOf(item.id) != -1
-                    })
-
+                    var assoFunctionCodeDTO = []
+                    this.getAllFunCode(this.tableData.children,assoFunctionCodeDTO)
+                    this.form.assoFunctionCodeDTO = assoFunctionCodeDTO
                     this.btnLoading = true
                     var a = '添加'
                     var api = 'addVersion'
@@ -241,8 +210,7 @@ export default {
         finish(){
             if(this.model == 'add'){
                 this.resetForm();
-                this.checkFunctions_back_up = [...this.checkFunctions]
-                this.codeList = []
+                this.init()
             }else{
                 this.$store.commit('removeHistoryPath',this.$route.path);
                 this.$store.commit('removeHistory',this.$route.path);
@@ -288,6 +256,9 @@ export default {
                 return false
             }
             this.queryParams.apply = this.form.applyId
+            if(this.model == 'edit'){
+                this.queryParams.versonId = 1
+            }
             this.loading = true
             await this.$api.queryFunctionList(this.queryParams).then(response => {
                 this.tableData = response.data
@@ -314,11 +285,66 @@ export default {
                 this.loading = true
             })
         },
+       
+
+
+        /**
+         * 无用代码
+         * @param {*} val 
+         */
         //切换分页
-        handleCurrentChange(val){
-            this.queryParams.current = val
-            this.getList()
-        }
+        // handleCurrentChange(val){
+        //     this.queryParams.current = val
+        //     this.getList()
+        // },
+        // getFunctionId(data,checkData=[]){
+        //     for(var i = 0;i<data.length;i++){
+        //         checkData.push(data[i].id)
+        //         if(data[i].children && data[i].children.length>0){
+        //             this.getFunctionId(data[i].children,checkData)
+        //         }
+        //     }
+        //     this.checkFunctions = checkData
+        //     this.$nextTick(()=>{
+        //         this.checkFunctions_back_up = [...checkData]
+        //     })
+        // },
+        // //获取代码集合
+        // getCodeList(){
+        //     if(!this.form.id){
+        //         return 
+        //     }
+        //     this.codeList = []
+        // },
+        // //获取代码
+        // getCode(funId,field){
+        //     var index = this.codeList.findIndex(item=>{
+        //         return item.id == funId
+        //     })
+        //     if(index!=-1){
+        //         return this.codeList[index][field]
+        //     }
+        //     return ''
+        // },
+        // //改变代码
+        // setCodeList_code(funId,value,field){
+        //     var index1 = this.checkFunctions.indexOf(funId)
+        //     if(index1 ==-1){
+        //         this.checkFunctions.push(funId)
+        //     }
+        //     var index = this.codeList.findIndex(item=>{
+        //         return item.id == funId
+        //     })
+        //     if(index!=-1){
+        //         this.codeList[index][field] = value
+        //     }else{
+        //         var obj = {
+        //             id:funId,
+        //         }
+        //         obj[field] = value
+        //         this.codeList.push(obj)
+        //     }
+        // },
     },
 };
 </script>