阅行客电子档案
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.

286 lines
8.8 KiB

  1. <template>
  2. <!-- 插件 -->
  3. <el-dialog class="insertFile-dialog" title="插件" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="insertFileVisible" :before-close="handleCloseDialog">
  4. <div class="head-search">
  5. <el-input v-model="query.search" clearable size="small" placeholder="输入题名搜索" prefix-icon="el-icon-search" style="width: 200px; margin-right: 10px;" class="filter-item" @keyup.enter.native="toQuery" @clear="toQuery" />
  6. <el-button class="filter-item filter-search" style="margin-right: 10px;" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
  7. <el-button class="filter-item filter-refresh" size="mini" type="warning" icon="el-icon-refresh-left" @click="resetQuery">重置</el-button>
  8. </div>
  9. <el-table
  10. ref="table"
  11. v-loading="tableLoading"
  12. :data="tableData"
  13. highlight-current-row
  14. style="width: 100%;"
  15. :row-key="rowKey"
  16. @select-all="selectAll"
  17. @selection-change="selectionChangeHandler"
  18. @row-click="clickRowHandler"
  19. @select="handleCurrentChange"
  20. >
  21. <el-table-column type="selection" :reserve-selection="true" width="55" align="center" />
  22. <el-table-column type="index" label="序号" width="55" align="center" />
  23. <el-table-column v-for="field in tableDisplayFields" :key="field.id" :label="field.fieldCnName" :align="field.displayformatType" :width="field.displayLength" show-overflow-tooltip>
  24. <template slot="header">
  25. <el-tooltip
  26. class="item"
  27. effect="dark"
  28. :content="field.fieldCnName"
  29. placement="top-start"
  30. >
  31. <span>{{ field.fieldCnName }}</span>
  32. </el-tooltip>
  33. </template>
  34. <template slot-scope="scope">
  35. {{ scope.row[field.fieldName] }}
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <!--分页组件-->
  40. <el-pagination
  41. v-if="tableData.length !== 0"
  42. :current-page="page.page"
  43. :total="page.total"
  44. :page-size="page.size"
  45. :pager-count="5"
  46. layout="total, prev, pager, next, sizes"
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentPage"
  49. />
  50. <div slot="footer" class="dialog-footer">
  51. <el-button type="text" @click="handleCloseDialog">取消</el-button>
  52. <el-button type="primary" @click.native="handleComfireInsertFile">确定</el-button>
  53. </div>
  54. </el-dialog>
  55. </template>
  56. <script>
  57. import { FetchInitCategoryViewTable, FetchInitCategoryView, FetchInsertSingle } from '@/api/collect/collect'
  58. export default {
  59. name: 'InsertFile',
  60. props: {
  61. selectedCategory: {
  62. type: Object,
  63. default: function() {
  64. return {}
  65. }
  66. },
  67. collectLevel: {
  68. type: Number,
  69. default: function() {
  70. return null
  71. }
  72. },
  73. selections: {
  74. type: Array,
  75. default: () => []
  76. }
  77. },
  78. inject: ['parentsData'],
  79. data() {
  80. return {
  81. query: {
  82. search: null
  83. },
  84. insertFileVisible: false,
  85. tableLoading: false,
  86. insertSelections: [],
  87. tableData: [],
  88. tableDisplayFields: [],
  89. arrySort: [],
  90. parentsId: null,
  91. categoryLevel: null,
  92. fileNoSelectionData: [],
  93. page: {
  94. page: 1,
  95. size: 10,
  96. total: 0
  97. }
  98. }
  99. },
  100. created() {
  101. },
  102. mounted() {
  103. },
  104. methods: {
  105. rowKey(row) {
  106. return row.id
  107. },
  108. setInsertBase() {
  109. if (this.collectLevel === 2) {
  110. // 该门类下的"未整理"文件列表
  111. this.parentsId = null
  112. this.categoryLevel = 3
  113. } else if (this.collectLevel === 3) {
  114. // 该门类下的"已整理"案卷列表
  115. this.categoryLevel = 2
  116. if (this.selectedCategory.arrangeType === 3) {
  117. this.parentsId = this.parentsData.parentsProjectId
  118. } else {
  119. this.parentsId = null
  120. }
  121. }
  122. },
  123. toQuery() {
  124. this.setInsertBase()
  125. this.getInsertList(this.categoryLevel, this.parentsId)
  126. },
  127. resetQuery() {
  128. this.query.search = null
  129. this.toQuery()
  130. },
  131. getInsertViewTable() {
  132. this.tableDisplayFields = []
  133. this.setInsertBase()
  134. FetchInitCategoryViewTable({ categoryId: this.selectedCategory.id, categoryLevel: this.categoryLevel }).then((res) => {
  135. if (res) {
  136. this.arrySort = []
  137. this.tableDisplayFields = res
  138. const orderSortArry = this.tableDisplayFields.filter(item => item.displayOrder).sort((a, b) => a.displayOrder - b.displayOrder)
  139. orderSortArry.forEach(item => {
  140. if (item.displayOrderBy) {
  141. this.arrySort.push(item.fieldName + ',' + item.displayOrderBy)
  142. }
  143. })
  144. this.$nextTick(() => {
  145. this.getInsertList(this.categoryLevel, this.parentsId)
  146. })
  147. }
  148. })
  149. },
  150. getInsertList(categoryLevel, parentsId) {
  151. this.tableLoading = true
  152. const params = {
  153. 'parentId': parentsId,
  154. 'categoryId': this.selectedCategory.id,
  155. 'categoryLevel': categoryLevel,
  156. 'search': this.query.search,
  157. 'page': this.page.page - 1,
  158. 'size': this.page.size,
  159. 'sort': this.arrySort
  160. }
  161. FetchInitCategoryView(params).then((res) => {
  162. if (res.code !== 500) {
  163. this.insertFileVisible = true
  164. this.tableData = res.list.content
  165. this.page.total = res.list.totalElements
  166. setTimeout(() => {
  167. this.tableLoading = false
  168. }, 500)
  169. }
  170. })
  171. },
  172. // table - 全选
  173. selectAll(val) {
  174. if (this.categoryLevel === 2) {
  175. val.splice(0, val.length)
  176. this.insertSelections = val
  177. } else {
  178. this.insertSelections = val
  179. }
  180. },
  181. clickRowHandler(row) {
  182. console.log('row', row)
  183. if (this.categoryLevel === 2) {
  184. this.$refs.table.clearSelection()
  185. this.$refs.table.toggleRowSelection(row)
  186. this.insertSelections = []
  187. this.insertSelections.push(row)
  188. } else {
  189. this.$refs.table.toggleRowSelection(row)
  190. }
  191. },
  192. selectionChangeHandler(selection) {
  193. if (this.categoryLevel === 2) {
  194. if (selection.length > 1) {
  195. selection.splice(0, selection.length - 1)
  196. this.insertSelections = selection
  197. }
  198. } else {
  199. this.insertSelections = selection
  200. }
  201. },
  202. handleCurrentChange(selection, row) {
  203. if (this.categoryLevel === 2) {
  204. this.$refs.table.clearSelection()
  205. this.$refs.table.toggleRowSelection(row)
  206. this.insertSelections = []
  207. this.insertSelections.push(row)
  208. } else {
  209. this.insertSelections = selection
  210. }
  211. },
  212. handleComfireInsertFile() {
  213. console.log('insertSelections', this.insertSelections)
  214. let archivesIds
  215. let params
  216. if (this.collectLevel === 2) {
  217. archivesIds = this.insertSelections.map(item => item.id)
  218. params = {
  219. 'categoryId': this.selectedCategory.id, // 门类id
  220. 'archivesIds': archivesIds, // 卷内级档案id
  221. 'parentsId': this.selections[0].id // 案卷级档案id
  222. }
  223. } else {
  224. if (this.selections.length === 0) {
  225. archivesIds = this.fileNoSelectionData.map(item => item.id)
  226. } else {
  227. archivesIds = this.selections.map(item => item.id)
  228. }
  229. params = {
  230. 'categoryId': this.selectedCategory.id, // 门类id
  231. 'archivesIds': archivesIds, // 卷内级档案id
  232. 'parentsId': this.insertSelections[0].id // 案卷级档案id
  233. }
  234. }
  235. console.log(params)
  236. FetchInsertSingle(params).then((res) => {
  237. if (res.code !== 500) {
  238. this.$message.success('插件成功')
  239. this.$emit('close-dialog')
  240. } else {
  241. this.$message.error('插件失败')
  242. }
  243. this.insertFileVisible = false
  244. })
  245. },
  246. handleSizeChange(size) {
  247. this.page.size = size
  248. this.page.page = 1
  249. this.toQuery()
  250. },
  251. handleCurrentPage(val) {
  252. this.page.page = val
  253. this.toQuery()
  254. },
  255. handleCloseDialog(done) {
  256. // 重置表单数据
  257. this.query.search = null
  258. this.tableDisplayFields = []
  259. this.tableData = []
  260. this.$refs.table.clearSelection()
  261. this.insertSelections = []
  262. this.insertFileVisible = false
  263. // 关闭弹框
  264. // done()
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang='scss' scoped>
  270. .insertFile-dialog{
  271. ::v-deep .el-dialog{
  272. width: 815px;
  273. .search-btn-box{
  274. .el-button{
  275. margin-left: 10px;
  276. }
  277. }
  278. }
  279. }
  280. .dialog-footer{
  281. margin-top: 20px;
  282. }
  283. </style>