selectUserDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <script>
  2. import SecurityDeviceSelect from "@/components/security/common/securityDeviceSelect.vue";
  3. export default {
  4. comments: {
  5. SecurityDeviceSelect
  6. },
  7. props: {
  8. callback: Function,
  9. show: Boolean,
  10. },
  11. data() {
  12. return {
  13. companyData: [
  14. {
  15. title: '北京电信规划院',
  16. key: '北京电信规划院'
  17. }
  18. ],
  19. data: [
  20. {
  21. name: '李自成',
  22. phone: '15602407624',
  23. dept: '业务一部',
  24. },
  25. {
  26. name: '张丰毅',
  27. phone: '13084694502',
  28. dept: '业务一部',
  29. },
  30. {
  31. name: '李佳佳',
  32. phone: '13002413640',
  33. dept: '业务一部',
  34. },
  35. {
  36. name: '王雪',
  37. phone: '17574063735',
  38. dept: '业务一部',
  39. },
  40. {
  41. name: '吴义刚',
  42. phone: '17135546914',
  43. dept: '业务一部',
  44. },
  45. {
  46. name: '王羽',
  47. phone: '15970548072',
  48. dept: '业务一部',
  49. },
  50. {
  51. name: '李一水',
  52. phone: '13485387535',
  53. dept: '业务一部',
  54. },{
  55. name: '张果果',
  56. phone: '15826958745',
  57. dept: '业务一部',
  58. },{
  59. name: '王峰',
  60. phone: '17658963247',
  61. dept: '业务一部',
  62. },{
  63. name: '孙舒予',
  64. phone: '13025698756',
  65. dept: '业务一部',
  66. },
  67. ],
  68. columns: [
  69. {
  70. title: "姓名",
  71. dataIndex: "name",
  72. key: "name",
  73. scopedSlots: { customRender: 'name' },
  74. },
  75. {
  76. title: "手机号",
  77. dataIndex: "phone",
  78. key: "phone",
  79. scopedSlots: { customRender: 'phone' },
  80. },
  81. {
  82. title: "部门",
  83. dataIndex: "dept",
  84. key: "dept",
  85. scopedSlots: { customRender: 'dept' },
  86. },
  87. ],
  88. selectedRowKeys: [],
  89. }
  90. },
  91. emits: ["update:show"],
  92. setup(props, context) {
  93. const methods = {
  94. updateShow(obj) {
  95. context.emit("update:show", obj);
  96. if (!obj) {
  97. this.selectedRowKeys = []
  98. }
  99. },
  100. };
  101. return methods;
  102. },
  103. mounted() {
  104. this.selectedRowKeys = []
  105. },
  106. created() {
  107. },
  108. methods: {
  109. ok() {
  110. if (this.selectedRowKeys.length>0) {
  111. let data = [];
  112. this.selectedRowKeys.forEach(i=>{
  113. data.push(this.data[i])
  114. });
  115. this.callback(data);
  116. this.updateShow(false);
  117. } else {
  118. this.$message.warning('请至少选择一项')
  119. }
  120. },
  121. addUser(val) {
  122. //console.log(val)
  123. },
  124. onSelectChange(keys) {
  125. this.selectedRowKeys = keys
  126. }
  127. }
  128. }
  129. </script>
  130. <template>
  131. <div class="selectUserDialog">
  132. <a-modal
  133. title="添加人员"
  134. v-if="show"
  135. :visible="show"
  136. width="900px"
  137. @cancel="updateShow(false)"
  138. @ok="ok"
  139. >
  140. <a-row :gutter="[12,12]" style="height: 450px">
  141. <a-col :span="6" style="height: 100%">
  142. <div class="selectUserDialog-company" style="height: 100%">
  143. <SecurityDeviceSelect :select-first="true" left-title="名单" :tree-data="companyData" :callback="addUser"></SecurityDeviceSelect>
  144. </div>
  145. </a-col>
  146. <a-col :span="18" style="height: 100%;">
  147. <div class="selectUserDialog-userList">
  148. <a-table
  149. :rowKey=" (record, index) => index"
  150. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  151. :columns="columns"
  152. :data-source="data"
  153. :scroll="{y: 400}"
  154. :pagination="false"
  155. >
  156. </a-table>
  157. </div>
  158. </a-col>
  159. </a-row>
  160. </a-modal>
  161. </div>
  162. </template>
  163. <style lang="less">
  164. .selectUserDialog {
  165. width: 100%;
  166. height: 100%;
  167. .selectUserDialog-company {
  168. }
  169. .selectUserDialog-userList {
  170. }
  171. }
  172. </style>