audit-maintain-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div :class="[$style.wrapHeight, $style.maintainlist]">
  3. <div :class="$style.rowHeight">
  4. <!-- <audit-maintain-classify-tree
  5. ref="auditMattersCatalogTree"
  6. :key="key"
  7. show-line
  8. top-node-text="审计模型"
  9. :is-select-dep="true"
  10. @treeSelect="treeSelect"
  11. @de,
  12. AduitAreaTreepChanged="depChanged"
  13. ></audit-maintain-classify-tree> -->
  14. <AduitAreaTree ref="auditAreaTree" @treeSelect="treeSelect"></AduitAreaTree>
  15. <div :class="$style.rightcard">
  16. <a-card>
  17. <!-- 高级搜索组件 -->
  18. <audit-advanced-query
  19. :expand="expand"
  20. :search-data="formData"
  21. :ref-name="searchform"
  22. :search-style="{ height: '150px', left: '20px', top: '57px' }"
  23. :search-fun="handleSearch"
  24. @searchedClick="searchedClick"
  25. >
  26. <template>
  27. <a-col :span="12">
  28. <a-form-model-item :label="'模型编号'" prop="modelCode">
  29. <a-input v-model="formData.modelCode" allow-clear />
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :span="12">
  33. <a-form-model-item :label="'模型名称'" prop="modelName">
  34. <a-input v-model="formData.modelName" allow-clear />
  35. </a-form-model-item>
  36. </a-col>
  37. </template>
  38. </audit-advanced-query>
  39. <sd-data-table-ex
  40. ref="SJMXDataTable"
  41. :projectlist="true"
  42. :filter-expressions="expressions"
  43. :columns="columns"
  44. :actions="actions"
  45. form-id="iamModelMaintain"
  46. page-id="audit/maintain/iamModelMaintain"
  47. :search-fields="['modelCode', 'modelName']"
  48. show-selection
  49. :show-advance-query="true"
  50. :fnonloadsum="fnonloadsum"
  51. @searchbtnClick="searchbtnClick"
  52. >
  53. <div slot="islink" slot-scope="text, record">
  54. <a v-if="isCreateUser(record)" :title="text" @click="rowClick(record)">{{ text }}</a>
  55. <span v-else :title="text">{{ text }}</span>
  56. </div>
  57. <div slot="shareType" slot-scope="text, record">
  58. <a-switch
  59. v-if="isCreateUser(record)"
  60. :checked="shareStatus(record.sharedSetting)"
  61. checked-children="开"
  62. un-checked-children="关"
  63. @change="shareTypeChange(record)"
  64. ></a-switch>
  65. </div>
  66. <!-- <div slot="edit" slot-scope="text, record">
  67. <a-button
  68. :disabled="!isCreateUser(record)"
  69. type="link"
  70. :title="text"
  71. @click="setStatus(record)"
  72. >{{ record.lineStatus === '下线' ? '上线' : '下线' }}</a-button
  73. >
  74. </div> -->
  75. </sd-data-table-ex>
  76. </a-card>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import { Modal, message } from 'ant-design-vue'
  83. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  84. import TableActionTypes from '@/common/services/table-action-types'
  85. import { getUserInfo } from '@/common/store-mixin'
  86. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  87. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  88. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  89. import components from './_import-components/audit-maintain-list-import'
  90. import auditMaintainService from './audit-maintain-service'
  91. import AduitAreaTree from './aduit-area-tree.vue'
  92. export default {
  93. name: 'AuditMaintainList',
  94. metaInfo: {
  95. title: '审计模型',
  96. },
  97. components: {
  98. ...components,
  99. auditAdvancedQuery,
  100. AduitAreaTree,
  101. },
  102. mixins: [auditAdvancedQueryMixins, auditAdvancedGroupMixins],
  103. data() {
  104. return {
  105. key: 0,
  106. treeData: [],
  107. searchform: 'searchform',
  108. formData: {
  109. modelCode: '',
  110. modelName: '',
  111. },
  112. formId: 'iamModelMaintain',
  113. columns: [
  114. {
  115. title: '序号',
  116. dataIndex: 'sortNum',
  117. width: '80px',
  118. customRender: (text, record, index) => `${index + 1}`,
  119. },
  120. {
  121. title: '模型名称',
  122. dataIndex: 'modelName',
  123. scopedSlots: { customRender: 'islink' },
  124. },
  125. {
  126. title: '模型编号',
  127. // dataIndex: 'id',
  128. dataIndex: 'modelCode',
  129. },
  130. {
  131. title: '风险描述',
  132. dataIndex: 'risk',
  133. },
  134. // 任务名称 jobName
  135. {
  136. title: '任务名称',
  137. dataIndex: 'jobName',
  138. sdHidden: true,
  139. },
  140. {
  141. title: '创建人',
  142. dataIndex: 'creatorId',
  143. sdHidden: true,
  144. },
  145. ],
  146. expressions: [
  147. {
  148. dataType: 'str',
  149. name: 'source',
  150. op: 'eq',
  151. stringValue: 0,
  152. },
  153. ],
  154. catalogId: null,
  155. catalogName: '',
  156. actions: [
  157. {
  158. label: '新建',
  159. permission: 'create',
  160. id: 'new',
  161. type: TableActionTypes.primary,
  162. callback: this.createMatters,
  163. },
  164. {
  165. label: '删除',
  166. id: 'delete',
  167. permission: 'delete',
  168. // 您确定删除这项内容吗?
  169. // 删除这条数据后,就无法恢复初始的状态。
  170. callback: () => {
  171. const selectedRows = this.$refs.SJMXDataTable.getSelectedRows()
  172. if (selectedRows.length === 0) {
  173. Modal.warning({
  174. title: '提示',
  175. content: '请选择要删除的数据',
  176. })
  177. return
  178. }
  179. const noDelete = selectedRows.filter(
  180. (item) => item.jobName !== null && item.jobName !== ''
  181. )
  182. const noDeleteName = noDelete.map((item) => item.modelName).join(',')
  183. if (noDelete.length > 0) {
  184. Modal.warning({
  185. title: '提示',
  186. content: `"${noDeleteName}"` + '有跑批任务在执行无法删除此模型 ',
  187. })
  188. return
  189. }
  190. Modal.confirm({
  191. title: '您确定删除这项内容吗?',
  192. content: '删除这条数据后,就无法恢复初始的状态。',
  193. okText: '确定',
  194. okType: 'danger',
  195. cancelText: '取消',
  196. onOk: () => {
  197. const ids = selectedRows.map((item) => item.id).join(',')
  198. auditMaintainService.deleteCheckModel(ids).then((res) => {
  199. if (res) {
  200. message.success('删除成功')
  201. this.refresh()
  202. }
  203. })
  204. },
  205. })
  206. },
  207. },
  208. ],
  209. actionscsh: [
  210. // todo暂时注释 11-30
  211. // {
  212. // label: '模型授权',
  213. // id: 'auditWarrant',
  214. // permission: null,
  215. // callback: this.Matterssq,
  216. // },
  217. // {
  218. // label: '分类配置',
  219. // id: 'auditMattersCatalog',
  220. // permission: null,
  221. // callback: () => {
  222. // const url = '#/sd-frame/audit-maintain-catalog' // 新页面要打开的路由地址
  223. // window.open(url)
  224. // // openAsTrustId(url, null)
  225. // },
  226. // },
  227. ],
  228. parentorgId: '',
  229. isroot: true,
  230. modelDomain: '',
  231. }
  232. },
  233. created() {},
  234. methods: {
  235. setStatus(record) {
  236. const status = record.lineStatus === '下线' ? 1 : 0
  237. auditMaintainService
  238. .updateModelStatus({ id: parseInt(record.id), status: status })
  239. .then((res) => {
  240. if (res) {
  241. this.refresh()
  242. }
  243. })
  244. },
  245. // <!-- 判断自己是否是创建人 -->
  246. isCreateUser(record) {
  247. const userInfo = getUserInfo()
  248. const roles = this.$store.state.sd.common.userInfo.default.roles
  249. const isExport = roles.map((val) => val.code).includes('G-1_DATA_AUDIT_RULE')
  250. return userInfo.id === record.creatorId || isExport
  251. },
  252. shareStatus(record) {
  253. return record === 0
  254. },
  255. depChanged(oldId, value) {
  256. this.parentorgId = oldId
  257. // 获取当前节点权限 判断按钮是否显示
  258. if (typeof this.parentorgId !== 'number' && this.parentorgId.indexOf('o_') > -1) {
  259. this.showeditbutton(this.parentorgId.replaceAll('o_', ''))
  260. } else {
  261. this.showeditbutton(this.parentorgId)
  262. }
  263. },
  264. // 调整共享开关
  265. shareTypeChange(record) {
  266. const type = record.sharedSetting === 0 ? 1 : 0
  267. auditMaintainService
  268. .setShareStatus({ id: parseInt(record.id), sharedSetting: type })
  269. .then((res) => {
  270. if (res) {
  271. this.refresh()
  272. }
  273. })
  274. },
  275. fnonloadsum() {
  276. if (
  277. document
  278. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  279. .getElementsByClassName('ant-btn').length > 4 &&
  280. document
  281. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  282. .getElementsByClassName('ant-btn')[5]
  283. .innerHTML.indexOf('模型授权') > -1
  284. ) {
  285. if (
  286. document
  287. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  288. .getElementsByClassName('ant-btn').length > 4 &&
  289. document
  290. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  291. .getElementsByClassName('ant-btn')[5]
  292. .classList.value.indexOf('ant-btn-primary') === -1
  293. ) {
  294. document
  295. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  296. .getElementsByClassName('ant-btn')[5]
  297. .classList.add('ant-btn-primary')
  298. }
  299. }
  300. if (
  301. document
  302. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  303. .getElementsByClassName('ant-btn').length > 4 &&
  304. document
  305. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  306. .getElementsByClassName('ant-btn')[4]
  307. .innerHTML.indexOf('删') > -1
  308. ) {
  309. document
  310. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  311. .getElementsByClassName('ant-btn')[4]
  312. .parentElement.appendChild(
  313. document
  314. .getElementsByClassName('maintainlist_audit-maintain-list_product')[0]
  315. .getElementsByClassName('ant-btn')[4]
  316. )
  317. }
  318. },
  319. treeSelect(selectedKeys, info) {
  320. this.modelDomain = selectedKeys[0] || ''
  321. this.handleSearch()
  322. },
  323. // 判断按钮显示
  324. showeditbutton(deptId) {
  325. // axios({
  326. // url: 'api/xcoa-mobile/v1/iammodelmaintain/getRole?selectOrgId=' + deptId,
  327. // method: 'get',
  328. // }).then((res) => {
  329. // if (res.data === true) {
  330. // if (this.actions.length === 0) {
  331. // todo暂时放开权限11-30
  332. // this.actionscsh.forEach((a) => {
  333. // this.actions.push(a)
  334. // })
  335. // }
  336. // } else {
  337. // this.actions = []
  338. // }
  339. // })
  340. },
  341. createMatters() {
  342. if (this.modelDomain !== '') {
  343. const url = '/audit-maintain-from?modelDomain=' + this.modelDomain
  344. // 新页面要打开的路由地址
  345. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  346. if (refreshFlag) {
  347. // 这里写或者调刷新的方法
  348. this.refresh()
  349. }
  350. })
  351. } else {
  352. Modal.confirm({
  353. title: '请先选择审计模型领域',
  354. content: '请先选择审计模型领域。',
  355. okText: '确定',
  356. okType: 'danger',
  357. })
  358. }
  359. },
  360. Matterssq() {
  361. const arrid = this.$refs.SJMXDataTable.getSelectedRowKeys()
  362. if (arrid.length > 0) {
  363. const url = '#/audit-warrant-from?selectid=' + arrid.join(',') // 新页面要打开的路由地址
  364. // 新页面要打开的路由地址
  365. window.open(url, '_blank')
  366. } else {
  367. Modal.warning({
  368. title: '提示',
  369. content: '请选择审计模型!',
  370. })
  371. }
  372. },
  373. refresh() {
  374. return this.$refs.SJMXDataTable.refresh(true)
  375. },
  376. rowClick(record) {
  377. const url = '/audit-maintain-from?record=' + record.id // 新页面要打开的路由地址
  378. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  379. if (refreshFlag) {
  380. this.refresh()
  381. }
  382. })
  383. },
  384. // 查询
  385. handleSearch() {
  386. this.expressions = []
  387. this.expressions.push({
  388. dataType: 'str',
  389. name: 'source',
  390. op: 'eq',
  391. stringValue: 0,
  392. })
  393. // 模型编号
  394. if (this.formData.modelCode) {
  395. this.expressions.push({
  396. dataType: 'str',
  397. name: 'modelCode',
  398. op: 'like',
  399. stringValue: `%${this.formData.modelCode}%`,
  400. })
  401. }
  402. // 模型名称
  403. if (this.formData.modelName) {
  404. this.expressions.push({
  405. dataType: 'str',
  406. name: 'modelName',
  407. op: 'like',
  408. stringValue: `%${this.formData.modelName}%`,
  409. })
  410. }
  411. // 模型领域
  412. if (this.modelDomain) {
  413. this.expressions.push({
  414. dataType: 'str',
  415. name: 'modelDomain',
  416. op: 'eq',
  417. stringValue: this.modelDomain,
  418. })
  419. }
  420. },
  421. },
  422. }
  423. </script>
  424. <style module lang="scss">
  425. @use '@/common/design' as *;
  426. .wrap-height {
  427. height: 100%;
  428. .row-height {
  429. display: flex;
  430. flex: auto;
  431. height: 100%;
  432. .rightcard {
  433. flex: 1;
  434. width: calc(100% - 20%);
  435. height: 100%;
  436. }
  437. }
  438. }
  439. .maintainlist {
  440. :global(.projectlist .ant-table-empty .ant-table-body) {
  441. overflow-x: hidden !important;
  442. }
  443. :global(span > .ant-btn:nth-child(2)) {
  444. color: #fff;
  445. background-color: #1890ff;
  446. border-color: #1890ff;
  447. }
  448. // :global(.ant-table-placeholder) {
  449. // width: auto;
  450. // }
  451. }
  452. </style>