zhouwx
2024-06-11 bb677211fa6a0916869eb264ba047aa88a8181be
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <el-dialog
    :title="dialogStatus==='add'?'新增':'编辑'"
    :visible.sync="dialogVisible"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    width="500px"
    :before-close="handleClose"
  >
    <el-form ref="dataForm" :model="dataForm"  :rules="rules" label-position="right" label-width="150px" style="padding-right: 50px" element-loading-text="保存中...">
      <el-form-item label="平台名称:" prop="name">
        <el-input v-model.trim="dataForm.name"/>
      </el-form-item>
      <el-form-item label="AccessKey:" prop="AccessKey">
        <el-input  v-model.trim="dataForm.AccessKey"/>
      </el-form-item>
      <el-form-item label="SecretKey:" prop="SecretKey">
        <el-input v-model.trim="dataForm.SecretKey"/>
      </el-form-item>
      <el-form-item label="联系人:" prop="people">
        <el-input v-model.trim="dataForm.people"/>
      </el-form-item>
      <el-form-item label="联系电话:" prop="phone">
        <el-input v-model.trim="dataForm.phone" :maxlength="11" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>
 
<script >
export default {
  name: 'addUser',
  components: {
  },
  data() {
    return {
      dialogVisible: false,
      dialogStatus: '',
      rules: {
        name: [{ required: true, message: '请输入平台名称', trigger: 'blur' }],
        phone: [
          {
            pattern: /^1[0-9]{10}$/,
            message: '手机号格式不正确',
            trigger: 'blur'
          }
        ],
      },
      dataForm: {}
    }
  },
  created() {
    this.getArea();
    this.getTrain();
  },
  methods: {
    openDialog (type, data) {
      this.resetDataForm();
      this.dialogVisible = true;
      this.dialogStatus = type;
      if(this.dialogStatus == 'edit') {
        this.dataForm = data;
        this.dataForm.institutionId = data.institutionId.toString()
      }
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    async getTrain() {
      const param = {
        isCm: 1
      }
      const res = await getTrainList(param);
      if(res.code == 200) {
        this.trainList = res.data;
      }else{
        this.$message({
          type:'warning',
          message: res.msg
        })
      }
    },
    async getArea() {
      const res = await getAreaList();
      if(res.code == 200) {
        this.areaList = res.data;
      }else{
        this.$message({
          type:'warning',
          message: res.msg
        })
      }
    },
    handleClose() {
      this.dialogVisible = false;
      this.$emit("getList");
    },
    onSubmit() {
      this.$refs["dataForm"].validate( async valid => {
        if (valid) {
          if(this.dialogStatus == 'add'){
            // this.dataForm.isCm = 1;
            // console.log("this.dataForm",this.dataForm)
            // const res = await addExam(this.dataForm);
            // if(res.code == 200) {
              this.$emit("getList");
              this.dialogVisible = false;
            //   this.$message({
            //     type:'success',
            //     message: '新增成功'
            //   })
            // }else{
            //   this.$message({
            //     type:'warning',
            //     message: res.msg
            //   })
            // }
          }else {
            // this.dataForm.isCm = 1;
            // console.log("this.dataForm",this.dataForm)
            // const res = await updateExam(this.dataForm);
            // if(res.code == 200) {
              this.$emit("getList");
              this.dialogVisible = false;
            //   this.$message({
            //     type:'success',
            //     message: '编辑成功'
            //   })
            // }else{
            //   this.$message({
            //     type:'warning',
            //     message: res.msg
            //   })
            // }
          }
        }
      })
 
    },
    resetDataForm() {
      this.dataForm = {
      }
    },
  }
}
 
</script>
<style scoped>
 
</style>