GroupAuth.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <!-- 分组权限管理 -->
  2. <template>
  3. <div>
  4. <el-row>
  5. <el-col :span="24">
  6. <el-form :inline="true" class="demo-form-inline search-center">
  7. <el-form-item label="名称">
  8. <el-input
  9. v-model="searchKey"
  10. placeholder="请输入量表或认知任务名称"
  11. size="small"
  12. />
  13. </el-form-item>
  14. <el-form-item label="类型">
  15. <el-select
  16. v-model="type"
  17. @change="searchList(0)"
  18. placeholder="请选择类型"
  19. size="small"
  20. >
  21. <el-option label="量表" value="0"></el-option>
  22. <el-option label="认知任务" value="1"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button
  27. type="primary"
  28. icon="el-icon-search"
  29. size="small"
  30. @click="searchList(0)"
  31. >
  32. 查询
  33. </el-button>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" size="small" icon="el-icon-plus" @click="addAuthList">
  37. 新增
  38. </el-button>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button
  42. type="primary"
  43. size="small"
  44. icon="el-icon-refresh-left"
  45. @click="goreturn"
  46. >
  47. 返回
  48. </el-button>
  49. </el-form-item>
  50. </el-form>
  51. </el-col>
  52. </el-row>
  53. <!-- 权限列表 -->
  54. <el-table :data="authList" border class="table-padding center-table" size="small">
  55. <el-table-column prop="name" label="名称" width="auto" align="center">
  56. </el-table-column>
  57. <el-table-column label="操作" width="240" align="center">
  58. <template slot-scope="scope">
  59. <el-button
  60. type="danger"
  61. size="small"
  62. @click="delAuthItem(scope.row.id)"
  63. >
  64. 删除
  65. </el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <div class="txt-center mt20">
  70. <el-pagination
  71. @size-change="handleSizeChange1"
  72. @current-change="handleCurrentChange"
  73. :current-page="pageNum"
  74. :page-sizes="[10, 20, 50, 100]"
  75. :page-size="pageSize"
  76. layout="total, sizes, prev, pager, next, jumper"
  77. :total="total"
  78. size="small"
  79. />
  80. </div>
  81. <!--新增量表权限-->
  82. <el-dialog
  83. :inline="true"
  84. title="新增权限"
  85. :visible.sync="dialogVisible"
  86. width="60%"
  87. :close-on-click-modal="false"
  88. append-to-body
  89. >
  90. <div>
  91. <el-form :inline="true" size="small" class="demo-form-inline">
  92. <el-form-item label="名称">
  93. <el-input v-model="scaleName" size="small" placeholder="请输入名称"></el-input>
  94. </el-form-item>
  95. <el-form-item label="类型">
  96. <el-select
  97. v-model="aType"
  98. size="small"
  99. @change="searchList(1)"
  100. placeholder="请选择类型"
  101. >
  102. <el-option label="量表" value="0"></el-option>
  103. <el-option label="认知任务" value="1"></el-option>
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item>
  107. <el-button type="primary" size="small" @click="searchList(1)">查询</el-button>
  108. </el-form-item>
  109. </el-form>
  110. <el-table
  111. ref="tableSe"
  112. @header-click="headerCli"
  113. @row-click="clickRow"
  114. :data="scaleList"
  115. :row-key="getRowKeys"
  116. @selection-change="changeHandle"
  117. border
  118. style="width: 100%"
  119. class="table-padding mt20"
  120. v-loading="loading"
  121. size="small"
  122. >
  123. <el-table-column type="selection" :reserve-selection="true" width="60"> </el-table-column>
  124. <el-table-column prop="name" label="名称" width="auto" align="center">
  125. </el-table-column>
  126. </el-table>
  127. <div class="mt20 txt-center">
  128. <el-pagination
  129. @size-change="handleSizeChange"
  130. @current-change="handleCurrentChange2"
  131. :current-page="scalePageNum"
  132. :page-sizes="[10, 20, 50, 100]"
  133. :page-size="pageSize"
  134. layout="total, sizes, prev, pager, next, jumper"
  135. :total="scaleTotal"
  136. size="small"
  137. />
  138. </div>
  139. <div class="btnArea">
  140. <el-button size="small" @click="cancelSave">取消</el-button>
  141. <el-button type="primary" size="small" @click="savaNewAuth" :disabled="isdisabled">
  142. 保存
  143. </el-button>
  144. </div>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. export default {
  151. name: "GroupAuth",
  152. data() {
  153. return {
  154. gId: "", // 组idI
  155. pageNum: 1,
  156. pageSize: 10,
  157. searchKey: "",
  158. type: "0", // 已有查询type
  159. authList: [],
  160. total: 0,
  161. formInline: {},
  162. dialogVisible: false,
  163. scaleList: [],
  164. aType: "0", // 全量查询type
  165. scaleName: "",
  166. checkList: [],
  167. scalePageNum: 1,
  168. scalePageSize: 10,
  169. scaleTotal: 0,
  170. loading: true, //设置加载读取
  171. isdisabled: true, //设置保存按钮是否可用
  172. getRowKeys(row) {
  173. return row.id;
  174. },//获取row的key值
  175. };
  176. },
  177. created() {
  178. this.gId = this.$route.query.gId;
  179. this.institutionNo = sessionStorage.getItem(
  180. "f7a42fe7211f98ac7a60a285ac3a9527"
  181. );
  182. this.loadData();
  183. },
  184. methods: {
  185. // 查询已有权限列表
  186. loadData() {
  187. this.$http.get(
  188. `group/auth/find?groupId=${this.gId}&type=${this.type}&pageNum=${this.pageNum}&pageSize=${this.pageSize}&searchKey=${this.searchKey}`,
  189. {},
  190. (msg) => {
  191. console.log(msg);
  192. this.authList = msg.data.content;
  193. this.total = msg.data.totalElements;
  194. }
  195. );
  196. },
  197. clickRow(row) {
  198. this.$refs.tableSe.toggleRowSelection(row);
  199. },
  200. //点击表头选中
  201. headerCli(column, event) {
  202. this.toggleSelection(this.scaleList);
  203. },
  204. toggleSelection(rows) {
  205. let that = this;
  206. if (rows) {
  207. rows.forEach((row) => {
  208. that.$refs.tableSe.toggleRowSelection(row);
  209. });
  210. } else {
  211. that.$refs.tableSe.clearSelection();
  212. }
  213. },
  214. // 已有权限分页切换
  215. handleCurrentChange(i) {
  216. this.pageNum = i;
  217. this.loadData();
  218. },
  219. goreturn() {
  220. this.$router.push("UserGroupManagement");
  221. },
  222. // 全量量表权限切换
  223. handleCurrentChange2(i) {
  224. this.scalePageNum = i;
  225. this.getAllList();
  226. },
  227. // 切换类型
  228. searchList(index) {
  229. if (index == 0) {
  230. this.pageNum = 1;
  231. this.loadData();
  232. } else {
  233. this.scalePageNum = 1;
  234. this.getAllList();
  235. }
  236. },
  237. handleSizeChange1(val) {
  238. console.log("进入了该方法");
  239. this.pageSize = val;
  240. console.log(this.pageSize);
  241. this.loadData();
  242. },
  243. handleSizeChange(val) {
  244. console.log("进入了该方法");
  245. this.scalePageSize = val;
  246. console.log(this.pageSize);
  247. this.getAllList();
  248. },
  249. // 查询全部量表或认知任务
  250. getAllList() {
  251. this.loading = true;
  252. this.isdisabled = true;
  253. this.$http.get(
  254. `group/auth/findNoAuth?institutionNo=${this.institutionNo}&groupId=${this.gId}&type=${this.aType}&pageNum=${this.scalePageNum}&pageSize=${this.scalePageSize}&searchKey=${this.scaleName}`,
  255. {},
  256. (msg) => {
  257. console.log(msg);
  258. this.scaleList = msg.data.data;
  259. this.scaleTotal = msg.data.allNum;
  260. this.loading = false;
  261. this.isdisabled = false;
  262. }
  263. );
  264. // this.$http.post(
  265. // "institutionAuth/getInstitutionAuth",
  266. // {
  267. // pageNum: this.scalePageNum,
  268. // pageSize: this.scalePageSize,
  269. // institutionNo: this.institutionNo,
  270. // type: this.aType,
  271. // searchKey: this.searchKey,
  272. // },
  273. // (msg) => {
  274. // console.log(msg);
  275. // this.scaleList = msg.data.data;
  276. // this.scaleTotal = msg.data.allNum;
  277. // }
  278. // );
  279. },
  280. // 多选添加
  281. changeHandle(selection) {
  282. console.log(selection);
  283. this.checkList = selection;
  284. },
  285. // 新增
  286. addAuthList() {
  287. this.getAllList();
  288. this.dialogVisible = true;
  289. //清空选中项数据
  290. this.$nextTick(()=>{
  291. this.$refs.tableSe.clearSelection();
  292. });
  293. this.checkList = [];
  294. },
  295. // 保存新增权限
  296. savaNewAuth() {
  297. let arr = [];
  298. this.checkList.forEach((el) => {
  299. arr.push({
  300. bId: el.bid,
  301. groupId: this.gId,
  302. type: el.type,
  303. });
  304. });
  305. const loading = this.$loading({
  306. lock: true,
  307. fullscreenLoading: true,
  308. text: "添加权限中,请耐心等待.....",
  309. // spinner: 'el-icon-loading',
  310. // background: 'rgba(0, 0, 0, 0.7)'
  311. });
  312. console.log(arr);
  313. if (arr.length == 0) {
  314. this.$message.info("未添加权限");
  315. this.dialogVisible = false;
  316. loading.close();
  317. this.loadData();
  318. } else {
  319. this.$http.post("group/auth/add", arr, (msg) => {
  320. this.$message.success("权限新增成功");
  321. this.dialogVisible = false;
  322. loading.close();
  323. this.loadData();
  324. });
  325. }
  326. },
  327. // 取消保存
  328. cancelSave() {
  329. this.dialogVisible = false;
  330. },
  331. // 删除已有权限
  332. delAuthItem(id) {
  333. this.$confirm("此操作将删除该权限, 是否继续?", "提示", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning",
  337. })
  338. .then(() => {
  339. this.$http.post(
  340. `group/auth/del`,
  341. {
  342. ids: [id],
  343. },
  344. (msg) => {
  345. this.$message.success("删除成功");
  346. this.loadData();
  347. }
  348. );
  349. })
  350. .catch(() => {});
  351. },
  352. },
  353. };
  354. </script>
  355. <style>
  356. .btnArea {
  357. padding: 20px;
  358. text-align: center;
  359. }
  360. </style>