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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<template>
<div class="app-content" style="height:80vh;overflow: auto;">
<a-spin :spinning="loading">
<a-form-model ref="form" :model="formData" :rules="rules" class="from-table">
<a-row>
<a-col :span="2" class="bg-gray">
<div class="required">年 度:</div>
</a-col>
<a-col :span="22">
<a-form-model-item prop="year">
<base-select v-model="formData.year" :type="4" :isAll="true" :width="150" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="2" class="bg-gray">
<div class="required">批 次:</div>
</a-col>
<a-col :span="22">
<a-form-model-item prop="batch">
<base-select v-model="formData.batch" :type="10" :isAll="true" :width="150" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="2" class="bg-gray expertGroupMembers">
<div class="required">批次名称:</div>
</a-col>
<a-col :span="22">
<a-form-model-item prop="name">
<a-input placeholder="批次名称" v-model="formData.name" :maxLength="100" style="width:300px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="2" class="bg-gray expertGroupMembers">
<div style="margin-left:10px">备 注:</div>
</a-col>
<a-col :span="22">
<a-form-model-item prop="remark">
<a-input placeholder="备注" v-model="formData.remark" :maxLength="100" style="width:300px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<div class="tb-title">
<span>专家组</span>
</div>
</a-col>
</a-row>
<a-row style="text-align: center;">
<a-col :span="2" class="bg-gray">
序号
</a-col>
<a-col :span="8" class="bg-gray required">
专家组名称
</a-col>
<a-col :span="6" class="bg-gray">
备注
</a-col>
<a-col :span="2" class="bg-gray">
专家数
</a-col>
<a-col :span="6" class="bg-gray">
操作
</a-col>
</a-row>
<a-row v-for="(expert, index) in formData.expertGroup" :key="index">
<a-col :span="2" style="text-align: center;">
{{index+1}}
</a-col>
<a-col :span="8" style="text-align: left;">
<a-form-model-item :prop="'expertGroup.' + index + '.name'" :rules="{required: true,message: '*',trigger: 'blur',}">
<a-input placeholder="名称" v-model="expert.name" :maxLength="200" style="width:80%" />
</a-form-model-item>
</a-col>
<a-col :span="6" style="text-align: left;">
<a-form-model-item :prop="'expertGroup.' + index + '.remark'">
<a-input placeholder="备注" v-model="expert.remark" :maxLength="200" style="width:80%" />
</a-form-model-item>
</a-col>
<a-col :span="2" style="text-align: center;">
{{expert.members.length}}
</a-col>
<a-col :span="6" style="text-align: center;">
<a-popconfirm title="确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="removeMembers(expert)">
<a-button type="link" size="small">删除</a-button>
</a-popconfirm>
<a-button type="link" @click="selectExpert(expert,index)">选择评审专家</a-button>
</a-col>
</a-row>
<a-row v-if="formData.expertGroup && formData.expertGroup.length < 10">
<a-col :span="24" style="text-align: center;">
<a-button type="dashed" style="width: 30%" @click="addMembers">
<a-icon type="plus" /> 添加
</a-button>
</a-col>
</a-row>
<a-row>
<a-col style="text-align: center;">
<a-button type="primary" @click="submit">提交</a-button>
</a-col>
</a-row>
</a-form-model>
<!-- @close="() => this.visibleEdit=false" -->
<a-modal v-model="visibleEdit" :title="'选择专家'" :width="'850px'" :dialog-style="{ top: '11%' }" :maskClosable="false" :footer="null" destroyOnClose>
<expert-group-members v-model="expertArray" @close="closeWindow" />
</a-modal>
</a-spin>
</div>
</template>
<script>
const Expert = { id: null, name: null, remark: null, members: [] }
import moment from 'moment'
import { isEmptyParams, filterExportExcelData, tableColumnsName } from "@/views/utils/common";
import expertGroupMembers from '@/views/expertGroup/expertGroupMembers'
import baseSelect from '@/views/components/common/baseSelect'
export default {
name: 'expertGroup',
components: {
expertGroupMembers, baseSelect
},
data () {
return {
// 表单
formData: { year: null, batch: null, name: null, remark: null, expertGroup: [{ id: null, name: null, remark: null, members: [] }] },
rules: {
year: { required: true, message: '请选择年度', trigger: 'change' },
batch: { required: true, message: '请选择批次', trigger: 'change' },
name: { required: true, message: '请填写批次名称', trigger: 'blur' },
},
// 弹窗标志
visibleView: false,
visibleEdit: false,
expertArray: [{}],
expertIndex: 0,
loading: true,
}
},
props: {
value: {
type: String,
default: () => {
return null
}
},
},
created () {
this.load()
},
methods: {
load () {
if (this.value != null) {
let pars = { id: this.value }
this.$api.expertBatch.getBatchById(pars).then(({ data = {} }) => {
if (data) {
this.formData = data
this.loading = false
}
}).catch(() => { })
} else {
var date = new Date();
let year = date.getFullYear()
this.formData.year = year
this.loading = false
}
},
batchCreate () {
this.visibleEdit = true
},
removeMembers (item) {//移除成员
if (this.formData.expertGroup.length == 1) {
alert('至少创建一个专家组')
return
}
let index = this.formData.expertGroup.indexOf(item)
if (index !== -1) {
this.formData.expertGroup.splice(index, 1)
}
},
memberToTop (item) {//成员置顶
let index = this.formData.expertGroup.indexOf(item)
if (index !== -1) {
this.formData.expertGroup.splice(index, 1)
this.formData.expertGroup.unshift({ ...item })
}
},
addMembers () {//添加成员
this.formData.expertGroup.push({ ...Expert })
},
selectExpert (obj, index) {
this.expertIndex = index
this.expertArray = obj.members
this.visibleEdit = true
},
closeWindow (value) {
if (value === 'view') {
this.visibleView = false
}
else {
this.visibleEdit = false
this.formData.expertGroup[this.expertIndex].members = this.expertArray
}
this.expertIndex = 0
this.expertArray = []
},
submit () {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
let pars = isEmptyParams(this.formData)
let par = { ...pars }
this.$api.expertBatch.save(par).then(({ data = {} }) => {
if (data) {
this.loading = false
this.$message.success('提交成功!')
this.$emit('close', 'edit')
}
else
this.loading = false
}).catch(() => {
this.loading = false
})
}
})
},
}
}
</script>