Blame view

src/components/market/EditMarketGoods.vue 2.53 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
cc7e0d1a   wuxw   开发 admin 营销功能
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
    <el-dialog
      :title="$t('marketGoods.edit')"
      :visible.sync="visible"
      width="50%"
      @close="handleClose"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="120px"
      >
        <el-form-item
          :label="$t('marketGoods.name')"
          prop="name"
        >
          <el-input
            v-model="form.name"
            :placeholder="$t('marketGoods.name')"
          />
        </el-form-item>
        <el-form-item
          :label="$t('marketGoods.remark')"
          prop="remark"
        >
          <el-input
            v-model="form.remark"
            type="textarea"
            :rows="4"
            :placeholder="$t('marketGoods.remark')"
          />
        </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.save') }}
        </el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { updateMarketGoods } from '@/api/market/marketWayApi'
  
  export default {
    name: 'EditMarketGoods',
    data() {
      return {
        visible: false,
        form: {
          goodsId: '',
          name: '',
          remark: ''
        },
        rules: {
          name: [
            { required: true, message: this.$t('marketGoods.name') + this.$t('common.required'), trigger: 'blur' },
            { max: 64, message: this.$t('marketGoods.name') + this.$t('common.maxLength64'), trigger: 'blur' }
          ],
          remark: [
            { required: true, message: this.$t('marketGoods.remark') + this.$t('common.required'), trigger: 'blur' },
            { max: 512, message: this.$t('marketGoods.remark') + this.$t('common.maxLength512'), trigger: 'blur' }
          ],
          goodsId: [
            { required: true, message: 'ID' + this.$t('common.required'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(row) {
        this.form = { ...row }
        this.visible = true
      },
      handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              await updateMarketGoods(this.form)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
84
              this.$message.success(this.$t('common.operationSuccess'))
cc7e0d1a   wuxw   开发 admin 营销功能
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
              this.$emit('success')
              this.visible = false
            } catch (error) {
              this.$message.error(error.message)
            }
          }
        })
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.form = {
          goodsId: '',
          name: '',
          remark: ''
        }
      }
    }
  }
  </script>