roleManage.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="roleManage_container">
  3. <div class="role_cont_top">
  4. <div>
  5. <el-button v-permission="permissionBtn.sysDepartPermission.sysRole_addRole"
  6. type="primary" @click="addRole" style="marginRight:14px;">{{$t('SystemManage.RoleManage.role_add_btn')}}</el-button>
  7. <!-- <el-button v-permission="permissionBtn.sysDepartPermission.sysRole_settingAuth"
  8. type="primary" @click="setAuth">设置权限</el-button> -->
  9. </div>
  10. <el-input
  11. :placeholder="$t('SystemManage.RoleManage.search_placeholder')"
  12. v-model="search_txt"
  13. @input="getTableList"
  14. style="maxWidth:359px">
  15. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  16. </el-input>
  17. </div>
  18. <div class="role_bot">
  19. <!-- 表格 -->
  20. <el-table
  21. ref="roleTable"
  22. :data="tableData"
  23. v-loading="isShowloadding"
  24. :element-loading-text="$t('Table.data_loading')"
  25. border>
  26. <el-table-column
  27. prop="no"
  28. :label="$t('SystemManage.RoleManage.serial_num')"
  29. align="center">
  30. <template slot-scope="scope"> <span>{{scope.row.no}}</span> </template>
  31. </el-table-column>
  32. <el-table-column
  33. prop="RoleName"
  34. :label="$t('SystemManage.RoleManage.role_name')"
  35. align="center">
  36. <template slot-scope="scope"> <span>{{scope.row.RoleName}}</span> </template>
  37. </el-table-column>
  38. <el-table-column
  39. prop="RoleType"
  40. :label="$t('SystemManage.RoleManage.role_type')"
  41. align="center">
  42. <template slot-scope="scope"> <span>{{scope.row.RoleType}}</span> </template>
  43. </el-table-column>
  44. <el-table-column :label="$t('Table.column_operations')" align="center">
  45. <template slot-scope="scope">
  46. <div style="color:#4099ef; font-size:24px;">
  47. <!-- <span v-permission="permissionBtn.sysDepartPermission.sysRole_settingAuth"
  48. class="editsty" @click.stop="getAuthDetail(scope.row)" style="marginRight:20px;">查看权限</span> -->
  49. <span v-permission="permissionBtn.sysDepartPermission.sysRole_settingAuth"
  50. class="editsty" @click.stop="getAuthDetail(scope.row)" style="marginRight:20px;">{{$t('SystemManage.RoleManage.set_permission')}}</span>
  51. <span v-permission="permissionBtn.sysDepartPermission.sysRole_addRole"
  52. class="editsty" @click.stop="editRole(scope.row)" style="marginRight:20px;">{{$t('Table.edit_btn')}}</span>
  53. <span v-permission="permissionBtn.sysDepartPermission.sysRole_del"
  54. class="deletesty" @click.stop="delRole(scope.row)">{{$t('Table.delete_btn')}}</span>
  55. </div>
  56. </template>
  57. </el-table-column>
  58. <div slot="empty" style="lineHeight:25px;margin:20px 0;color:#95A9C5;">
  59. <tableNoData :text="$t('SystemManage.RoleManage.no_role_data')" size="mini"/>
  60. </div>
  61. </el-table>
  62. <el-col :span="24" class="toolbar">
  63. <el-pagination
  64. layout="total,prev,pager,next,jumper"
  65. background
  66. :current-page="page_no"
  67. @current-change="handleCurrentChange"
  68. :page-size="pageSize"
  69. :total="total"
  70. style="float:right;">
  71. </el-pagination>
  72. </el-col>
  73. </div>
  74. <!-- 添加角色 -->
  75. <el-dialog
  76. :title="roleForm.title"
  77. :visible.sync="isAddRole"
  78. :close-on-click-modal="false"
  79. :modal-append-to-body='false'
  80. @close="cancelHandle()"
  81. center
  82. width="30%"
  83. v-dialogDrag>
  84. <div slot="title" style="display:flex;alignItems:center;">
  85. <img :src="!roleForm.role_id?$icons.add:$icons.edit" style="color:#fff;width:16px;height:16px;marginRight:5px;">
  86. <span style="fontSize:16px;">{{roleForm.title}}</span>
  87. </div>
  88. <el-form :model="roleForm" :rules="roleRule" ref="roleForm" label-width="100px" class="demo-ruleForm" style="marginTop:15px;">
  89. <el-form-item :label="$t('SystemManage.RoleManage.role_name')" prop="name">
  90. <el-input v-model="roleForm.name" :placeholder="$t('SystemManage.RoleManage.input_role_placeholder')" style="width: 90%"></el-input>
  91. </el-form-item>
  92. <el-form-item :label="$t('SystemManage.RoleManage.role_type')" prop="roleType">
  93. <el-select v-model="roleForm.roleType" :placeholder="$t('SystemManage.RoleManage.select_role_placeholder')" style="width:90%">
  94. <el-option
  95. v-for="item in roleTypeArr"
  96. :key="item"
  97. :label="item"
  98. :value="item">
  99. </el-option>
  100. </el-select>
  101. </el-form-item>
  102. </el-form>
  103. <div style="display:flex;justify-content:center;margin:75px 0 26px;">
  104. <el-button type="primary" style="width:80px;marginRight:24px;" @click="saveRole">{{$t('Dialog.confirm_save_btn')}}</el-button>
  105. <el-button style="width:80px;" @click="cancelHandle()">{{$t('Dialog.cancel_btn')}}</el-button>
  106. </div>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. import {departInterence} from '@/api/api.js';
  112. export default {
  113. name:'',
  114. components: {},
  115. computed:{
  116. roleTypeArr(){
  117. if(this.$i18n.locale==='en') return ['None','Administrator','FICC Administrator',
  118. 'FICC Sales','Equity Administrator','Equity Sales','FICC Sales Supervisor','FICC Sales Team Leader',
  119. 'Equity Sales Team Leader','FICC Department Manager','Equity Department Manager','FICC Researcher','Equity Researcher']
  120. return ['无','管理员','ficc管理员','ficc销售','权益管理员','权益销售','ficc销售主管','ficc销售组长','权益销售组长','ficc部门经理','权益部门经理','ficc研究员','权益研究员']
  121. }
  122. },
  123. data () {
  124. return {
  125. search_txt:'',//关键字搜索
  126. isShowloadding:false,
  127. tableData:[],//表格数据
  128. page_no:1,
  129. total:1,
  130. pageSize:10,
  131. isAddRole: false,
  132. roleForm:{
  133. title:'添加角色',
  134. name:'',
  135. roleType:'无'
  136. },
  137. roleRule:{
  138. name:[
  139. { required: true, message: this.$t('SystemManage.RoleManage.input_role_placeholder'), trigger: 'blur' },
  140. ],
  141. roleType:[
  142. { required: true, message: this.$t('SystemManage.RoleManage.select_role_placeholder'), trigger: 'blur' },
  143. ]
  144. },
  145. // roleTypeArr:['无','管理员','ficc管理员','ficc销售','权益管理员','权益销售','ficc销售主管','ficc销售组长','权益销售组长','ficc部门经理','权益部门经理','ficc研究员','权益研究员'],
  146. };
  147. },
  148. methods: {
  149. /* 角色表格数据 */
  150. getTableList() {
  151. this.isShowloadding = true
  152. departInterence.getRoleList({
  153. PageSize:this.pageSize,
  154. CurrentIndex:this.page_no,
  155. KeyWord:this.search_txt
  156. }).then(res => {
  157. if(res.Ret === 200) {
  158. this.isShowloadding = false;
  159. // this.tableData = res.Data.List;
  160. let arr = [];
  161. res.Data.List&&res.Data.List.forEach((item,index) => {
  162. let obj ={
  163. no:index+1,
  164. ...item
  165. }
  166. arr.push(obj)
  167. });
  168. this.tableData = arr;
  169. this.total = res.Data.Paging.Totals || 1;
  170. }
  171. })
  172. },
  173. /* 页码改变 */
  174. handleCurrentChange(page) {
  175. this.page_no = page;
  176. this.getTableList();
  177. },
  178. /* 查看权限 */
  179. getAuthDetail(item) {
  180. this.$router.push({
  181. path:'/Sysauth',
  182. query:{
  183. id:item.RoleId
  184. }
  185. })
  186. },
  187. /* 设置权限 */
  188. setAuth() {
  189. this.$router.push({path:'/Sysauth'})
  190. },
  191. /* 添加角色 */
  192. addRole() {
  193. this.isAddRole = true;
  194. this.roleForm = {
  195. title:this.$t('SystemManage.RoleManage.role_add_btn'),
  196. name:'',
  197. roleType:this.roleTypeArr[0]
  198. }
  199. },
  200. // 取消
  201. cancelHandle() {
  202. this.isAddRole = false;
  203. this.roleForm = {
  204. title:this.$t('SystemManage.RoleManage.role_add_btn'),
  205. name:'',
  206. roleType:this.roleTypeArr[0]
  207. }
  208. this.$refs.roleForm.resetFields();
  209. },
  210. /* 保存角色 */
  211. saveRole() {
  212. this.$refs.roleForm.validate((valid) => {
  213. if (valid) {
  214. if(!this.roleForm.role_id) {
  215. departInterence.addRole({
  216. RoleName:this.roleForm.name,
  217. roleType:this.roleForm.roleType
  218. }).then(res => {
  219. if(res.Ret === 200) {
  220. this.$message.success(res.Msg)
  221. this.getTableList();
  222. this.isAddRole = false;
  223. }
  224. })
  225. }else {
  226. departInterence.editRole({
  227. RoleId:Number(this.roleForm.role_id),
  228. RoleName:this.roleForm.name,
  229. RoleType:this.roleForm.roleType
  230. }).then(res =>{
  231. if(res.Ret === 200) {
  232. this.$message.success(res.Msg);
  233. this.getTableList();
  234. this.isAddRole = false;
  235. }
  236. })
  237. }
  238. }
  239. })
  240. },
  241. /* 编辑角色 */
  242. editRole(item) {
  243. this.isAddRole = true;
  244. this.roleForm = {
  245. title:this.$t('SystemManage.RoleManage.role_edit_btn'),
  246. name:item.RoleName,
  247. role_id:item.RoleId,
  248. roleType:item.RoleType
  249. }
  250. },
  251. /* 删除角色*/
  252. delRole(item) {
  253. this.$confirm(this.$t('SystemManage.RoleManage.delete_role_msg'),this.$t('Confirm.prompt'),{
  254. type:'warning'
  255. }).then(() => {
  256. departInterence.delRole({
  257. RoleId:item.RoleId
  258. }).then(res => {
  259. if(res.Ret === 200) {
  260. this.$message.success(this.$t('MsgPrompt.delete_msg'));
  261. this.isAddRole = false;
  262. this.getTableList();
  263. }
  264. })
  265. }).catch(() => {});
  266. }
  267. },
  268. mounted() {
  269. this.getTableList()
  270. },
  271. }
  272. </script>
  273. <style lang='scss' >
  274. .roleManage_container {
  275. min-height: calc(100vh - 120px);
  276. display: flex;
  277. flex-direction: column;
  278. /* reset */
  279. .el-form-item__label {
  280. font-size: 16px;
  281. padding-right: 20px !important;
  282. }
  283. .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before {
  284. content: '';
  285. }
  286. .role_cont_top {
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. border: 1px solid #ECECEC;
  291. padding: 20px 30px;
  292. background: #fff;
  293. border-radius: 4px;
  294. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  295. }
  296. .role_bot {
  297. flex: 1;
  298. //min-height: calc(100vh - 260px);
  299. padding: 20px 30px;
  300. background: #fff;
  301. margin-top: 20px;
  302. position: relative;
  303. border: 1px solid #ECECEC;
  304. border-radius: 4px;
  305. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  306. }
  307. }
  308. </style>