ScoreRuleEdit.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-loading="loading"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :visible.sync="isShow"
  8. :title="this.curObj && this.curObj.id ? '编辑规则' : '添加规则'"
  9. :fullscreen="false"
  10. width="700px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
  15. <div slot="footer">
  16. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  17. <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
  18. </div>
  19. </base-form>
  20. </el-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. components: {},
  26. mixins: [...mixins],
  27. props: {
  28. isShow: Boolean,
  29. curObj: Object
  30. },
  31. inject: ['parentData'],
  32. data() {
  33. return {
  34. formData: [],
  35. loading: true,
  36. cObj: {},
  37. isShowMap: false
  38. }
  39. },
  40. watch: {
  41. isShow: function(val) {
  42. if (val) {
  43. this.getDef()
  44. }
  45. },
  46. },
  47. methods: {
  48. getDef() {
  49. const params = { ...this.curObj }
  50. this.formData = [
  51. { label: '类目', key: 'category', class: 'c-2', rules: 1 },
  52. { label: '奖励积分', key: 'reward_point', class: 'c-2', rules: 1 },
  53. { label: '奖励周期', key: 'cycle', class: 'c-2', type: 'inputFont', appendFont: '天', rules: 1 },
  54. { label: '奖励次数', key: 'reward_num', class: 'c-2', rules: 1 },
  55. { label: '类型', key: 'rule_type', class: 'c-2', rules: 1, type: 'select', options: this.$dictData.sale_rule_type },
  56. { label: '说明', key: 'remark' },
  57. ]
  58. this.setDefaultValue(params)
  59. },
  60. close(str) {
  61. if (str === 'confirm') {
  62. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  63. if (valid) {
  64. const oldform = this.$refs.ruleForm.baseForm
  65. let newForm = { ...oldform }
  66. let apiStr = 'admsaleruleadd'
  67. if (this.curObj.id) {
  68. apiStr = 'admsaleruleedit'
  69. newForm.id = this.curObj.id
  70. }
  71. this.$api.facility[apiStr](newForm).then(data => {
  72. this.$msgs(this.curObj.id ? '编辑成功' : '新增成功')
  73. this.$emit('close', newForm)
  74. })
  75. }
  76. })
  77. } else {
  78. this.$emit('close')
  79. this.setDefaultValue()
  80. }
  81. },
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. @import "../../../../styles/libEdit.scss";
  87. .lib-edit {
  88. padding-top: 0;
  89. width:100%;
  90. ::v-deep .el-form-item {
  91. margin-bottom: 10px;
  92. }
  93. ::v-deep .el-date-editor.el-input {
  94. width: 100%;
  95. }
  96. }
  97. </style>