123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <div>
- <div v-if="subId">
- <div style="height: calc(100vh - 22rem)">
- <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>
-
- </div>
- <div v-else>
- <p v-if="subType == 'BUSINESS'">请选择标签。</p>
- <p v-else-if="subType == 'ORG'">请选择机构。</p>
- <p v-else>请选择人员。</p>
- </div>
- </div>
- </template>
- <script>
- import * as api from "@/api/data-auth.js";
- import setAuthTree from "./set-auth-tree";
- import checkList from "./check-list";
- export default {
- props: {
- subId: String,
- subType: String,
- saveApi: String,
- tab: String,
- reactTree:Boolean,
- singleAuthData: Array
- },
- components: {
- setAuthTree
- },
- data() {
- return {
- 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;
- const layer = this.$dgLayer({
- title: "授权清单",
- content: checkList,
- props: {
- type: vm.tab,
- authTree: vm.authTree
- },
- on: {
- success(params) {
- layer.close(layer.dialogIndex);
- }
- },
- cancel: function (index, layero) {
-
- layer.close(index);
- return false;
- },
- area: ["1150px", "850px"]
- });
- },
-
- handleReset() {
- this.$emit("submitReset", this.tab)
- },
-
- handleSave() {
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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)
- 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) => {
- const { subId, subType } = this;
- const params = {
- authType: this.tab,
- subId,
- subType
- };
- api.getSubDataAuth(params).then((res) => {
- resolve(res.data.content);
- });
- });
- },
- getAllDataTree() {
-
- return new Promise((resolve) => {
- api.getAllDataTree({ attrType: this.tab }).then((res) => {
- resolve(res.data.content);
- });
- });
- },
- async initAuthTree() {
- if (this.subId) {
- const singleAuthData = await this.getSubDataAuth();
- let authTree = await this.getAllDataTree();
- if (singleAuthData.length > 0) {
- this.showCheckListBtn = true;
- for (let i = 0; i < singleAuthData.length; i++) {
- const { id, tickedDatas } = singleAuthData[i];
- for (let j = 0; j < authTree.length; j++) {
- let element = authTree[j];
- if (element.id == id) {
- this.saveAuthVoList[id] = element.selectNodes = tickedDatas.map((item) => {
- const { dataId, dataType, dataCode, classifyCode } = item;
- return {
- dataId,
- classifyCode,
- dataCode
- };
- });
- }
- }
- }
- } else {
- this.showCheckListBtn = false;
- }
- console.log("saveAuthVoList", this.saveAuthVoList);
- this.authData = authTree;
- }
- }
- },
- created() {
- console.log("初始化");
- this.initAuthTree();
- },
- mounted() {}
- };
- </script>
- <style lang='scss'>
- </style>
|