|
|
@@ -11,7 +11,14 @@
|
|
|
<el-button class="delete_button_border_no_bg" @click="ClearReviewAccount">全部清空</el-button>
|
|
|
<el-button class="button_border" @click="OpenBatchEditForm">批量编辑</el-button>
|
|
|
<el-button class="button_refresh" @click="HandleExportExcel">批量导出</el-button>
|
|
|
- <el-button class="button_refresh" @click="">批量导入</el-button>
|
|
|
+ <el-upload action="#"
|
|
|
+ :auto-upload="false"
|
|
|
+ :show-file-list="false"
|
|
|
+ @change="(file)=>HandleImportExcel(file)">
|
|
|
+ <el-button class="button_refresh"> 批量导入</el-button>
|
|
|
+ </el-upload>
|
|
|
+
|
|
|
+
|
|
|
<el-button class="button_background" @click="GoToGenerateCodePage">生成评价码</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -28,17 +35,20 @@
|
|
|
<template v-for="item in Object.values(originReviewAccount)"
|
|
|
v-slot:[`num_${item.evaluationGradeId}`]="{row}" :key="item">
|
|
|
<!-- 没有班级的行不渲染 -->
|
|
|
- <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number" v-model="row[`num_${item.evaluationGradeId}`]" placeholder="请输入"/>
|
|
|
+ <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number"
|
|
|
+ v-model="row[`num_${item.evaluationGradeId}`]" placeholder="请输入" @change="(val)=>HandleNumberChange(val,item.evaluationGradeId,row,'total')" />
|
|
|
</template>
|
|
|
|
|
|
<template v-for="item in Object.values(originReviewAccount)"
|
|
|
v-slot:[`male_${item.evaluationGradeId}`]="{row}" :key="item">
|
|
|
- <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number" v-model="row[`male_${item.evaluationGradeId}`]" placeholder="请输入"/>
|
|
|
+ <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number"
|
|
|
+ v-model="row[`male_${item.evaluationGradeId}`]" placeholder="请输入" @change="(val)=>HandleNumberChange(val,item.evaluationGradeId,row,'boy')" />
|
|
|
</template>
|
|
|
|
|
|
<template v-for="item in Object.values(originReviewAccount)"
|
|
|
v-slot:[`female_${item.evaluationGradeId}`]="{row}" :key="item">
|
|
|
- <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number" v-model="row[`female_${item.evaluationGradeId}`]" placeholder="请输入"/>
|
|
|
+ <el-input v-if="row[`class_${item.evaluationGradeId}`]?.classId" type="number"
|
|
|
+ v-model="row[`female_${item.evaluationGradeId}`]" placeholder="请输入" @change="(val)=>HandleNumberChange(val,item.evaluationGradeId,row,'girl')" />
|
|
|
</template>
|
|
|
</Table>
|
|
|
|
|
|
@@ -96,6 +106,7 @@
|
|
|
import { onMounted,ref,watch } from 'vue';
|
|
|
import { useStore } from 'vuex';
|
|
|
import { useRoute,useRouter } from 'vue-router';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
|
|
|
import ExcelJS from 'exceljs';
|
|
|
|
|
|
@@ -103,7 +114,8 @@ import Table from '@/baseComponents/Table.vue';
|
|
|
import FormDialog from '@/baseComponents/FormDialog.vue';
|
|
|
|
|
|
import {
|
|
|
- getReviewAccountListApi,
|
|
|
+ getReviewAccountListApi,importReviewAccountDataApi,
|
|
|
+ updateReviewAccountDataApi,
|
|
|
} from '@/api/reviewAccountComponent'
|
|
|
|
|
|
const route = useRoute()
|
|
|
@@ -263,6 +275,7 @@ const batchEditGradeList = ref<batchEditGradeItm[]>([]);
|
|
|
// 关闭批量编辑弹窗
|
|
|
const CloseBatchEditForm = ()=>{
|
|
|
batchEditFormVisible.value = false
|
|
|
+ batchEditFormLoading.value = false
|
|
|
batchAccountNum.value = null
|
|
|
batchMaleNum.value = null
|
|
|
batchFemaleNum.value = null
|
|
|
@@ -281,7 +294,9 @@ const OpenBatchEditForm = ()=>{
|
|
|
}
|
|
|
|
|
|
// 保存批量编辑配置 ——
|
|
|
-const SaveBatchEditForm = (params:any)=>{
|
|
|
+const SaveBatchEditForm = async (params:any)=>{
|
|
|
+ batchEditFormLoading.value = true
|
|
|
+
|
|
|
const batchData = batchEditGradeList.value.map(item=>{
|
|
|
return {
|
|
|
gradeName: item.evaluationGradeName,
|
|
|
@@ -290,36 +305,43 @@ const SaveBatchEditForm = (params:any)=>{
|
|
|
}
|
|
|
})?.filter(item=>{return item.selectedClassList?.length > 0})
|
|
|
|
|
|
- // 选中的值赋值
|
|
|
- batchEditGradeList.value.map(grade=>{
|
|
|
- let gradeId = grade.evaluationGradeId
|
|
|
- let classDataList = grade.classData
|
|
|
- let changeAim = batchData.find(itm=>itm.gradeId == gradeId)
|
|
|
- // 有需要批量修改的 年级
|
|
|
- if(changeAim){
|
|
|
- classDataList.map((classItm,index)=>{
|
|
|
- // 有需要批量修改的 班级
|
|
|
- if(changeAim.selectedClassList.find(classId=>classId == classItm.id )){
|
|
|
- if(typeof tableData.value[index] !== 'object'){
|
|
|
- tableData.value[index] = {}
|
|
|
- }
|
|
|
- // 当前年级下 某个班级 的行赋值
|
|
|
- if(store.state.evaluationManageStepData.isGenerateAccountByGender){
|
|
|
- // 按男女生成
|
|
|
- tableData.value[index][`num_${gradeId}`] = Number(batchMaleNum.value) + Number(batchFemaleNum.value)
|
|
|
- tableData.value[index][`male_${gradeId}`] = batchMaleNum.value
|
|
|
- tableData.value[index][`female_${gradeId}`] = batchFemaleNum.value
|
|
|
- }else{
|
|
|
- // 按总人数生成
|
|
|
- tableData.value[index][`num_${gradeId}`] = batchAccountNum.value
|
|
|
- tableData.value[index][`male_${gradeId}`] = Math.floor(batchAccountNum.value / 2)
|
|
|
- tableData.value[index][`female_${gradeId}`] = Math.ceil(batchAccountNum.value / 2)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ let ids = batchData.map(item=>{
|
|
|
+ return item.selectedClassList
|
|
|
+ }).flat() || []
|
|
|
+
|
|
|
+ let transferData = {}
|
|
|
+ if(store.state.evaluationManageStepData.isGenerateAccountByGender){
|
|
|
+ transferData = {
|
|
|
+ ids,
|
|
|
+ count: 0,
|
|
|
+ boyCount:batchMaleNum.value,
|
|
|
+ girlCount: batchFemaleNum.value,
|
|
|
+ gender:1
|
|
|
}
|
|
|
- })
|
|
|
- CloseBatchEditForm()
|
|
|
+ }else{
|
|
|
+ transferData = {
|
|
|
+ ids,
|
|
|
+ count: batchAccountNum.value,
|
|
|
+ boyCount: 0,
|
|
|
+ girlCount: 0,
|
|
|
+ gender:0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let res = undefined
|
|
|
+ try{
|
|
|
+ res = await updateReviewAccountDataApi(transferData)
|
|
|
+ }catch{}
|
|
|
+
|
|
|
+ if(res?.code == 200){
|
|
|
+ CloseBatchEditForm()
|
|
|
+ // 重新查询
|
|
|
+ ElMessage.success(res.msg)
|
|
|
+ await GetReviewAccountList()
|
|
|
+ // 更新全局配置
|
|
|
+ await store.dispatch('updateEvaluationManageStepData',route.query.id)
|
|
|
+ }else{
|
|
|
+ batchEditFormLoading.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 年级全选/全不选
|
|
|
@@ -494,6 +516,83 @@ const HandleExportExcel = async () => {
|
|
|
URL.revokeObjectURL(url);
|
|
|
};
|
|
|
|
|
|
+// 批量导入
|
|
|
+const HandleImportExcel = async(file)=>{
|
|
|
+ console.log('file----------',file)
|
|
|
+ if(file.name.split('.').pop() !== 'xlsx' && file.name.split('.').pop() !== 'xls' ){
|
|
|
+ ElMessage.warning('请上传以.xlsx、.xls结尾的文件')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const fomData = new FormData()
|
|
|
+ fomData.append('file',file.raw)
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ evaluationId:route.query.id,
|
|
|
+ gender:store.state.evaluationManageStepData.isGenerateAccountByGender ? 1 : 0 , // 0-不按男女,1-按男女
|
|
|
+ }
|
|
|
+
|
|
|
+ let res = await importReviewAccountDataApi(fomData,params)
|
|
|
+ if(res?.code == 200){
|
|
|
+ // 查询查询数据
|
|
|
+ ElMessage.success(res.msg)
|
|
|
+ await GetReviewAccountList()
|
|
|
+ // 更新全局配置
|
|
|
+ await store.dispatch('updateEvaluationManageStepData',route.query.id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 6. 单次修改输入框操作
|
|
|
+const HandleNumberChange = async (val,gradeId,row,type)=>{
|
|
|
+ let boyCount = 0
|
|
|
+ let girlCount = 0
|
|
|
+ let totalCount = 0
|
|
|
+
|
|
|
+ let ids = [row[`class_${gradeId}`].classId]
|
|
|
+
|
|
|
+ switch(type){
|
|
|
+ case 'total':{
|
|
|
+ totalCount = val
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'girl':{
|
|
|
+ girlCount = val
|
|
|
+ boyCount = row[`male_${gradeId}`]
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'boy':{
|
|
|
+ boyCount = val
|
|
|
+ girlCount = row[`female_${gradeId}`]
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let transferData = {}
|
|
|
+ if(store.state.evaluationManageStepData.isGenerateAccountByGender){
|
|
|
+ transferData = {
|
|
|
+ ids,
|
|
|
+ count: 0,
|
|
|
+ boyCount:boyCount,
|
|
|
+ girlCount:girlCount,
|
|
|
+ gender:1
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ transferData = {
|
|
|
+ ids,
|
|
|
+ count:totalCount,
|
|
|
+ boyCount: 0,
|
|
|
+ girlCount: 0,
|
|
|
+ gender:0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let res = undefined
|
|
|
+ try{
|
|
|
+ res = await updateReviewAccountDataApi(transferData)
|
|
|
+ }catch{}
|
|
|
+ if(res?.code == 200){
|
|
|
+ ElMessage.success(res?.msg)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
onMounted(async ()=>{
|
|
|
let reviewAccountMsg = sessionStorage.getItem('reviewAccountMsg')
|