auth_list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div style="display:inline">
  3. <el-button type="primary" size="mini" @click="onShow" icon="el-icon-thumb">授 权</el-button>
  4. <el-dialog class="auth-container" title="授权应用列表" append-to-body :visible.sync="dialogTableVisible" width="90%">
  5. <div class="flex-align-center normal-margin">
  6. <p style="width:50px">搜索:&nbsp;</p>
  7. <el-input style="width:250px" v-model="value" size="small" @keyup.native.enter="query_all_auth(param.content.where.condition = value)" @clear="query_all_auth(param.content.where.condition = '')" placeholder="应用名称" clearable></el-input>
  8. </div>
  9. <el-row :gutter="10">
  10. <el-col :span="12">
  11. <el-table
  12. :data="list"
  13. style="width: 100%"
  14. size="small"
  15. highlight-current-row
  16. border
  17. stripe
  18. :header-cell-style="{background:'#f1f2f3',color:'#333'}"
  19. @row-click="onRowClick">
  20. <el-table-column
  21. prop="systemclientname"
  22. label="端口">
  23. </el-table-column>
  24. <el-table-column
  25. prop="systemname"
  26. label="系统名称">
  27. </el-table-column>
  28. <el-table-column
  29. prop="systemmodulename"
  30. label="模块名称">
  31. </el-table-column>
  32. <el-table-column
  33. prop="systemappname"
  34. label="应用名称">
  35. </el-table-column>
  36. </el-table>
  37. <div style="margin:20px 0">
  38. <el-pagination
  39. background
  40. small
  41. @size-change="handleSizeChange"
  42. @current-change="handleCurrentChange"
  43. :current-page="currentPage"
  44. :page-size="param.content.pageSize"
  45. layout="total, prev, pager, next, jumper"
  46. :total="total">
  47. </el-pagination>
  48. </div>
  49. </el-col>
  50. <el-col :span="12">
  51. <!-- 功能区域 -->
  52. <div>
  53. <el-button-group style="margin-bottom:10px">
  54. <el-button size="mini" type="primary" icon="el-icon-plus" :disabled="func_selection.length === 0" @click="insert_opt_hid_select">添加功能</el-button>
  55. <el-button size="mini" type="primary" icon="el-icon-plus" :disabled="field_selection.length === 0" @click="insert_opt_hid_select">添加隐藏字段</el-button>
  56. </el-button-group>
  57. <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
  58. <el-tab-pane label="功能添加" name="first">
  59. <el-table
  60. ref="multipleTable"
  61. :data="fun_list"
  62. style="width: 100%"
  63. size="mini"
  64. stripe
  65. :header-cell-style="{background:'#f1f2f3',color:'#333'}"
  66. @selection-change="onFuncSelection">
  67. <el-table-column
  68. type="selection"
  69. width="55">
  70. </el-table-column>
  71. <el-table-column
  72. prop="optionname"
  73. label="功能描述">
  74. </el-table-column>
  75. <el-table-column
  76. prop="option"
  77. label="名称">
  78. </el-table-column>
  79. </el-table>
  80. </el-tab-pane>
  81. <el-tab-pane label="隐藏字段添加" name="second">
  82. <!-- 隐藏字段区域 -->
  83. <el-table
  84. ref="multipleTable2"
  85. :data="hide_field_list"
  86. style="width: 100%"
  87. size="mini"
  88. :header-cell-style="{background:'#f1f2f3',color:'#333'}"
  89. @selection-change="onFieldSelection">
  90. <el-table-column
  91. type="selection"
  92. width="55">
  93. </el-table-column>
  94. <el-table-column
  95. prop="fieldname"
  96. label="字段描述">
  97. </el-table-column>
  98. <el-table-column
  99. prop="field"
  100. label="字段名">
  101. <template slot-scope="scope">
  102. <el-tag size="mini" type="primary" effect="dark">{{scope.row.field}}</el-tag>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </el-tab-pane>
  107. </el-tabs>
  108. </div>
  109. </el-col>
  110. </el-row>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. export default {
  116. props:['data'],
  117. data () {
  118. return {
  119. dialogTableVisible:false,
  120. activeName:'first',
  121. param:{
  122. "classname": "webmanage.role.role",
  123. "method": "query_appselect",
  124. "content": {
  125. "pageNumber": 1,
  126. "pageSize": 10,
  127. "where":{
  128. "condition":"",
  129. "systemname":"",
  130. "systemagentname":"",
  131. "systemmodulename":"",
  132. "systemappname":""
  133. }
  134. }
  135. },
  136. list:[],
  137. total:0,
  138. currentPage:0,
  139. systemappid:0,
  140. fun_list:[],
  141. hide_field_list:[],
  142. func_selection:[],
  143. field_selection:[],
  144. value:'',
  145. row:''
  146. }
  147. },
  148. methods:{
  149. onShow () {
  150. console.log(this.$route.query)
  151. if (!this.$route.query.id) return this.$message({
  152. message:'请先保存角色信息',
  153. type:'error'
  154. })
  155. this.dialogTableVisible = true
  156. this.query_all_auth()
  157. },
  158. handleClick(val) {
  159. this.func_selection.length > 0 ? this.$refs.multipleTable.clearSelection():''
  160. this.field_selection.length > 0 ? this.$refs.multipleTable2.clearSelection():''
  161. },
  162. query_all_auth() {
  163. // this.param.content.roleid = this.data.roleid
  164. this.$api.requested(this.param).then(res=>{
  165. this.list = res.data
  166. this.total = res.total
  167. this.currentPage = res.pageNumber
  168. })
  169. },
  170. handleSizeChange(val) {
  171. // console.log(`每页 ${val} 条`);
  172. this.param.content.pageSize = val
  173. this.query_all_auth()
  174. },
  175. handleCurrentChange(val) {
  176. // console.log(`当前页: ${val}`);
  177. this.param.content.pageNumber = val
  178. this.query_all_auth()
  179. },
  180. onRowClick (row) {
  181. this.systemappid = row.systemappid
  182. this.query_function_list(row)
  183. this.query_field_list(row)
  184. this.row = row
  185. },
  186. query_function_list (row) {
  187. this.$api.requested({
  188. "classname": "webmanage.role.role",
  189. "method": "query_appoptionselect",
  190. "content": {
  191. "roleid":this.$route.query.id,
  192. "systemappid": row.systemappid
  193. }
  194. }).then(res=>{
  195. this.fun_list = res.data
  196. console.log(this.fun_list);
  197. })
  198. },
  199. query_field_list (row) {
  200. this.$api.requested({
  201. "classname": "webmanage.role.role",
  202. "method": "query_apphiddenfieldselect",
  203. "content": {
  204. "roleid":this.$route.query.id,
  205. "systemappid": row.systemappid
  206. }
  207. }).then(res=>{
  208. this.hide_field_list = res.data
  209. console.log(this.hide_field_list);
  210. })
  211. },
  212. onFuncSelection (selection) {
  213. this.func_selection = selection
  214. },
  215. onFieldSelection (selection) {
  216. this.field_selection = selection
  217. },
  218. insert_opt_hid_select () {
  219. let filterid = (array,idname) => {
  220. let arr = []
  221. array.filter(e=>{
  222. arr.push(e[idname])
  223. })
  224. return arr
  225. }
  226. console.log(filterid(this.func_selection,'optionid'))
  227. this.$api.requested({"classname": "webmanage.role.role",
  228. "method": "add_appauth",
  229. "content": {
  230. "roleid":this.$route.query.id,
  231. "systemapps": [
  232. {
  233. "systemappid": this.systemappid,
  234. "optionids": this.func_selection.length > 0?filterid(this.func_selection,'optionid'):[],
  235. "hiddenfields":this.field_selection.length > 0?filterid(this.field_selection,'hiddenfieldid'):[]
  236. }
  237. ]
  238. }
  239. }).then(res=>{
  240. if (res.code === 1) {
  241. this.$notify({
  242. title: '成功',
  243. message: this.activeName === 'first'?'功能授权成功':'设置成功',
  244. type: 'success'
  245. });
  246. this.query_function_list(this.row)
  247. this.$emit('onSuccess')
  248. } else {
  249. this.$notify({
  250. title: '失败',
  251. message: res.data,
  252. type: 'error'
  253. });
  254. }
  255. })
  256. }
  257. }
  258. }
  259. </script>
  260. <style>
  261. .auth-container .el-tabs--border-card{
  262. box-shadow: none !important;
  263. }
  264. .auth-container .el-tabs--border-card>.el-tabs__content{
  265. padding: 0;
  266. }
  267. </style>