Commit 707e5868 authored by 赵啸非's avatar 赵啸非

前端员工关怀添加了导入导出

parent 03c74975
<template> <template>
<div class="page"> <div class="page">
<LayoutTable :data="tableData" :config="tableConfig"> <LayoutTable :data="tableData" :config="tableConfig">
</LayoutTable> <el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="handleImport"
>导入</el-button>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="doExport"
:disabled="isExport"
>导出</el-button>
</LayoutTable>
<!-- 员工关怀信息导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-checkbox
v-model="upload.updateSupport"
/>是否更新已经存在的数据
<el-link type="primary" style="font-size: 14px" @click="downloadTemplate"
>下载模板</el-link
>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
提示:仅允许导入“xls”或“xlsx”格式文件!
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
<drawer-show ref="drawerform" @ok="getData" /> <drawer-show ref="drawerform" @ok="getData" />
</div> </div>
</template> </template>
<script> <script>
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import drawerShow from "./drawershow"; import drawerShow from "./drawershow";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "StaffCareList", name: "StaffCareList",
components: { components: {
drawerShow drawerShow
}, },
mixins: [table], mixins: [table],
created() { created() {
}, },
methods: { methods: {
/** 重写新增方法 */ /** 导入 */
toAdd(row) { handleImport() {
this.$refs.drawerform.add(row); this.upload.title = "员工关怀信息导入";
}, this.upload.open = true;
/** 重写编辑方法 */ },
toEdit(row) { /** 下载模板操作 */
this.$refs.drawerform.edit(row); downloadTemplate() {
}, this.isExport = true;
/** 重写查看方法 */ this.$download("/staff/care/downloadTemplate", {}, { type: "excel" })
toView(row) { .then(() => (this.isExport = false))
this.$refs.drawerform.view(row); .catch((error) => {
}, this.isExport = false;
this.$message.error(error.message);
});
},
/** 文件上传中处理 */
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
/** 文件上传成功处理 */
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.getData();
},
/** 提交上传文件 */
submitFileForm() {
this.$refs.upload.submit();
},
/** 导出Excel */
doExport() {
this.isExport = true;
this.$download("/staff/care/exportExcel", {
"idList": this.selection,
'staffName': this.$route.query['staffName'],
'careType': this.$route.query['careType'],
'sendStatus': this.$route.query['sendStatus'],
}, { type: "excel" }).then(() => this.isExport = false).catch(error => {
this.isExport = false;
this.$message.error(error.message);
});
},
/** 重写新增方法 */
toAdd(row) {
this.$refs.drawerform.add(row);
},
/** 重写编辑方法 */
toEdit(row) {
this.$refs.drawerform.edit(row);
},
/** 重写查看方法 */
toView(row) {
this.$refs.drawerform.view(row);
},
}, },
data() { data() {
return { return {
config: { // 用户导入参数
search: [ upload: {
{ // 是否显示弹出层(员工关怀信息导入)
name: "staffName", open: false,
type: "text", // 弹出层标题(员工关怀信息导入)
label: "员工姓名", title: "导入员工关怀信息数据",
fuzzy: true // 是否禁用上传
}, isUploading: false,
], // 是否更新已经存在的数据
columns: [ updateSupport: 0,
{type: "selection", width: 60}, // 上传的地址
{type: "index",label: "序号",width: 50}, url: "/attendance/staff/care/importData",
},
isExport: false,
config: {
search: [
{
name: "staffName",
type: "text",
label: "员工姓名",
fuzzy: true
},
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{label: "员工姓名", prop: "staffName"}, {label: "员工姓名", prop: "staffName"},
{label: "入职时间", prop: "entryDate", formatter: this.formatterDate}, {label: "入职时间", prop: "entryDate", formatter: this.formatterDate},
{label: "关怀类型", prop: "careType",formatter: this.formatter}, {label: "关怀类型", prop: "careType",formatter: this.formatter},
{label: "发送状态", prop: "sendStatus",formatter: this.formatter}, {label: "发送状态", prop: "sendStatus",formatter: this.formatter},
{label: "创建用户", prop: "createUserId", formatter: this.formatter}, {label: "创建用户", prop: "createUserId", formatter: this.formatter},
{ {
label: "操作", label: "操作",
width: 240, width: 240,
formatter: row => { formatter: row => {
return ( return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} /> <table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
); );
} }
} }
] ]
} }
};
}
}; };
}
};
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment