|
@@ -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>
|