You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
6.5 KiB

1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
7 months ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
1 month ago
1 year ago
  1. <template>
  2. <div class="mod-role">
  3. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  4. <el-form-item>
  5. <el-input v-model="dataForm.roleName" :placeholder="$t('sys.role.roleName')" clearable></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="getDataList()">{{buttons.search || $t('sys.common.search') }}</el-button>
  9. <el-button type="primary" @click="addOrUpdateHandle()"> {{buttons.add|| $t('sys.common.add')}}</el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-table
  13. :data="dataList"
  14. border
  15. v-loading="dataListLoading"
  16. @selection-change="selectionChangeHandle"
  17. style="width: 100%;">
  18. <el-table-column
  19. prop="roleName"
  20. header-align="center"
  21. align="center"
  22. :label="buttons.roleName||$t('sys.role.roleName')">
  23. </el-table-column>
  24. <el-table-column
  25. prop="remark"
  26. header-align="center"
  27. align="center"
  28. :label="buttons.remark||$t('sys.role.remark')">
  29. </el-table-column>
  30. <el-table-column
  31. prop="createTime"
  32. header-align="center"
  33. align="center"
  34. width="180"
  35. :label="buttons.createTime||$t('sys.common.createTime')">
  36. </el-table-column>
  37. <el-table-column
  38. fixed="right"
  39. header-align="center"
  40. align="center"
  41. width="150"
  42. :label="buttons.cz||$t('sys.common.operation')">
  43. <template slot-scope="scope">
  44. <a type="text" size="small" @click="addOrUpdateHandle(scope.row.roleId)">{{buttons.edit||$t('sys.common.edit')}}</a>
  45. <a type="text" size="small" @click="deleteHandle(scope.row.roleId)">{{buttons.delete|| $t('sys.common.delete')}}</a>
  46. <!-- <a type="text" size="small" @click="showAuthCustomerReportModal(scope.row)">{{buttons.reportRole || '报表赋权'}}</a>-->
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <el-pagination
  51. @size-change="sizeChangeHandle"
  52. @current-change="currentChangeHandle"
  53. :current-page="pageIndex"
  54. :page-sizes="[20, 50, 100, 200,500]"
  55. :page-size="pageSize"
  56. :total="totalPage"
  57. layout="total, sizes, prev, pager, next, jumper">
  58. </el-pagination>
  59. <!-- 弹窗, 新增 / 修改 -->
  60. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  61. <!--报表赋权限-->
  62. <authCustomerReport ref="authCustomerReport" :close-on-click-modal="false"
  63. :visible.sync="showAuthCustomerReportFlag" @refreshDataList="getDataList">
  64. </authCustomerReport>
  65. </div>
  66. </template>
  67. <script>
  68. import {
  69. searchSysLanguageParam,
  70. searchFunctionButtonList,
  71. saveButtonList,
  72. } from "@/api/sysLanguage.js"
  73. import AddOrUpdate from './role-add-or-update'
  74. import authCustomerReport from '../report/com_auth_customer_report' /**/
  75. export default {
  76. data () {
  77. return {
  78. showAuthCustomerReportFlag: false,
  79. dataForm: {
  80. roleName: ''
  81. },
  82. dataList: [],
  83. pageIndex: 1,
  84. pageSize: 20,
  85. totalPage: 0,
  86. dataListLoading: false,
  87. dataListSelections: [],
  88. addOrUpdateVisible: false,
  89. buttons: {
  90. cz: this.$t('sys.common.operation'), search: this.$t('sys.common.search'), add: this.$t('sys.common.add'),
  91. edit: this.$t('sys.common.edit'), delete: this.$t('sys.common.delete'), reportRole: this.$t('sys.role.reportRole'),
  92. roleName: this.$t('sys.role.roleName'), remark: this.$t('sys.role.remark'), createTime: this.$t('sys.common.createTime')
  93. },
  94. }
  95. },
  96. components: {
  97. AddOrUpdate,
  98. authCustomerReport,/*报表赋权限*/
  99. },
  100. activated () {
  101. this.getDataList()
  102. },
  103. methods: {
  104. // 获取button的词典
  105. getFunctionButtonList() {
  106. let queryButton = {
  107. functionId: this.$route.meta.menuId,
  108. tableId: '*',
  109. languageCode: this.$i18n.locale,
  110. objectType: 'button'
  111. }
  112. searchFunctionButtonList(queryButton).then(({data}) => {
  113. if (data.code == 0 && data.data) {
  114. this.buttons = data.data
  115. }
  116. })
  117. },
  118. // 获取数据列表
  119. getDataList () {
  120. this.dataListLoading = true
  121. this.$http({
  122. url: this.$http.adornUrl('/sys/role/list'),
  123. method: 'get',
  124. params: this.$http.adornParams({
  125. 'page': this.pageIndex,
  126. 'limit': this.pageSize,
  127. 'roleName': this.dataForm.roleName
  128. })
  129. }).then(({data}) => {
  130. if (data && data.code === 0) {
  131. this.dataList = data.page.list
  132. this.totalPage = data.page.totalCount
  133. } else {
  134. this.dataList = []
  135. this.totalPage = 0
  136. }
  137. this.dataListLoading = false
  138. })
  139. },
  140. // 每页数
  141. sizeChangeHandle (val) {
  142. this.pageSize = val
  143. this.pageIndex = 1
  144. this.getDataList()
  145. },
  146. // 当前页
  147. currentChangeHandle (val) {
  148. this.pageIndex = val
  149. this.getDataList()
  150. },
  151. // 多选
  152. selectionChangeHandle (val) {
  153. this.dataListSelections = val
  154. },
  155. // 新增 / 修改
  156. addOrUpdateHandle (id) {
  157. this.addOrUpdateVisible = true
  158. this.$nextTick(() => {
  159. this.$refs.addOrUpdate.init(id)
  160. })
  161. },
  162. // 删除
  163. deleteHandle (id) {
  164. var ids = id ? [id] : this.dataListSelections.map(item => {
  165. return item.roleId
  166. })
  167. this.$confirm(this.$t('sys.role.confirmDelete'), this.$t('sys.common.tip'), {
  168. confirmButtonText: this.$t('sys.common.confirm'),
  169. cancelButtonText: this.$t('sys.common.cancel'),
  170. type: 'warning'
  171. }).then(() => {
  172. this.$http({
  173. url: this.$http.adornUrl('/sys/role/delete'),
  174. method: 'post',
  175. data: this.$http.adornData(ids, false)
  176. }).then(({data}) => {
  177. if (data && data.code === 0) {
  178. this.$message.success(this.$t('sys.common.success'))
  179. this.getDataList()
  180. } else {
  181. this.$message.error(data.msg)
  182. }
  183. })
  184. }).catch(() => {})
  185. },
  186. /*给角色报表赋权限*/
  187. showAuthCustomerReportModal(currentRow){
  188. this.$nextTick(() => {
  189. this.showAuthCustomerReportFlag = true;
  190. this.$refs.authCustomerReport.init(currentRow);
  191. });
  192. },
  193. },
  194. created() {
  195. //this.getFunctionButtonList()
  196. }
  197. }
  198. </script>