Blame view

src/components/scm/addIntegralRuleConfig.vue 2.52 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
f52d2b06   wuxw   积分功能开发中
2
3
4
5
6
7
8
9
10
11
12
13
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    <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"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button 
          type="primary" 
          @click="handleSubmit"
        >{{ $t('common.confirm') }}</el-button>
      </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
          
          try {
            await saveIntegralRuleConfig(this.form)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
96
            this.$message.success(this.$t('common.operationSuccess'))
f52d2b06   wuxw   积分功能开发中
97
98
99
100
101
102
103
104
105
106
            this.visible = false
            this.$emit('success')
          } catch (error) {
            this.$message.error(error.message || this.$t('common.addFailed'))
          }
        })
      }
    }
  }
  </script>