导出报表,时分秒可选
This commit is contained in:
@@ -1,25 +1,56 @@
|
||||
<!--报表导出-->
|
||||
<template>
|
||||
<el-dialog :close-on-click-modal="false" draggable v-model="machineVisible" :title="title" width="500">
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
draggable
|
||||
v-model="machineVisible"
|
||||
:title="title"
|
||||
width="500"
|
||||
>
|
||||
<div>
|
||||
<div class="smsConfig">
|
||||
<el-form :model="form" inline label-width="auto" class=" ml30 mt10">
|
||||
<el-form :model="form" inline label-width="auto" class="ml30 mt10">
|
||||
<el-form-item label="时间">
|
||||
<el-date-picker v-model="timeValue" size="small" type="daterange" :disabled-date="isFutureDate"
|
||||
style="width: 250px; margin-right: 10px" unlink-panels :clearable="false" range-separator="至"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss" />
|
||||
<el-date-picker
|
||||
v-model="timeValue"
|
||||
size="small"
|
||||
type="datetimerange"
|
||||
:disabled-date="isFutureDate"
|
||||
style="width: 250px; margin-right: 10px"
|
||||
unlink-panels
|
||||
:clearable="false"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="部门集合">
|
||||
<el-select v-model="form.deptList" placeholder="请选择部门集合" style="width: 250px" size="small" multiple
|
||||
collapse-tags collapse-tags-tooltip>
|
||||
<el-select
|
||||
v-model="form.deptList"
|
||||
placeholder="请选择部门集合"
|
||||
style="width: 250px"
|
||||
size="small"
|
||||
multiple
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
>
|
||||
<template #header>
|
||||
<el-checkbox v-model="checkAll" :indeterminate="indeterminate" @change="handleCheckAll">
|
||||
<el-checkbox
|
||||
v-model="checkAll"
|
||||
:indeterminate="indeterminate"
|
||||
@change="handleCheckAll"
|
||||
>
|
||||
全部
|
||||
</el-checkbox>
|
||||
</template>
|
||||
<el-option v-for="item in deptLists" :key="item.deptsIndex" :label="item.deptsname"
|
||||
:value="item.deptsIndex" />
|
||||
<el-option
|
||||
v-for="item in deptLists"
|
||||
:key="item.deptsIndex"
|
||||
:label="item.deptsname"
|
||||
:value="item.deptsIndex"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -32,7 +63,9 @@
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button :icon="Close" @click="setUp" size="small">取消</el-button>
|
||||
<el-button type="primary" :icon="Check" @click="save" size="small">确定</el-button>
|
||||
<el-button type="primary" :icon="Check" @click="save" size="small"
|
||||
>确定</el-button
|
||||
>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -41,7 +74,7 @@ import { ref, watch, inject, onMounted } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { Check, Close } from "@element-plus/icons-vue";
|
||||
import { getDept, exportForms } from "@/api/statistics/index";
|
||||
import type { CheckboxValueType } from 'element-plus'
|
||||
import type { CheckboxValueType } from "element-plus";
|
||||
import { useStore } from "vuex";
|
||||
const store = useStore();
|
||||
const machineVisible = ref(false);
|
||||
@@ -50,8 +83,8 @@ const timeValue = ref([]);
|
||||
const deptLists = ref();
|
||||
//form表单校验规则
|
||||
const emit = defineEmits(["flushed"]);
|
||||
const checkAll = ref(false)
|
||||
const indeterminate = ref(false)
|
||||
const checkAll = ref(false);
|
||||
const indeterminate = ref(false);
|
||||
const form = ref({
|
||||
searchBeginTime: "",
|
||||
searchEndTime: "",
|
||||
@@ -88,28 +121,28 @@ const init = () => {
|
||||
// }
|
||||
// })
|
||||
watch(
|
||||
() => form.value.deptList, // 使用函数返回值的形式
|
||||
() => form.value.deptList, // 使用函数返回值的形式
|
||||
(val) => {
|
||||
if (val.length == 0) {
|
||||
checkAll.value = false
|
||||
indeterminate.value = false
|
||||
checkAll.value = false;
|
||||
indeterminate.value = false;
|
||||
} else if (val.length == deptLists.value.length) {
|
||||
checkAll.value = true
|
||||
indeterminate.value = false
|
||||
checkAll.value = true;
|
||||
indeterminate.value = false;
|
||||
} else {
|
||||
indeterminate.value = true
|
||||
indeterminate.value = true;
|
||||
}
|
||||
},
|
||||
{ deep: true } // 添加深度监听选项
|
||||
)
|
||||
{ deep: true } // 添加深度监听选项
|
||||
);
|
||||
const handleCheckAll = (val: CheckboxValueType) => {
|
||||
indeterminate.value = false
|
||||
indeterminate.value = false;
|
||||
if (val) {
|
||||
form.value.deptList = deptLists.value.map((_) => _.deptsIndex)
|
||||
form.value.deptList = deptLists.value.map((_) => _.deptsIndex);
|
||||
} else {
|
||||
form.value.deptList = []
|
||||
form.value.deptList = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
const save = () => {
|
||||
if (!timeValue.value[0]) {
|
||||
ElMessage.warning("请选择时间!");
|
||||
@@ -122,9 +155,8 @@ const save = () => {
|
||||
|
||||
(form.value.deptId = store.state.deptId),
|
||||
(form.value.searchBeginTime = timeValue.value[0]),
|
||||
(form.value.searchEndTime = timeValue.value[1]
|
||||
? timeValue.value[1].split(" ")[0] + " 23:59:59"
|
||||
: "");
|
||||
(form.value.searchEndTime = timeValue.value[1]);
|
||||
|
||||
exportForms(form.value).then((res: any) => {
|
||||
let blob = new Blob([res], {
|
||||
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=UTF-8",
|
||||
|
||||
Reference in New Issue
Block a user