audit-matters-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <div :class="$style.wrapHeight">
  3. <div :class="$style.rowHeight">
  4. <audit-matters-catalog-tree
  5. ref="auditMattersCatalogTree"
  6. :key="key"
  7. show-line
  8. top-node-text="指引库"
  9. :is-select-dep="true"
  10. manager-type="view"
  11. @treeSelect="treeSelect"
  12. ></audit-matters-catalog-tree>
  13. <div :class="$style.rightcard">
  14. <a-card>
  15. <!-- 高级搜索组件 -->
  16. <audit-advanced-query
  17. :expand="expand"
  18. :search-data="formData"
  19. :ref-name="searchform"
  20. :search-style="{ height: '150px', left: '20px', top: '57px' }"
  21. :search-fun="handleSearch"
  22. @searchedClick="searchedClick"
  23. >
  24. <template>
  25. <a-col :span="12">
  26. <a-form-model-item label="审计事项名称" prop="auditMattersName">
  27. <a-input v-model="formData.auditMattersName" allow-clear />
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :span="12">
  31. <a-form-model-item label="审计事项编号" prop="auditMattersCode">
  32. <a-input v-model="formData.auditMattersCode" allow-clear />
  33. </a-form-model-item>
  34. </a-col>
  35. </template>
  36. </audit-advanced-query>
  37. <sd-data-table-ex
  38. :key="key"
  39. ref="auditMattersTable"
  40. :editnode="editnode"
  41. form-id="iamAuditMatters"
  42. page-id="audit/matters/iamAuditMatters"
  43. :columns="columns"
  44. :actions="actions"
  45. show-selection
  46. :show-advance-query="true"
  47. :filter-expressions="expressions"
  48. :search-fields="['auditMattersName']"
  49. @searchbtnClick="searchbtnClick"
  50. >
  51. <div slot="islink" slot-scope="text, record">
  52. <a :title="text" @click="rowClick(record)">{{ text }}</a>
  53. </div>
  54. </sd-data-table-ex>
  55. <audit-matters-export-modal :visible="visible"></audit-matters-export-modal>
  56. </a-card>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import { Modal, message } from 'ant-design-vue'
  63. import errorUtil from '@/common/services/error-util'
  64. import download from '@/common/services/download'
  65. import TableActionTypes from '@/common/services/table-action-types'
  66. import TableColumnTypes from '@/common/services/table-column-types'
  67. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  68. import openAsTrustId from '@/common/services/open-as-trust-id'
  69. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  70. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  71. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  72. import auditMattersExportModal from './audit-matters-export-modal'
  73. import auditMattersCatalogTree from './audit-matters-catalog-tree'
  74. import auditMattersService from './audit-matters-service'
  75. import components from './_import-components/audit-matters-list-import'
  76. export default {
  77. name: 'AuditMattersList',
  78. metaInfo: {
  79. title: '审计事项列表',
  80. },
  81. components: {
  82. ...components,
  83. auditMattersCatalogTree,
  84. auditAdvancedQuery,
  85. auditMattersExportModal,
  86. },
  87. mixins: [auditAdvancedQueryMixins, auditAdvancedGroupMixins],
  88. data() {
  89. return {
  90. editnode: true, // 列表是否可以新建
  91. key: 0,
  92. treeData: [],
  93. searchform: 'searchform',
  94. formData: {
  95. auditMattersName: '',
  96. auditMattersCode: '',
  97. },
  98. columns: [
  99. {
  100. title: '序号',
  101. customRender: (text, record, index) => `${index + 1}`,
  102. width: '80px',
  103. },
  104. {
  105. title: '审计事项名称',
  106. dataIndex: 'auditMattersName',
  107. scopedSlots: { customRender: 'islink' },
  108. width: '50%',
  109. },
  110. {
  111. title: '审计事项编号',
  112. dataIndex: 'auditMattersCode',
  113. },
  114. {
  115. title: '编制人员',
  116. dataIndex: 'creatorName',
  117. },
  118. {
  119. title: '编制日期',
  120. dataIndex: 'creationTime',
  121. sdRender: TableColumnTypes.date,
  122. sorter: true,
  123. defaultSortOrder: 'desc',
  124. },
  125. ],
  126. actions: [
  127. {
  128. label: '新建',
  129. id: 'new',
  130. type: TableActionTypes.primary, // 新建按钮,不需要回调,自动处理
  131. permission: 'iamAuditMatters-create', // 纯前端操作,不需要权限控制
  132. callback: this.createMatters,
  133. },
  134. {
  135. label: '批量导入',
  136. id: 'importItem',
  137. permission: 'iamAuditMatters-import',
  138. callback: this.importItem, // 纯前端操作,不需要权限控制
  139. },
  140. {
  141. label: '导出',
  142. id: 'exportItem',
  143. permission: 'iamAuditMatters-export',
  144. callback: this.exportItem, // 纯前端操作,不需要权限控制
  145. },
  146. {
  147. label: '分类配置',
  148. id: 'auditMattersCatalog',
  149. permission: 'iamAuditMatters-catalog',
  150. callback: () => {
  151. const url = '/sd-frame/audit-matters-catalog' // 新页面要打开的路由地址
  152. openAsTrustId(url, null)
  153. },
  154. },
  155. {
  156. label: '删除',
  157. id: 'delete',
  158. permission: 'iamAuditMatters-delete',
  159. type: TableActionTypes.batch,
  160. callback: this.deleteRows,
  161. },
  162. ],
  163. expressions: [
  164. {
  165. dataType: 'str',
  166. name: 'catalogId',
  167. op: 'eq',
  168. stringValue: 0,
  169. },
  170. ],
  171. catalogId: null,
  172. catalogName: '',
  173. auditMattersPath: '',
  174. visible: false,
  175. }
  176. },
  177. methods: {
  178. // 选择上级分类后给对应的域赋值
  179. fnTreePicker(value) {
  180. if (value.length > 0) {
  181. this.$refs.dataTable.getDetailModal().setFieldValue('catalogId', value[0].id)
  182. this.$refs.dataTable.getDetailModal().setFieldValue('catalogName', value[0].name)
  183. } else {
  184. this.$refs.dataTable.getDetailModal().setFieldValue('catalogId', '')
  185. this.$refs.dataTable.getDetailModal().setFieldValue('catalogName', '')
  186. this.$refs.dataTable.getDetailModal().setFieldValue('auditMattersPath', '')
  187. }
  188. },
  189. treeSelect(selectedKeys, info) {
  190. this.auditMattersPath = null
  191. // 父级id
  192. if (info != null && info.selectedNodes.length > 0) {
  193. this.parentId = Number(info.selectedNodes[0].data.props.id)
  194. this.parentName = info.selectedNodes[0].data.props.text // 父级名称
  195. this.catalogId = Number(info.selectedNodes[0].data.props.id)
  196. this.catalogName = info.selectedNodes[0].data.props.text // 父级名称
  197. this.editnode = info.selectedNodes[0].data.props.edit
  198. if (info.selectedNodes[0].data.props.props) {
  199. if (info.selectedNodes[0].data.props.props.catalogPath) {
  200. this.auditMattersPath =
  201. info.selectedNodes[0].data.props.props.catalogPath + ',' + this.parentId
  202. } else {
  203. this.auditMattersPath = this.parentId
  204. }
  205. }
  206. } else {
  207. if (selectedKeys.id) {
  208. this.parentId = Number(selectedKeys.id)
  209. this.parentName = selectedKeys.text // 父级名称
  210. }
  211. }
  212. const orgId = this.$refs.auditMattersCatalogTree.depvalue
  213. // 判断当前节点是否为根节点
  214. if (this.catalogId === orgId) {
  215. this.expressions.forEach((item) => {
  216. if (item.name === 'catalogId' || item.name === 'orgId') {
  217. item.name = 'orgId'
  218. item.stringValue = orgId + ''
  219. }
  220. })
  221. } else {
  222. this.expressions.forEach((item) => {
  223. if (item.name === 'catalogId' || item.name === 'orgId') {
  224. item.name = 'catalogId'
  225. item.stringValue = this.catalogId
  226. }
  227. })
  228. }
  229. this.expressions = [...this.expressions]
  230. },
  231. handleSearch() {
  232. this.expressions = []
  233. // 审计事项名称
  234. if (this.formData.auditMattersName) {
  235. this.expressions.push({
  236. dataType: 'str',
  237. name: 'auditMattersName',
  238. op: 'like',
  239. stringValue: '%' + this.formData.auditMattersName + '%',
  240. })
  241. }
  242. // 审计事项编号
  243. if (this.formData.auditMattersCode) {
  244. this.expressions.push({
  245. dataType: 'str',
  246. name: 'auditMattersCode',
  247. op: 'like',
  248. stringValue: '%' + this.formData.auditMattersCode + '%',
  249. })
  250. }
  251. this.expressions.push({
  252. dataType: 'str',
  253. name: 'catalogId',
  254. op: 'eq',
  255. stringValue: this.catalogId,
  256. })
  257. const orgId = this.$refs.auditMattersCatalogTree.depvalue
  258. // 判断当前节点是否为根节点
  259. if (this.catalogId === orgId) {
  260. this.expressions.forEach((item) => {
  261. if (item.name === 'catalogId' || item.name === 'orgId') {
  262. item.name = 'orgId'
  263. item.stringValue = orgId + ''
  264. }
  265. })
  266. } else {
  267. this.expressions.forEach((item) => {
  268. if (item.name === 'catalogId' || item.name === 'orgId') {
  269. item.name = 'catalogId'
  270. item.stringValue = this.catalogId
  271. }
  272. })
  273. }
  274. this.expressions = [...this.expressions]
  275. },
  276. // 新建、详情打开新页面
  277. rowClick(record) {
  278. const url =
  279. '/audit-matters-form?record=' +
  280. record.id +
  281. '&orgId=' +
  282. this.$refs.auditMattersCatalogTree.depvalue // 新页面要打开的路由地址
  283. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  284. if (refreshFlag) {
  285. this.refresh()
  286. }
  287. })
  288. // const res = crossWindowWatcher.waitForChanged(url)
  289. },
  290. // 部门下拉框选择事件
  291. depChanged(value, info) {
  292. this.orgId = this.$refs.auditMattersCatalogTree.depvalue // 选中的值
  293. },
  294. // 新建保存回调刷新树
  295. onRecordSaved() {
  296. this.key = this.key + 1
  297. },
  298. // 删除回调
  299. onRecordsDeleted() {
  300. message.success('删除成功')
  301. this.key = this.key + 1
  302. this.refresh()
  303. },
  304. deleteRows() {
  305. const ids = this.$refs.auditMattersTable.getSelectedRowKeys()
  306. if (ids.length === 0) {
  307. Modal.info({
  308. content: '请选择需要删除的文件',
  309. })
  310. return
  311. }
  312. return new Promise((resolve) => {
  313. Modal.confirm({
  314. title: '您确定删除这项内容吗?',
  315. content: '删除数据后,就无法恢复初始的状态。',
  316. okText: '删除',
  317. cancelText: '取消',
  318. okType: 'danger',
  319. onOk: () => {
  320. auditMattersService
  321. .deleteIamAuditMatters(ids)
  322. .then(() => {
  323. message.success('删除成功')
  324. this.$refs.auditMattersTable.clearSelection()
  325. this.refresh()
  326. })
  327. .catch((err) => {
  328. const msg = errorUtil.getMessage(err) || '删除失败'
  329. message.error(msg)
  330. })
  331. .finally(resolve)
  332. },
  333. onCancel: () => {
  334. resolve()
  335. },
  336. })
  337. })
  338. },
  339. createMatters() {
  340. const rootId = this.$refs.auditMattersCatalogTree.depvalue
  341. if (this.catalogId != null && this.catalogId !== rootId) {
  342. const url =
  343. '/audit-matters-form?catalogId=' +
  344. this.catalogId +
  345. '&catalogName=' +
  346. this.catalogName +
  347. '&auditMattersPath=' +
  348. this.auditMattersPath +
  349. '&orgId=' +
  350. this.$refs.auditMattersCatalogTree.depvalue
  351. // 新页面要打开的路由地址
  352. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  353. if (refreshFlag) {
  354. // 这里写或者调刷新的方法
  355. this.refresh()
  356. }
  357. })
  358. } else {
  359. if (this.catalogId === rootId) {
  360. Modal.confirm({
  361. title: '注意',
  362. content: '不能在根节点下新建审计事项',
  363. okText: '确定',
  364. okType: 'danger',
  365. })
  366. } else {
  367. Modal.confirm({
  368. title: '请先选择审计事项分类',
  369. content: '请先选择审计事项分类。',
  370. okText: '确定',
  371. okType: 'danger',
  372. })
  373. }
  374. }
  375. },
  376. // 导出
  377. exportItem() {
  378. const rootId = this.$refs.auditMattersCatalogTree.depvalue
  379. const id = this.catalogId
  380. auditMattersService.exportItem(id, rootId).then((res) => {
  381. if (res.status === 200) {
  382. const url = URL.createObjectURL(res.data)
  383. const filename = res.headers['content-disposition']
  384. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  385. download(url, decodeURI(fname))
  386. } else {
  387. Modal.warning({
  388. title: '提示',
  389. content: '导出报错,请联系管理员!',
  390. })
  391. return false
  392. }
  393. })
  394. },
  395. // 导入
  396. importItem() {
  397. // 选择事项分类
  398. this.visible = true
  399. },
  400. refresh() {
  401. this.$refs.auditMattersTable.refresh()
  402. },
  403. },
  404. }
  405. </script>
  406. <style module lang="scss">
  407. @use '@/common/design' as *;
  408. .wrap-height {
  409. height: 100%;
  410. .row-height {
  411. display: flex;
  412. flex: auto;
  413. height: 100%;
  414. .rightcard {
  415. flex: 1;
  416. width: calc(100% - 20%);
  417. height: 100%;
  418. }
  419. }
  420. }
  421. </style>