dataOperaAuth.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. <template>
  2. <div class="operate-auth-box">
  3. <div class="header">
  4. <div>
  5. <el-select
  6. v-model="currAuthSet"
  7. @change="changeSet"
  8. >
  9. <!-- <el-option :label="$t('SystemManage.OperateAuth.set_assets_tab')" :value="1"/> -->
  10. <el-option :label="$t('SystemManage.OperateAuth.set_data_tab')" :value="2"/>
  11. </el-select>
  12. <el-cascader
  13. v-model="searchForm.user"
  14. :options="userList"
  15. :props="{
  16. value: 'NodeId',
  17. label: 'NodeName',
  18. children: 'Children',
  19. emitPath: false
  20. }"
  21. collapse-tags
  22. :show-all-levels="false"
  23. clearable
  24. @change="()=>{ filterChange();getUserDataCount();}"
  25. filterable
  26. :placeholder="this.$t('SystemManage.OperateAuth.placeholder04')"
  27. style="margin: 0 20px"
  28. />
  29. </div>
  30. <div>
  31. <el-button
  32. type="primary"
  33. @click="transferAuthHandle({},'all')"
  34. v-if="currAuthSet===1&&authBtn('operateAuth_transfer_all')"
  35. ><!-- 全量资产转移 -->{{$t('SystemManage.OperateAuth.transfer_all_btn')}}</el-button>
  36. <template v-if="currAuthSet===2">
  37. <el-tooltip effect="dark" placement="right" v-if="authBtn('operateAuth_set_classifySercet')">
  38. <div
  39. slot="content"
  40. v-html="$i18n.locale==='en'?ruleTips.classifySetEn:ruleTips.classifySet "
  41. style="line-height: 20px;width:300px"
  42. ></div>
  43. <i class="el-icon-warning" style="color: #666" />
  44. </el-tooltip>
  45. <el-button
  46. type="primary"
  47. @click="setMenuSecretHandle"
  48. v-if="authBtn('operateAuth_set_classifySercet')"
  49. >
  50. <!-- 分类加密设置 -->{{$t('SystemManage.OperateAuth.classify_secret_btn')}}
  51. </el-button>
  52. <el-button
  53. type="primary"
  54. @click="setAuthHandle({},'classify')"
  55. v-if="authBtn('operateAuth_set_classifySet')"
  56. >
  57. <!-- 按分类设置权限 -->{{$t('SystemManage.OperateAuth.classify_set_btn')}}
  58. </el-button>
  59. </template>
  60. <el-button
  61. type="primary"
  62. v-if="authBtn(currAuthSet===1?'operateAuth_transfer_batch':'operateAuth_set_batch')"
  63. @click="()=>{ currAuthSet===1 ? transferAuthHandle({},'multiple') : setAuthHandle({},'multiple') }"
  64. >
  65. <!-- 批量设置 -->{{$t('SystemManage.OperateAuth.btn_text01')}}
  66. </el-button>
  67. </div>
  68. </div>
  69. <div class="main">
  70. <ul class="tab-wrapper">
  71. <li :class="['tab-li',{act: default_tab===item.key}]" v-for="item in tabs" :key="item.key" @click="changeTab(item)">
  72. {{item.label}}
  73. <div style="margin-top:20px;color: #666;" v-if="statisticCountMap[item.key]"><!-- 数量: -->{{$t('SystemManage.OperateAuth.label_count')}}:{{statisticCountMap[item.key]}}</div>
  74. </li>
  75. </ul>
  76. <el-tabs v-model="default_sub_tab" @tab-click="changeSubTab" v-if="default_tab===6">
  77. <el-tab-pane :label="item.label" v-for="item in subTabs" :key="item.key" :name="String(item.key)"></el-tab-pane>
  78. </el-tabs>
  79. <div class="filter-wrapper">
  80. <div>
  81. <el-input
  82. v-model="searchForm.key_word"
  83. :placeholder="phText"
  84. style="width: 250px;margin-right:20px;"
  85. @change="filterChange"
  86. clearable
  87. >
  88. <i slot="prefix" class="el-input__icon el-icon-search"/>
  89. </el-input>
  90. <el-cascader
  91. v-model="searchForm.classifys"
  92. :options="classifyOption"
  93. :props="{
  94. value: 'ClassifyId',
  95. label: 'ClassifyName',
  96. children: 'Child',
  97. emitPath: true,
  98. multiple:true
  99. }"
  100. collapse-tags
  101. :show-all-levels="false"
  102. :key="classifysOptKey"
  103. clearable
  104. filterable
  105. @change="filterChange"
  106. :placeholder="this.$t('SystemManage.OperateAuth.placeholder03')"
  107. style="width: 250px;"
  108. />
  109. </div>
  110. <div>
  111. <span>{{$t('SystemManage.OperateAuth.label_checked')}}:{{ isSelectAll ? (total-filterDuplicateChecked.length) : filterDuplicateChecked.length }}</span>
  112. <el-checkbox
  113. v-model="searchForm.checkAll"
  114. :indeterminate="searchForm.checkSome"
  115. :disabled="tableData.length===0"
  116. style="margin-left:20px"
  117. @change="listCheckAllChange"
  118. ><!-- 列表全选 -->{{$t('SystemManage.OperateAuth.all_select')}}</el-checkbox>
  119. </div>
  120. </div>
  121. <el-table
  122. :data="tableData"
  123. ref="table"
  124. element-loading-text="加载中..."
  125. v-loading="tableLoading"
  126. border
  127. style="margin:20px 0"
  128. @selection-change="selectionChange"
  129. @select="selectHandle"
  130. @select-all="selectAllPageHandle"
  131. >
  132. <el-table-column
  133. type="selection"
  134. width="55"
  135. />
  136. <el-table-column
  137. v-for="item in tableColums"
  138. :key="item.label"
  139. :label="item.label"
  140. :prop="item.key"
  141. :width="item.widthsty"
  142. :min-width="item.minwidthsty"
  143. align="center"
  144. >
  145. <template slot-scope="{row}">
  146. <span v-if="item.key==='Name'">
  147. {{ currentLang==='en' ? (row.NameEn||row.Name) : row.Name }}
  148. </span>
  149. <template v-else-if="item.key==='handle'">
  150. <span
  151. class="editsty"
  152. @click="() => {currAuthSet===1 ? transferAuthHandle(row) : setAuthHandle(row)}"
  153. v-if="authBtn(currAuthSet===1?'operateAuth_transfer_one':'operateAuth_set_one')"
  154. >
  155. <!-- 编辑 -->{{$t('Dialog.title_prefix_edit')}}
  156. </span>
  157. </template>
  158. <span v-else>{{ row[item.key] }}</span>
  159. </template>
  160. </el-table-column>
  161. <div slot="empty" style="padding: 100px 0">
  162. <tableNoData :text="$t('Table.prompt_slogan')" size="mini"/>
  163. </div>
  164. </el-table>
  165. <div style="height:35px;margin: 20px 0;">
  166. <m-page
  167. :page_no="page_no"
  168. :pageSize="pageSize"
  169. :total="total"
  170. @handleCurrentChange="pageChange"
  171. />
  172. </div>
  173. </div>
  174. <!-- 资产转移弹窗 -->
  175. <m-dialog
  176. :show.sync="isTransferDia"
  177. width="650px"
  178. :title="transferTitMap[transferForm.type]"
  179. @close="isTransferDia = false"
  180. >
  181. <div class="dialog-main operateauth-dialog-cont">
  182. <el-form
  183. ref="formRef"
  184. label-position="left"
  185. hide-required-asterisk
  186. label-width="110px"
  187. :model="transferForm"
  188. @close="cancelTransfer"
  189. >
  190. <!-- 原创建人 -->
  191. <el-form-item :label="$t('SystemManage.OperateAuth.original_creator')" v-if="transferForm.type!=='multiple'">
  192. <span v-if="transferForm.type==='single'">{{ transferForm.creatorName }}</span>
  193. <el-cascader
  194. v-else-if="transferForm.type==='all'"
  195. v-model="transferForm.creatorIds"
  196. :options="userList"
  197. :props="{
  198. value: 'NodeIdKey',
  199. label: 'NodeName',
  200. children: 'Children',
  201. emitPath: false,
  202. multiple:true
  203. }"
  204. collapse-tags
  205. :show-all-levels="false"
  206. clearable
  207. filterable
  208. :placeholder="this.$t('SystemManage.OperateAuth.placeholder04')"
  209. style="width: 250px"
  210. />
  211. </el-form-item>
  212. <el-form-item :label="$t('SystemManage.OperateAuth.new_creator')" prop="newUser" :rules="[
  213. { required: true, message: this.$t('SystemManage.OperateAuth.placeholder05'), trigger: 'change' }
  214. ]"
  215. >
  216. <el-cascader
  217. v-model="transferForm.newUser"
  218. :options="userList"
  219. :props="{
  220. value: 'NodeId',
  221. label: 'NodeName',
  222. children: 'Children',
  223. emitPath: false,
  224. }"
  225. collapse-tags
  226. :show-all-levels="false"
  227. clearable
  228. filterable
  229. :placeholder="$t('SystemManage.OperateAuth.placeholder04')"
  230. style="width: 250px"
  231. />
  232. </el-form-item>
  233. <el-form-item :label="$t('SystemManage.OperateAuth.label_assets')" prop="assetTypes" v-if="transferForm.type==='all'">
  234. <el-select v-model="transferForm.assetTypes" multiple style="width: 250px">
  235. <el-option v-for="item in tabs" :key="item.key" :value="item.key" :label="item.label"/>
  236. </el-select>
  237. </el-form-item>
  238. </el-form>
  239. </div>
  240. <div class="dia-bot">
  241. <el-button
  242. type="primary"
  243. style="margin-right: 60px"
  244. @click="confirmTransferHandle"
  245. >{{$t('Dialog.confirm_save_btn')}}</el-button
  246. >
  247. <el-button type="primary" plain @click="cancelTransfer"
  248. >{{$t('Dialog.cancel_btn')}}</el-button
  249. >
  250. </div>
  251. </m-dialog>
  252. <!-- 权限设置弹窗 -->
  253. <opearAuthSetDia
  254. :isShow.sync="isSetAuthDia"
  255. :userList="userList"
  256. :tabs="tabs"
  257. :subTabs="subTabs"
  258. :form="authForm"
  259. />
  260. <!-- 分类私密设置 -->
  261. <setClassifySecretDia
  262. :isShow.sync="isSetClassifySecret"
  263. :tabs="tabs"
  264. :subTabs="subTabs"
  265. />
  266. </div>
  267. </template>
  268. <script>
  269. import { operateAuthInterface,departInterence } from '@/api/modules/setApi';
  270. import {dataAuthInterface} from '@/api/modules/dataApi.js'
  271. import { traverseTree } from "@/utils/commonOptions"
  272. import mPage from '@/components/mPage.vue';
  273. import mDialog from '@/components/mDialog.vue'
  274. import opearAuthSetDia from './components/opearAuthSetDia.vue';
  275. import setClassifySecretDia from './components/setClassifySecretDia.vue';
  276. export default {
  277. components: { mPage,mDialog,opearAuthSetDia,setClassifySecretDia },
  278. computed: {
  279. tabs(){
  280. const tabs = [
  281. { label: '数据查看', key: 3 },
  282. // { label: '指标加工', key: 7 },
  283. // { label: '衍生指标', key: 4 },
  284. // { label: this.$t('SystemManage.OperateAuth.tab05'), key: 5 },
  285. // { label: this.$t('SystemManage.OperateAuth.tab06'), key: 6 },
  286. ]
  287. return this.currAuthSet===1 ? tabs : tabs.filter(item => [3,4,5,6,7].includes(item.key))
  288. },
  289. subTabs() {
  290. const subTabs = [
  291. { label: /* '自定义分析' */this.$t('SystemManage.OperateAuth.tab_sub_sheet1'), key: 4 },
  292. { label:/* '时间序列表格' */this.$t('SystemManage.OperateAuth.tab_sub_sheet2'), key: 2 },
  293. { label: /* '混合表格' */this.$t('SystemManage.OperateAuth.tab_sub_sheet3'), key: 3 },
  294. { label: /* '平衡表' */this.$t('SystemManage.OperateAuth.tab_sub_sheet4'), key: 5 },
  295. ]
  296. return this.currAuthSet===1 ? subTabs : subTabs.filter(_ => _.key!==4)
  297. },
  298. tableColums() {
  299. const clomusMap = {
  300. 5: [
  301. { label: this.$t('SystemManage.OperateAuth.table_col_name01'),key: 'Name' },
  302. { label: this.$t('SystemManage.OperateAuth.table_col_name02'),key: 'ClassifyName' },
  303. { label: this.$t('SystemManage.OperateAuth.table_col_name03'),key: 'CreateUserName' },
  304. { label: this.$t('Table.column_operations'),key: 'handle' },
  305. ],
  306. 6: [
  307. { label: this.$t('SystemManage.OperateAuth.table_col_sheet_name'),key: 'Name' },
  308. { label: this.$t('SystemManage.OperateAuth.table_col_sheet_menu'),key: 'ClassifyName' },
  309. { label: this.$t('SystemManage.OperateAuth.table_col_name03'),key: 'CreateUserName' },
  310. { label: this.$t('Table.column_operations'),key: 'handle' },
  311. ],
  312. }
  313. return clomusMap[this.default_tab] ? clomusMap[this.default_tab]
  314. : [
  315. { label: this.$t('SystemManage.OperateAuth.table_col_name04'),key: 'Code' },
  316. { label: this.$t('SystemManage.OperateAuth.table_col_name05'),key: 'Name' },
  317. { label: this.$t('SystemManage.OperateAuth.table_col_name03'),key: 'CreateUserName' },
  318. { label: this.$t('Table.column_operations'),key: 'handle' },
  319. ]
  320. },
  321. phText() {
  322. const textMap = {
  323. 5: this.$t('SystemManage.OperateAuth.placeholder01'),
  324. 6: this.$t('SystemManage.OperateAuth.placeholder_sheet')
  325. }
  326. return textMap[this.default_tab] ? textMap[this.default_tab] : this.$t('SystemManage.OperateAuth.placeholder02')
  327. },
  328. filterDuplicateChecked() {
  329. return Array.from(new Set(this.checkedList))
  330. },
  331. currentLang() {
  332. return this.$store.state.lang
  333. }
  334. },
  335. data() {
  336. return {
  337. currAuthSet: 2,//设置资产
  338. default_tab: 3,
  339. default_sub_tab: '4',
  340. searchForm: {
  341. user: '',
  342. key_word: '',
  343. classifys:[],
  344. checkAll: false, //控制全选显示状态
  345. checkSome: false
  346. },
  347. isSelectAll: false, //真正意义上的全选或不全选
  348. classifyOption: [],
  349. classifysOptKey: 0,
  350. userList: [],
  351. checkedList: [], //不全选勾选中的 或 全选取消勾的
  352. selectionReactCancel:false,//手动设置选中中
  353. tableLoading: false,
  354. tableData:[],
  355. page_no: 1,
  356. total: 0,
  357. pageSize: 10,
  358. statisticCountMap: {},
  359. ruleTips: {
  360. 'classifySet': `
  361. 1、”分类加密设置“:分类默认公开,分类设置加密后,新增用户默认无加密分类的数据权限。<br>
  362. 2、按分类设置权限:加密的分类支持开放权限给用户。<br>
  363. 3、批量设置:同时设置单个或多个数据的权限。
  364. `,
  365. 'classifySetEn': `
  366. 1. "Classified Encryption Settings": By default, categories are public. Once a category is set to encrypted, new users will not have data permissions for the encrypted category by default.<br>
  367. 2. "Set Permissions by Category": Encrypted categories support granting access permissions to users.<br>
  368. 3. "Batch Settings": Set permissions for single or multiple data entries at the same time.
  369. `
  370. },
  371. /* 转移弹窗 */
  372. isTransferDia: false,
  373. transferForm: {
  374. type:'',
  375. creatorName: '',//创建人姓名
  376. creatorIds: [],//创建人id
  377. ids:'',
  378. newUser: '',
  379. assetTypes: []
  380. },
  381. transferTitMap: {
  382. 'all': /* '全量资产转移' */ this.$t('SystemManage.OperateAuth.transfer_title1'),
  383. 'multiple': /* '批量设置资产转移' */this.$t('SystemManage.OperateAuth.transfer_title2'),
  384. 'single':/* '设置资产转移' */this.$t('SystemManage.OperateAuth.transfer_title3'),
  385. },
  386. /* 设置权限弹窗 */
  387. isSetAuthDia: false,
  388. authForm: {
  389. type:'',//分类设置 批量设置 单设置
  390. ids:[],
  391. },
  392. /* 设置加密分类弹窗 */
  393. isSetClassifySecret: false,
  394. }
  395. },
  396. mounted(){
  397. this.getClassifyList()
  398. this.getUserList();
  399. this.getTableData()
  400. },
  401. methods:{
  402. /* 获取分类列表 */
  403. getClassifyList() {
  404. if(!this.default_tab) return
  405. operateAuthInterface.getClassificationBySource({
  406. Source: this.default_tab,
  407. SubSource: this.default_tab === 6 ? Number(this.default_sub_tab) : 0
  408. }).then(res => {
  409. if(res.Ret == 200){
  410. this.classifyOption = res.Data.List || []
  411. //如果是多级分类,去掉最后一级分类的child
  412. if([3,4,5,6,7].includes(this.default_tab)){
  413. this.filterNodes(this.classifyOption)
  414. }
  415. ++this.classifysOptKey;
  416. }
  417. })
  418. },
  419. filterNodes(arr) {
  420. arr.length && arr.forEach(item => {
  421. item.Child && item.Child.length && this.filterNodes(item.Child)
  422. if(item.Child && !item.Child.length) {
  423. delete item.Child
  424. }
  425. })
  426. },
  427. /* 获取用户列表 */
  428. async getUserList() {
  429. const res = await departInterence.getSystemUser();
  430. if (res.Ret !== 200) return
  431. this.userList = res.Data || []
  432. //遍历加上唯一的key
  433. traverseTree(
  434. {Children:this.userList},
  435. {
  436. childKey:'Children',
  437. nodeKey:'NodeIdKey',
  438. cb:(node)=>node.NodeType===3,
  439. cb2:(node)=>node.NodeId+''
  440. }
  441. )
  442. this.filterTreeEmpty({Children:this.userList})
  443. },
  444. // 递归处理数组
  445. filterTreeEmpty(arr) {
  446. function dfs(node) {
  447. if (Array.isArray(node.Children)) {
  448. for (let child of node.Children) {
  449. dfs(child);
  450. }
  451. if(node.Children.length===0) delete node.Children
  452. }
  453. //若为叶子节点,且不为用户,禁止选中
  454. if(!node.Children||!Array.isArray(node.Children)){
  455. if(node.NodeType!==3) node.disabled = true
  456. }
  457. }
  458. dfs(arr);
  459. },
  460. /* 获取用户的资产数量 */
  461. async getUserDataCount() {
  462. if(!this.searchForm.user){
  463. this.statisticCountMap = {}
  464. return
  465. }
  466. const res = await operateAuthInterface.getUserStatistic({ UserId: this.searchForm.user,CountType: this.currAuthSet})
  467. if(res.Ret !== 200) return
  468. this.statisticCountMap = res.Data;
  469. },
  470. getTableData(type) {
  471. if(!this.default_tab) return
  472. let Classify = Array.from(new Set(this.searchForm.classifys.flat())).join(',')
  473. this.tableLoading = true;
  474. let params = {
  475. Source: this.default_tab,
  476. UserId: this.searchForm.user || 0,
  477. CurrentIndex: this.page_no,
  478. PageSize: this.pageSize,
  479. Keyword: this.searchForm.key_word,
  480. Classify,
  481. SubSource: this.default_tab === 6 ? Number(this.default_sub_tab) : 0
  482. }
  483. operateAuthInterface.list(params).then(res => {
  484. this.tableLoading = false;
  485. if( res.Ret!==200 )return
  486. const { Data } = res;
  487. this.tableData = Data.List || [];
  488. this.total = Data.Paging.Totals;
  489. if(type==='pageChange'){
  490. //页码变化 选中项不做清空
  491. this.checkedSomeSelection()
  492. }else {
  493. this.listCheckAllChange(false)
  494. }
  495. });
  496. },
  497. /* 设置当页数据勾选状态 */
  498. checkedSomeSelection() {
  499. this.selectionReactCancel=true
  500. console.log(this.checkedList,this.isSelectAll)
  501. if(!this.isSelectAll){
  502. this.checkedList.map(_ =>{
  503. let row = this.tableData.find(item => item.DataId==_.DataId)
  504. if(row){ //设置部分选中
  505. setTimeout(()=>{
  506. this.$refs.table.toggleRowSelection(row,true)
  507. },20)
  508. }
  509. })
  510. }else{
  511. // this.$refs.table && this.$refs.table.clearSelection()
  512. this.$refs.table &&this.$refs.table.toggleAllSelection()
  513. this.checkedList.map(_ =>{
  514. let row = this.tableData.find(item => item.DataId==_.DataId)
  515. if(row){ //设置部分不勾选
  516. setTimeout(()=>{
  517. this.$refs.table.toggleRowSelection(row,false)
  518. },20)
  519. }
  520. })
  521. }
  522. setTimeout(()=>{
  523. this.selectionReactCancel=false
  524. },30)
  525. },
  526. /* 切换模块 */
  527. changeTab({key}) {
  528. this.default_tab = key;
  529. this.default_sub_tab = String(this.subTabs[0].key);
  530. this.searchForm.classifys=[]
  531. this.searchForm.key_word=''
  532. this.searchForm.checkAll = false
  533. this.page_no = 1;
  534. this.getClassifyList()
  535. this.getTableData();
  536. },
  537. changeSubTab() {
  538. this.searchForm.classifys=[]
  539. this.searchForm.key_word=''
  540. this.searchForm.checkAll = false
  541. this.page_no = 1;
  542. this.getClassifyList()
  543. this.getTableData();
  544. },
  545. changeSet() {
  546. this.changeTab({key: 3})
  547. this.getUserDataCount()
  548. },
  549. //列表全选或全不选
  550. listCheckAllChange(value){
  551. this.checkedList = []
  552. this.isSelectAll = value
  553. this.$refs.table && this.$refs.table.clearSelection()
  554. value && this.$refs.table && this.$refs.table.toggleAllSelection()
  555. },
  556. //筛选改变
  557. filterChange() {
  558. this.page_no = 1;
  559. this.getTableData()
  560. },
  561. // 页码改变
  562. pageChange(page) {
  563. this.page_no = page;
  564. this.getTableData('pageChange')
  565. },
  566. selectionChange(val) {
  567. if(this.selectionReactCancel) return
  568. // selectAllHandle的触发在selectionChange后面,将selectionChange的逻辑延迟一下
  569. //设置全选框状态 选中 半选 不选
  570. setTimeout(()=>{
  571. let filterChecked = Array.from(new Set(this.checkedList))
  572. //全选
  573. if(
  574. (filterChecked.length===this.total&&this.total>0 && (!this.isSelectAll))
  575. || (filterChecked.length === 0 && this.isSelectAll)
  576. ){
  577. this.searchForm.checkAll = true
  578. this.searchForm.checkSome = false
  579. //不选
  580. }else if(
  581. (filterChecked.length === 0 && (!this.isSelectAll))
  582. || (filterChecked.length === this.total && this.isSelectAll)
  583. ){
  584. this.searchForm.checkAll = false
  585. this.searchForm.checkSome = false
  586. //半选
  587. }else{
  588. this.searchForm.checkAll = false
  589. this.searchForm.checkSome=true
  590. }
  591. },1)
  592. },
  593. //单选
  594. selectHandle(selection,row){ //当前选中的项是进选中还是取消选中中
  595. console.log(selection,row)
  596. if(this.selectionReactCancel) return
  597. //当前项是选中还是取消选
  598. let haveChecked = selection.some(_ => _.DataId === row.DataId);
  599. //全选取消选和不全选选中才有意义
  600. if((haveChecked&&!this.isSelectAll) || (!haveChecked&&this.isSelectAll)) {
  601. this.checkedList.push(row)
  602. }else {
  603. this.checkedList=this.checkedList.filter(_ => _.DataId!==row.DataId)
  604. }
  605. },
  606. //整列选
  607. selectAllPageHandle(selection){
  608. if(this.selectionReactCancel) return
  609. //当前页是选中还是取消
  610. let haveChecked = selection && selection.length>0;
  611. //全选取消选和不全选选中才有意义
  612. if((haveChecked&&!this.isSelectAll) || (!haveChecked&&this.isSelectAll)) {
  613. this.checkedList = [...this.checkedList,...this.tableData]
  614. }else {
  615. let pageIds = this.tableData.map(_ => _.DataId);
  616. this.checkedList = this.checkedList.filter(_ => !pageIds.includes(_.DataId))
  617. }
  618. },
  619. /* 转移所属权限 单转 批量转 全量转*/
  620. transferAuthHandle({ CreateUserName,DataId },type='single') {
  621. if(type === 'multiple' && !this.checkedList.length &&!this.isSelectAll) return this.$message.warning(this.$t('SystemManage.OperateAuth.msg01'))
  622. this.transferForm = {
  623. type,
  624. creatorName: type==='single' ? CreateUserName : '',
  625. creatorIds: [],
  626. ids:type === 'single' ? [DataId] : this.checkedList.map(_ => _.DataId),
  627. newUser: '',
  628. assetTypes: this.tabs.map(_=>_.key)
  629. }
  630. this.isTransferDia = true
  631. },
  632. /* 转移权限 */
  633. async confirmTransferHandle() {
  634. await this.$refs.formRef.validate()
  635. //全量转
  636. if(this.transferForm.type==='all') return this.transferAllHandle()
  637. let Classify = Array.from(new Set(this.searchForm.classifys.flat())).join(',')
  638. //单模块转
  639. const res = await operateAuthInterface.authEdit({
  640. Source: this.default_tab,
  641. SubSource: this.default_tab === 6 ? Number(this.default_sub_tab) : 0,
  642. DataIdList: this.isSelectAll ? [] : this.transferForm.ids,
  643. NoDataIdList: this.isSelectAll ? this.transferForm.ids : [],
  644. NewUserId: Number(this.transferForm.newUser),
  645. Keyword:this.searchForm.key_word,
  646. UserId:this.searchForm.user||0,
  647. Classify,
  648. IsSelectAll:this.isSelectAll
  649. })
  650. if(res.Ret !== 200) return
  651. this.$message.success(res.Msg);
  652. this.cancelTransfer();
  653. this.getTableData();
  654. },
  655. /* 全量转移 */
  656. async transferAllHandle() {
  657. if(!this.transferForm.creatorIds.length) return this.$message.warning(/* '请选择原创建人' */this.$t('SystemManage.OperateAuth.old_creator_msg'))
  658. if(!this.transferForm.assetTypes.length) return this.$message.warning(/* '请选择要转移资产模块' */)
  659. const res = await operateAuthInterface.transferAllData({
  660. Source: this.transferForm.assetTypes,
  661. OldUserId: this.transferForm.creatorIds.map(_ => Number(_)),
  662. NewUserId: Number(this.transferForm.newUser)
  663. })
  664. if(res.Ret !== 200) return
  665. this.$message.success(res.Msg);
  666. this.cancelTransfer();
  667. this.getTableData();
  668. },
  669. cancelTransfer() {
  670. this.$refs.formRef.resetFields();
  671. this.isTransferDia = false
  672. },
  673. /* 设置加密分类 */
  674. setMenuSecretHandle() {
  675. this.isSetClassifySecret = true
  676. },
  677. /* 设置可见权限 分类设置 单设置 批量设置*/
  678. setAuthHandle({ DataId,Name },type='single') {
  679. if(type === 'multiple' && !this.checkedList.length&&!this.isSelectAll) return this.$message.warning(this.$t('SystemManage.OperateAuth.msg01'))
  680. let checked = type === 'single' ? [ DataId ] : this.checkedList.map(_ => _.DataId)
  681. let Classify = Array.from(new Set(this.searchForm.classifys.flat())).join(',')
  682. this.authForm = {
  683. type,
  684. dataName: Name,
  685. params: type!=='classify' ? {
  686. Source: this.default_tab,
  687. SubSource: this.default_tab === 6 ? Number(this.default_sub_tab) : 0,
  688. DataIdList: (this.isSelectAll&&type==='multiple') ? [] : checked,
  689. NoDataIdList: (this.isSelectAll&&type==='multiple') ? checked : [],
  690. Keyword:this.searchForm.key_word,
  691. UserId:this.searchForm.user||0,
  692. Classify,
  693. IsSelectAll:(this.isSelectAll&&type==='multiple') ? true : false
  694. } : null
  695. }
  696. this.isSetAuthDia = true
  697. },
  698. authBtn(key){
  699. const {operateAuthPermission,checkPermissionBtn} = this.permissionBtn
  700. return checkPermissionBtn(operateAuthPermission[key])
  701. }
  702. },
  703. }
  704. </script>
  705. <style scoped lang='scss'>
  706. @import "~@/styles/theme-vars.scss";
  707. .operate-auth-box {
  708. * {
  709. box-sizing: border-box;
  710. }
  711. .header,.main {
  712. padding: 20px 30px;
  713. background: #fff;
  714. position: relative;
  715. border: 1px solid #ececec;
  716. border-radius: 4px;
  717. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  718. }
  719. .header {
  720. display: flex;
  721. justify-content: space-between;
  722. margin-bottom: 30px;
  723. gap: 10px;
  724. }
  725. .main {
  726. min-height: calc(100vh - 240px);
  727. .tab-wrapper {
  728. display: flex;
  729. gap: 20px;
  730. margin-bottom: 20px;
  731. .tab-li {
  732. width: 16%;
  733. height: 90px;
  734. background: #ececec;
  735. padding: 15px 20px;
  736. border-radius: 8px;
  737. border: 1px solid transparent;
  738. cursor: pointer;
  739. &.act {
  740. border-color: $theme-color;
  741. background: #e6eefb;
  742. }
  743. }
  744. }
  745. .filter-wrapper {
  746. display: flex;
  747. align-items: center;
  748. justify-content: space-between;
  749. }
  750. }
  751. }
  752. .dialog-main {
  753. padding-left: 110px;
  754. }
  755. .dia-bot {
  756. display: flex;
  757. justify-content: center;
  758. margin-top: 50px;
  759. }
  760. </style>
  761. <style lang="scss">
  762. .operateauth-dialog-cont .el-input {
  763. width: 100%;
  764. }
  765. .operate-auth-box .el-tabs__nav-wrap::after {
  766. background: transparent;
  767. }
  768. </style>