阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
7.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <!-- 归档范围 -->
  3. <el-dialog class="move-form" append-to-body :modal-append-to-body="false" :close-on-click-modal="false" :before-close="handleClose" :visible="scopeVisible" title="归档范围">
  4. <span class="dialog-right-top" />
  5. <span class="dialog-left-bottom" />
  6. <div class="setting-dialog">
  7. <div class="move-main">
  8. <div class="move-left">
  9. <!--门类树状结构-->
  10. <div class="tree-scroll">
  11. <el-tree
  12. ref="tree2"
  13. v-loading="crud.loading"
  14. :data="crud.data"
  15. node-key="id"
  16. default-expand-all
  17. :props="defaultProps"
  18. :expand-on-click-node="false"
  19. @node-click="handleNodeClick2"
  20. />
  21. </div>
  22. </div>
  23. <div class="move-right">
  24. <h4>归档范围</h4>
  25. <div class="raido-main" style="height: 395px;">
  26. <el-table
  27. ref="table"
  28. v-loading="loading"
  29. lazy
  30. :show-header="false"
  31. :data="tableData"
  32. :row-key="getRowKey"
  33. :load="getSonClass"
  34. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  35. :highlight-current-row="false"
  36. height="395px"
  37. @select="handleSelect"
  38. @selection-change="selectionChangeHandler"
  39. @row-click="clickRowHandler"
  40. >
  41. <el-table-column type="selection" align="center" width="55" />
  42. <el-table-column :show-overflow-tooltip="true" prop="scopeName" label="名称">
  43. <template slot-scope="scope">
  44. {{ scope.row.scopeCode }}{{ scope.row.scopeName }}
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. </div>
  49. <div class="select-content">
  50. <span>当前选中</span>
  51. <el-tooltip v-if="selections.length !== 0" class="item" effect="dark" :content="'【'+ selections[0].scopeCode +'】'+ selections[0].scopeName" :enterable="false" placement="top">
  52. <p>{{ selections[0].scopeCode }}{{ selections[0].scopeName }}</p>
  53. </el-tooltip>
  54. </div>
  55. </div>
  56. </div>
  57. <div slot="footer" class="dialog-footer">
  58. <el-button type="text" @click="cancelScope">取消</el-button>
  59. <el-button type="primary" @click="confirmedScope">确定</el-button>
  60. </div>
  61. </div>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import { preLibraryCrud } from '../mixins/index'
  66. import { FetchInitArchivesScope, FetchSonArchivesScope } from '@/api/system/archivesScope'
  67. import CRUD, { presenter, header, crud } from '@crud/crud'
  68. import Vue from 'vue'
  69. export default {
  70. name: 'ScopeModule',
  71. components: { },
  72. cruds() {
  73. return [
  74. CRUD({
  75. title: '归档范围', url: 'api/category/menu',
  76. crudMethod: {}, sort: []
  77. })
  78. ]
  79. },
  80. mixins: [presenter(), header(), crud(), preLibraryCrud],
  81. data() {
  82. return {
  83. scopeVisible: false,
  84. selectedCategory: null,
  85. loading: false,
  86. tableData: [],
  87. selections: [],
  88. defaultProps: { children: 'children', label: 'cnName' }
  89. }
  90. },
  91. created() {
  92. },
  93. mounted() {
  94. },
  95. methods: {
  96. getRowKey(row) {
  97. return row.id
  98. },
  99. [CRUD.HOOK.afterRefresh]() {
  100. this.crud.data = this.filterData(this.crud.data)
  101. this.$nextTick(() => {
  102. if (this.$refs.tree2) {
  103. let currentKey
  104. if (this.crud.data[0].isType === 1) {
  105. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  106. return node.isType !== 1
  107. })
  108. } else {
  109. currentKey = this.crud.data[0]
  110. }
  111. // 设置某个节点的当前选中状态
  112. this.$refs.tree2.setCurrentKey(currentKey.id)
  113. this.$nextTick(() => {
  114. // 设置某个节点的父级展开
  115. const selectedKey = this.$refs.tree2.getCurrentNode()
  116. if (this.$refs.tree2.getNode(selectedKey) && this.$refs.tree2.getNode(selectedKey).parent) {
  117. this.expandParents(this.$refs.tree2.getNode(selectedKey).parent)
  118. }
  119. // 选中节点的门类详情
  120. this.handleNodeClick2(selectedKey)
  121. })
  122. }
  123. })
  124. },
  125. // 选中门类后,设置门类详情数据
  126. handleNodeClick2(val) {
  127. console.log('handleNodeClick2', val)
  128. console.log('handleNodeClick233', val.isType)
  129. if (val) {
  130. this.selectedCategory = val
  131. if (val.pid !== '0') {
  132. Vue.set(this.selectedCategory, 'parentName', this.$refs.tree2.getNode(val.pid).data.cnName)
  133. }
  134. this.loading = true
  135. this.getInitArchivesScope(this.selectedCategory)
  136. }
  137. },
  138. getInitArchivesScope(data) {
  139. this.tableData = []
  140. let params
  141. if (data.isType !== 3) {
  142. params = {
  143. 'categoryId': data.id
  144. }
  145. } else {
  146. params = {
  147. 'categoryId': data.pid
  148. }
  149. }
  150. FetchInitArchivesScope(params).then(res => {
  151. this.tableData = res.content.map(function(item, index) {
  152. if (item.sonNum !== 0) {
  153. item.hasChildren = true
  154. item.children = null
  155. } else {
  156. item.hasChildren = false
  157. }
  158. return item
  159. })
  160. this.loading = false
  161. })
  162. },
  163. getSonClass(tree, treeNode, resolve) {
  164. setTimeout(() => {
  165. FetchSonArchivesScope({ pid: tree.id }).then(res => {
  166. const data = res.map(function(obj) {
  167. if (obj.sonNum !== 0 && obj.sonNum) {
  168. obj.hasChildren = true
  169. obj.children = null
  170. } else {
  171. obj.hasChildren = false
  172. }
  173. return obj
  174. })
  175. resolve(data)
  176. })
  177. }, 100)
  178. },
  179. handleSelect(selection) {
  180. this.$refs.table.clearSelection() // 清除当前选择
  181. if (selection.length > 0) {
  182. // 设置选中项
  183. this.$refs.table.toggleRowSelection(selection[0])
  184. }
  185. },
  186. // table - 当前选中得row
  187. clickRowHandler(row) {
  188. this.$refs.table.clearSelection()
  189. this.$refs.table.toggleRowSelection(row)
  190. },
  191. selectionChangeHandler(val) {
  192. if (val.length > 1) {
  193. this.$refs.table.clearSelection()
  194. this.$refs.table.toggleRowSelection(val.pop())
  195. } else {
  196. this.selections = val
  197. }
  198. },
  199. cancelScope() {
  200. this.scopeVisible = false
  201. this.$refs.table.clearSelection() // 清除当前选择
  202. this.selections = []
  203. },
  204. confirmedScope() {
  205. this.scopeVisible = false
  206. console.log('confirmedScope', this.selectedCategory)
  207. this.$emit('getScope', this.selections, this.selectedCategory)
  208. },
  209. handleClose(done) {
  210. this.scopeVisible = false
  211. this.$refs.table.clearSelection() // 清除当前选择
  212. this.selections = []
  213. done()
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. @import "~@/assets/styles/prearchive-library.scss";
  220. </style>