levelTwoMonth.vue
9.35 KB
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<template>
<div class="from-Card">
<el-form ref="queryRef" size="small" :model="queryParams" inline label-position="top">
<el-row style="width: 100%;">
<el-col :span="4">
<el-form-item label="年度">
<el-date-picker
v-model="queryParams.year"
:clearable="false"
style="width: 100%;"
type="year"
value-format="YYYY"
@change="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="月份">
<el-select v-model="queryParams.month" style="width: 100%" @change="handleQuery">
<el-option label="一月" value="1" />
<el-option label="二月" value="2" />
<el-option label="三月" value="3" />
<el-option label="四月" value="4" />
<el-option label="五月" value="5" />
<el-option label="六月" value="6" />
<el-option label="七月" value="7" />
<el-option label="八月" value="8" />
<el-option label="九月" value="9" />
<el-option label="十月" value="10" />
<el-option label="十一月" value="11" />
<el-option label="十二月" value="12" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="是否达标">
<el-select v-model="queryParams.isStandard" clearable style="width: 100%" @change="handleQuery">
<el-option label="达标" value="1" />
<el-option label="未达标" value="0" />
</el-select>
</el-form-item>
</el-col>
<div class="po-r-btns">
<el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</div>
</el-row>
</el-form>
</div>
<div class="table">
<div style="position: relative" class="title">
<el-row>
<el-col :span="6"><span>单位年度约定数:<span class="number">{{ promiseMemberNum }}</span></span></el-col>
<el-col :span="6"><span>单位实际数量:<span class="number">{{ memberRealNum }}</span></span></el-col>
<el-col :span="6"><span>单位完成比: <span class="number">{{ memberPercent }}</span> </span></el-col>
</el-row>
<el-row>
<el-col :span="6"><span>个人年度约定数:<span class="number">{{ promisePersonNum }}</span></span></el-col>
<el-col :span="6"><span>个人实际数量:<span class="number">{{ personRealNum }}</span></span></el-col>
<el-col :span="6"><span>个人完成比: <span class="number">{{ personPercent }}</span> </span></el-col>
</el-row>
<el-button style="position: absolute;right: 25px;top: 0" type="warning" icon="Download" @click="handleData">导出
</el-button>
</div>
<br>
<el-table v-loading="loading" height="700" :data="tableList" border stripe>
<el-table-column type="index" width="55" align="center" label="序号" />
<el-table-column label="月份" align="center" prop="monthStr" />
<el-table-column label="约定数量" align="center" prop="promiseNum" />
<el-table-column label="约定金额" align="center" prop="promiseAmount" />
<el-table-column label="服务数量(人/年)" align="center" prop="realNum" />
<el-table-column label="完成比" align="center" prop="percent" />
<el-table-column label="月度是否达标" align="center" prop="isStandard" />
<el-table-column label="月度应支付金额" align="center" prop="amount" />
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<span>{{ ['/', '未确认', '已确认', '已上传', '已打款'][scope.row.status] }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="200">
<template #default="scope">
<!-- <el-button type="primary" @click="handleSure(scope.row)">确认</el-button>-->
<el-button type="primary" :disabled="handleMonths(scope.row)" @click="handleSure(scope.row)">确认</el-button>
<el-button
type="warning" :disabled="!(scope.row.status==2||scope.row.status==3)"
@click="handleUpload(scope.row)"
>上传发票
</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog
v-model="uploadData.showUpload" title="上传发票" destroy-on-close align-center append-to-body
width="500"
>
<el-form label-suffix=":" label-width="80">
<el-form-item label="发票">
<FileUpload
v-model="uploadData.fileObj" :file-type="['pdf','png','jpg','jpeg','gif']" :limit="1"
class="father"
/>
</el-form-item>
</el-form>
<template #footer>
<div style="text-align: center;">
<el-button :loading="uploadData.buttonLoading" type="primary" @click="submitFile">确 定</el-button>
<el-button @click="uploadData.showUpload=false">取 消</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { onMounted, reactive, ref, getCurrentInstance } from 'vue'
import dayjs from 'dayjs'
import { getLevelTwoMonth, getLevelOneYear2 } from '@/api/report/business'
import useUserStore from '@/store/modules/user'
import { addBusinessData, updateBusinessData } from '@/api/report/businessData'
import _ from 'lodash'
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const queryParams = reactive({
year: `${dayjs().year()}`,
month: undefined,
isStandard: undefined,
deptId: undefined
})
const form = ref({
yearPercent: '0',
yearRealNum: '0',
yearPromiseNum: '0'
})
const loading = ref(false)
const tableList = ref([])
const uploadData = reactive({
showUpload: false,
buttonLoading: false,
fileObj: undefined,
reportId: undefined
})
onMounted(() => {
queryParams.deptId = userStore.user.deptId
getTeamInfo()
})
function init() {
handleQuery()
}
function handleQuery() {
loading.value = true
getLevelTwoMonth(queryParams).then(res => {
tableList.value = res.data.list
form.value = res.data
}).catch(() => {
tableList.value = []
}).finally(() => {
loading.value = false
})
}
const promiseMemberNum = ref('')
const memberRealNum = ref('')
const memberPercent = ref('')
const promisePersonNum = ref('')
const personRealNum = ref('')
const personPercent = ref('')
function getTeamInfo() {
getLevelOneYear2({
year: new Date().getFullYear()
}).then(res => {
if (res.data && res.data.length > 0) {
promisePersonNum.value = res.data[0].promisePersonNum
personRealNum.value = res.data[0].personRealNum
personPercent.value = res.data[0].personPercent
promiseMemberNum.value = res.data[0].promiseMemberNum
memberRealNum.value = res.data[0].memberRealNum
memberPercent.value = res.data[0].memberPercent
}
}).catch((err) => {
console.log(err)
promisePersonNum.value = ''
personRealNum.value = ''
personPercent.value = ''
})
}
function resetQuery() {
// queryParams.year = `${dayjs().year()}`
queryParams.month = undefined
queryParams.isStandard = undefined
handleQuery()
}
function handleSure(row) {
proxy.$modal.confirm('是否确认?').then(() => {
addBusinessData({
deptId: row.deptId,
year: row.year,
month: row.month,
status: 2,
content: JSON.stringify(row),
type: '0'
}).then(res => {
row.reportId = res.data
row.status = 2
proxy.$modal.msgSuccess('保存成功')
})
})
}
function handleUpload(row) {
uploadData.showUpload = true
uploadData.reportId = row.reportId
uploadData.fileObj = JSON.parse(row.file)
uploadData.buttonLoading = false
}
function submitFile() {
if (!uploadData.fileObj || uploadData.fileObj.length == 0) {
proxy.$modal.msgError('请选择发票')
return
}
uploadData.buttonLoading = true
const row = _.find(tableList.value, (t) => t.reportId == uploadData.reportId)
updateBusinessData({
id: uploadData.reportId,
file: JSON.stringify(uploadData.fileObj),
status: row.status == 2 ? 3 : undefined
}).then(() => {
proxy.$modal.msgSuccess('上传成功')
uploadData.buttonLoading = false
row.file = JSON.stringify(uploadData.fileObj)
if (row.status == 2) {
row.status = 3
}
setTimeout(() => {
uploadData.showUpload = false
}, 500)
})
}
function handleData() {
proxy.download('/report/exportLevelTwoMonth', {
...queryParams
}, `省协会${queryParams.year}年度业务${new Date().getTime()}.xlsx`)
}
function handleMonths(row) {
const year1 = row.year
const month1 = row.month
const year2 = dayjs().year()
const month2 = dayjs().month()
if (row.deptId == '147' && row.monthStr == '十二月') {
return false
}
if (year1 && month1) {
if (year1 < year2) {
return row.status !== 1
} else if (year1 == year2) {
return month1 > month2 || row.status !== 1
} else {
return true
}
} else {
return true
}
}
defineExpose({
init
})
</script>
<style scoped lang="scss">
.title {
font-size: 24px;
.number {
color: orange;
margin-right: 50px;
}
}
</style>