教育训练处考试制证前端
马宇豪
2025-02-10 02bd5982028af6e791dd0857f535a41aaf74679e
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
<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    width="450px"
    :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="categoryType">
        <el-radio-group v-model="dataForm.categoryType">
          <el-radio :label="1">理论</el-radio>
          <el-radio :label="2">实操</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="科目名称:" prop="subjectName">
        <el-input v-model.trim="dataForm.subjectName"/>
      </el-form-item>
      <el-form-item label="金额:" prop="amount">
        <el-input v-model.trim.number="dataForm.amount">
          <template #append>元</template>
        </el-input>
      </el-form-item>
      <el-form-item label="业务代码:" prop="businessCode">
        <el-input v-model.trim="dataForm.businessCode"/>
      </el-form-item>
      <el-form-item label="描述:" prop="describe">
        <el-input v-model.trim="dataForm.describe"/>
      </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 >
import { addPlat, updatePlat } from '@/api/onlineEducation/plat'
import { verifySimplePhone } from '@/utils/validate'
import {addCoalPayCategory, updateCoalPayCategory} from "@/api/specialOperationsPay/coalPay";
 
export default {
  name: 'detailDialog',
  components: {
  },
  data() {
    return {
      dialogVisible: false,
      title: '',
      rules: {
        categoryType: [{ required: true, message: '请选择类别', trigger: 'blur' }],
        subjectName: [{ required: true, message: '请输入科目名称', trigger: 'blur' }],
        amount: [{ required: true, message: '请输入金额', trigger: 'blur' }]
      },
      dataForm: {},
 
    }
  },
  created() {
 
  },
  methods: {
    openDialog (type, data) {
      this.resetDataForm()
      this.dialogVisible = true
      this.title = type == 'add'?'新增':'编辑'
      if(this.title == '编辑') {
        const {id,categoryType,subjectName,amount,describe} = data
        this.dataForm = {id,categoryType,subjectName,amount,describe}
      }
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    handleClose() {
      this.dialogVisible = false;
      this.$emit("getList");
    },
    onSubmit() {
      this.$refs["dataForm"].validate( async valid => {
        if (valid) {
          if(this.title == '新增'){
            console.log("this.dataForm",this.dataForm)
            const res = await addCoalPayCategory(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 {
            const res = await updateCoalPayCategory(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>
.infoTitle{
  margin-top:-10px;
  margin-bottom:20px;
  display: flex;
  justify-content: space-around;
  font-weight: 800;
  font-size: 16px
}
 
</style>