a169a2cde6a0d74cf14bb6bed5d7f3f0e1434713.svn-base 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <a-drawer
  3. :title="title"
  4. :maskClosable="true"
  5. width=600
  6. placement="right"
  7. :closable="true"
  8. @close="close"
  9. :visible="visible"
  10. style="overflow: auto;padding-bottom: 53px;">
  11. <a-spin :spinning="confirmLoading">
  12. <a-form :form="form" v-if="designNameOption.length>0">
  13. <a-form-item label=''>
  14. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  15. <a-card :style="{ marginTop: '12px',height:'auto' }">
  16. <a-checkbox-group @change="designNameChange" v-model="designNameValue" style="width: 100%">
  17. <a-row>
  18. <template v-for="(des) in designNameOption">
  19. <a-col :span="6">
  20. <a-checkbox :value="des.value">{{ des.text }}</a-checkbox>
  21. </a-col>
  22. </template>
  23. </a-row>
  24. </a-checkbox-group>
  25. </a-card>
  26. </a-col>
  27. </a-form-item>
  28. </a-form>
  29. <div v-else><h3>无可配置角色!</h3></div>
  30. </a-spin>
  31. <div class="drawer-bootom-button">
  32. <a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
  33. <a-menu slot="overlay">
  34. <a-menu-item key="1" @click="checkALL">全部勾选</a-menu-item>
  35. <a-menu-item key="2" @click="cancelCheckALL">取消全选</a-menu-item>
  36. </a-menu>
  37. <a-button>
  38. 操作 <a-icon type="up" />
  39. </a-button>
  40. </a-dropdown>
  41. <a-popconfirm title="确定放弃编辑?" @confirm="close" okText="确定" cancelText="取消">
  42. <a-button style="margin-right: .8rem">取消</a-button>
  43. </a-popconfirm>
  44. <a-button @click="handleSubmit(true)" type="primary">保存</a-button>
  45. </div>
  46. </a-drawer>
  47. </template>
  48. <script>
  49. import {httpAction, getAction} from '@/api/manage'
  50. import JEllipsis from '@/components/jeecg/JEllipsis'
  51. import {initDictOptions} from '@/components/dict/JDictSelectUtil'
  52. export default {
  53. name: 'DeptRoleUserModal',
  54. components: {
  55. JEllipsis
  56. },
  57. data() {
  58. return {
  59. currentDeptId:"",
  60. title: "部门角色分配",
  61. visible: false,
  62. model: {},
  63. labelCol: {
  64. xs: {span: 24},
  65. sm: {span: 5},
  66. },
  67. wrapperCol: {
  68. xs: {span: 24},
  69. sm: {span: 16},
  70. },
  71. confirmLoading: false,
  72. form: this.$form.createForm(this),
  73. validatorRules: {},
  74. url: {
  75. add: "/sys/sysDepartRole/deptRoleUserAdd",
  76. getDeptRoleList:"/sys/sysDepartRole/getDeptRoleList",
  77. getDeptRoleByUserId:"/sys/sysDepartRole/getDeptRoleByUserId"
  78. },
  79. designNameOption: [],
  80. userId: "",
  81. newRoleId:"",
  82. oldRoleId:"",
  83. designNameValue:[],
  84. desformList: [],
  85. }
  86. },
  87. created() {
  88. },
  89. methods: {
  90. add(record,departId) {
  91. this.userId = record.id;
  92. this.currentDeptId = departId;
  93. this.loadDesformList();
  94. this.edit({});
  95. },
  96. edit(record) {
  97. this.form.resetFields();
  98. this.model = Object.assign({}, record);
  99. this.visible = true;
  100. getAction(this.url.getDeptRoleByUserId,{userId:this.userId,departId:this.currentDeptId}).then((res) => {
  101. if (res.success) {
  102. var designName = [];
  103. for (let value of res.result) {
  104. designName.push(value.droleId)
  105. }
  106. this.oldRoleId=designName.join(",");
  107. this.designNameValue = designName;
  108. this.newRoleId = designName.join(",");
  109. }
  110. });
  111. },
  112. close() {
  113. this.$emit('close');
  114. this.visible = false;
  115. },
  116. handleSubmit() {
  117. const that = this;
  118. // 触发表单验证
  119. that.confirmLoading = true;
  120. let httpurl = this.url.add;
  121. let method = 'post';
  122. let formData = Object.assign(this.model, {});
  123. //时间格式化
  124. formData.userId = this.userId;
  125. formData.newRoleId=this.newRoleId;
  126. formData.oldRoleId=this.oldRoleId;
  127. httpAction(httpurl, formData, method).then((res) => {
  128. if (res.success) {
  129. that.$message.success(res.message);
  130. that.$emit('reload');
  131. that.$emit('ok');
  132. } else {
  133. that.$message.warning(res.message);
  134. }
  135. }).finally(() => {
  136. that.confirmLoading = false;
  137. that.close();
  138. })
  139. },
  140. handleCancel() {
  141. this.designNameOption=[];
  142. this.designNameValue=[];
  143. this.close()
  144. },
  145. designNameChange(selectedValue) {
  146. this.newRoleId=selectedValue.join(",");
  147. },
  148. checkALL(){
  149. var designName = [];
  150. for (let value of this.desformList) {
  151. designName.push(
  152. value.id
  153. )
  154. }
  155. this.designNameValue = designName;
  156. this.newRoleId=designName.join(",");
  157. },
  158. cancelCheckALL(){
  159. this.designNameValue=[];
  160. this.newRoleId="";
  161. },
  162. /** 加载desform */
  163. loadDesformList() {
  164. getAction(this.url.getDeptRoleList, { departId: this.currentDeptId, userId:this.userId }).then((res) => {
  165. if (res.success) {
  166. this.desformList = res.result
  167. var designName = [];
  168. for (let value of this.desformList) {
  169. designName.push({
  170. value: value.id,
  171. text: value.roleName,
  172. })
  173. }
  174. this.designNameOption = designName;
  175. }
  176. });
  177. },
  178. }
  179. }
  180. </script>
  181. <style scoped>
  182. .drawer-bootom-button {
  183. position: absolute;
  184. bottom: 0;
  185. width: 100%;
  186. border-top: 1px solid #e8e8e8;
  187. padding: 10px 16px;
  188. text-align: right;
  189. left: 0;
  190. background: #fff;
  191. border-radius: 0 0 2px 2px;
  192. }
  193. </style>