roleContent copy.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="normal-panel drewer__panel">
  3. <div>
  4. <p class="normal-title mb-16">角色信息</p>
  5. <el-form :inline="true" :model="form" :rules="rules" ref="form" size="small" label-width="100px" label-position="left" class="demo-form-inline">
  6. <el-form-item label="角色名称" prop="rolename">
  7. <el-input v-model="form.rolename" placeholder="输入角色名称"></el-input>
  8. </el-form-item>
  9. <el-form-item label="角色描述" prop="remarks">
  10. <el-input v-model="form.remarks" placeholder="输入角色描述"></el-input>
  11. </el-form-item>
  12. <el-form-item label="角色类型" prop="usertype">
  13. <el-select v-model="form.usertype" placeholder="角色类型">
  14. <el-option v-for="item in options" :key="item.index" :label="item.remarks" :value="Number(item.value)"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. <div>
  20. <p class="normal-title mb-16">角色授权</p>
  21. <el-row :gutter="20">
  22. <el-col :span="12">
  23. <div class="mb-16">
  24. <auth @onSuccess="roleMain"></auth>
  25. </div>
  26. <el-collapse>
  27. <el-collapse-item title="筛选" name="1">
  28. <el-row class="normal-margin">
  29. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
  30. <div style="margin: 15px 0;"></div>
  31. <el-checkbox-group v-model="checkModuleList" @change="handleCheckedCitiesChange">
  32. <el-col style="margin-bottom:5px" :span="6" v-for="item in modulesList" :key="item.index">
  33. <el-checkbox :label="item"></el-checkbox>
  34. </el-col>
  35. </el-checkbox-group>
  36. </el-row>
  37. </el-collapse-item>
  38. </el-collapse>
  39. <tableLayout :layout="tablecols" :data="apps" :custom="false" height="500px" @rowClick="appoptionselect">
  40. </tableLayout>
  41. </el-col>
  42. <el-col :span="11">
  43. <el-row :gutter="40">
  44. <el-col :span="12">
  45. <p class="title">功能</p>
  46. <el-row>
  47. <el-checkbox-group v-model="checkedApps">
  48. <el-col class="normal-margin" v-for="item in appoptions" :key="item.rowindex">
  49. <el-checkbox :label="item.optionid">{{item.optionname}}</el-checkbox>
  50. </el-col>
  51. </el-checkbox-group>
  52. </el-row>
  53. <div class="flex-align-center flex-between option-item">
  54. <el-checkbox :indeterminate="isIndeterminate2" v-model="checkAll2" @change="handleCheckAllChange2">全选</el-checkbox>
  55. <cancelAuth v-if="checkedApps.length > 0" :data="{roleid:data.roleid,systemappid:active_systemappid,optionid:checkedApps}" @onSuccess="(roleMain(),$emit('onSuccess'))"></cancelAuth>
  56. </div>
  57. </el-col>
  58. <el-col :span="12">
  59. <p class="title">隐藏字段</p>
  60. <div class="flex-align-center flex-between option-item" v-for="item in hiddenfields" :key="item.index">
  61. <p>{{item.fieldname}}</p>
  62. <cancelFields :data="{roleid:roleid,systemappid:active_systemappid,hiddenfieldid:item.hiddenfieldid}" @onSuccess="(roleMain(),$emit('onSuccess'))"></cancelFields>
  63. </div>
  64. </el-col>
  65. </el-row>
  66. </el-col>
  67. </el-row>
  68. </div>
  69. <div class="fixed__btn__panel">
  70. <slot name="cancel"></slot>
  71. <el-button type="primary" size="small" class="normal-btn-width" @click="onSubmit">保 存</el-button>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import auth from './auth_list.vue'
  77. import cancelAuth from './cancel_auth.vue'
  78. import cancelFields from './cancel_fields.vue'
  79. export default {
  80. props:['data'],
  81. components:{
  82. auth,
  83. cancelAuth,
  84. cancelFields
  85. },
  86. data () {
  87. return{
  88. isIndeterminate:false,
  89. isIndeterminate2:false,
  90. checkAll: true,
  91. checkAll2: false,
  92. rules:{
  93. rolename: [
  94. { required: true, message: '请输入角色名称', trigger: 'blur' },
  95. ],
  96. remarks: [
  97. { required: true, message: '请输入角色描述', trigger: 'blur' },
  98. ],
  99. usertype: [
  100. { required: true, message: '请选择角色类型', trigger: 'change' }
  101. ],
  102. },
  103. form:{
  104. "roleid":0,
  105. "rolename":"",
  106. "remarks":""
  107. },
  108. roleMainInfo:{},
  109. options:[],
  110. tablecols:[],
  111. appoptions:[],
  112. hiddenfields:[],
  113. modulesList:[],
  114. checkModuleList:[],
  115. apps:[],
  116. checkedApps:[],
  117. roleid:0,
  118. active_systemappid:''
  119. }
  120. },
  121. methods:{
  122. async roleMain () {
  123. const res = await this.$api.requested({
  124. "classname": "webmanage.role.role",
  125. "method": "query_roleMain",
  126. "content": {
  127. "roleid":this.data.roleid
  128. }
  129. })
  130. this.form = {
  131. "roleid":res.data.roleid,
  132. "rolename":res.data.rolename,
  133. "remarks":res.data.remarks,
  134. "usertype":res.data.usertype
  135. }
  136. this.roleMainInfo = res.data
  137. //显示默认授权信息,一般默认信息为第一条数据
  138. res.data.apps[0]?this.appoptionselect(res.data.apps[0]):''
  139. this.filterModules()
  140. },
  141. async usertype () {
  142. let param = {
  143. "classname": "sysmanage.develop.optiontype.optiontype",
  144. "method": "optiontypeselect",
  145. "content": {
  146. "pageNumber": 1,
  147. "pageSize": 20,
  148. "typename": "usertype",
  149. "parameter": {
  150. }
  151. }
  152. }
  153. const res = await this.$api.requested(param)
  154. this.options = res.data
  155. },
  156. async appoptionselect (row) {
  157. this.active_systemappid = row.systemappid
  158. this.appoptions = row.options
  159. this.hiddenfields = row.hiddenfields
  160. },
  161. onSubmit () {
  162. this.$refs['form'].validate((valid) => {
  163. if (!valid) return false
  164. this.$api.requested({
  165. "classname": "webmanage.role.role",
  166. "method": "insertormodify_role",
  167. "content": this.form
  168. }).then(res=>{
  169. this.tool.showMessage(res,()=>{
  170. this.$router.push({path:this.$route.path,query:{id:res.data.roleid}})
  171. this.$emit('onSuccess')
  172. })
  173. })
  174. })
  175. },
  176. //遍历权限模块用于筛选
  177. filterModules () {
  178. let arr = this.roleMainInfo.apps.map(e=>{
  179. return e.systemmodulename
  180. })
  181. this.modulesList = this.checkModuleList = [...new Set(arr)]
  182. this.filterApps()
  183. },
  184. handleCheckAllChange(val) {
  185. this.checkModuleList = val ? this.modulesList : [];
  186. this.isIndeterminate = false;
  187. this.filterApps()
  188. },
  189. handleCheckedCitiesChange(value) {
  190. let checkedCount = value.length;
  191. this.checkAll = checkedCount === this.modulesList.length;
  192. this.isIndeterminate = checkedCount > 0 && checkedCount < this.modulesList.length;
  193. this.filterApps()
  194. },
  195. filterApps () {
  196. let arr = []
  197. this.roleMainInfo.apps.forEach(app => {
  198. this.checkModuleList.filter(e=>{
  199. if (e === app.systemmodulename) {
  200. arr.push(app)
  201. }
  202. })
  203. });
  204. this.apps = arr
  205. },
  206. handleCheckAllChange2 (val) {
  207. let arr = this.appoptions.map(e=>{return e.optionid})
  208. this.checkedApps = val ? arr : [];
  209. this.isIndeterminate2 = false;
  210. },
  211. },
  212. mounted () {
  213. // 获取应用表结构
  214. this.tablecols = this.tool.tabelCol(this.$route.name).detailsAppsTable.tablecols
  215. this.data.roleid !== '0'?this.roleMain():''
  216. this.usertype()
  217. },
  218. created () {
  219. // 验证是否有编辑权限,若无权限则弹出
  220. // // this.tool.checkAuth(this.$route.name,'update')?'':this.$router.go(-1)
  221. }
  222. }
  223. </script>
  224. <style>
  225. </style>
  226. <style scoped>
  227. .mb-16{
  228. margin-bottom:16px
  229. }
  230. .title{
  231. height: 20px;
  232. line-height: 20px;
  233. font-size: 14px;
  234. text-indent: 7px;
  235. font-weight: bold;
  236. color: #333333;
  237. margin-bottom: 20px;
  238. border-left: .3rem solid #3874F6;
  239. }
  240. .option-item{
  241. color:#333333;
  242. font-size: 14px;
  243. border-top:1px solid #f1f2f3;
  244. padding-top:16px;
  245. }
  246. </style>