CreditConfigDialog.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <confirm-dialog
  3. ref="creditDialog"
  4. :title="creditTitle"
  5. @confirm="onSave"
  6. >
  7. <div class="c-grid-form mini u-align-self--center">
  8. <span class="c-grid-form__label">阈值</span>
  9. <el-input-number
  10. v-model="threshold"
  11. :min="1"
  12. :max="999999"
  13. step-strictly
  14. />
  15. </div>
  16. </confirm-dialog>
  17. </template>
  18. <script>
  19. import {
  20. getCreditConfig,
  21. addCreditConfig,
  22. updateCreditConfig
  23. } from '../api'
  24. export default {
  25. name: 'CreditConfigDialog',
  26. data () {
  27. return {
  28. has: false,
  29. threshold: 0
  30. }
  31. },
  32. computed: {
  33. creditTitle () {
  34. return this.has ? '更新阈值' : '新增阈值'
  35. }
  36. },
  37. methods: {
  38. show (tenant) {
  39. this.$tenant = tenant
  40. getCreditConfig(tenant).then(({ data }) => {
  41. if (data) {
  42. this.has = true
  43. this.threshold = data.threshold
  44. } else {
  45. this.has = false
  46. this.threshold = 1000
  47. }
  48. this.$refs.creditDialog.show()
  49. })
  50. },
  51. onSave (done) {
  52. (this.has ? updateCreditConfig : addCreditConfig)(this.threshold, this.$tenant).then(done)
  53. }
  54. }
  55. }
  56. </script>