AuthorityJob.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div v-loading="loading"
  3. element-loading-text="拼命加载中"
  4. element-loading-spinner="el-icon-loading">
  5. <div class="job-box">
  6. <div class="job-head">
  7. <div>
  8. <el-select @change="Inquirechange()" v-model="value" clearable placeholder="权限模块">
  9. <el-option v-for="item in authority" :key="item.value" :label="item.name" :value="item.id">
  10. </el-option>
  11. </el-select>
  12. </div>
  13. <div>
  14. <el-select @change="companyChange()" v-model="valuecorporation" clearable placeholder="公司">
  15. <el-option v-for="item in corporation" :key="item.value" :label="item.companyName" :value="item.id">
  16. </el-option>
  17. </el-select>
  18. <el-select @change="depaChange()" v-model="valuedepartmental" clearable placeholder="部门">
  19. <el-option v-for="item in departmental" :key="item.id" :label="item.depName" :value="item.id">
  20. </el-option>
  21. </el-select>
  22. <el-select @change="JobChange()" v-model="valueposition" clearable placeholder="职位">
  23. <el-option v-for="item in position" :key="item.id" :label="item.jobName" :value="item.id">
  24. </el-option>
  25. </el-select>
  26. <el-button type="primary" @click="saveAuth()">保 存</el-button>
  27. </div>
  28. </div>
  29. <div class="job-table">
  30. <el-table :data="authorityLists.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
  31. @select="handleSelect" @select-all="allchange" style="width: 100%">
  32. <el-table-column type="selection" width="55">
  33. </el-table-column>
  34. <el-table-column prop="name" label="权限页面" width="180">
  35. </el-table-column>
  36. <el-table-column width="55" :label="op.functionName" :key="op.id" v-for="op in opList">
  37. <template slot-scope="scope">
  38. <div>
  39. <el-checkbox @change='checkchange(scope.row.id,op.id)' v-if=" scope.row.opList.indexOf(op.id) != -1" :value="scope.row.selList.indexOf(op.id) != -1" >
  40. </el-checkbox >
  41. <el-checkbox v-else :disabled="true" >
  42. </el-checkbox>
  43. </div>
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="address" label="备注">
  47. </el-table-column>
  48. </el-table>
  49. <div class="block">
  50. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  51. :current-page="currentPage" :page-sizes="[14, 20]" :page-size="pageSize"
  52. layout="total, sizes, prev, pager, next" :total="authorityList.length">
  53. </el-pagination>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import { promised, reject, resolve } from 'q';
  61. export default {
  62. data() {
  63. return {
  64. authority: [],
  65. value: '',
  66. corporation: [],
  67. valuecorporation: '',
  68. departmental: [], //部门数据
  69. valuedepartmental: '', //部门val
  70. position: [], //职位数据
  71. valueposition: '',//职位val
  72. authorityLists: [],
  73. authorityList: [],
  74. currentPage: 1, // 当前页码
  75. pageSize: 14,// 每页的数据条数
  76. stateArr: [],
  77. selectedAccount: [],
  78. PathUrl:'http://localhost:5256',
  79. opList :[],//操作方式
  80. loading:true,
  81. }
  82. },
  83. methods: {
  84. //每页条数改变时触发 选择一页显示多少行
  85. handleSizeChange(val) {
  86. this.currentPage = 1;
  87. this.pageSize = val;
  88. },
  89. //当前页改变时触发 跳转其他页
  90. handleCurrentChange(val) {
  91. this.currentPage = val;
  92. },
  93. //模块下拉框
  94. Inquirechange() {
  95. this.currentPage = 1;
  96. this.pageload(this.value);
  97. },
  98. //多选框选中方法
  99. handleSelect(selection, row) {
  100. console.log(selection,row)
  101. if (selection.length > 0) {
  102. row.selList = this.opList.map(x => x.id);
  103. }else{
  104. row.selList = [];
  105. }
  106. },
  107. selectRadiocheck(index, row) {
  108. console.log(index)
  109. console.log(row)
  110. },
  111. selectRadioerase(index, row) {
  112. console.log(index, row)
  113. },
  114. selectRadioedit(index, row) {
  115. console.log(index, row)
  116. },
  117. selectRadiodown(index, row) {
  118. console.log(index, row)
  119. },
  120. selectRadioup(index, row) {
  121. console.log(index, row)
  122. },
  123. pageload(moduleId){
  124. var that = this;
  125. //初始化界面数据
  126. this.$axios.post(this.PathUrl + '/api/System/GetAuth', {
  127. "pageSize": this.pageSize,
  128. "currentPage": this.currentPage,
  129. "moduleId":moduleId,
  130. }, {
  131. headers: {
  132. 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IkZ1dHVyZSIsImV4cCI6MTY3OTU0MjgwNSwiaXNzIjoiT0FTeXN0ZW0uY29tIiwiYXVkIjoiT0FTeXN0ZW0uY29tIn0.iy5SUInq1p3yjZultRPyzCa2ekLeepSdMLxvPwXY6MI',
  133. }
  134. }).then(resp => {
  135. if (resp.data.code == 200) {
  136. that.authority = resp.data.data.setDataResult; //模块数据
  137. that.corporation = resp.data.data.companyDataResult; //公司数据
  138. that.authorityList = resp.data.data.systemMenuPermissionData; //页面数据(默认权限页面)
  139. that.authorityLists = that.authorityList;
  140. that.opList = resp.data.data.pageOperation; //操作方式
  141. that.loading =false;
  142. }
  143. }).then(suc=>{
  144. if(this.valueposition != ''){
  145. this.JobChange();
  146. }
  147. })
  148. },
  149. //公司下拉框
  150. companyChange(){
  151. this.valuedepartmental = ''; //清空数据
  152. this.valueposition = '';
  153. this.position = [];
  154. this.departmental = [];
  155. if(this.valuecorporation == ''){
  156. return;
  157. }
  158. var that = this;
  159. //初始化界面数据
  160. this.$axios.post(this.PathUrl + '/api/System/QueryDepartmentList', {
  161. "CompanyId": this.valuecorporation,
  162. "PortType": 1,
  163. }, {
  164. headers: {
  165. 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IkZ1dHVyZSIsImV4cCI6MTY3OTU0MjgwNSwiaXNzIjoiT0FTeXN0ZW0uY29tIiwiYXVkIjoiT0FTeXN0ZW0uY29tIn0.iy5SUInq1p3yjZultRPyzCa2ekLeepSdMLxvPwXY6MI',
  166. }
  167. }).then(resp => {
  168. console.log(resp);
  169. if (resp.data.code == 200) {
  170. that.departmental = resp.data.data;
  171. }
  172. })
  173. },
  174. //部门下拉框
  175. depaChange(){
  176. var that = this;
  177. this.position = []; //职位数据
  178. this.valueposition = '';//职位val
  179. if(this.valuecorporation == '' || this.valuedepartmental == ''){
  180. return;
  181. }
  182. //初始化界面数据
  183. this.$axios.post(this.PathUrl + '/api/System/QueryJobPost', {
  184. "CompanyId": this.valuecorporation,
  185. "DepId":this.valuedepartmental,
  186. "PortType": 1,
  187. }, {
  188. headers: {
  189. 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IkZ1dHVyZSIsImV4cCI6MTY3OTU0MjgwNSwiaXNzIjoiT0FTeXN0ZW0uY29tIiwiYXVkIjoiT0FTeXN0ZW0uY29tIn0.iy5SUInq1p3yjZultRPyzCa2ekLeepSdMLxvPwXY6MI',
  190. }
  191. }).then(resp => {
  192. console.log(resp);
  193. if (resp.data.code == 200) {
  194. that.position = resp.data.data;
  195. }
  196. })
  197. },
  198. //保存权限
  199. saveAuth(){
  200. var that = this;
  201. if(this.valueposition == ''){
  202. this.$message.error('请选择职位!');
  203. return;
  204. }
  205. var savejob = [];
  206. this.authorityLists.forEach(item=>{
  207. savejob.push({
  208. SmId:item.id,
  209. FIds:item.selList,
  210. });
  211. })
  212. console.log(savejob);
  213. //初始化界面数据
  214. this.$axios.post(this.PathUrl + '/api/System/SaveJobAuth', {
  215. "Jpid": this.valueposition,
  216. "Savejobs": savejob,
  217. }, {
  218. headers: {
  219. 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IkZ1dHVyZSIsImV4cCI6MTY3OTU0MjgwNSwiaXNzIjoiT0FTeXN0ZW0uY29tIiwiYXVkIjoiT0FTeXN0ZW0uY29tIn0.iy5SUInq1p3yjZultRPyzCa2ekLeepSdMLxvPwXY6MI',
  220. }
  221. }).then(resp => {
  222. console.log(resp);
  223. if (resp.data.code == 200) {
  224. this.$message({
  225. message: '保存成功!',
  226. type: 'success'
  227. });
  228. }else{
  229. this.$message.error('保存失败!'+ resp.data.msg);
  230. }
  231. })
  232. },
  233. //职位下拉获取权限
  234. JobChange(){
  235. let val = this.value == '' ? 13 :this.value;
  236. var that = this;
  237. if(this.valueposition == ''){
  238. var arr = this.authorityList;
  239. arr.forEach(item=>{
  240. item.selList = [];
  241. })
  242. this.authorityList = arr;
  243. this.authorityLists = this.authorityList;
  244. return
  245. }
  246. //初始化界面数据
  247. this.$axios.post(this.PathUrl + '/api/System/QueryJobAuth', {
  248. "jobid": this.valueposition,
  249. "moduleId":val,
  250. }, {
  251. headers: {
  252. 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IkZ1dHVyZSIsImV4cCI6MTY3OTU0MjgwNSwiaXNzIjoiT0FTeXN0ZW0uY29tIiwiYXVkIjoiT0FTeXN0ZW0uY29tIn0.iy5SUInq1p3yjZultRPyzCa2ekLeepSdMLxvPwXY6MI',
  253. }
  254. }).then(resp => {
  255. console.log(resp);
  256. if (resp.data.code == 200) {
  257. that.authorityList = resp.data.data; //页面数据(默认权限页面)
  258. that.authorityLists = that.authorityList;
  259. }
  260. })
  261. },
  262. //全选
  263. allchange(selection){
  264. let that = this;
  265. if (selection.length > 0) {
  266. selection.forEach(item => {
  267. item.selList = that.opList.map(x => x.id);
  268. });
  269. }else{
  270. this.authorityLists.forEach(item => {
  271. item.selList = [];
  272. });
  273. }
  274. },
  275. checkchange(rowid, linid) {
  276. this.authorityLists.forEach(item => {
  277. if (item.id == rowid) {
  278. if(item.selList.indexOf(linid) == -1){
  279. item.selList.push(linid);
  280. }else{
  281. item.selList.splice(item.selList.indexOf(linid), 1)
  282. }
  283. }
  284. });
  285. console.warn(this.authorityLists);
  286. }
  287. },
  288. mounted() {
  289. this.pageload(13);
  290. }
  291. }
  292. </script>
  293. <style>
  294. body {
  295. margin: 0;
  296. padding: 0;
  297. }
  298. .job-head {
  299. display: flex;
  300. justify-content: space-between;
  301. }
  302. .job-box {
  303. background-color: #fff;
  304. padding: 10px;
  305. border-radius: 10px;
  306. }
  307. .job-table {
  308. margin-top: 10px;
  309. }
  310. .job-table .block {
  311. margin-top: 10px;
  312. }
  313. .job-table .el-table--enable-row-transition .el-table__body td.el-table__cell {
  314. text-align: center;
  315. }
  316. .job-table .el-table--border .el-table__cell:first-child .cell {
  317. text-align: center;
  318. }
  319. </style>