audit-data-class.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div :class="[$style.wrapHeight, $style.dataclass]">
  3. <div :class="$style.rowHeight">
  4. <div :class="$style.rowLeft">
  5. <audit-class-tree
  6. ref="auditMaintainCatalogTree"
  7. show-line
  8. top-node-text="数据分类维护"
  9. :is-select-dep="true"
  10. :draggable="true"
  11. :cate="true"
  12. @treeSelect="treeSelect"
  13. ></audit-class-tree>
  14. </div>
  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="categoryId">
  29. <a-input v-model="formData.categoryId" allow-clear />
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :span="12">
  33. <a-form-model-item :label="'分类名称'" prop="categoryName">
  34. <a-input v-model="formData.categoryName" allow-clear />
  35. </a-form-model-item>
  36. </a-col>
  37. </template>
  38. </audit-advanced-query>
  39. <SdDataTableEx
  40. :key="key"
  41. ref="dataTable"
  42. :projectlist="true"
  43. :editnode="editnode"
  44. form-id="iamDataCategory"
  45. page-id="audit/maintain/iamDataCategory"
  46. :columns="columns"
  47. :actions="actions"
  48. :filter-expressions="expressions"
  49. :custom-delete-fun="deleteRows"
  50. :search-fields="['categoryId', 'categoryName']"
  51. :show-advance-query="true"
  52. :show-selection="(item) => item.editAndDeleteAuth !== 0"
  53. @recordSaved="onRecordSaved"
  54. @searchbtnClick="searchbtnClick"
  55. >
  56. <template slot="categoryName" slot-scope="text, record">
  57. <a
  58. v-if="record.editAndDeleteAuth !== 0"
  59. @click="
  60. () => {
  61. $refs.dataTable.showDetailModal(record.id, 'audit/maintain/iamDataCategory')
  62. }
  63. "
  64. >{{ text }}</a
  65. >
  66. <span v-else>{{ text }}</span>
  67. </template>
  68. <!-- 详情表单 -->
  69. <template v-slot:form="{ model }" v-sd-watermark="waterMark" @saved="onSaved">
  70. <SdFormItem name="categoryId" />
  71. <SdFormItem name="categoryName" />
  72. <a-form-model-item label="移动端分类名称">
  73. <a-input v-model="model.reservestring4" />
  74. </a-form-model-item>
  75. <SdFormItem name="weightNum" />
  76. <SdFormItem name="sortNum" />
  77. <a-form-model-item label="分类级别">
  78. <a-input :value="parentId === 0 ? '一级' : className" disabled />
  79. </a-form-model-item>
  80. <SdFormItem name="categoryDesc">
  81. <a-textarea v-model="model.categoryDesc" :rows="3" />
  82. </SdFormItem>
  83. <SdFormItem
  84. :hidden="true"
  85. name="parentId"
  86. :input-props="{ defaultValue: parentId, disabled: true }"
  87. />
  88. <SdFormItem
  89. :hidden="true"
  90. name="auditOrgId"
  91. :input-props="{ defaultValue: auditOrgId, disabled: true }"
  92. />
  93. <SdFormItem
  94. :hidden="true"
  95. name="parentCategoryId"
  96. :input-props="{ defaultValue: parentCategoryId, disabled: true }"
  97. />
  98. <SdFormItem name="level" :hidden="true" :input-props="{ defaultValue: level }" />
  99. </template>
  100. </SdDataTableEx>
  101. </a-card>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import { Modal, message } from 'ant-design-vue'
  108. import axios from '@/common/services/axios-instance'
  109. import auditClassTree from './audit-class-tree.vue'
  110. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  111. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  112. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  113. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  114. import SdDataTableEx from '@/common/components/sd-data-table-ex.vue'
  115. import SdFormItem from '@/common/components/sd-form-item.vue'
  116. import dataService from './data-config'
  117. import TableActionTypes from '@/common/services/table-action-types'
  118. export default {
  119. name: 'AuditDataClass',
  120. metaInfo: {
  121. title: '数据分类维护',
  122. },
  123. components: {
  124. SdDataTableEx,
  125. SdFormItem,
  126. auditClassTree,
  127. auditAdvancedQuery,
  128. },
  129. mixins: [auditAdvancedQueryMixins, auditAdvancedGroupMixins],
  130. data() {
  131. return {
  132. editnode: true,
  133. key: 0,
  134. searchform: 'searchform',
  135. formData: {
  136. categoryName: '',
  137. categoryId: '',
  138. },
  139. auditOrgId: null,
  140. parentId: 0,
  141. parentCategoryId: '000000',
  142. level: 1,
  143. isEnd: null,
  144. columns: [
  145. {
  146. dataIndex: 'id',
  147. sdHidden: true,
  148. },
  149. {
  150. dataIndex: 'parentId',
  151. sdHidden: true,
  152. },
  153. {
  154. title: '排序号',
  155. dataIndex: 'sortNum',
  156. defaultSortOrder: 'ascend',
  157. width: '100px',
  158. },
  159. {
  160. title: '分类编号',
  161. dataIndex: 'categoryId',
  162. },
  163. {
  164. title: '分类名称',
  165. dataIndex: 'categoryName',
  166. scopedSlots: { customRender: 'categoryName' },
  167. },
  168. {
  169. tiltle: '移动端分类名称',
  170. dataIndex: 'reservestring4',
  171. sdHidden: true,
  172. },
  173. {
  174. title: '权重排序',
  175. dataIndex: 'weightNum',
  176. sdHidden: true,
  177. },
  178. {
  179. title: '分类描述',
  180. dataIndex: 'categoryDesc',
  181. },
  182. ],
  183. actions: [
  184. {
  185. label: '新建',
  186. permission: null,
  187. // id: 'new',
  188. type: TableActionTypes.primary,
  189. callback: this.create,
  190. },
  191. {
  192. label: '审搜索引',
  193. permission: null,
  194. id: 'auditMattersCatalog',
  195. callback: this.toIndexList,
  196. },
  197. {
  198. label: '数据授权',
  199. id: 'auditWarrant',
  200. permission: null,
  201. callback: this.Matterssq,
  202. },
  203. {
  204. label: '删除',
  205. // id: 'delete',
  206. permission: null,
  207. callback: this.deleteRows,
  208. },
  209. ],
  210. expressions: [
  211. {
  212. dataType: 'long',
  213. name: 'parentId',
  214. op: 'eq',
  215. longValue: 0,
  216. },
  217. ],
  218. isroot: true,
  219. className: '',
  220. }
  221. },
  222. methods: {
  223. toIndexList() {
  224. if (this.parentId === 0) {
  225. message.warning('请选择分类')
  226. return
  227. }
  228. const name = this.className === '' ? '全部分类' : this.className
  229. const url =
  230. '#/sd-frame/audit-class-index?classId=' + this.parentCategoryId + '&className=' + name
  231. window.open(url)
  232. },
  233. handleSearch() {
  234. this.expressions = []
  235. // 模型编号
  236. if (this.formData.categoryId) {
  237. this.expressions.push({
  238. dataType: 'str',
  239. name: 'categoryId',
  240. op: 'like',
  241. stringValue: `%${this.formData.categoryId}%`,
  242. })
  243. }
  244. // 模型名称
  245. if (this.formData.categoryName) {
  246. this.expressions.push({
  247. dataType: 'str',
  248. name: 'categoryName',
  249. op: 'like',
  250. stringValue: `%${this.formData.categoryName}%`,
  251. })
  252. }
  253. this.expressions.push({
  254. dataType: 'long',
  255. name: 'parentId',
  256. op: 'eq',
  257. longValue: this.parentId,
  258. })
  259. },
  260. // 删除回调
  261. onRecordsDeleted() {
  262. message.success('删除成功')
  263. this.$refs.auditMaintainCatalogTree.initTreeData()
  264. },
  265. // 新建保存回调刷新树
  266. onRecordSaved() {
  267. this.$refs.auditMaintainCatalogTree.initTreeData()
  268. },
  269. treeSelect(selectedKeys, info) {
  270. // 父级id
  271. if (info != null && info.selectedNodes[0]) {
  272. if (info.node.dataRef.props.isroot) {
  273. this.parentId = 0
  274. this.level = 1
  275. this.parentCategoryId = '000000'
  276. } else {
  277. this.parentCategoryId = info.selectedNodes[0].data.props.dataRef.props.categoryId
  278. this.parentId = Number(info.selectedNodes[0].data.props.id)
  279. this.className = info.selectedNodes[0].data.props.text // 父级名称
  280. this.level = 2
  281. }
  282. this.editnode = info.selectedNodes[0].data.props.edit
  283. if (info.selectedNodes[0].data.props.props) {
  284. this.isEnd = info.selectedNodes[0].data.props.props.isEnd
  285. }
  286. } else {
  287. if (selectedKeys.length > 0) {
  288. this.parentId = Number(selectedKeys)
  289. this.level = 2
  290. } else {
  291. this.parentId = 0
  292. this.level = 1
  293. this.parentCategoryId = '000000'
  294. }
  295. }
  296. // 如果是末级,则隐藏新建按钮
  297. this.expressions.forEach((item) => {
  298. if (item.name === 'parentId') {
  299. item.longValue = this.parentId
  300. }
  301. })
  302. this.expressions = [...this.expressions]
  303. },
  304. // 新增
  305. create() {
  306. this.$refs.dataTable.showDetailModal(null, 'audit/maintain/iamDataCategory')
  307. },
  308. // 删除
  309. deleteRows() {
  310. const ids = this.$refs.dataTable.getSelectedRowKeys()
  311. dataService.deleteCategory(ids).then(() => {
  312. this.onRecordsDeleted()
  313. this.refresh()
  314. })
  315. },
  316. refresh() {
  317. this.$refs.dataTable.refresh()
  318. },
  319. // 判断按钮显示
  320. showeditbutton(deptId) {
  321. // axios({
  322. // url: 'api/xcoa-mobile/v1/iamdatacategory/getRole?selectOrgId=0',
  323. // method: 'get',
  324. // }).then((res) => {
  325. // if (res.data === true) {
  326. // if (this.actions.length === 0) {
  327. this.actionscsh.forEach((a) => {
  328. this.actions.push(a)
  329. })
  330. // }
  331. // } else {
  332. // this.actions = []
  333. // }
  334. // })
  335. },
  336. Matterssq() {
  337. // window.open('#/audit-data-from', '_blank')
  338. const arrid = this.$refs.dataTable.getSelectedRowKeys()
  339. if (arrid.length > 0) {
  340. const url = '#/audit-data-from?selectid=' + arrid.join(',') // 新页面要打开的路由地址
  341. // 新页面要打开的路由地址
  342. window.open(url, '_blank')
  343. } else {
  344. Modal.warning({
  345. title: '提示',
  346. content: '请选择数据分类!',
  347. })
  348. }
  349. },
  350. createMatters() {
  351. const rootId = this.$refs.auditMattersCatalogTree.depvalue
  352. // if (this.catalogId != null && this.catalogId !== rootId) {
  353. if (this.catalogId !== null || this.parentId !== null) {
  354. const url =
  355. '/audit-data-from?catalogId=' +
  356. this.parentId +
  357. '&catalogName=' +
  358. this.catalogName +
  359. '&auditMattersPath=' +
  360. this.auditMattersPath +
  361. '&orgId=' +
  362. this.$refs.auditMattersCatalogTree.depvalue
  363. // 新页面要打开的路由地址
  364. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  365. if (refreshFlag) {
  366. // 这里写或者调刷新的方法
  367. this.refresh()
  368. }
  369. })
  370. } else {
  371. Modal.confirm({
  372. title: '请先选择审计模型分类',
  373. content: '请先选择审计模型分类。',
  374. okText: '确定',
  375. okType: 'danger',
  376. })
  377. }
  378. },
  379. },
  380. }
  381. </script>
  382. <style module lang="scss">
  383. @use '@/common/design' as *;
  384. .wrap-height {
  385. height: 100%;
  386. .row-left {
  387. width: 20%;
  388. }
  389. .row-height {
  390. display: flex;
  391. flex: auto;
  392. height: 100%;
  393. .rightcard {
  394. flex: 1;
  395. width: calc(100% - 20%);
  396. height: 100%;
  397. overflow-y: auto;
  398. }
  399. }
  400. }
  401. .dataclass {
  402. :global(.projectlist .ant-table-empty .ant-table-body) {
  403. overflow-x: hidden !important;
  404. }
  405. :global(span > .ant-btn:nth-child(2)) {
  406. color: #fff;
  407. background-color: #1890ff;
  408. border-color: #1890ff;
  409. }
  410. // :global(.ant-table-placeholder) {
  411. // width: auto;
  412. // }
  413. }
  414. </style>