round-setting-weight.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <mx-table :prop-defines="scoreWeightDefines" :rows="settingModel.importWeight">
  3. <template #weight="{row}">
  4. <el-input-number :min="0" :max="1" :step="0.1" controls v-model="row.weight"
  5. style="width: 120px"></el-input-number>
  6. </template>
  7. <template #delete="{row}">
  8. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)">删除
  9. </el-button>
  10. </template>
  11. </mx-table>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'round-setting-weight',
  16. props: {
  17. settingModel: {
  18. type: Object,
  19. default: _ => ({})
  20. }
  21. },
  22. data() {
  23. return {
  24. scoreWeightDefines: {
  25. importId: {
  26. label: '编号'
  27. },
  28. scoreName: {
  29. label: '名称'
  30. },
  31. type: {
  32. label: '类型'
  33. },
  34. weight: {
  35. label: '权重',
  36. slot: 'weight'
  37. },
  38. action: {
  39. label: '操作',
  40. slot: 'delete'
  41. }
  42. }
  43. }
  44. },
  45. methods: {
  46. shouldGoNext() {
  47. const sumWeight = this.settingModel.importWeight.sum(s => s.weight)
  48. if (sumWeight != 1) {
  49. const error = '全部成绩的权重和必须为1'
  50. this.$alert(error, '错误提示', { type: 'error' })
  51. return Promise.reject(error)
  52. }
  53. return Promise.resolve(this.settingModel)
  54. },
  55. handleDelete(row) {
  56. this.$confirm(`确定删除[${row.scoreName}]`).then(_ => {
  57. this.settingModel.importWeight.remove(row)
  58. if (this.settingModel.importWeight.length == 0) {
  59. // 没有成绩之后步骤自动后退
  60. this.$emit('resetStep')
  61. }
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped>
  68. </style>