Blame view

merchant-web-master/src/views/customerService/setting/index.vue 1.94 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="servicePage">
      <div class="configuration">
        <el-form
          ref="ruleForm"
          :model="ruleForm"
          :rules="rules"
          label-width="180px"
          class="demo-ruleForm"
        >
          <el-form-item label="服务ID" prop="appId">
            <el-input v-model="ruleForm.appId" />
          </el-form-item>
          <el-form-item label="Secret" prop="secret">
            <el-input v-model="ruleForm.secret" />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              @click="submitForm('ruleForm')"
            >保存</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </template>
  
  <script>
  import { getConfig, saveOrUpdateConfig } from '@/api/server';
  export default {
    data() {
      return {
        ruleForm: {
          appId: '',
          secret: '',
        },
        rules: {
          appId: [{ required: true, message: '请输入服务ID', trigger: 'blur' }],
          secret: [{ required: true, message: '请输入Secret', trigger: 'blur' }],
        },
      };
    },
    created() {
      this.getConfig();
    },
    methods: {
      // 获取客服配置
      getConfig() {
        getConfig().then((res) => {
          console.log(res);
          this.ruleForm = res.data;
        });
      },
      // 保存
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            saveOrUpdateConfig(this.ruleForm).then((res) => {
              console.log(res);
              if (res.code === '') {
                this.$message.success('保存成功');
              }
            });
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
    },
  };
  </script>
  
  <style lang="scss" scpoed>
  .servicePage {
    padding: 5rem 20px;
    .configuration {
      width: 600px;
    }
  }
  </style>