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
<template>
<div style="height: 60vh; overflow: auto;">
<!-- <div class="card-head">{{ totalTitle }}</div> -->
<div class="ant-descriptions ant-descriptions-bordered">
<div class="ant-descriptions-view">
<table>
<tbody>
<tr class="ant-descriptions-row">
<th class="ant-descriptions-item-label ant-descriptions-item-colon" style="text-align: center" v-for="(col, index) in colunms" :key="index">{{ col.title }}</th>
</tr>
<tr class="ant-descriptions-row" v-for="item in tableData" :key="item.knowledge2Id">
<td class="ant-descriptions-item-label ant-descriptions-item-colon" style="text-align: center" v-if="item.visiable" :rowspan="item.rowspan">
{{ item.knowledge1Name }}
</td>
<td class="ant-descriptions-item-content">
<a-tag v-if="!item.disabled">{{ item.knowledge2Name }}</a-tag>
<a-tag v-else :color="knowledgeColor">{{ item.knowledge2Name }}</a-tag>
</td>
<td class="ant-descriptions-item-content" style="text-align: right">
{{ item.knowledgeCount }}
<a-checkbox @change="onCBChange($event, item)" :disabled="item.disabled"></a-checkbox>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script>
import { getType } from '@/views/utils/auth'
export default {
name: "knowledgeSelect",
props: {
value: {
type: String,
default: () => {
return null
}
}
},
data() {
return {
totalTitle: '',
colunms: [
{ title: "一级学科" },
{ title: "二级学科" },
{ title: "项目个数" }
],
tableData: [],
reportYear: null,
knowledgeIds: [],
knowledgeColor: 'green',
};
},
created () {
this.getYear()
},
methods: {
getYear () {
this.$api.batch.getCurrentYearBatch({ type: 1, projType: getType(), timeType: 1 }).then(({ data = {} }) => {
if (data) {
this.reportYear = data.year
this.totalTitle = this.reportYear + '项目二级学科选择'
this.getKnowledgeSelectedList()
}
}).catch(() => { })
},
getKnowledgeSelectedList () {
this.$api.statistical.getKnowledgeSelectedList({ reportYear: this.reportYear, auditType: 1, projType: getType() }).then(({ data = {} }) => {
if (data) {
this.tableData = data
}
}).catch(() => { })
},
onCBChange (e, item) {
if (e.target.checked) {
this.knowledgeIds.push(item.knowledge2Id)
} else {
let index = this.knowledgeIds.indexOf(item.knowledge2Id)
this.knowledgeIds.splice(index, 1)
}
},
submit () {
if (this.knowledgeIds.length <= 0) {
this.$message.info('请选择二级学科!')
return
}
this.$api.projectGroupAssign.addProjectGroupKnowledge({ groupId: this.value, knowledgeIds: this.knowledgeIds, reportYear: this.reportYear }).then(({ data = {} }) => {
if (data === '数据保存成功!') {
this.$message.success(data)
this.$emit('close')
} else {
this.$message.info(data)
}
}).catch(() => {})
}
},
};
</script>
<style scoped lang="less">
.card-head {
min-height: 30px;
margin-bottom: -1px;
padding: 0 5px;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 16px;
background: transparent;
border-bottom: 1px solid #e8e8e8;
border-radius: 2px 2px 0 0;
zoom: 1;
text-align: center;
}
</style>