index.vue 4.0 KB

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