AuthorityUser.vue 15 KB

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