authSetDialog.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body="false"
  6. @close="cancelHandle"
  7. custom-class="auth-set-dialog"
  8. center
  9. width="850px"
  10. top="5vh"
  11. v-dialogDrag
  12. :title="edbForm.title"
  13. >
  14. <div class="cont">
  15. <div class="header">
  16. <span>{{$t('SystemManage.OperateAuth.invisible_users')}}</span>
  17. <el-cascader
  18. v-model="filterUsers"
  19. :options="userList"
  20. :props="{
  21. value: 'AdminId',
  22. label: 'RealName',
  23. children: 'ChildrenList',
  24. emitPath: false,
  25. multiple: true,
  26. disabled: 'Creater'
  27. }"
  28. collapse-tags
  29. :show-all-levels="false"
  30. clearable
  31. filterable
  32. :placeholder="$t('SystemManage.OperateAuth.placeholder04')"
  33. style="margin: 0 20px"
  34. />
  35. <el-button type="primary" @click="setAuthHandle">{{$t('Dialog.set_btn')}}</el-button>
  36. </div>
  37. <template v-if="edbForm.title===$t('SystemManage.OperateAuth.permission_title01')">
  38. <el-table
  39. :data="filterTable"
  40. border
  41. style="margin: 20px 0"
  42. >
  43. <el-table-column v-for="item in tableColums" :key="item.key" align="center" :label="item.label">
  44. <template slot-scope="{row}">
  45. <span>{{ row[item.key] }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column align="center" :label="$t('Table.column_operations')">
  49. <template slot-scope="{row}" >
  50. <el-popconfirm
  51. :title="$t('SystemManage.OperateAuth.permission_confirm_msg')"
  52. @onConfirm="removeUser(row)"
  53. >
  54. <span slot="reference" class="deletesty">{{$t('Table.delete_btn')}}</span>
  55. </el-popconfirm>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <el-col :span="24" style="height:100px">
  60. <m-page
  61. :page_no="pageNo"
  62. :pageSize="pageSize"
  63. :total="total"
  64. @handleCurrentChange="pageChange"
  65. />
  66. </el-col>
  67. </template>
  68. </div>
  69. </el-dialog>
  70. </template>
  71. <script>
  72. import { operateAuthInterface } from '@/api/modules/setApi';
  73. import mPage from '@/components/mPage';
  74. export default {
  75. props: {
  76. isShow: {
  77. type: Boolean
  78. },
  79. users: {
  80. type: Array
  81. },
  82. edbForm: {
  83. type: Object
  84. }
  85. },
  86. components: { mPage },
  87. watch: {
  88. isShow(nval) {
  89. if(!nval) return
  90. let uers_arr = _.cloneDeep(this.users);
  91. this.disableCreaterHandle(uers_arr);
  92. this.userList = uers_arr;
  93. this.edbForm.title===this.$t('SystemManage.OperateAuth.permission_title01') && this.getTableList()
  94. }
  95. },
  96. computed:{
  97. tableColums(){
  98. return [
  99. { label:this.$t('SystemManage.DepartManage.user_table_name'),key: 'RealName' },
  100. { label:this.$t('SystemManage.DepartManage.user_table_role'),key: 'RoleName' },
  101. { label:this.$t('SystemManage.DepartManage.user_table_depart'),key: 'DepartmentGroup' },
  102. ]
  103. }
  104. },
  105. data() {
  106. return {
  107. userList: [],
  108. filterUsers: [],
  109. tableData: [],
  110. filterTable: [],
  111. // tableColums:[
  112. // { label:'姓名',key: 'RealName' },
  113. // { label:'角色',key: 'RoleName' },
  114. // { label:'部门/分组',key: 'DepartmentGroup' },
  115. // ],
  116. pageNo:1,
  117. pageSize: 10,
  118. total: 0,
  119. }
  120. },
  121. methods: {
  122. /* 数据列表 */
  123. getTableList() {
  124. operateAuthInterface.getEdbNoAuthList({
  125. EdbInfoId: this.edbForm.ids[0]
  126. }).then(res => {
  127. if(res.Ret !== 200) return
  128. this.tableData = res.Data.List || [];
  129. this.total = this.tableData.length;
  130. this.filterTable = this.tableData.slice(0,this.pageSize*this.pageNo);
  131. // this.filterUsers = this.tableData.length ? this.tableData.map(_ => _.AdminId) : [];
  132. })
  133. },
  134. disableCreaterHandle(arr) {
  135. // let filter_arr = arr.form
  136. arr.forEach(item => {
  137. item.ChildrenList && item.ChildrenList.length && this.disableCreaterHandle(item.ChildrenList);
  138. if( Number(item.AdminId) === this.edbForm.createId) {
  139. item.Creater = true;
  140. }
  141. })
  142. },
  143. pageChange(page) {
  144. this.pageNo = page;
  145. this.filterTable = this.tableData.slice(this.pageSize*(this.pageNo-1),this.pageSize*this.pageNo);
  146. },
  147. cancelHandle() {
  148. this.pageNo = 1;
  149. this.filterUsers = [];
  150. this.filterTable = [];
  151. this.$emit('update:isShow',false)
  152. },
  153. /* 删除 */
  154. removeUser({AdminId}) {
  155. operateAuthInterface.edbNoAuthDel({
  156. EdbInfoId: Number(this.edbForm.ids[0]),
  157. AdminId
  158. }).then(res => {
  159. if(res.Ret !== 200) return
  160. this.$message.success(this.$t('MsgPrompt.delete_msg'));
  161. this.getTableList();
  162. })
  163. },
  164. /* 设置权限 */
  165. async setAuthHandle() {
  166. if(!this.filterUsers.length) return this.$message.warning(this.$t('SystemManage.OperateAuth.placeholder04'))
  167. // let res = this.edbForm.title === '权限设置'
  168. // ? await operateAuthInterface.edbNoAuthSet({
  169. // EdbInfoId: Number(this.edbForm.ids[0]),
  170. // AdminIdList: this.filterUsers.map(_ => Number(_))
  171. // })
  172. // :
  173. let res = await operateAuthInterface.edbNoAuthBatchSet({
  174. EdbInfoIdList: this.edbForm.ids.map(_ => Number(_)),
  175. AdminIdList: this.filterUsers.map(_ => Number(_))
  176. })
  177. if(res.Ret !== 200) return
  178. this.$message.success(this.$t('SystemManage.OperateAuth.set_success'))
  179. if(this.edbForm.title === this.$t('SystemManage.OperateAuth.permission_title01')) {
  180. this.filterUsers=[]
  181. this.getTableList()
  182. }else {
  183. this.$emit('setSuccess');
  184. this.cancelHandle()
  185. }
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" soped>
  191. .cont {
  192. min-height: 250px;
  193. }
  194. </style>
  195. <style lang='scss'>
  196. .auth-set-dialog {
  197. .el-cascader .el-input {width: 100%;}
  198. }
  199. </style>