AuthorityJob.vue 13 KB

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