round-settings.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div>
  3. <el-card>
  4. <mx-condition ref="condition" :query-params="queryParams" :require-fields="requireFields" @query="handleQuery"
  5. @invalid="handleInvalidQuery"></mx-condition>
  6. </el-card>
  7. <div class="mt20">
  8. <el-button type="primary" plain icon="el-icon-plus" size="mini" class="mb5" @click="handleSettingAdd">新增
  9. </el-button>
  10. <mx-table :prop-defines="tableDefines" :rows="dataList">
  11. <template #actions="{row}">
  12. <el-button type="text" @click="handleSettingEdit(row)">
  13. <i class="el-icon-edit"></i>编辑
  14. </el-button>
  15. <el-button type="text" @click="handleSettingDelete(row)">
  16. <i class="el-icon-delete"></i>删除
  17. </el-button>
  18. </template>
  19. </mx-table>
  20. <pagination v-show="total>queryParams.pageSize" :total="total" :limit.sync="queryParams.pageSize"
  21. :page.sync="queryParams.pageNum" @pagination="handleQuery"></pagination>
  22. </div>
  23. <el-drawer v-if="stepsVisible" :visible.sync="stepsVisible" :title="modifyTitle" :append-to-body="true" size="70%">
  24. <round-setting-steps :settingModel="settingModel" :default-active-step="activeStep" :year-options="yearOptions"
  25. @do-post="handleSubmit" v-loading="loading"></round-setting-steps>
  26. </el-drawer>
  27. </div>
  28. </template>
  29. <script>
  30. import * as ext from '@/utils'
  31. import selectTranslateMixin from '@/components/Cache/modules/mx-select-translate-mixin'
  32. import RoundModelConvert from './round-model-convert'
  33. import MxCondition from '@/components/MxCondition/mx-condition'
  34. import { deleteRound, getScoreImportConfig, roundList, saveScoreImportConfig } from '@/api/webApi/selection'
  35. import RoundSettingSteps from '@/views/elective/publish/components/steps/round-setting-steps'
  36. export default {
  37. mixins: [selectTranslateMixin, RoundModelConvert],
  38. name: 'round-settings',
  39. components: { RoundSettingSteps, MxCondition },
  40. data() {
  41. return {
  42. loading: false,
  43. // drawer
  44. stepsVisible: false,
  45. activeStep: 0,
  46. // query list
  47. requireFields: ['year'],
  48. queryParams: {
  49. pageNum: 1,
  50. pageSize: 20,
  51. year: ''
  52. },
  53. dataList: [],
  54. total: 0,
  55. tableDefines: {
  56. 'year': {
  57. label: '学年'
  58. },
  59. 'name': {
  60. label: '次数'
  61. },
  62. 'groupIdsName': {
  63. label: '选科组合'
  64. },
  65. 'beginTime': {
  66. label: '开始'
  67. },
  68. 'endTime': {
  69. label: '结束'
  70. },
  71. 'stateName': {
  72. label: '状态'
  73. },
  74. 'actions': {
  75. label: '操作',
  76. slot: 'actions'
  77. }
  78. },
  79. // modify
  80. settingModel: {},
  81. settingDialogVisible: false
  82. }
  83. },
  84. computed: {
  85. modifyTitle() {
  86. const type = this.settingModel.roundId ? '编辑' : '新增'
  87. return type + '/' + this.settingModel.year + '/' + this.settingModel.name
  88. },
  89. yearOptions() {
  90. return this.$refs.condition.conditions.find(c => c.key === 'year').list || []
  91. }
  92. },
  93. mounted() {
  94. console.log('round-settings mounted')
  95. },
  96. methods: {
  97. handleSettingsOpen() {
  98. this.settingsVisible = !this.settingsVisible
  99. },
  100. handleInvalidQuery() {
  101. this.dataList = []
  102. },
  103. handleQuery() {
  104. roundList(this.queryParams).then(res => {
  105. this.total = res.total
  106. this.dataList = res.rows || []
  107. this.dataList.forEach(r => {
  108. this.translateStateName(r)
  109. this.translateGroupIds(r)
  110. })
  111. })
  112. },
  113. translateStateName(row) {
  114. this.$set(row, 'stateName', row.allowSelect ? '开启' : '关闭')
  115. },
  116. translateGroupReady() {
  117. this.dataList.forEach(this.translateGroupIds)
  118. },
  119. // modify
  120. handleSettingAdd() {
  121. this.settingModel = {
  122. year: this.queryParams.year,
  123. name: `第${this.dataList.length + 1}次选科`,
  124. groupModels: [],
  125. dateRange: ext.getDefaultSelectRange(),
  126. state: true,
  127. importWeight: [],
  128. roundGroups: [],
  129. enableEsign: false,
  130. enablePaperSign: false,
  131. preferenceCount: 1,
  132. rankInvisible: false,
  133. scoreInvisible: false
  134. }
  135. this.activeStep = 0
  136. this.stepsVisible = true
  137. },
  138. handleSettingEdit(row) {
  139. getScoreImportConfig(row.roundId).then(res => {
  140. const model = this.fromApiModel(res.data)
  141. this.settingModel = model
  142. this.activeStep = model.importWeight.length ? 1 : 0
  143. this.stepsVisible = true
  144. })
  145. },
  146. handleSettingDelete(row) {
  147. const fullName = row.year + row.name
  148. this.$confirm('确认删除' + fullName + '?').then(() => {
  149. deleteRound(row.roundId).then(res => {
  150. this.msgSuccess('删除成功')
  151. this.queryParams.pageNum = 1
  152. this.handleQuery()
  153. })
  154. })
  155. },
  156. handleSubmit(commit) {
  157. this.loading = true
  158. const round = this.toApiModel(commit)
  159. // 提交
  160. saveScoreImportConfig(round).then(res => {
  161. this.stepsVisible = false
  162. this.msgSuccess('保存成功')
  163. this.handleQuery()
  164. }).finally(() => this.loading = false)
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. </style>
  171. <style scoped>
  172. </style>