agentChanell.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="tree">
  3. <a-tree
  4. v-if="treeData && treeData.length > 0 && type == 'a'"
  5. :tree-data="treeData"
  6. :title="'11'"
  7. :replaceFields="replaceFields"
  8. @select="onSelect"
  9. :checkable="checkable"
  10. @check="onCheck"
  11. v-model="checkList"
  12. :auto-expand-parent="autoExpandParent"
  13. ref="tree"
  14. >
  15. <template slot="custom" slot-scope="item">
  16. <span>{{ item }}</span>
  17. <!-- <span style="color: #f50">({{ item.num }})</span> -->
  18. </template>
  19. </a-tree>
  20. <a-tree
  21. v-if="userTreeData && userTreeData.length > 0 && type == 'b'"
  22. :tree-data="userTreeData"
  23. :title="'11'"
  24. :replaceFields="replaceFields"
  25. @select="onSelect"
  26. :checkable="checkable"
  27. @check="onCheck"
  28. v-model="checkList"
  29. :auto-expand-parent="autoExpandParent"
  30. ref="tree"
  31. >
  32. <template slot="custom" slot-scope="item">
  33. <span>{{ item }}</span>
  34. <!-- <span style="color: #f50">({{ item.num }})</span> -->
  35. </template>
  36. </a-tree>
  37. </div>
  38. </template>
  39. <script>
  40. // import mixin from "../../minins/mixin";
  41. import { mapState } from "vuex";
  42. export default {
  43. name: "FormRow",
  44. // mixins: [mixin],
  45. props: {
  46. checkable: {
  47. default: false,
  48. },
  49. type: {
  50. default: true,
  51. },
  52. // defaultCheckList: {
  53. // default: [],
  54. // },
  55. },
  56. data() {
  57. return {
  58. treeData: [],
  59. userTreeData: [],
  60. replaceFields: {
  61. children: "children",
  62. title: "name",
  63. key: "id",
  64. },
  65. checkList: [],
  66. autoExpandParent: true,
  67. expandedKeys: [],
  68. };
  69. },
  70. computed: {
  71. ...mapState("setting", ["userInfo"]),
  72. },
  73. watch: {
  74. // type(val) {
  75. // //
  76. // console.log(val);
  77. // },
  78. },
  79. created() {},
  80. mounted() {
  81. this.getUserTree();
  82. },
  83. methods: {
  84. onExpand(expandedKeys) {
  85. this.expandedKeys = expandedKeys;
  86. //expandedKeys
  87. this.autoExpandParent = true;
  88. },
  89. setExpandKys(item) {
  90. this.$nextTick(() => {
  91. // this.$refs.tree.expandedKeys = ["99D17"];
  92. // this.$refs.tree.defaultExpandedKeys = ["99D17"];
  93. // console.log(this.$refs.tree);
  94. // this.expandedKeys = ["99D17"];
  95. // this.checkList = ["99D17"];
  96. this.$API.sysManage
  97. .getUserItem({
  98. userId: item.userId,
  99. })
  100. .then((res) => {
  101. if (res.data.code === 200) {
  102. this.expandedKeys = res.data.data.deptIds;
  103. this.checkList = res.data.data.deptIds;
  104. }
  105. });
  106. });
  107. },
  108. getUserTree() {
  109. // console.log(this.userInfo);
  110. this.$API.business.findAgentChanellTree({}).then((res) => {
  111. if (res.data.code === 200) {
  112. this.$emit("showTab", res.data.data.type);
  113. this.userTreeData = res.data.data.userList;
  114. this.treeData = res.data.data.deptList;
  115. }
  116. });
  117. },
  118. onSelect(keys) {
  119. this.$emit("getList", { id: keys[0], type: this.$props.type });
  120. },
  121. onCheck(checkedKeys) {
  122. this.$emit("checkTree", checkedKeys);
  123. // this.checkedKeys = checkedKeys;
  124. },
  125. },
  126. };
  127. </script>
  128. <style lang="less" scoped>
  129. .tree {
  130. height: 100%;
  131. // overflow-y: auto;
  132. }
  133. </style>