|
@@ -7,21 +7,20 @@
|
|
|
<div>
|
|
|
<div v-if="subId">
|
|
|
<div style="height: calc(100vh - 22rem)">
|
|
|
- <dg-scrollbar>
|
|
|
+ <dg-scrollbar :key="key">
|
|
|
<set-auth-tree
|
|
|
+ :ref="'authTree_'+index"
|
|
|
:tab="tab"
|
|
|
v-for="(item, index) in authData"
|
|
|
:key="index"
|
|
|
:treeData="item"
|
|
|
+ :reactTree="reactTree"
|
|
|
@getSelectNodes="getSelectNodes"
|
|
|
+ @checkChange="checkChange"
|
|
|
></set-auth-tree>
|
|
|
</dg-scrollbar>
|
|
|
</div>
|
|
|
- <el-row class="property-wapper__right-btn">
|
|
|
- <!-- <el-button @click="handleViewAuthList" v-if="showCheckListBtn">清单</el-button> -->
|
|
|
- <dg-button @click="handleReset" :icon="'重置' | optIcon">重置</dg-button>
|
|
|
- <dg-button type="primary" @click="handleSave" :icon="'保存' | optIcon">保存</dg-button>
|
|
|
- </el-row>
|
|
|
+
|
|
|
</div>
|
|
|
<div v-else>
|
|
|
<p v-if="subType == 'BUSINESS'">请选择标签。</p>
|
|
@@ -41,7 +40,9 @@ export default {
|
|
|
subId: String,
|
|
|
subType: String,
|
|
|
saveApi: String,
|
|
|
- tab: String
|
|
|
+ tab: String,
|
|
|
+ reactTree:Boolean,
|
|
|
+ singleAuthData: Array
|
|
|
},
|
|
|
components: {
|
|
|
setAuthTree
|
|
@@ -51,9 +52,39 @@ export default {
|
|
|
authData: [],
|
|
|
showCheckListBtn: false,
|
|
|
saveAuthVoList: {},
|
|
|
+ key:0
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
+ watch: {
|
|
|
+ singleAuthData: {
|
|
|
+ deep: true,
|
|
|
+ handler(val) {
|
|
|
+ if (this.reactTree) {
|
|
|
+ let _authData = this.$lodash.cloneDeep(this.authData);
|
|
|
+ for (let i = 0; i < val.length; i++) {
|
|
|
+ const { id, tickedDatas } = val[i];
|
|
|
+ for (let j = 0; j < _authData.length; j++) {
|
|
|
+ let element = _authData[j];
|
|
|
+ if (element.id == id) {
|
|
|
+ element.selectNodes = tickedDatas.map((item) => {
|
|
|
+ const { dataId, dataType, dataCode, classifyCode } = item;
|
|
|
+ return {
|
|
|
+ dataId,
|
|
|
+ classifyCode,
|
|
|
+ dataCode
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.authData = _authData;
|
|
|
+ this.key++
|
|
|
+ console.log("authData",this.authData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleViewAuthList() {
|
|
|
const vm = this;
|
|
@@ -86,48 +117,45 @@ export default {
|
|
|
/**
|
|
|
* @description: 保存授权
|
|
|
*/
|
|
|
- handleSave() {
|
|
|
- let key = "";
|
|
|
- if (this.subType == "BUSINESS") {
|
|
|
- // 业务域
|
|
|
- key = "businessCode";
|
|
|
- } else if (this.subType == "ORG") {
|
|
|
- // 机构
|
|
|
- key = "orgCode";
|
|
|
- } else {
|
|
|
- // 人员
|
|
|
- key = "idcard";
|
|
|
- }
|
|
|
-
|
|
|
+ handleSave() {
|
|
|
// 保存的树节点
|
|
|
- let authVoList = [];
|
|
|
- for (const key in this.saveAuthVoList) {
|
|
|
- const element = this.saveAuthVoList[key];
|
|
|
- authVoList = [...authVoList, ...element];
|
|
|
- }
|
|
|
- // 数组去重
|
|
|
- let obj = {};
|
|
|
- const _authVoList = authVoList.reduce((cur, next) => {
|
|
|
- obj[next.dataId] ? "" : (obj[next.dataId] = true && cur.push(next));
|
|
|
- return cur;
|
|
|
- }, []);
|
|
|
+ // let authVoList = [];
|
|
|
+ // for (const key in this.saveAuthVoList) {
|
|
|
+ // const element = this.saveAuthVoList[key];
|
|
|
+ // authVoList = [...authVoList, ...element];
|
|
|
+ // }
|
|
|
+ // // 数组去重
|
|
|
+ // let obj = {};
|
|
|
+ // const _authVoList = authVoList.reduce((cur, next) => {
|
|
|
+ // obj[next.dataId] ? "" : (obj[next.dataId] = true && cur.push(next));
|
|
|
+ // return cur;
|
|
|
+ // }, []);
|
|
|
|
|
|
- let params = {
|
|
|
- authType: this.tab,
|
|
|
- authVoList: _authVoList
|
|
|
- };
|
|
|
- params[key] = this.subId;
|
|
|
- console.log("保存的参数", params);
|
|
|
+ // return _authVoList
|
|
|
+ let attr = []
|
|
|
+ for (let i = 0; i < this.authData.length; i++) {
|
|
|
+ const selectNode = this.$refs['authTree_'+i][0].$refs.authTree.getCheckedNodes(true);
|
|
|
+ attr = [...attr, ...selectNode]
|
|
|
+ }
|
|
|
+ console.log("attr",attr)
|
|
|
|
|
|
- api[this.saveApi](params).then((res) => {
|
|
|
- this.$message.success("保存成功!");
|
|
|
- });
|
|
|
+ return attr.map(item => {
|
|
|
+ return {
|
|
|
+ dataId: item.id,
|
|
|
+ dataCode: item.code,
|
|
|
+ classifyCode: item.classifyCode
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
|
|
|
// 获取勾选的节点
|
|
|
getSelectNodes({ type, selectNodes }) {
|
|
|
this.saveAuthVoList[type] = selectNodes;
|
|
|
},
|
|
|
+ checkChange(vo) {
|
|
|
+ this.$emit("checkChange", vo)
|
|
|
+ },
|
|
|
// 查询单个主体相关数据权限
|
|
|
getSubDataAuth() {
|
|
|
return new Promise((resolve) => {
|
|
@@ -162,10 +190,11 @@ export default {
|
|
|
let element = authTree[j];
|
|
|
if (element.id == id) {
|
|
|
this.saveAuthVoList[id] = element.selectNodes = tickedDatas.map((item) => {
|
|
|
- const { dataId, dataType } = item;
|
|
|
+ const { dataId, dataType, dataCode, classifyCode } = item;
|
|
|
return {
|
|
|
dataId,
|
|
|
- dataType
|
|
|
+ classifyCode,
|
|
|
+ dataCode
|
|
|
};
|
|
|
});
|
|
|
}
|
|
@@ -174,6 +203,7 @@ export default {
|
|
|
} else {
|
|
|
this.showCheckListBtn = false;
|
|
|
}
|
|
|
+ console.log("saveAuthVoList", this.saveAuthVoList);
|
|
|
this.authData = authTree;
|
|
|
}
|
|
|
}
|