audit-archives-tree.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div :class="$style.wrapHeight">
  3. <div :class="$style.rowHeight">
  4. <AuditArchivesListTree
  5. :key="key"
  6. :checkable="checkable"
  7. :draggable="draggable"
  8. :is-search="isSearch"
  9. :show-line="showLine"
  10. :selected-keys="defaultSelectedKeys"
  11. :top-node-text="topNodeText"
  12. :treeparams="treeparams"
  13. :default-expanded-keys="defaultSelectedKeys"
  14. :is-select-dep="isSelectDep"
  15. :dep-options="depOptions"
  16. @treeSelect="treeSelect"
  17. @depChanged="depChanged"
  18. ></AuditArchivesListTree>
  19. <div :class="$style.rightcard">
  20. <a-card :class="$style.acard">
  21. <sd-data-table-ex
  22. :key="key"
  23. ref="dataTable"
  24. :data-url="_computedDataUrl"
  25. :process-req="processReq"
  26. :form-id="formId"
  27. :page-id="pageId"
  28. :columns="columns"
  29. :show-selection="(item) => item.editAndDeleteAuth !== 0"
  30. :actions="actions"
  31. :search-fields="searchFields"
  32. :filter-expressions="expressions"
  33. @onChange="onChange"
  34. @recordSaved="onRecordSaved"
  35. @recordsDeleted="onRecordsDeleted"
  36. >
  37. <!-- 点击列插槽 -->
  38. <template slot="customCell" slot-scope="text, record">
  39. <slot name="customCell" :text="text" :record="record"></slot>
  40. </template>
  41. <template slot="islink" slot-scope="text, record">
  42. <a :title="text" @click="rowClick(record)">{{ text }}</a>
  43. </template>
  44. <!-- 详情表单 -->
  45. <template v-slot:form="{ model }" @saved="onRecordSaved">
  46. <slot :model="model" :parentId="parentId"></slot>
  47. </template>
  48. </sd-data-table-ex>
  49. </a-card>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import { getUserInfo } from '@/common/store-mixin'
  56. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  57. import AuditArchivesListTree from './audit-archives-list-tree.vue'
  58. import components from './_import-components/audit-archives-tree-import'
  59. export default {
  60. name: 'AuditArchivesTree',
  61. metaInfo: {
  62. title: 'AuditArchivesTree',
  63. },
  64. components: {
  65. ...components,
  66. AuditArchivesListTree,
  67. },
  68. props: {
  69. // table展示列
  70. columns: {
  71. type: Array,
  72. default: () => {
  73. return []
  74. },
  75. },
  76. // 按钮信息
  77. actions: {
  78. type: Array,
  79. default: () => {
  80. return []
  81. },
  82. },
  83. // 默认选中节点
  84. selectedKeys: {
  85. type: Array,
  86. default: function() {
  87. return []
  88. },
  89. },
  90. // 是否开启搜索
  91. isSearch: {
  92. type: Boolean,
  93. default: false,
  94. },
  95. // 是否显示复选框
  96. checkable: {
  97. type: Boolean,
  98. default: false,
  99. },
  100. // 是否可以拖拽
  101. draggable: {
  102. type: Boolean,
  103. default: false,
  104. },
  105. // 是否显示连线
  106. showLine: {
  107. type: Boolean,
  108. default: false,
  109. },
  110. // 根节点名称
  111. topNodeText: {
  112. type: String,
  113. default: '案卷信息',
  114. },
  115. // 地址树接口数据源
  116. treeparams: {
  117. type: Object,
  118. default: () => {
  119. return {}
  120. },
  121. },
  122. // 默认展开节点id
  123. defaultExpandedKeys: {
  124. type: Array,
  125. default: () => {
  126. return ['0']
  127. },
  128. },
  129. // 是否显示部门选择下拉框
  130. isSelectDep: {
  131. type: Boolean,
  132. default: false,
  133. },
  134. // 部门下拉框列表值
  135. depOptions: {
  136. type: Array,
  137. default: () => {
  138. return []
  139. },
  140. },
  141. // 部门下拉框默认值
  142. defaultDepValue: {
  143. type: Array,
  144. default: () => {
  145. return []
  146. },
  147. },
  148. // table搜索key
  149. searchFields: {
  150. type: Array,
  151. default: () => {
  152. return []
  153. },
  154. },
  155. // table formID
  156. formId: {
  157. type: String,
  158. default: '',
  159. },
  160. // table pageId
  161. pageId: {
  162. type: String,
  163. default: '',
  164. },
  165. change: {
  166. type: Function,
  167. defult: null,
  168. },
  169. code: {
  170. type: String,
  171. default: '',
  172. },
  173. status: {
  174. type: String,
  175. default: null,
  176. },
  177. fromflag: {
  178. type: String,
  179. default: null,
  180. },
  181. userinfoname: {
  182. type: String,
  183. default: null,
  184. },
  185. archivesType: {
  186. type: String,
  187. default: null,
  188. },
  189. /**
  190. * 主表ID
  191. */
  192. recordId: {
  193. type: Number,
  194. default: 0,
  195. },
  196. dossierId: {
  197. type: String,
  198. default: null,
  199. },
  200. },
  201. data() {
  202. return {
  203. key: 0,
  204. treeData: [],
  205. parentId: 0,
  206. parentName: '业务类型',
  207. parentObj: [{ id: '0', name: '业务类型' }],
  208. defaultSelectedKeys: ['0'],
  209. pageSize: 10, // 分页数量
  210. startPosition: 0, // 分页起始数
  211. expressions: [
  212. {
  213. dataType: 'str',
  214. name: 'parentId',
  215. op: 'eq',
  216. stringValue: 0,
  217. },
  218. {
  219. dataType: 'str',
  220. name: 'code',
  221. op: 'eq',
  222. stringValue: null,
  223. },
  224. ],
  225. }
  226. },
  227. computed: {
  228. _computedDataUrl() {
  229. const dossierId = this.dossierId
  230. let archivesId = this.$route.query.record
  231. if (archivesId === undefined) {
  232. archivesId = this.recordId
  233. }
  234. const parentId = this.parentId
  235. if (dossierId === undefined && parentId !== 0 && archivesId !== undefined) {
  236. const dataurl =
  237. 'api/xcoa-mobile/v1/iamdossierdata/factor-list?archivesId=' +
  238. archivesId +
  239. '&parentId=' +
  240. parentId
  241. return dataurl
  242. } else if (dossierId !== undefined && parentId !== 0 && archivesId !== undefined) {
  243. const dataurl =
  244. 'api/xcoa-mobile/v1/iamdossierdata/factor-list?dossierId=' +
  245. dossierId +
  246. '&archivesId=' +
  247. archivesId +
  248. '&parentId=' +
  249. parentId
  250. return dataurl
  251. } else if (dossierId === undefined && archivesId === undefined) {
  252. const dataurl = 'api/xcoa-mobile/v1/iamdossierdata/factor-list?parentId=' + 0
  253. return dataurl
  254. } else {
  255. const dataurl = 'api/xcoa-mobile/v1/iamdossierdata/factor-list?parentId=' + parentId
  256. return dataurl
  257. }
  258. },
  259. },
  260. methods: {
  261. rowClick(record) {
  262. let archivesId = this.$route.query.record
  263. if (archivesId === undefined) {
  264. archivesId = this.recordId
  265. }
  266. const parentId = this.parentId
  267. const fileState = this.status
  268. const fromFlag = this.fromflag
  269. const archivesType = this.archivesType
  270. const userInfo = getUserInfo()
  271. const userInfoName = this.userinfoname
  272. let url = null
  273. if (
  274. archivesType === 'SYSTEM_FILE' &&
  275. record.url !== '' &&
  276. record.url != null &&
  277. record.url !== 'undefined'
  278. ) {
  279. url = record.url
  280. } else {
  281. url =
  282. '/audit-dossier-form?record=' +
  283. record.id +
  284. '&archivesId=' +
  285. archivesId +
  286. '&parentId=' +
  287. parentId +
  288. '&fileState=' +
  289. fileState +
  290. '&fromFlag=' +
  291. fromFlag +
  292. '&userInfoName=' +
  293. userInfo.name
  294. }
  295. // 新页面要打开的路由地址
  296. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  297. if (refreshFlag) {
  298. this.refresh()
  299. }
  300. })
  301. },
  302. refresh() {
  303. this.$refs.dataTable.refresh()
  304. },
  305. // 获取菜单树数据
  306. addTreeKey(data) {
  307. let result
  308. if (!data) {
  309. return
  310. }
  311. for (var i = 0; i < data.length; i++) {
  312. const item = data[i]
  313. item.key = item.id
  314. if (item.children && item.children.length > 0) {
  315. result = this.addTreeKey(item.children)
  316. } else {
  317. result = this.addTreeKey(item.children)
  318. }
  319. }
  320. return result
  321. },
  322. // 处理用户要选择的数据
  323. mapCategoryItems(items) {
  324. return (items || []).map((item) => {
  325. // 不能选择当前节点的下级节点
  326. let isLeaf = item.leaf
  327. if (item.id === String(this.$refs.dataTable.getDetailModal().getFieldValue('parentId'))) {
  328. isLeaf = true
  329. }
  330. const result = {
  331. id: item.id,
  332. name: item.text,
  333. checkable: true,
  334. isLeaf,
  335. }
  336. return result
  337. })
  338. },
  339. // 选择上级分类后给对应的域赋值
  340. fnTreePicker(value) {
  341. if (value.length > 0) {
  342. this.$refs.dataTable.getDetailModal().setFieldValue('parentId', value[0].id)
  343. this.$refs.dataTable.getDetailModal().setFieldValue('parentName', value[0].name)
  344. } else {
  345. this.$refs.dataTable.getDetailModal().setFieldValue('parentId', '')
  346. this.$refs.dataTable.getDetailModal().setFieldValue('parentName', '')
  347. }
  348. },
  349. treeSelect(selectedKeys, info) {
  350. // 切换节点,重置开始位置
  351. this.startPosition = 0
  352. this.parentId = info.node.dataRef.id // 父级id
  353. this.parentName = info.node.dataRef.text // 父级名称
  354. this.parentObj = [{ id: info.node.dataRef.id, name: info.node.dataRef.text }]
  355. this.defaultSelectedKeys = selectedKeys
  356. this.expressions.forEach((item) => {
  357. if (item.name === 'parentId') {
  358. item.stringValue = Number(info.node.dataRef.id)
  359. }
  360. })
  361. this.expressions = [...this.expressions]
  362. this.defaultSelectedKeys = selectedKeys
  363. this.parentId = Number(info.node.dataRef.id)
  364. this.unableselect = info.node.dataRef.unableselect
  365. if (this.change !== null) {
  366. this.change(this.unableselect, this.parentId)
  367. }
  368. },
  369. // 部门下拉框选择事件
  370. depChanged(value, info) {
  371. // console.log(value) // 选中的值
  372. // console.log(info.data.props) // 选中的下拉json
  373. },
  374. // 新建保存回调刷新树
  375. onRecordSaved() {
  376. this.key = this.key + 1
  377. },
  378. // 删除回调
  379. onRecordsDeleted() {
  380. this.key = this.key + 1
  381. },
  382. // 设置请求内容
  383. processReq(req) {
  384. // 获取查询内容
  385. const searchExp = req.data.expressions.find((item) => {
  386. return item.dataType === 'exps'
  387. })
  388. const searchText = searchExp?.expressionsValue[0]?.stringValue.replaceAll(/%/g, '')
  389. req.data = {
  390. configId: this.treeparams.configId,
  391. parentId: this.parentId,
  392. key: searchText ?? '',
  393. maxResults: this.pageSize,
  394. startPosition: this.startPosition,
  395. }
  396. return req
  397. },
  398. // 翻页操作
  399. onChange(pagination, filters, sorter) {
  400. this.pageSize = pagination.pageSize
  401. this.startPosition = (pagination.current - 1) * pagination.pageSize
  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. .acard {
  419. min-height: 100%;
  420. }
  421. }
  422. }
  423. }
  424. </style>