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

179 lines
4.8 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. const archivesIds = this.selections.map(item => item.id)
  85. let params
  86. if (this.isJuannei) {
  87. params = {
  88. 'categoryId': this.selectedCategory.id,
  89. 'archivesIds': archivesIds,
  90. 'categoryLevel': 3
  91. }
  92. } else {
  93. params = {
  94. 'categoryId': this.selectedCategory.id,
  95. 'archivesIds': archivesIds,
  96. 'categoryLevel': this.collectLevel
  97. }
  98. }
  99. FetchDoArchivesAdjust(params).then((res) => {
  100. console.log(res)
  101. this.categoryB = res.category.id
  102. this.sortTableData = res.list
  103. this.queryCnFields = res.queryCnFields
  104. this.queryFields = res.queryFields
  105. }).catch(err => {
  106. console.log(err)
  107. })
  108. },
  109. // 行拖拽
  110. rowDrop(className, targetName) {
  111. const tbody = document.querySelector('.' + className + ' .el-table__body-wrapper tbody')
  112. const that = this
  113. Sortable.create(tbody, {
  114. draggable: '.el-table__row',
  115. onEnd({ newIndex, oldIndex }) {
  116. if (newIndex === oldIndex) return
  117. that[targetName].splice(newIndex, 0, that[targetName].splice(oldIndex, 1)[0])
  118. }
  119. })
  120. },
  121. opened() {
  122. this.rowDrop('category-sort', 'sortTableData')
  123. },
  124. handleSort() {
  125. const archivesIds = []
  126. const sequences = []
  127. this.sortTableData.map((value, index) => {
  128. archivesIds.push(value.id)
  129. sequences.push(index + 1)
  130. })
  131. const params = {
  132. 'categoryId': this.categoryB,
  133. 'archivesIds': archivesIds,
  134. 'sequences': sequences
  135. }
  136. console.log(params)
  137. FetchArchivesAdjust(params).then((res) => {
  138. if (res !== 500) {
  139. this.$message({
  140. message: '保存成功',
  141. type: 'success',
  142. duration: 2500
  143. })
  144. this.adjustmentVisible = false
  145. this.$emit('close-dialog')
  146. } else {
  147. this.$message({
  148. message: '调整顺序失败',
  149. type: 'error',
  150. duration: 2500
  151. })
  152. }
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang='scss' scoped>
  159. .adjust-dialog{
  160. ::v-deep .el-dialog{
  161. width: 815px;
  162. .el-dialog__body{
  163. padding: 16px 0 30px 0;
  164. }
  165. }
  166. }
  167. .base-info{
  168. display: flex;
  169. justify-content: space-between;
  170. color: #0c0e1e;
  171. padding: 0 20px 30px 20px;
  172. p{
  173. flex: 1;
  174. }
  175. }
  176. </style>