audit-dossier-tree.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div :class="$style.wrapHeight">
  3. <div :class="$style.rowHeight">
  4. <AuditDossierListTree
  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. ></AuditDossierListTree>
  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. <!-- 详情表单 -->
  42. <template v-slot:form="{ model }" @saved="onRecordSaved">
  43. <slot :model="model" :parentId="parentId"></slot>
  44. </template>
  45. </sd-data-table-ex>
  46. </a-card>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import AuditDossierListTree from './audit-dossier-list-tree.vue'
  53. import components from './_import-components/audit-dossier-tree-import'
  54. export default {
  55. name: 'AuditDossierTree',
  56. metaInfo: {
  57. title: 'AuditDossierTree',
  58. },
  59. components: {
  60. ...components,
  61. AuditDossierListTree,
  62. },
  63. props: {
  64. // table展示列
  65. columns: {
  66. type: Array,
  67. default: () => {
  68. return []
  69. },
  70. },
  71. // 按钮信息
  72. actions: {
  73. type: Array,
  74. default: () => {
  75. return []
  76. },
  77. },
  78. // 默认选中节点
  79. selectedKeys: {
  80. type: Array,
  81. default: function() {
  82. return []
  83. },
  84. },
  85. // 是否开启搜索
  86. isSearch: {
  87. type: Boolean,
  88. default: false,
  89. },
  90. // 是否显示复选框
  91. checkable: {
  92. type: Boolean,
  93. default: false,
  94. },
  95. // 是否可以拖拽
  96. draggable: {
  97. type: Boolean,
  98. default: false,
  99. },
  100. // 是否显示连线
  101. showLine: {
  102. type: Boolean,
  103. default: false,
  104. },
  105. // 根节点名称
  106. topNodeText: {
  107. type: String,
  108. default: '案卷信息',
  109. },
  110. // 地址树接口数据源
  111. treeparams: {
  112. type: Object,
  113. default: () => {
  114. return {}
  115. },
  116. },
  117. // 默认展开节点id
  118. defaultExpandedKeys: {
  119. type: Array,
  120. default: () => {
  121. return ['0']
  122. },
  123. },
  124. // 是否显示部门选择下拉框
  125. isSelectDep: {
  126. type: Boolean,
  127. default: false,
  128. },
  129. // 部门下拉框列表值
  130. depOptions: {
  131. type: Array,
  132. default: () => {
  133. return []
  134. },
  135. },
  136. // 部门下拉框默认值
  137. defaultDepValue: {
  138. type: Array,
  139. default: () => {
  140. return []
  141. },
  142. },
  143. // table搜索key
  144. searchFields: {
  145. type: Array,
  146. default: () => {
  147. return []
  148. },
  149. },
  150. // table formID
  151. formId: {
  152. type: String,
  153. default: '',
  154. },
  155. // table pageId
  156. pageId: {
  157. type: String,
  158. default: '',
  159. },
  160. change: {
  161. type: Function,
  162. defult: null,
  163. },
  164. code: {
  165. type: String,
  166. default: '',
  167. },
  168. },
  169. data() {
  170. return {
  171. key: 0,
  172. treeData: [],
  173. parentId: 0,
  174. parentName: '业务类型',
  175. parentObj: [{ id: '0', name: '业务类型' }],
  176. defaultSelectedKeys: ['0'],
  177. pageSize: 10, // 分页数量
  178. startPosition: 0, // 分页起始数
  179. expressions: [
  180. {
  181. dataType: 'str',
  182. name: 'parentId',
  183. op: 'eq',
  184. stringValue: 0,
  185. },
  186. {
  187. dataType: 'str',
  188. name: 'code',
  189. op: 'eq',
  190. stringValue: null,
  191. },
  192. ],
  193. }
  194. },
  195. computed: {
  196. _computedDataUrl() {
  197. let archivesCode = ''
  198. this.expressions.forEach((item) => {
  199. if (item.name === 'code') {
  200. archivesCode = item.stringValue
  201. }
  202. })
  203. const parentId = this.parentId
  204. const unableselect = this.unableselect
  205. if (archivesCode !== null && parentId !== 0 && unableselect !== true) {
  206. const dataurl =
  207. 'api/xcoa-mobile/v1/iamdossierdata/factor-list?parentId=' +
  208. parentId +
  209. '&archivesCode=' +
  210. archivesCode
  211. return dataurl
  212. } else {
  213. const dataurl = 'api/xcoa-mobile/v1/iamdossierdata/factor-list?parentId=' + parentId
  214. return dataurl
  215. }
  216. },
  217. },
  218. methods: {
  219. // 获取菜单树数据
  220. addTreeKey(data) {
  221. let result
  222. if (!data) {
  223. return
  224. }
  225. for (var i = 0; i < data.length; i++) {
  226. const item = data[i]
  227. item.key = item.id
  228. if (item.children && item.children.length > 0) {
  229. result = this.addTreeKey(item.children)
  230. } else {
  231. result = this.addTreeKey(item.children)
  232. }
  233. }
  234. return result
  235. },
  236. // 处理用户要选择的数据
  237. mapCategoryItems(items) {
  238. return (items || []).map((item) => {
  239. // 不能选择当前节点的下级节点
  240. let isLeaf = item.leaf
  241. if (item.id === String(this.$refs.dataTable.getDetailModal().getFieldValue('parentId'))) {
  242. isLeaf = true
  243. }
  244. const result = {
  245. id: item.id,
  246. name: item.text,
  247. checkable: true,
  248. isLeaf,
  249. }
  250. return result
  251. })
  252. },
  253. // 选择上级分类后给对应的域赋值
  254. fnTreePicker(value) {
  255. if (value.length > 0) {
  256. this.$refs.dataTable.getDetailModal().setFieldValue('parentId', value[0].id)
  257. this.$refs.dataTable.getDetailModal().setFieldValue('parentName', value[0].name)
  258. } else {
  259. this.$refs.dataTable.getDetailModal().setFieldValue('parentId', '')
  260. this.$refs.dataTable.getDetailModal().setFieldValue('parentName', '')
  261. }
  262. },
  263. treeSelect(selectedKeys, info) {
  264. this.parentId = info.node.dataRef.id // 父级id
  265. this.parentName = info.node.dataRef.text // 父级名称
  266. this.parentObj = [{ id: info.node.dataRef.id, name: info.node.dataRef.text }]
  267. this.defaultSelectedKeys = selectedKeys
  268. this.expressions.forEach((item) => {
  269. if (item.name === 'parentId') {
  270. item.stringValue = Number(info.node.dataRef.id)
  271. }
  272. })
  273. this.expressions = [...this.expressions]
  274. this.defaultSelectedKeys = selectedKeys
  275. this.parentId = Number(info.node.dataRef.id)
  276. this.unableselect = info.node.dataRef.unableselect
  277. if (this.change !== null) {
  278. this.change(this.unableselect, this.parentId)
  279. }
  280. },
  281. // 部门下拉框选择事件
  282. depChanged(value, info) {
  283. // console.log(value) // 选中的值
  284. // console.log(info.data.props) // 选中的下拉json
  285. },
  286. // 新建保存回调刷新树
  287. onRecordSaved() {
  288. this.key = this.key + 1
  289. },
  290. // 删除回调
  291. onRecordsDeleted() {
  292. this.key = this.key + 1
  293. },
  294. // 设置请求内容
  295. processReq(req) {
  296. // 获取查询内容
  297. const searchExp = req.data.expressions.find((item) => {
  298. return item.dataType === 'exps'
  299. })
  300. const searchText = searchExp?.expressionsValue[0]?.stringValue.replaceAll(/%/g, '')
  301. req.data = {
  302. configId: this.treeparams.configId,
  303. parentId: this.parentId,
  304. key: searchText ?? '',
  305. maxResults: this.pageSize,
  306. startPosition: this.startPosition,
  307. }
  308. return req
  309. },
  310. // 翻页操作
  311. onChange(pagination, filters, sorter) {
  312. this.pageSize = pagination.pageSize
  313. this.startPosition = (pagination.current - 1) * pagination.pageSize
  314. },
  315. },
  316. }
  317. </script>
  318. <style module lang="scss">
  319. @use '@/common/design' as *;
  320. .wrap-height {
  321. height: 100%;
  322. :global(.ant-card-body) {
  323. height: 100%;
  324. }
  325. :global(.collapse_audit-dossier-list-tree_product) {
  326. :global(.fold_audit-dossier-list-tree_product) {
  327. left: 0;
  328. }
  329. }
  330. .row-height {
  331. display: flex;
  332. flex: auto;
  333. min-height: 500px;
  334. .rightcard {
  335. flex: 1;
  336. width: calc(100% - 20%);
  337. height: 100%;
  338. .acard {
  339. min-height: 100%;
  340. }
  341. :global(.ant-card-body) {
  342. width: 98%;
  343. padding: 0;
  344. }
  345. }
  346. }
  347. }
  348. </style>