index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="bf-organization">
  3. <!-- 上级组织 -->
  4. <div class="left">
  5. <div class="paren_header">
  6. <p>{{ title }}</p>
  7. <div class="column" v-show="vice">
  8. <div :class="active == index ? 'column_childs' : 'column_child'" v-for="(item, index) in colType" :key="index" @click="upStart(index)">
  9. {{ item.name }}
  10. </div>
  11. </div>
  12. </div>
  13. <div class="paren_content">
  14. <div class="dptBox" v-show="active == 0">
  15. <el-scrollbar style="height: 100%">
  16. <el-tree :data="data" :check-strictly="true" show-checkbox @node-click="nodeClick" @check-change="currentChange" :props="defaultProps" default-expand-all :default-checked-keys="checkedKeys" :expand-on-click-node="false" :node-key="nodekey" ref="tree" highlight-current>
  17. </el-tree>
  18. </el-scrollbar>
  19. </div>
  20. <div class="dptBox" v-show="active == 1">
  21. <Rolelist :type="true" @radioChange="radioChange" :radioCheck="radioCheck" :number="8" :active="true" class="lessData" :dataList="mainData" />
  22. </div>
  23. <div class="dptBox" v-show="active == 2">
  24. <Rolelist :number="8" @checkClick="checkClick" @checkChange="checkChange" :checkBoxList="checkBoxList" :active="true" class="lessData" :dataList="lessData" />
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import Rolelist from '@/components/rolelist'
  32. export default {
  33. props: {
  34. title: {
  35. type: String,
  36. default: "",
  37. },
  38. vice: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. data: {
  43. type: Array,
  44. default: () => [],
  45. },
  46. nodekey: {
  47. type: String,
  48. default: "",
  49. },
  50. defaultProps: {
  51. type: Object,
  52. default: () => { },
  53. },
  54. checkedKeys: {
  55. //已选中
  56. type: Array,
  57. default: () => [],
  58. },
  59. lessData: {
  60. //副岗
  61. type: Array,
  62. default: () => [],
  63. },
  64. mainData: {
  65. //主岗
  66. type: Array,
  67. default: () => [],
  68. },
  69. radioCheck: {
  70. type: Number,
  71. default: 0,
  72. },
  73. checkBoxList: {
  74. type: Array,
  75. default: () => [],
  76. },
  77. },
  78. components: { Rolelist },
  79. data () {
  80. return {
  81. active: 0,
  82. colType: [
  83. {
  84. name: "组织",
  85. },
  86. {
  87. name: "主岗",
  88. },
  89. {
  90. name: "副岗",
  91. },
  92. ],
  93. checkedDatas: [],
  94. checkedId: null,
  95. checkedList: [], //选中的列表,
  96. nodekeys: "nodekey",
  97. };
  98. },
  99. watch: {
  100. checkedKeys: {
  101. handler (val) {
  102. this.checkedList = val;
  103. this.$refs.tree.setCheckedKeys(val)
  104. },
  105. deep: true,
  106. },
  107. },
  108. mounted () {
  109. this.data = this.formatData(this.data)
  110. },
  111. methods: {
  112. //点击选择
  113. upStart (index) {
  114. this.active = index;
  115. this.$emit("getTreeindex", index)
  116. },
  117. formatData (params) {
  118. let data = params;
  119. data.map((item) => {
  120. if (item.hasOwnProperty('children')) {
  121. item.disabled = true;
  122. this.formatData(item.children)
  123. }
  124. });
  125. return data;
  126. },
  127. currentChange (data, isChecked) {
  128. const { OrganId } = data
  129. this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
  130. if (isChecked) {
  131. const checked = [OrganId]
  132. this.$refs.tree.setCheckedKeys(checked)
  133. }
  134. },
  135. // 选中后设置初始数据
  136. setDataObj (arr) {
  137. arr.forEach((item) => {
  138. if (!item.children) {
  139. item.children = {
  140. OrganId: item.OrganId,
  141. ValidBegin: "",
  142. ValidEnd: "",
  143. Action: "",
  144. QueryRow: "",
  145. QueryCol: "",
  146. NewCol: "",
  147. EditRow: "",
  148. EditCol: "",
  149. DeleteRow: "",
  150. };
  151. }
  152. });
  153. this.$emit("getTreeData", arr)
  154. },
  155. nodeClick (data) {
  156. this.$emit("getTreeDatas", data)
  157. this.checkedId = data.nodekey
  158. },
  159. radioChange (val) {
  160. this.$emit('radioChange', val)
  161. },
  162. //多选框
  163. checkChange (arr) {
  164. this.$emit("checkChange", arr)
  165. },
  166. checkClick (item) {
  167. this.$emit("checkClick", item)
  168. }
  169. },
  170. };
  171. </script>
  172. <style lang="scss">
  173. @import "./organization.scss";
  174. .DBox {
  175. cursor: not-allowed;
  176. }
  177. .dptBox {
  178. height: 100%;
  179. }
  180. </style>