index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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-checked-keys="checkedKeys" :expand-on-click-node="false" :node-key="nodekey" ref="tree" highlight-current>
  17. <span v-if="orgType == 'org'" slot-scope="{ data }" :title="data.OrganName" class="org-data-tree-node">
  18. {{ data.OrganName }}
  19. </span>
  20. <span v-else slot-scope="{ data }" :title="data.AuthName" class="org-data-tree-node">
  21. {{ data.AuthName }}
  22. </span>
  23. </el-tree>
  24. </el-scrollbar>
  25. </div>
  26. <div class="dptBox" v-show="active == 1">
  27. <Rolelist :type="true" @radioChange="radioChange" :radioCheck="radioCheck" :number="8" :active="true" class="lessData" :mainData="mainData" />
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import Rolelist from '@/components/rolelist'
  35. export default {
  36. props: {
  37. title: {
  38. type: String,
  39. default: "",
  40. },
  41. vice: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. data: {
  46. type: Array,
  47. default: () => [],
  48. },
  49. nodekey: {
  50. type: String,
  51. default: "",
  52. },
  53. defaultProps: {
  54. type: Object,
  55. default: () => { },
  56. },
  57. checkedKeys: {
  58. //已选中
  59. type: Array,
  60. default: () => [],
  61. },
  62. lessData: {
  63. //副岗
  64. type: Array,
  65. default: () => [],
  66. },
  67. mainData: {
  68. //主岗
  69. type: Array,
  70. default: () => [],
  71. },
  72. radioCheck: {
  73. type: Number,
  74. default: 0,
  75. },
  76. checkBoxList: {
  77. type: Array,
  78. default: () => [],
  79. },
  80. orgType: {
  81. type: String,
  82. default: "org",
  83. },
  84. },
  85. components: { Rolelist },
  86. data () {
  87. return {
  88. active: 0,
  89. colType: [
  90. {
  91. name: "组织",
  92. },
  93. {
  94. name: "岗位",
  95. }
  96. ],
  97. checkedDatas: [],
  98. checkedId: null,
  99. checkedList: [], //选中的列表,
  100. nodekeys: "nodekey",
  101. };
  102. },
  103. watch: {
  104. checkedKeys: {
  105. handler (val) {
  106. this.checkedList = val;
  107. this.$refs.tree.setCheckedKeys(val)
  108. },
  109. deep: true,
  110. },
  111. },
  112. mounted () {
  113. if (this.data != null) {
  114. this.data = this.formatData(this.data)
  115. }
  116. },
  117. methods: {
  118. //点击选择
  119. upStart (index) {
  120. this.active = index;
  121. this.$emit("getTreeindex", index)
  122. },
  123. formatData (params) {
  124. let data = params;
  125. data.map((item) => {
  126. if (item.hasOwnProperty('children')) {
  127. item.disabled = true;
  128. this.formatData(item.children)
  129. }
  130. });
  131. return data;
  132. },
  133. currentChange (data, isChecked) {
  134. if (this.orgType == 'org') {
  135. const { OrganId } = data
  136. this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
  137. if (isChecked) {
  138. const checked = [OrganId]
  139. this.$refs.tree.setCheckedKeys(checked)
  140. }
  141. } else if (this.orgType == 'auth') {
  142. const { AuthId } = data
  143. this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
  144. if (isChecked) {
  145. const checked = [AuthId]
  146. this.$refs.tree.setCheckedKeys(checked)
  147. }
  148. }
  149. },
  150. // 选中后设置初始数据
  151. setDataObj (arr) {
  152. arr.forEach((item) => {
  153. if (!item.children) {
  154. item.children = {
  155. OrganId: item.OrganId,
  156. ValidBegin: "",
  157. ValidEnd: "",
  158. Action: "",
  159. QueryRow: "",
  160. QueryCol: "",
  161. NewCol: "",
  162. EditRow: "",
  163. EditCol: "",
  164. DeleteRow: "",
  165. };
  166. }
  167. });
  168. this.$emit("getTreeData", arr)
  169. },
  170. nodeClick (data) {
  171. this.$emit("getTreeDatas", data)
  172. this.checkedId = data.nodekey
  173. },
  174. radioChange (val) {
  175. this.$emit('radioChange', val)
  176. },
  177. //多选框
  178. checkChange (arr) {
  179. this.$emit("checkChange", arr)
  180. },
  181. checkClick (item) {
  182. this.$emit("checkClick", item)
  183. }
  184. },
  185. };
  186. </script>
  187. <style lang="scss">
  188. @import "./organization.scss";
  189. .DBox {
  190. cursor: not-allowed;
  191. }
  192. .dptBox {
  193. height: 100%;
  194. .org-data-tree-node {
  195. font-size: 14px;
  196. max-width: 10vw;
  197. white-space: nowrap;
  198. text-overflow: ellipsis;
  199. overflow: hidden;
  200. margin-left: 10px;
  201. }
  202. }
  203. </style>