<template>
|
<el-dialog
|
:close-on-click-modal="false"
|
:visible.sync="isopen"
|
width="28rem"
|
class="add-event-dialog"
|
@close="shutdown"
|
>
|
<div slot="title" class="tac drawerHeader">{{ title }}</div>
|
<div class="dialog-content-box">
|
<el-form ref="form" :rules="rules" :model="form" label-width="110px">
|
<el-form-item label="上传考勤:" prop="doc" class="down-box">
|
<uploadImportBtn
|
ref="mychild"
|
buttonText="上传"
|
name="processModel"
|
:isFileListShow="true"
|
:continueImport="continueImport"
|
:importObj="importObj"
|
@fileSuccess="fileSuccess"
|
@remove="remove"
|
>
|
</uploadImportBtn>
|
<span class="margin_left_20px cursor_pinter down-btn color_blue" @click="downHttpClick"><i class="el-icon-download"></i>下载模板</span>
|
</el-form-item>
|
</el-form>
|
</div>
|
<div slot="footer" class="dialog-footer tac">
|
<el-button @click="shutdown">取消</el-button>
|
|
<el-button @click="onSubmit" type="primary">确定</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { attendanceInput,getTemplate } from "@/api/employeeSalary/attendanceManage.js"
|
import uploadImportBtn from "@/components/common/uploadImportBtn";
|
export default {
|
components: {
|
uploadImportBtn,
|
},
|
props: ["title"],
|
data() {
|
return {
|
form: {
|
doc: null,
|
doc2: null,
|
},
|
rules: {
|
doc: [{ required: true, message: "请上传", trigger: "change" }],
|
},
|
isopen: false,
|
// 上传
|
continueImport: false, //是否继续上传
|
continueImport2: false, //是否继续上传
|
|
importObj: {
|
suffix: "xlsx",
|
size: 20,
|
num: 1,
|
},
|
};
|
},
|
mounted() {},
|
watch: {
|
isopen(val) {
|
if (val) {
|
this.form.doc = null;
|
this.form.doc2 = null;
|
this.$nextTick(()=>{
|
this.$refs.form.resetFields();
|
})
|
}
|
},
|
},
|
methods: {
|
//导入成功
|
fileSuccess(fd, file) {
|
this.continueImport = true;
|
this.form.doc = file;
|
},
|
shutdown() {
|
this.isopen = false;
|
this.$refs.mychild.remove(0);
|
this.$emit("fileSuccess", this.form);
|
},
|
remove(){
|
this.continueImport = false;
|
this.form.doc = null;
|
this.$refs.mychild.remove(0);
|
},
|
downHttpClick(){
|
getTemplate({category:13}).then(res=>{
|
if (res.code === 200) {
|
const fileUrl = res.data[0].fileUrl;
|
const downloadLink = document.createElement("a");
|
downloadLink.href = fileUrl;
|
downloadLink.download = "模板.excel";
|
document.body.appendChild(downloadLink);
|
downloadLink.click();
|
this.$message.success("模板下载成功!");
|
}
|
});
|
},
|
onSubmit() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
let fd = new FormData(); // 创建form对象
|
fd.append("file", this.form.doc.raw); // file对象是 beforeUpload参数
|
// fd.append('file2', this.form.doc2.raw) // file对象是 beforeUpload参数
|
|
attendanceInput(fd).then((res) => {
|
if (res.code == 200) {
|
this.$message.success("上传成功!");
|
this.shutdown();
|
}
|
});
|
} else {
|
this.$message.error("请上传!");
|
}
|
});
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
/* .title {
|
font-size: 13px;
|
line-height: 18px;
|
color: #2a78fb;
|
} */
|
.dialog-content-box {
|
height: 17rem;
|
min-height: 110px;
|
overflow: auto;
|
}
|
::v-deep .el-select-dropdown__wrap {
|
overflow: auto !important;
|
}
|
|
::v-deep .el-select-dropdown {
|
position: absolute !important;
|
top: 36px !important;
|
left: 0px !important;
|
}
|
.down-box{
|
position:relative;
|
.down-btn{
|
position:absolute;
|
left:90px;
|
top:0;
|
}
|
}
|
</style>
|