permissionsAuth.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div class="menu">
  3. <div class="menu-head">
  4. <a-input
  5. placeholder="名称"
  6. style="width: 300px"
  7. v-model="searchName"
  8. allowClear
  9. ></a-input>
  10. <a-button type="primary" @click="searchList">查询</a-button>
  11. </div>
  12. <standard-table
  13. bordered
  14. :columns="columns"
  15. :dataSource="tableList"
  16. :pagination="pagination"
  17. @change="onChange"
  18. :loading="loading"
  19. >
  20. <div class="operation-list" slot="operation" slot-scope="record">
  21. <a-button type="primary" @click="editMenu(record)">数据权限</a-button>
  22. </div>
  23. </standard-table>
  24. <a-modal
  25. v-model="visible"
  26. :title="title"
  27. @ok="handleOk"
  28. layout="inline"
  29. width="70%"
  30. :confirm-loading="confirmLoading"
  31. >
  32. <div style="display: flex">
  33. <div style="width: 28%">
  34. <tree
  35. :checkable="checkable"
  36. @checkTree="checkTree"
  37. ref="tree"
  38. @getList="getMessageList"
  39. ></tree>
  40. </div>
  41. <div style="flex: 1">
  42. <a-form layout="inline" :model="formState" class="users">
  43. <a-form-item label="姓名" :labelCol="{ span: 5 }" :colon="false">
  44. <a-input
  45. placeholder="请输入姓名"
  46. v-model="formState.userName"
  47. allowClear
  48. ></a-input>
  49. </a-form-item>
  50. <a-form-item label="工号" :labelCol="{ span: 5 }" :colon="false">
  51. <a-input
  52. placeholder="请输入工号"
  53. v-model="formState.userId"
  54. allowClear
  55. ></a-input>
  56. </a-form-item>
  57. <a-form-item label="管理人" :labelCol="{ span: 5 }" :colon="false">
  58. <a-cascader
  59. change-on-select
  60. style="width: 300px"
  61. placeholder="请选择管理人"
  62. v-model="formState.leaderId"
  63. allowClear
  64. :options="manageList"
  65. :display-render="displayRender"
  66. >
  67. </a-cascader>
  68. </a-form-item>
  69. <a-form-item
  70. label=" "
  71. :labelCol="{ span: 5 }"
  72. :colon="false"
  73. class="form-item-search"
  74. >
  75. <a-button type="primary" @click="searchChannel()">查询</a-button>
  76. </a-form-item>
  77. </a-form>
  78. <a-tabs
  79. default-active-key="1"
  80. :tab-position="'top'"
  81. style="margin-left: 15px; flex: 1"
  82. @change="tabChange"
  83. >
  84. <a-tab-pane key="1" tab="代理人">
  85. <standard-table
  86. bordered
  87. :columns="columns1"
  88. :dataSource="perTable"
  89. :pagination="perPagination"
  90. @change="onChangePer"
  91. :loading="perLoading"
  92. >
  93. </standard-table>
  94. </a-tab-pane>
  95. <a-tab-pane key="2" tab="渠道">
  96. <standard-table
  97. bordered
  98. :columns="columns1"
  99. :dataSource="perTable"
  100. :pagination="perPagination"
  101. @change="onChangePer"
  102. :loading="perLoading"
  103. >
  104. </standard-table>
  105. </a-tab-pane>
  106. </a-tabs>
  107. </div>
  108. </div>
  109. <!-- <a-form :layout="formLayout"> -->
  110. <!-- <tree :checkable="checkable" @checkTree="checkTree" ref="tree"></tree> -->
  111. <!-- </a-form> -->
  112. </a-modal>
  113. </div>
  114. </template>
  115. <script>
  116. import StandardTable from "@/components/table/StandardTable";
  117. import tree from "@/components/tree/allTree.vue";
  118. const columns = [
  119. {
  120. title: "员工工号",
  121. dataIndex: "id",
  122. //
  123. },
  124. {
  125. title: "姓名",
  126. dataIndex: "name",
  127. },
  128. {
  129. title: "机构Id",
  130. dataIndex: "deptId",
  131. },
  132. {
  133. title: "机构名称",
  134. dataIndex: "deptName",
  135. },
  136. {
  137. title: "操作",
  138. key: "operation",
  139. scopedSlots: { customRender: "operation" },
  140. },
  141. ];
  142. const columns1 = [
  143. {
  144. title: "员工工号",
  145. dataIndex: "id",
  146. //
  147. },
  148. {
  149. title: "姓名",
  150. dataIndex: "name",
  151. },
  152. {
  153. title: "管理人",
  154. dataIndex: "leaderName",
  155. },
  156. {
  157. title: "业务来源",
  158. dataIndex: "managementSource",
  159. },
  160. ];
  161. import manageminxin from "../../minins/manageMixin";
  162. export default {
  163. components: {
  164. StandardTable,
  165. tree,
  166. },
  167. mixins: [manageminxin],
  168. data() {
  169. return {
  170. formState: {
  171. userId: undefined,
  172. userName: undefined,
  173. leaderId: [],
  174. },
  175. visible: false,
  176. confirmLoading: false,
  177. title: "",
  178. checkable: true,
  179. formLayout: "horizontal",
  180. menuTypeList: ["目录", "菜单", "按钮"],
  181. replaceFields: {
  182. children: "children",
  183. title: "name",
  184. key: "id",
  185. },
  186. dataForm: {
  187. id: 0,
  188. type: 1,
  189. name: "",
  190. parentId: 0,
  191. parentName: "",
  192. url: "",
  193. perms: "",
  194. orderNum: 0,
  195. icon: "",
  196. },
  197. pagination: {
  198. current: 1,
  199. defaultPageSize: 10,
  200. total: 0,
  201. pagesize0ptions: ["10", "20", "30", "50", "100"],
  202. hideOnSinglePage: false,
  203. showQuickJumper: true, //
  204. showSizeChanger: true, //是否可以改变pagesize
  205. showTotal: (total) => `共 ${total} 条数据`,
  206. },
  207. columns1,
  208. perPagination: {
  209. current: 1,
  210. defaultPageSize: 10,
  211. total: 0,
  212. pagesize0ptions: ["10", "20", "30", "50", "100"],
  213. hideOnSinglePage: false,
  214. showQuickJumper: true, //
  215. showSizeChanger: true, //是否可以改变pagesize
  216. showTotal: (total) => `共 ${total} 条数据`,
  217. },
  218. perTable: [],
  219. perLoading: false,
  220. formItemLayout: {
  221. labelCol: {
  222. xs: { span: 5 },
  223. sm: { span: 5 },
  224. },
  225. wrapperCol: {
  226. xs: { span: 24 },
  227. sm: { span: 16 },
  228. },
  229. },
  230. menuList: [],
  231. columns,
  232. tableList: [],
  233. loading: false,
  234. resetForm: {},
  235. authType: false,
  236. authList: [],
  237. authPermissions: {
  238. customScriptFlag: 0,
  239. dataPermissionId: "",
  240. id: undefined,
  241. menuId: 0,
  242. scriptContent: "",
  243. url: "",
  244. },
  245. checkList: [],
  246. defaultCheckList: [],
  247. searchName: "",
  248. tabs: 1,
  249. deptId: "",
  250. };
  251. },
  252. created() {
  253. this.getList();
  254. this.resetForm = { ...this.dataForm };
  255. this.getAuthList();
  256. },
  257. mounted() {},
  258. methods: {
  259. displayRender({ labels }) {
  260. return labels[labels.length - 1];
  261. },
  262. filterOption(input, option) {
  263. return (
  264. option.componentOptions.children[0].text
  265. .toLowerCase()
  266. .indexOf(input.toLowerCase()) >= 0
  267. );
  268. },
  269. searchList() {
  270. this.pagination.current = 1;
  271. this.pagination.defaultPageSize = 10;
  272. this.getList();
  273. },
  274. tabChange(key) {
  275. // console.log(key);
  276. this.tabs = key;
  277. this.perPagination.current = 1;
  278. this.perPagination.defaultPageSize = 10;
  279. this.getChannelList(this.deptId);
  280. },
  281. searchChannel() {
  282. this.perPagination.current = 1;
  283. this.perPagination.defaultPageSize = 10;
  284. this.getChannelList(this.deptId);
  285. },
  286. getMessageList(id) {
  287. this.deptId = id;
  288. this.perPagination.current = 1;
  289. this.perPagination.defaultPageSize = 10;
  290. this.getChannelList(id);
  291. },
  292. getChannelList(id) {
  293. this.perLoading = true;
  294. this.$API.sysManage
  295. .getAgentOrChannel({
  296. deptId: id,
  297. type: this.tabs,
  298. pageNum: this.perPagination.current,
  299. pageSize: this.perPagination.defaultPageSize,
  300. ...this.formState,
  301. leaderId: this.formState.leaderId[this.formState.leaderId.length - 1],
  302. })
  303. .then((res) => {
  304. console.log(res);
  305. if (res.data.code === 200) {
  306. this.perLoading = false;
  307. this.perTable = [...res.data.data.content];
  308. this.perPagination.total = res.data.data.totalSize;
  309. }
  310. });
  311. },
  312. checkTree(list) {
  313. this.checkList = [...list];
  314. // console.log(list);
  315. },
  316. getAuthList() {
  317. this.$API.sysManage.getAuthModule("sjqx").then((res) => {
  318. if (res.data.code === 200) {
  319. this.authList = [...res.data.data];
  320. }
  321. });
  322. },
  323. editMenu(item) {
  324. // this.defaultCheckList = [];
  325. this.title = "数据权限配置";
  326. this.visible = true;
  327. this.dataForm = { ...item.record };
  328. this.$nextTick(() => {
  329. this.$refs.tree.setExpandKys(item.record);
  330. // this.defaultCheckList = [""];
  331. });
  332. this.perTable = [];
  333. this.perPagination.current = 1;
  334. this.perPagination.defaultPageSize = 10;
  335. this.deptId = "";
  336. this.formState = {
  337. userId: undefined,
  338. userName: undefined,
  339. leaderId: [],
  340. };
  341. // this.setExpandKys(item.record);
  342. },
  343. setExpandKys() {},
  344. onChange(pagination) {
  345. // this.$message.info('表格状态改变了')
  346. // console.log(pagination, filters, sorter, { currentDataSource });
  347. this.pagination = {
  348. current: pagination.current,
  349. defaultPageSize: pagination.pageSize,
  350. total: pagination.total,
  351. };
  352. this.getList();
  353. },
  354. onChangePer(pagination) {
  355. this.perPagination = {
  356. current: pagination.current,
  357. defaultPageSize: pagination.pageSize,
  358. total: pagination.total,
  359. };
  360. this.getMessageList(this.deptId);
  361. },
  362. getList() {
  363. this.loading = true;
  364. this.$API.sysManage
  365. .getDeptList({
  366. pageNum: this.pagination.current,
  367. pageSize: this.pagination.defaultPageSize,
  368. name: this.searchName,
  369. agentFlag: 0,
  370. roleId: "22",
  371. })
  372. .then((res) => {
  373. if (res.data.code === 200) {
  374. this.loading = false;
  375. this.tableList = [...res.data.data.content];
  376. // this.pagination.current = res.data.data.pageNum;
  377. // this.pagination.defaultPageSize = res.data.data.pageSize;
  378. this.pagination.total = res.data.data.totalSize;
  379. }
  380. });
  381. },
  382. // addMenu() {
  383. // this.title = "新增";
  384. // this.visible = true;
  385. // this.dataForm = { ...this.resetForm };
  386. // },
  387. handleOk() {
  388. // this.visible = false;
  389. // this.confirmLoading = true;
  390. // console.log(this.dataForm, this.checkList);
  391. this.$API.sysManage
  392. .UserSetDeptAuth({
  393. userId: this.dataForm.id,
  394. deptIds: this.checkList,
  395. })
  396. .then((res) => {
  397. if (res.data.code === 200) {
  398. this.$message.success("操作成功");
  399. this.confirmLoading = false;
  400. this.visible = false;
  401. this.getList();
  402. }
  403. });
  404. },
  405. },
  406. };
  407. </script>
  408. <style lang='less' scoped>
  409. .ant-tabs-tabpane {
  410. display: flex;
  411. }
  412. .menu {
  413. display: flex;
  414. flex-direction: column;
  415. background: #fff;
  416. .menu-head {
  417. display: flex;
  418. padding: 15px;
  419. box-sizing: border-box;
  420. button {
  421. margin-left: 15px;
  422. }
  423. }
  424. /deep/ .ant-form .ant-form-item {
  425. display: flex !important;
  426. }
  427. .operation-list {
  428. button {
  429. margin-right: 10px;
  430. }
  431. }
  432. }
  433. </style>