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
<template>
<div class="app-content">
<a-spin :spinning="loading" style="width: 100%;height: 100%;">
<a-form-model ref="form" :model="formData" :rules="rules" class="from-table">
<a-row>
<a-col :span="24">
<div class="tb-title">
<span>项目组信息</span>
</div>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">项目组名称</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="groupName">
<a-input v-model="formData.groupName" placeholder="项目组名称" style="width:400px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">年度</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="groupYear">
<base-select v-model="formData.groupYear" :type="8" :width="160" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">项目组学科</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="knowledgeId">
<para-select v-model="formData.knowledgeId" :typeId="56" />
<!-- <para-multi-select v-model="formData.knowledgeId" :typeId="57" /> -->
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">项目数量</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="projCount">
<a-input-number v-model="formData.projCount" placeholder="项目数量" style="width:400px" :min="0" :max="1000" :disabled="true" :default-value="0" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">专家数量</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="expertCount">
<a-input-number v-model="formData.expertCount" placeholder="专家数量" style="width:400px" :min="0" :max="1000" :disabled="true" :default-value="0" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">分配状态</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="assignState">
<a-tag v-if="formData.assignState===0" :color="'red'">未分配</a-tag>
<a-tag v-else v-for="data in formData.expertList" :key="data.id" :color="'orange'">{{data.personName}}</a-tag>
<!-- <a-tag v-else :color="'green'">已分配</a-tag> -->
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">备注</div>
</a-col>
<a-col :span="20">
<a-form-model-item prop="remark">
<a-textarea v-model="formData.remark" placeholder="备注" :auto-size="{ minRows: 3, maxRows: 5 }"/>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</a-spin>
</div>
</template>
<script>
import moment from 'moment'
import baseSelect from '@/views/components/common/baseSelect'
import paraSelect from '@/views/components/common/paraSelect'
import { isEmptyParams } from "@/views/utils/common"
export default {
name: "GroupEdit",
components: {
baseSelect, paraSelect
},
props: {
value: {
type: String,
default: () => {
return null
}
}
},
data() {
return {
loading: false,
formData: { id: null, groupName: null, groupYear: null, knowledgeId: null, projCount: 0, expertCount: 0, assignState: 0, remark: '' },
rules: {
groupName: [{ required: true, message: '请输入项目组名称' }],
groupYear: { required: true, message: '请输入年度' },
knowledgeId: { required: true, message: '请选择申报学科', trigger: 'change' },
projCount: [{ required: false }],
assignState: [{ required: false }],
remark: [{ required: false }],
}
}
},
created() {
if (this.value) {
this.loading = true
this.getGroupById()
} else {
this.formData.groupYear = moment().format('YYYY').toString()
}
},
methods: {
moment,
getGroupById () {
this.$api.projectGroupAssign.getGroupById({ id: this.value }).then(({ data = {} }) => {
if (data) {
data.groupYear = data.groupYear + ''
this.formData = data
}
this.loading = false
}).catch(() => { this.loading = false })
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
let pars = isEmptyParams(this.formData)
let par = { ...pars }
if (!this.value) {
this.$api.projectGroupAssign.addGroup(par).then(({ data = {} }) => {
if (data) {
this.$message.success('添加成功!')
this.$emit('close', 'edit')
}
this.loading = false
}).catch(() => { this.loading = false })
} else {
this.$api.projectGroupAssign.updateGroup(par).then(({ data = {} }) => {
if (data) {
this.$message.success('修改成功!')
this.$emit('close', 'edit')
}
this.loading = false
}).catch(() => { this.loading = false })
}
}
})
}
},
};
</script>