Blame view

src/components/scm/addIntegralRuleConfig.vue 2.44 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
ab44ac83   wuxw   v1.9 测试优惠相关功能 修复部...
2
3
4
5
6
7
    <el-dialog :title="$t('integralRule.addConfigTitle')" :visible.sync="visible" width="50%" @close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item :label="$t('integralRule.configName')" prop="configId">
          <el-select v-model="form.configId" :placeholder="$t('integralRule.configPlaceholder')" style="width: 100%">
            <el-option v-for="item in configOptions" :key="item.configId" :label="item.configName"
              :value="item.configId" />
f52d2b06   wuxw   积分功能开发中
8
9
10
11
12
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
ab44ac83   wuxw   v1.9 测试优惠相关功能 修复部...
13
        <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
f52d2b06   wuxw   积分功能开发中
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { saveIntegralRuleConfig, listIntegralConfig } from '@/api/scm/integralRuleApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'AddIntegralRuleConfig',
    props: {
      ruleId: {
        type: String,
        required: true
      }
    },
    data() {
      return {
        visible: false,
        form: {
          configId: '',
          ruleId: ''
        },
        rules: {
          configId: [
            { required: true, message: this.$t('integralRule.configRequired'), trigger: 'change' }
          ]
        },
        configOptions: []
      }
    },
    methods: {
      async open() {
        this.visible = true
        this.form.ruleId = this.ruleId
        await this.fetchConfigOptions()
      },
      async fetchConfigOptions() {
        try {
          const { data } = await listIntegralConfig({
            page: 1,
            row: 100,
            communityId: getCommunityId()
          })
          this.configOptions = data
        } catch (error) {
          this.$message.error(this.$t('common.fetchError'))
        }
      },
      handleClose() {
        this.$refs.form.resetFields()
      },
      async handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (!valid) return
ab44ac83   wuxw   v1.9 测试优惠相关功能 修复部...
69
  
f52d2b06   wuxw   积分功能开发中
70
          try {
ab44ac83   wuxw   v1.9 测试优惠相关功能 修复部...
71
72
73
74
75
            const {code,msg} = await saveIntegralRuleConfig(this.form)
            if(code != 0){
              this.$message.error(msg)
              return
            }
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
76
            this.$message.success(this.$t('common.operationSuccess'))
f52d2b06   wuxw   积分功能开发中
77
78
79
80
81
82
83
84
85
86
            this.visible = false
            this.$emit('success')
          } catch (error) {
            this.$message.error(error.message || this.$t('common.addFailed'))
          }
        })
      }
    }
  }
  </script>