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

180 lines
4.9 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
  1. <template>
  2. <!-- 卷内顺序调整 -->
  3. <div>
  4. <el-dialog class="adjust-dialog" :title="titleAdjustment" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="adjustmentVisible" @opened="opened">
  5. <div class="setting-dialog">
  6. <div v-if="isJuannei" class="base-info">
  7. <p>案卷档号{{ selections.length !== 0 && selections[0].archive_no }}</p>
  8. <p>案卷题名{{ selections.length !== 0 && selections[0].maintitle }}</p>
  9. </div>
  10. <i class="drag-tip">提示请通过拖动鼠标来调整当前顺序</i>
  11. <el-table
  12. ref="table"
  13. :data="sortTableData"
  14. :tree-props="{children: 'childrens'}"
  15. class="category-sort"
  16. style="width: 100%;"
  17. row-key="id"
  18. >
  19. <el-table-column type="index" label="序号" width="55" align="center" />
  20. <template v-for="(field, index) in queryFields">
  21. <el-table-column
  22. v-if="field !== 'id'"
  23. :key="index"
  24. :prop="field"
  25. :label="queryCnFields[index]"
  26. :width="field === 'archive_no' ? '250px' : '120px'"
  27. />
  28. </template>
  29. </el-table>
  30. <div slot="footer" class="dialog-footer">
  31. <el-button @click="adjustmentVisible = false">取消</el-button>
  32. <el-button type="primary" @click.native="handleSort">确定</el-button>
  33. </div>
  34. </div>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script>
  39. import { FetchDoArchivesAdjust, FetchArchivesAdjust } from '@/api/collect/collect'
  40. import Sortable from 'sortablejs'
  41. export default {
  42. name: 'FileSeqAdjustment',
  43. components: { },
  44. mixins: [],
  45. props: {
  46. selectedCategory: {
  47. type: Object,
  48. default: function() {
  49. return {}
  50. }
  51. },
  52. collectLevel: {
  53. type: Number,
  54. default: function() {
  55. return null
  56. }
  57. },
  58. selections: {
  59. type: Array,
  60. default: () => []
  61. }
  62. },
  63. data() {
  64. return {
  65. titleAdjustment: '',
  66. isJuannei: false,
  67. adjustmentVisible: false,
  68. categoryB: null,
  69. sortTableData: [],
  70. queryCnFields: [],
  71. queryFields: []
  72. }
  73. },
  74. watch: {
  75. selectedCategory: function(newValue, oldValue) {
  76. }
  77. },
  78. created() {
  79. },
  80. mounted() {
  81. },
  82. methods: {
  83. getDoArchivesAdjust() {
  84. this.loading = true
  85. this.sortTableData = []
  86. const archivesIds = this.selections.map(item => item.id)
  87. let params
  88. if (this.isJuannei) {
  89. params = {
  90. 'categoryId': this.selectedCategory.id,
  91. 'archivesIds': archivesIds,
  92. 'categoryLevel': 3
  93. }
  94. } else {
  95. params = {
  96. 'categoryId': this.selectedCategory.id,
  97. 'archivesIds': archivesIds,
  98. 'categoryLevel': this.collectLevel
  99. }
  100. }
  101. FetchDoArchivesAdjust(params).then((res) => {
  102. this.categoryB = res.category.id
  103. this.sortTableData = res.list
  104. this.queryCnFields = res.queryCnFields
  105. this.queryFields = res.queryFields
  106. this.adjustmentVisible = true
  107. }).catch(err => {
  108. console.log(err)
  109. })
  110. },
  111. // 行拖拽
  112. rowDrop(className, targetName) {
  113. const tbody = document.querySelector('.' + className + ' .el-table__body-wrapper tbody')
  114. const that = this
  115. Sortable.create(tbody, {
  116. draggable: '.el-table__row',
  117. onEnd({ newIndex, oldIndex }) {
  118. if (newIndex === oldIndex) return
  119. that[targetName].splice(newIndex, 0, that[targetName].splice(oldIndex, 1)[0])
  120. }
  121. })
  122. },
  123. opened() {
  124. this.rowDrop('category-sort', 'sortTableData')
  125. },
  126. handleSort() {
  127. const archivesIds = []
  128. const sequences = []
  129. this.sortTableData.map((value, index) => {
  130. archivesIds.push(value.id)
  131. sequences.push(index + 1)
  132. })
  133. const params = {
  134. 'categoryId': this.categoryB,
  135. 'archivesIds': archivesIds,
  136. 'sequences': sequences
  137. }
  138. FetchArchivesAdjust(params).then((res) => {
  139. if (res !== 500) {
  140. this.$message({
  141. message: '保存成功',
  142. type: 'success',
  143. duration: 2500
  144. })
  145. this.adjustmentVisible = false
  146. this.$emit('close-dialog')
  147. } else {
  148. this.$message({
  149. message: '调整顺序失败',
  150. type: 'error',
  151. duration: 2500
  152. })
  153. }
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang='scss' scoped>
  160. .adjust-dialog{
  161. ::v-deep .el-dialog{
  162. width: 815px;
  163. .el-dialog__body{
  164. padding: 16px 0 30px 0;
  165. }
  166. }
  167. }
  168. .base-info{
  169. display: flex;
  170. justify-content: space-between;
  171. color: #0c0e1e;
  172. padding: 0 20px 30px 20px;
  173. p{
  174. flex: 1;
  175. }
  176. }
  177. </style>