1
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
  <!--
      作者 yj
  -->
  <el-dialog title="编辑等级" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
    :close-on-press-escape="false" width="600px">
    <el-form size="small" :model="form" ref="form">
      <el-form-item label="等级名称" :label-width="formLabelWidth" prop="name" :rules="[{required: true,message: ' '}]">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="等级图标" :label-width="formLabelWidth" prop="img" :rules="[{required: true,message: ' '}]">
        <el-row>
          <el-button icon="el-icon-picture-outline" @click="openUpload('img')">选择图片</el-button>
          <div v-if="form.img!='' && form.img!=null" class="img">
            <img :src="form.img" width="100" height="100" />
          </div>
        </el-row>
      </el-form-item>
      <el-form-item label="等级权重" :label-width="formLabelWidth" prop="weight" :rules="[{required: true,message: '请输入等级权重'}]">
        <el-input v-model="form.weight" type="number" placeholder="请输入等级权重"></el-input>
        <div class="gray9">权重越大,等级越高</div>
      </el-form-item>
      <el-form-item label="升级条件" :label-width="formLabelWidth">
        <div class="gray9">0或不填均无法升级到该等级</div>
        <div class="d-s-c mt16">
          <span>累计好评达</span>
          <el-input v-model="form.upgrade_num" type="number" style="width: 160px; margin-left: 10px;" ></el-input>
          <span class="ml10">条</span>
        </div>
      </el-form-item>
    </el-form>
 
    <!--上传图片组件-->
    <Upload v-if="isupload" :isupload="isupload" :type="type" @returnImgs="returnImgsFunc">上传图片</Upload>
 
 
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible">取 消</el-button>
      <el-button type="primary" @click="editGrade" :disabled="submit_loading">确 定</el-button>
    </div>
  </el-dialog>
</template>
 
<script>
  import PlusApi from '@/api/plus/release.js';
  import Upload from '@/components/file/Upload';
  export default {
    components: {
      /*上传组件*/
      Upload,
    },
    data() {
      return {
        /*左边长度*/
        formLabelWidth: '120px',
        /*是否显示*/
        dialogVisible: false,
        /*是否正在提交*/
        submit_loading: false,
        /*是否上传图片*/
        isupload: false,
      };
    },
    props: ['open_edit', 'form'],
    created() {
      this.dialogVisible = this.open_edit;
    },
    methods: {
      /*修改用户*/
      editGrade() {
        let self = this;
        let params = this.form;
        self.$refs.form.validate((valid) => {
          if (valid) {
            self.submit_loading = true;
            PlusApi.editGrade(params, true)
              .then(data => {
                self.submit_loading = false;
                self.$message({
                  message: '恭喜你,等级修改成功',
                  type: 'success'
                });
                self.dialogFormVisible(true);
 
              })
              .catch(error => {
                self.submit_loading = false;
              });
 
          }
        });
      },
      /*上传*/
      openUpload(e) {
        this.type = e;
        this.isupload = true;
      },
      /*获取图片*/
      returnImgsFunc(e) {
        if (e != null && e.length > 0) {
          if (this.type == 'img') {
            this.form.img = e[0].file_path;
          }
        }
        this.isupload = false;
      },
      /*取消*/
      cancelFunc() {
        this.$router.back(-1);
      },
 
      /*关闭弹窗*/
      dialogFormVisible(e) {
        if (e) {
          this.$emit('closeDialog', {
            type: 'success',
            openDialog: false
          })
        } else {
          this.$emit('closeDialog', {
            type: 'error',
            openDialog: false
          })
        }
      }
 
    }
  };
</script>
 
<style></style>