|
@@ -0,0 +1,154 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button @click="startExport" type="primary">{{ name }}</el-button>
|
|
|
+ <el-dialog
|
|
|
+ title="请选择导出字段"
|
|
|
+ :visible.sync="chioseVisiable"
|
|
|
+ width="850px"
|
|
|
+ >
|
|
|
+ <div class="chioseWrap">
|
|
|
+ <el-checkbox
|
|
|
+ :indeterminate="isIndeterminate"
|
|
|
+ v-model="checkAll"
|
|
|
+ @change="handleCheckAllChange"
|
|
|
+ >全选</el-checkbox
|
|
|
+ >
|
|
|
+ <div style="margin: 15px 0"></div>
|
|
|
+ <el-checkbox-group v-model="checked" @change="handleCheckedChange">
|
|
|
+ <el-checkbox
|
|
|
+ v-for="city in chioseList"
|
|
|
+ :label="city"
|
|
|
+ :key="city"
|
|
|
+ style="min-width: 125px; margin-bottom: 10px"
|
|
|
+ >{{ city }}</el-checkbox
|
|
|
+ >
|
|
|
+ </el-checkbox-group>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="chioseVisiable = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="exportDataStart">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import cleanDeep from "clean-deep";
|
|
|
+import qs from "qs";
|
|
|
+import { getFields } from "./api";
|
|
|
+import { Export } from "@/utils/downLoadFile";
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ default: "导出",
|
|
|
+ },
|
|
|
+ fileName: {
|
|
|
+ type: String,
|
|
|
+ default: "导出文件.xls",
|
|
|
+ },
|
|
|
+ message: {
|
|
|
+ type: String,
|
|
|
+ default: "您确定导出",
|
|
|
+ },
|
|
|
+ errorMsg: {
|
|
|
+ type: String,
|
|
|
+ default: "参数错误",
|
|
|
+ },
|
|
|
+ flag: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ isDownList: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ ExportEnum: {
|
|
|
+ type: String,
|
|
|
+ },
|
|
|
+ exportData: {
|
|
|
+ type: Object,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ chioseVisiable: false,
|
|
|
+ isIndeterminate: true,
|
|
|
+ checkAll: false,
|
|
|
+ checked: [],
|
|
|
+ chioseList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {},
|
|
|
+ methods: {
|
|
|
+ async startExport() {
|
|
|
+ if (this.flag) {
|
|
|
+ this.$message.error(this.errorMsg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.ExportEnum) {
|
|
|
+ this.$message.error("导出参数异常");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const res = await getFields({
|
|
|
+ exportEnum: this.ExportEnum,
|
|
|
+ });
|
|
|
+ this.chioseList = res.data;
|
|
|
+ this.checked = res.data;
|
|
|
+ this.checkAll = true;
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ this.chioseVisiable = true;
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCheckedChange(value) {
|
|
|
+ let checkedCount = value.length;
|
|
|
+ this.checkAll = checkedCount === this.chioseList.length;
|
|
|
+ this.isIndeterminate =
|
|
|
+ checkedCount > 0 && checkedCount < this.chioseList.length;
|
|
|
+ },
|
|
|
+ handleCheckAllChange(val) {
|
|
|
+ this.checked = val ? this.chioseList : [];
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ },
|
|
|
+ exportDataStart() {
|
|
|
+ console.log(this.exportData);
|
|
|
+ if (this.isDownList) {
|
|
|
+ Export(
|
|
|
+ this,
|
|
|
+ {
|
|
|
+ url: "/api-web/export/managerDownload",
|
|
|
+ fileName: this.fileName,
|
|
|
+ method: "post",
|
|
|
+ params: qs.stringify(this.exportData),
|
|
|
+ },
|
|
|
+ this.message
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ Export(
|
|
|
+ this,
|
|
|
+ {
|
|
|
+ url: "/api-web/export/now",
|
|
|
+ fileName: this.fileName,
|
|
|
+ method: "post",
|
|
|
+ params: {
|
|
|
+ queryInfo: this.exportData,
|
|
|
+ exportEnum: this.ExportEnum,
|
|
|
+ headColumns: this.checked,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ this.message,
|
|
|
+ () => {
|
|
|
+ this.chioseVisiable = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|