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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<template>
<div>
<a-form-model ref="form" :model="formData" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
<a-row :gutter="24">
<a-col :span="24">
<a-form-model-item ref="name" label="子项名称" prop="name">
<a-input v-model="formData.name" style="width:350px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="24">
<a-form-model-item ref="score" label="总分" prop="score">
<a-input-number v-model="formData.score" :min="1" :max="100" @change="onScoreNumberChange" />
</a-form-model-item>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="24">
<a-form-model-item ref="showIndex" label="排序号" prop="showIndex">
<a-input-number v-model="formData.showIndex" :min="1" :max="200" @change="onShowIndexNumberChange" />
</a-form-model-item>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="24">
<a-form-model-item ref="remark" label="备注" prop="remark">
<a-textarea v-model="formData.remark" style="width:350px;" :rows="3" />
</a-form-model-item>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="24" style="text-align: center">
<a-button type="primary" size="small" @click="submitEvaluateItem">提交</a-button>
</a-col>
</a-row>
</a-form-model>
</div>
</template>
<script>
import { isEmptyParams } from '@/views/utils/common'
export default {
name: '',
props: {
value: {
type: String,
default: () => {
return null
},
},
contentId: {
type: String,
default: () => {
return null
},
},
totalCount: {
type: Number,
default: () => {
return 1
},
},
totalScore: {
type: Number,
default: () => {
return 0
},
},
currentScore: {
type: Number,
default: () => {
return 0
},
},
editType: {
type: String,
default: () => {
return 'edit'
}
}
},
data() {
return {
formData: {
id: null,
contentId: null,
name: '',
score: 1,
showIndex: 1,
remark: ''
},
rules: {
name: { required: true, message: '请填写评审内容名称', trigger: 'blur' },
score: { required: true, message: '请填写评审内容分数', trigger: 'blur' },
showIndex: { required: true, message: '请填写评审内容排序号', trigger: 'blur' },
remark: { required: false },
}
}
},
created() {
if (this.editType === 'add') {
this.formData = {
id: null,
contentId: null,
name: '',
score: 1,
valueType: 1,
showIndex: this.totalCount,
remark: ''
}
} else {
this.getEvaluationItemById()
}
},
methods: {
getEvaluationItemById() {
let par = { id: this.value }
this.$api.systemManage.getEvaluationItemById(par).then(({ data = {} }) => {
if (data) {
this.formData = data
}
}).catch(() => {})
},
onScoreNumberChange(value) {
this.formData.score = value
},
onShowIndexNumberChange(value) {
this.formData.showIndex = value
},
calculateIsAddScore() {
let ScoreT = this.currentScore + this.formData.score
if (ScoreT > this.totalScore)
return false
else
return true
},
submitEvaluateItem() {
if (!this.calculateIsAddScore()) {
this.$message.info('内容子项学分总和不能超过评审内容项学分!')
return
}
this.$refs.form.validate(valid => {
if (valid) {
if (this.editType === 'add') {
this.formData.contentId = this.contentId
let pars = isEmptyParams(this.formData)
let par = { ...pars }
this.$api.systemManage.insertEvaluationItem(par).then(({ data = {} }) => {
if (data) {
this.$message.info(data)
this.$emit('close')
}
}).catch(() => {})
} else {
let pars = isEmptyParams(this.formData)
let par = { ...pars }
this.$api.systemManage.updateEvaluationItem(par).then(({ data = {} }) => {
if (data) {
this.$message.info(data)
this.$emit('close')
}
}).catch(() => {})
}
}
})
}
}
}
</script>