AuthorityJob.vue 15 KB

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