feat:增加面授课成绩导入

This commit is contained in:
lixg
2023-01-04 15:04:21 +08:00
parent 9b3f9e47ee
commit 78119e4093
5 changed files with 130 additions and 22 deletions

View File

@@ -25,11 +25,26 @@
<div class="upload">
<div class="text">上传</div>
<div class="right">
<div class="load">
<div style="height: 176px; margin-bottom: 20px">
<a-upload-dragger
v-model:fileList="fileList"
:action="BATCH_IMPORT_SCORE + '?offcoursePlanId=' + id"
name="file"
:multiple="true"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<inbox-outlined></inbox-outlined>
</p>
<p class="ant-upload-text">点击或将文件拖拽到此处上传</p>
<p class="ant-upload-hint">支持扩展名.xls/.xlsx</p>
</a-upload-dragger>
</div>
<!-- <div class="load">
<div class="cloud"></div>
<div class="tip">点击或将文件拖拽到此处上传</div>
<div class="tipz">支持扩展名.xls/.xlsx</div>
</div>
</div> -->
<div class="loadstate">
<div class="loadborder">
<div class="content">
@@ -93,14 +108,17 @@
</div>
</div>
<div class="btnn">
<button class="btn1">取消</button>
<button class="btn2">确定</button>
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="closeDrawer">确定</button>
</div>
</div>
</a-drawer>
</template>
<script>
import { reactive, toRefs } from "vue";
import { message } from "ant-design-vue";
import * as api from "../../api/index1";
import { BATCH_IMPORT_SCORE } from "@/api/config";
export default {
name: "EScore",
props: {
@@ -108,9 +126,20 @@ export default {
type: Boolean,
default: false,
},
//type=3:面授课
type: {
type: String,
default: null,
},
id: {
type: Number,
default: null,
},
},
setup(props, ctx) {
const state = reactive({});
const state = reactive({
fileType: ["xls", "xlsx"],
});
const closeDrawer = () => {
ctx.emit("update:eScorevisible", false);
};
@@ -119,10 +148,35 @@ export default {
console.log("state", bool);
};
//上传文件
const handleChange = (info) => {
console.log("info", info, props.id);
const status = info.file.status;
if (status !== "uploading") {
console.log(info.file, info.fileList);
}
if (status === "done") {
const formData = new FormData();
formData.append("uploadFile", info.file);
// formData.append("offcoursePlanId", props.id);
console.log(info.file);
api.batchImportScore(props.id, formData).then((res) => {
// if (res.data.code === 200) {
// console.log('上传成功')
// }
console.log("上传成绩", res);
});
message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === "error") {
message.error(`${info.file.name} file upload failed.`);
}
};
return {
...toRefs(state),
afterVisibleChange,
closeDrawer,
handleChange,
BATCH_IMPORT_SCORE,
};
},
};