index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <div class="newRole">
  3. <div class="newRole-content flex-wrap">
  4. <div class="newRole-content-left">
  5. <div class="newRole-content-left-top">
  6. <div class="flex head">
  7. <div class="title">账号列表</div>
  8. <!-- <el-button @click="handleAdd" class="serButton" size="small">新增</el-button> -->
  9. </div>
  10. <div class="search">
  11. <el-input size="small" placeholder="请输入内容" clearable prefix-icon="el-icon-search" :filter-node-method="filterArrNode" v-model="search">
  12. </el-input>
  13. </div>
  14. </div>
  15. <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="newRole-content-left-bottom">
  16. <el-scrollbar ref="scroll" style="height: 100%">
  17. <div class="treeArr">
  18. <el-tree ref="treeArr" :data="arrs" :props="defaultArrProps" highlight-current :filter-node-method="filterArrNode" default-expand-all node-key="user_group_id" @node-click="handleClick" :expand-on-click-node="false">
  19. <span class="custom-tree-node" slot-scope="{ node,data }">
  20. <div class="flex">
  21. <div :class="!data.user_id ? 'bigText':''">
  22. <span class="customTxt">{{ node.label }}</span>
  23. </div>
  24. </div>
  25. </span>
  26. </el-tree>
  27. </div>
  28. </el-scrollbar>
  29. </div>
  30. </div>
  31. <div class="newRole-content-right">
  32. <div style="height: 100%" class="flex newRole-content-right-new">
  33. <div class="newRole-content-right-bottom contents1 flex1">
  34. <div class="newRole-content-left-top">
  35. <div class="flex head">
  36. <div class="title">功能授权</div>
  37. </div>
  38. <div class="search">
  39. <el-input size="small" placeholder="请输入内容" clearable prefix-icon="el-icon-search" :filter-node-method="filterNode" v-model="filterText">
  40. </el-input>
  41. </div>
  42. </div>
  43. <div class="newRole-content-left-bottom">
  44. <el-scrollbar ref="scroll" style="height: 100%">
  45. <div class="newRole-content-left-bottom-tree">
  46. <el-tree ref="tree" show-checkbox :data="treeData" :props="defaultProps" highlight-current :filter-node-method="filterNode" default-expand-all node-key="auth_id" @check="checkChange" @node-click="handleNodeClick" :expand-on-click-node="false">
  47. <span class="custom-tree-node" slot-scope="{ node, data }">
  48. <span class="customTxt">{{ node.label }}</span>
  49. <span v-show="treeCheckId == data.auth_id" class="customBtn">
  50. <span @click.stop="setItem(node,data)" v-if="data.auth_id != 0 && (data.auth_type == 4 || data.auth_type == 5)" class="ym">列授权</span>
  51. </span>
  52. </span>
  53. </el-tree>
  54. </div>
  55. </el-scrollbar>
  56. </div>
  57. </div>
  58. <div class="newRole-content-right-bottom contents2 flex1">
  59. <div class="newRole-content-left-top">
  60. <div class="flex head">
  61. <div class="title">数据授权</div>
  62. <el-button type="primary" @click="handleColSave" class="bcButton" size="small">保存</el-button>
  63. </div>
  64. </div>
  65. <div class="newRole-content-left-bottom">
  66. <el-table ref="multipleTable" class="multipleTable" :data="checkArrs" border height="100%" stripe tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
  67. <el-table-column label-class-name="DisabledSelection" type="selection" width="100">
  68. </el-table-column>
  69. <el-table-column prop="columnLabel" label="列名">
  70. </el-table-column>
  71. <el-table-column v-if="isAuth" label="行授权">
  72. <template slot-scope="scope">
  73. <el-input size="small" placeholder="请输入内容" v-model="scope.row.row_auth" clearable>
  74. </el-input>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <Dialog :flag="rmFlag">
  84. <div class="airportInfoDialog">
  85. <div class="title del-title">删除</div>
  86. <div class="content del-content">
  87. <span class="el-icon-error error r10"></span>您是否确认删除<span class="error l10">{{ dataObj.user_group_name }}</span>
  88. </div>
  89. <div class="foot right Delfoot">
  90. <el-button size="medium" class="r24" @click="tableRemove" type="danger">删除</el-button>
  91. <el-button size="medium" @click="rmFlag = false">取消</el-button>
  92. </div>
  93. </div>
  94. </Dialog>
  95. </div>
  96. </template>
  97. <script>
  98. import Table from '@/views/newTable/index.vue'
  99. import Dialog from "@/layout/components/Dialog/index.vue"
  100. import { getAuthData, listToTree } from '@/utils/validate'
  101. import { getToken } from '@/utils/auth'
  102. import pf from '@/layout/mixin/publicFunc'
  103. import * as _ from 'lodash'
  104. export default {
  105. name: 'NewService',
  106. components: { Table, Dialog },
  107. mixins: [pf],
  108. data () {
  109. return {
  110. title: '服务设置',
  111. search: '',
  112. filterText: '',
  113. arrs: [
  114. {
  115. "user_group_id": 0,
  116. "user_group_name": "默认用户组",
  117. "up_user_group_id": -1,
  118. "user_group_status": null,
  119. "user_group_comment": null,
  120. children: []
  121. }
  122. ],
  123. flag: true,
  124. formInline: {
  125. role_name: '',
  126. comment: ''
  127. },
  128. activeIndex: null,
  129. pageIndex: 0,
  130. pageSize: 9999,
  131. dataContent: {},
  132. queryId: '',
  133. dataObj: {},
  134. dataType: 'edit',
  135. noMore: false,
  136. loading: false,
  137. treeData: [
  138. {
  139. auth_name: '所有权限',
  140. auth_id: 0,
  141. children: [],
  142. up_auth_id: -1
  143. }
  144. ],
  145. treeCheckId: '',
  146. treeCheckObj: {},
  147. defaultProps: {
  148. children: 'children',
  149. label: 'auth_name'
  150. },
  151. defaultArrProps: {
  152. children: 'children',
  153. label: 'user_group_name'
  154. },
  155. checkGroup: [],
  156. checkArrs: [],
  157. checkDatas: [],
  158. checkGroups: [],
  159. multipleTable: [],
  160. rmFlag: false,
  161. msgUserId: '',
  162. userId: '',
  163. userGroupArr: [],
  164. userArr: []
  165. }
  166. },
  167. watch: {
  168. filterText (val) {
  169. this.$refs.tree.filter(val);
  170. },
  171. search (val) {
  172. this.$refs.treeArr.filter(val);
  173. },
  174. treeCheckId () {
  175. this.checkArrs = []
  176. }
  177. },
  178. computed: {
  179. isAuth () {
  180. if (this.userId) {
  181. return true
  182. } else {
  183. return false
  184. }
  185. }
  186. },
  187. created () {
  188. const { title, qid, auth_id } = this.$route.meta
  189. this.title = title
  190. this.queryId = qid
  191. const { arrs } = getAuthData(auth_id)
  192. const btns = arrs.filter(item => item.auth_type == 3)
  193. if (btns && btns.length) {
  194. this.userId = btns[0].auth_ident
  195. }
  196. this.getQueryListCo(qid)
  197. this.setTreeData()
  198. },
  199. updated () {
  200. this.scrollDown()
  201. },
  202. methods: {
  203. //获取tree数据
  204. async setTreeData () {
  205. const { code, returnData } = await this.getQueryList(SERVICE_ID.sysAuthId, { user_id: getToken('userid') })
  206. if (code == 0) {
  207. const treeMenu = listToTree(returnData, 'up_auth_id', 'auth_id')
  208. this.treeData[0].children = treeMenu
  209. }
  210. },
  211. filterNode (value, data) {
  212. if (!value) return true;
  213. return data.auth_name.indexOf(value) !== -1;
  214. },
  215. filterArrNode (value, data) {
  216. if (!value) return true;
  217. return data.user_group_name.indexOf(value) !== -1;
  218. },
  219. async getQueryListCo (id) {
  220. try {
  221. this.loading = true;
  222. const { code, returnData } = await this.getQueryListAuth(SERVICE_ID.userListId)
  223. if (code == 0 && returnData && returnData.length) {
  224. this.userGroupArr = [...returnData]
  225. const treeMenu = listToTree(this.userGroupArr, 'up_user_group_id', 'user_group_id')
  226. this.arrs = treeMenu
  227. this.loading = false;
  228. } else {
  229. this.loading = false;
  230. }
  231. } catch (error) {
  232. this.loading = false;
  233. }
  234. },
  235. load () {
  236. if (!this.noMore) {
  237. this.getQueryListCo(this.queryId);
  238. }
  239. },
  240. scrollDown () {
  241. if (this.$refs['scroll'] && this.dataType == 'add') {
  242. this.$refs['scroll'].wrap.scrollTop = this.$refs['scroll'].wrap.scrollHeight
  243. }
  244. },
  245. resetTable () {
  246. this.pageIndex = 0;
  247. this.noMore = false;
  248. this.arrs = [];
  249. },
  250. //服务列表-新增
  251. handleAdd () {
  252. const datas = this.arrs.filter(item => item.role_name == '新建角色')
  253. if (datas && datas.length) {
  254. return
  255. }
  256. this.dataType = 'add'
  257. this.flag = false
  258. this.dataObj.role_name = '新建角色'
  259. this.arrs.push({ role_name: '新建角色' })
  260. this.activeIndex = this.arrs.length - 1
  261. for (const key in this.formInline) {
  262. if (Object.hasOwnProperty.call(this.formInline, key)) {
  263. this.formInline[key] = null
  264. }
  265. }
  266. },
  267. //获取角色已有权限
  268. async getRoleQuth (item) {
  269. this.$refs.tree.setCheckedKeys([])
  270. const newItem = _.cloneDeep(item)
  271. const newObj = {}
  272. if (newItem.hasOwnProperty('user_id')) {
  273. newObj.user_id = newItem.user_id
  274. } else {
  275. newObj.user_group_id = newItem.user_group_id
  276. }
  277. let msgId = null
  278. if (newItem.hasOwnProperty('user_id')) {
  279. msgId = SERVICE_ID.userAuthorizationId
  280. } else {
  281. msgId = SERVICE_ID.userGroupAuthorizationId
  282. }
  283. const { code, returnData } = await this.getQueryList(msgId, newObj)
  284. if (code == 0) {
  285. const result = returnData
  286. if (result && result.length) {
  287. const datas = []
  288. result.forEach(item => {
  289. datas.push(item.auth_id)
  290. })
  291. this.$refs.tree.setCheckedKeys(datas)
  292. const treeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
  293. const res = [...treeDatas, ...result].filter((item) => !(treeDatas.some((p) => item.auth_id == p.auth_id) && result.some((c) => item.auth_id == c.auth_id)))
  294. setTimeout(() => {
  295. res.forEach((item) => {
  296. if (item.auth_id) {
  297. this.$refs.tree.setChecked(item.auth_id, false, false);
  298. }
  299. });
  300. }, 50);
  301. setTimeout(() => {
  302. const newTreeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
  303. const arrs = newTreeDatas.filter(item => item.auth_id != 0)
  304. this.checkDatas.push(arrs)
  305. }, 70);
  306. }
  307. }
  308. },
  309. removeClass (elements) {
  310. elements.className = '';
  311. },
  312. disRemoveArr (arr, key) {
  313. arr.forEach(item => {
  314. if (item.children) {
  315. item.children = _.uniqBy(item.children, key)
  316. this.disRemoveArr(item.children, key)
  317. }
  318. })
  319. return arr
  320. },
  321. //服务列表-点击
  322. handleClick (item) {
  323. this.dataType = 'edit'
  324. this.dataObj = _.cloneDeep(item)
  325. this.formInline = _.cloneDeep(item)
  326. this.activeIndex = item.user_group_id
  327. this.flag = false
  328. this.treeCheckId = null
  329. this.$refs.tree.setCurrentKey(null)
  330. this.msgUserId = null
  331. this.checkDatas = []
  332. if (!item.user_id) {
  333. this.getUser(item.user_group_id)
  334. }
  335. this.getRoleQuth(item)
  336. },
  337. //获取用户组-用户
  338. async getUser (id) {
  339. const a1 = _.cloneDeep(this.userGroupArr)
  340. const result = await this.getQueryList(SERVICE_ID.getUserTableId, { up_user_group_id: id })
  341. if (result.code == 0 && result.returnData && result.returnData.length) {
  342. this.userArr.push(...result.returnData)
  343. const a2 = _.cloneDeep(this.userArr)
  344. a2.forEach(item => {
  345. if (item.hasOwnProperty('user_name') || item.hasOwnProperty('user_group_id')) {
  346. item.user_group_name = item.user_name
  347. item.user_group_id = item.user_id
  348. }
  349. })
  350. const a3 = _.uniqBy(a2, 'user_id')
  351. const menus = [...a1, ...a3]
  352. const treeMenu = listToTree(menus, 'up_user_group_id', 'user_group_id')
  353. this.arrs = this.disRemoveArr(treeMenu, 'user_group_id')
  354. }
  355. },
  356. //服务列表-保存
  357. async handleSave () {
  358. if (this.dataObj.role_ID && this.dataType == 'edit') {
  359. const { code } = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
  360. if (code == 0) {
  361. this.resetTable()
  362. this.getQueryListCo(this.queryId)
  363. }
  364. this.tipMsg(code)
  365. } else if (this.dataType == 'add' && this.arrs[this.arrs.length - 1].role_ID) {
  366. this.formInline.role_ID = this.arrs[this.arrs.length - 1].role_ID
  367. const { code } = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
  368. if (code == 0) {
  369. this.resetTable()
  370. this.getQueryListCo(this.queryId)
  371. }
  372. this.tipMsg(code)
  373. } else if (this.dataType == 'add') {
  374. const { code } = await this.getChangeList(this.queryId, this.formInline, 1)
  375. if (code == 0) {
  376. this.resetTable()
  377. this.getQueryListCo(this.queryId)
  378. }
  379. this.tipMsg(code)
  380. }
  381. else {
  382. this.$message.error('请先选中服务后再操作')
  383. }
  384. },
  385. async tableRemove () {
  386. if (this.dataObj.role_ID && this.dataType == 'edit') {
  387. const { code } = await this.getChangeList(this.queryId, this.dataObj, 3)
  388. if (code == 0) {
  389. this.resetTable()
  390. this.getQueryListCo(this.queryId)
  391. this.activeIndex = null;
  392. this.dataObj = {};
  393. for (const key in this.formInline) {
  394. if (Object.hasOwnProperty.call(this.formInline, key)) {
  395. this.formInline[key] = null
  396. }
  397. }
  398. this.flag = true
  399. }
  400. this.tipMsg(code)
  401. } else if (this.dataType == 'add' && this.arrs[this.arrs.length - 1].role_ID) {
  402. const { code } = await this.getChangeList(this.queryId, this.arrs[this.arrs.length - 1], 3)
  403. if (code == 0) {
  404. this.resetTable()
  405. this.getQueryListCo(this.queryId)
  406. this.activeIndex = null;
  407. this.dataObj = {};
  408. for (const key in this.formInline) {
  409. if (Object.hasOwnProperty.call(this.formInline, key)) {
  410. this.formInline[key] = null
  411. }
  412. }
  413. this.flag = true
  414. this.dataType = 'edit'
  415. }
  416. this.tipMsg(code)
  417. }
  418. else {
  419. this.arrs.splice(this.activeIndex, 1)
  420. this.activeIndex = null
  421. this.flag = true
  422. this.dataObj = {}
  423. }
  424. this.rmFlag = false
  425. },
  426. //服务列表-删除
  427. handleError () {
  428. this.rmFlag = true
  429. },
  430. handleNodeClick (data) {
  431. this.msgUserId = null
  432. this.treeCheckId = data.auth_id
  433. this.treeCheckObj = data
  434. // this.treeCheckId = null
  435. // this.checkArrs = []
  436. },
  437. async checkChange () {
  438. if (this.dataObj.user_group_id) {
  439. const datas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes());
  440. const arrs = datas.filter(item => item.auth_id != 0)
  441. this.checkDatas.push(arrs)
  442. if (this.checkDatas.length == 1) {
  443. const res = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
  444. const addRes = []
  445. const newDatas = []
  446. const newItem = _.cloneDeep(this.dataObj)
  447. res.forEach(item => {
  448. if (item.children) {
  449. delete item.children
  450. }
  451. if (newItem.hasOwnProperty('user_id')) {
  452. item.user_id = newItem.user_id
  453. } else {
  454. item.user_group_id = newItem.user_group_id
  455. }
  456. addRes.push(item)
  457. })
  458. const newMsgs = _.cloneDeep(addRes)
  459. newMsgs.forEach(item => {
  460. const { auth_id, auth_type, queryTemplateColumnSetID, row_auth, user_group_id, user_id } = item
  461. const newObj = { auth_id, auth_type, queryTemplateColumnSetID, row_auth, user_group_id, user_id }
  462. newDatas.push(newObj)
  463. })
  464. let msgId = null
  465. if (newItem.hasOwnProperty('user_id')) {
  466. msgId = SERVICE_ID.userAuthorizationId
  467. } else {
  468. msgId = SERVICE_ID.userGroupAuthorizationId
  469. }
  470. const { code } = await this.getChangeList(msgId, newDatas, 1)
  471. if (code == 0) {
  472. setTimeout(() => {
  473. this.getRoleQuth(this.dataObj)
  474. }, 100);
  475. }
  476. this.tipMsg(code)
  477. } else {
  478. const data1 = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
  479. const data2 = this.checkDatas[this.checkDatas.length - 2]; //倒数第二条数据
  480. if (data1.length > data2.length) {
  481. this.checksBoxTs(data1, data2, "add");
  482. } else {
  483. this.checksBoxTs(data2, data1, "del");
  484. }
  485. }
  486. } else {
  487. this.$message.error('请选中账号后再操作');
  488. this.$refs.tree.setCheckedKeys([]);
  489. }
  490. },
  491. async checksBoxTs (datas, arr, type) {
  492. const res = [...datas, ...arr].filter((item) => !(datas.some((p) => item.auth_id == p.auth_id) && arr.some((c) => item.auth_id == c.auth_id)));
  493. const addRes = []
  494. const newDatas = []
  495. const newItem = _.cloneDeep(this.dataObj)
  496. res.forEach(item => {
  497. if (item.children) {
  498. delete item.children
  499. }
  500. if (newItem.hasOwnProperty('user_id')) {
  501. item.user_id = newItem.user_id
  502. } else {
  503. item.user_group_id = newItem.user_group_id
  504. }
  505. addRes.push(item)
  506. })
  507. const newMsgs = _.cloneDeep(addRes)
  508. newMsgs.forEach(item => {
  509. const { auth_id, auth_type, queryTemplateColumnSetID, row_auth, user_group_id, user_id } = item
  510. let newObj = null
  511. if (newItem.hasOwnProperty('user_id')) {
  512. newObj = { auth_id, auth_type, queryTemplateColumnSetID, row_auth, user_id }
  513. } else {
  514. newObj = { auth_id, auth_type, queryTemplateColumnSetID, row_auth, user_group_id }
  515. }
  516. newDatas.push(newObj)
  517. })
  518. if (type == 'add') {
  519. let msgId = null
  520. if (newItem.hasOwnProperty('user_id')) {
  521. msgId = SERVICE_ID.userAuthorizationId
  522. } else {
  523. msgId = SERVICE_ID.userGroupAuthorizationId
  524. }
  525. const { code } = await this.getChangeList(msgId, newDatas, 1)
  526. if (code == 0) {
  527. setTimeout(() => {
  528. this.getRoleQuth(this.dataObj)
  529. }, 100);
  530. }
  531. this.tipMsg(code)
  532. } else {
  533. let msgId = null
  534. if (newItem.hasOwnProperty('user_id')) {
  535. msgId = SERVICE_ID.userAuthorizationId
  536. } else {
  537. msgId = SERVICE_ID.userGroupAuthorizationId
  538. }
  539. const { code } = await this.getChangeList(msgId, newDatas, 3)
  540. if (code == 0) {
  541. this.msgUserId = null
  542. this.checkArrs = []
  543. setTimeout(() => {
  544. this.getRoleQuth(this.dataObj)
  545. }, 100);
  546. }
  547. this.tipMsg(code)
  548. }
  549. // this.checkArrs = []
  550. },
  551. async setItem (node, data) {
  552. if (this.dataObj.user_id || this.dataObj.user_group_id) {
  553. this.msgUserId = data.auth_id
  554. const newItem = _.cloneDeep(this.dataObj)
  555. const newObj = {}
  556. if (newItem.hasOwnProperty('user_id')) {
  557. newObj.user_id = newItem.user_id
  558. } else {
  559. newObj.user_group_id = newItem.user_group_id
  560. }
  561. newObj.auth_id = data.auth_id
  562. const { code, returnData } = await this.getQueryList(SERVICE_ID.userColAuthId, { auth_id: data.auth_id, user_id: getToken('userid') })
  563. if (code == 0) {
  564. const result = returnData
  565. if (result && result.length) {
  566. result.map(item => {
  567. item.row_auth = null
  568. })
  569. this.checkArrs = [...result]
  570. let msgId = null
  571. if (newItem.hasOwnProperty('user_id')) {
  572. msgId = SERVICE_ID.userAuthorizationId
  573. } else {
  574. msgId = SERVICE_ID.userGroupAuthorizationId
  575. }
  576. const { code, returnData } = await this.getQueryList(msgId, newObj)
  577. if (code == 0 && returnData && returnData.length) {
  578. const res = returnData.filter(item => item.queryTemplateColumnSetID)
  579. if (res && res.length) {
  580. // const caps = _.intersectionBy([result, res], 'queryTemplateColumnSetID')
  581. // console.log(caps)
  582. const resmsg = []
  583. result.forEach((item) => {
  584. res.forEach(p => {
  585. if (item.queryTemplateColumnSetID == p.queryTemplateColumnSetID) {
  586. item.row_auth = p.row_auth
  587. resmsg.push(item)
  588. }
  589. })
  590. })
  591. if (resmsg && resmsg.length) {
  592. resmsg.forEach(row => {
  593. this.$refs.multipleTable.toggleRowSelection(row);
  594. });
  595. }
  596. this.multipleTable = resmsg
  597. }
  598. }
  599. }
  600. }
  601. } else {
  602. this.$message.error('请选中账号后再操作');
  603. }
  604. },
  605. sendCheckData (arr, type = false) {
  606. const newData = []
  607. const newItem = _.cloneDeep(this.dataObj)
  608. arr.forEach(item => {
  609. if (type) {
  610. const newObj = {
  611. "auth_id": this.treeCheckObj.auth_id,
  612. "queryTemplateColumnSetID": item.queryTemplateColumnSetID,
  613. }
  614. if (newItem.hasOwnProperty('user_id')) {
  615. newObj.user_id = newItem.user_id
  616. } else {
  617. newObj.user_group_id = newItem.user_group_id
  618. }
  619. newData.push(newObj)
  620. } else {
  621. const obj = {
  622. "auth_id": this.treeCheckObj.auth_id,
  623. "auth_type": this.treeCheckObj.auth_type,
  624. "queryTemplateColumnSetID": item.queryTemplateColumnSetID,
  625. "columnLabel": item.columnLabel,
  626. "columnname": item.columnName,
  627. "row_auth": item.row_auth
  628. }
  629. if (newItem.hasOwnProperty('user_id')) {
  630. obj.user_id = newItem.user_id
  631. } else {
  632. obj.user_group_id = newItem.user_group_id
  633. }
  634. newData.push(obj)
  635. }
  636. })
  637. return newData
  638. },
  639. getColName (arr) {
  640. const res = []
  641. this.checkArrs.forEach(item => {
  642. arr.forEach(p => {
  643. if (item.columnName == p) {
  644. res.push(item)
  645. }
  646. })
  647. })
  648. return res
  649. },
  650. handleSelectionChange (val) {
  651. this.multipleTable = val
  652. },
  653. async handleColSave () {
  654. if (this.treeCheckObj.auth_id && this.dataObj.user_group_id && this.msgUserId) {
  655. const newItem = _.cloneDeep(this.dataObj)
  656. const newObj = {
  657. "auth_id": this.treeCheckObj.auth_id,
  658. }
  659. if (newItem.hasOwnProperty('user_id')) {
  660. newObj.user_id = newItem.user_id
  661. } else {
  662. newObj.user_group_id = newItem.user_group_id
  663. }
  664. const result = this.sendCheckData(this.multipleTable)
  665. let msgId = null
  666. if (newItem.hasOwnProperty('user_id')) {
  667. msgId = SERVICE_ID.userAuthorizationId
  668. } else {
  669. msgId = SERVICE_ID.userGroupAuthorizationId
  670. }
  671. const tes = await this.getChangeList(msgId, [newObj], 3)
  672. if (tes.code == 0) {
  673. const { code } = await this.getChangeList(msgId, result, 1)
  674. this.tipMsg(code)
  675. }
  676. } else {
  677. this.$message.error('请先选中用户和权限后再操作列设置后保存数据')
  678. }
  679. }
  680. }
  681. }
  682. </script>
  683. <style lang="scss" scoped>
  684. @import "./css/index.scss";
  685. </style>