diff --git a/dist.tar b/dist.tar deleted file mode 100644 index ec4385e..0000000 Binary files a/dist.tar and /dev/null differ diff --git a/src/store/modules/data.js b/src/store/modules/data.js index 0c6f86e..1602551 100644 --- a/src/store/modules/data.js +++ b/src/store/modules/data.js @@ -1,4 +1,5 @@ import { defineStore } from "pinia"; +import { tenantSelect } from "@/api/subPlatform/tenant"; const useDataStore = defineStore("data", { state: () => ({ @@ -11,8 +12,12 @@ const useDataStore = defineStore("data", { }, }, actions: { - setSiteList(list) { - this.siteList = list; + async setSiteList(list) { + if (this.siteList.length !== 0) { + return; + } + const { rows } = await tenantSelect(); + this.siteList = rows; }, }, }); diff --git a/src/views/components/SiteOptions/index.vue b/src/views/components/SiteOptions/index.vue index 031a95d..b013e00 100644 --- a/src/views/components/SiteOptions/index.vue +++ b/src/views/components/SiteOptions/index.vue @@ -3,13 +3,13 @@ :model-value="modelValue" placeholder="请选择,支持搜索" size="default" - :loading="siteList.length === 0" + :loading="dataStore.siteList.length === 0" @change="valueChanged" filterable clearable > diff --git a/src/views/dataList/enterprise/index.vue b/src/views/dataList/enterprise/index.vue index dff9aec..7ed4863 100644 --- a/src/views/dataList/enterprise/index.vue +++ b/src/views/dataList/enterprise/index.vue @@ -61,7 +61,12 @@ > - 导入 @@ -135,6 +140,53 @@ v-model:limit="queryParams.page_size" @pagination="getList" /> + + + + + +
将文件拖到此处,或点击上传
+ +
+ +
@@ -144,13 +196,20 @@ import { companyExport, companyDelete, } from "@/api/dataList/enterprise"; -import { download } from "@/utils/request"; -import dayjs from "dayjs"; +import { getToken } from "@/utils/auth"; +import axios from "axios"; +// import { download } from "@/utils/request"; +// import dayjs from "dayjs"; +import { tansParams, blobValidate } from "@/utils/ruoyi"; +import { saveAs } from "file-saver"; import { tenantSelect } from "@/api/subPlatform/tenant"; import { reactive, ref, toRefs } from "vue"; import { useRouter } from "vue-router"; import { enterpriseOptions } from "@/utils/parameter"; -import { ElMessageBox } from "element-plus"; +import { ElLoading, ElMessageBox } from "element-plus"; +import request from "@/utils/request"; +import dayjs from "dayjs"; + const router = useRouter(); const data = reactive({ queryParams: { @@ -161,6 +220,23 @@ const data = reactive({ tenantId: undefined, }, }); + +/*** 用户导入参数 */ +const upload = reactive({ + // 是否显示弹出层(用户导入) + open: false, + // 弹出层标题(用户导入) + title: "", + // 是否禁用上传 + isUploading: false, + // 是否更新已经存在的用户数据 + // updateSupport: 0, + // 设置上传的请求头部 + headers: { Authorization: "Bearer " + getToken() }, + // 上传的地址 + url: import.meta.env.VITE_APP_BASE_API + "/business/enterprise/importData", +}); + const { queryParams } = toRefs(data); const showSearch = ref(true); const siteList = ref([]); @@ -205,6 +281,42 @@ const handleDetail = (id) => { query: { id }, }); }; +const uploadRef = ref(null); +/** 导入按钮操作 */ +function handleImport() { + upload.title = "用户导入"; + upload.open = true; +} +/** 下载模板操作 */ +function importTemplate() { + proxy.download( + "system/user/importTemplate", + {}, + `user_template_${new Date().getTime()}.xlsx` + ); +} +/**文件上传中处理 */ +const handleFileUploadProgress = (event, file, fileList) => { + upload.isUploading = true; +}; +/** 文件上传成功处理 */ +const handleFileSuccess = (response, file, fileList) => { + upload.open = false; + upload.isUploading = false; + uploadRef.value.handleRemove(file); + ElMessageBox.alert( + "
" + + response.msg + + "
", + "导入结果", + { dangerouslyUseHTMLString: true } + ); + getList(); +}; +/** 提交上传文件 */ +function submitFileForm() { + uploadRef.value.submit(); +} const handleDelete = async (id) => { ElMessageBox.confirm(`是否确认删除编号为${id}的数据项?`) .then(async () => { @@ -214,13 +326,51 @@ const handleDelete = async (id) => { }) .catch(() => {}); }; -const handleExport = () => { - ElMessageBox.confirm(`是否确认企业列表?`) - .then(() => { - download("/business/enterprise/export", {}, "res.xls"); - // companyExport(); + +let downloadLoadingInstance; +const download = (url, filename) => { + downloadLoadingInstance = ElLoading.service({ + text: "正在下载数据,请稍候", + background: "rgba(0, 0, 0, 0.7)", + }); + return request + .get(url, { + // transformRequest: [ + // (params) => { + // return tansParams(params); + // }, + // ], + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + responseType: "blob", }) - .catch(() => {}); + .then(async (data) => { + const isLogin = await blobValidate(data); + if (isLogin) { + const blob = new Blob([data]); + saveAs(blob, filename); + } else { + const resText = await data.text(); + const rspObj = JSON.parse(resText); + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode["default"]; + ElMessage.error(errMsg); + } + downloadLoadingInstance.close(); + }) + .catch((r) => { + console.error(r); + ElMessage.error("下载文件出现错误,请联系管理员!"); + downloadLoadingInstance.close(); + }); +}; + +const handleExport = () => { + ElMessageBox.confirm(`是否确认企业列表?`).then(() => { + download( + `/business/enterprise/export`, + `企业信息(${dayjs().format("YYYYMMDDHHmmss")}).xlsx` + ); + }); }; getList(); getSiteList(); diff --git a/src/views/website/aboutUs/index.vue b/src/views/website/aboutUs/index.vue index ca41d3b..a1a2581 100644 --- a/src/views/website/aboutUs/index.vue +++ b/src/views/website/aboutUs/index.vue @@ -8,7 +8,8 @@ @submit.native.prevent > - + - - + + + + - + - - - - + + @@ -103,7 +92,8 @@ - + @@ -139,13 +129,17 @@ import { import { cloneDeep } from "lodash"; import { ElMessage, ElMessageBox } from "element-plus"; import { tenantSelect } from "@/api/subPlatform/tenant"; +import SiteOptions from "@/views/components/SiteOptions"; +import useDataStore from "@/store/modules/data"; +const dataStore = useDataStore(); +dataStore.setSiteList(); const queryFormRef = ref(null); const dataList = ref([]); const loading = ref(true); const total = ref(0); const showEditDialog = ref(false); const formRef = ref(null); -const siteList = ref([]); // 站点列表 +// const siteList = ref([]); // 站点列表 const showSearch = ref(true); const title = ref(""); @@ -191,10 +185,10 @@ const getList = async () => { }; // 获取站点列表 -const getSiteList = async () => { - const resp = await tenantSelect(); - siteList.value = resp.rows; -}; +// const getSiteList = async () => { +// const resp = await tenantSelect(); +// siteList.value = resp.rows; +// }; // const getSiteName = (tenantId) => { // const item = siteList.value.find((el) => { @@ -255,5 +249,5 @@ const handleDelete = (row) => { .catch(() => {}); }; getList(); -getSiteList(); +// getSiteList(); diff --git a/src/views/website/innovate/service/index.vue b/src/views/website/innovate/service/index.vue index 326f6ff..808aebd 100644 --- a/src/views/website/innovate/service/index.vue +++ b/src/views/website/innovate/service/index.vue @@ -8,7 +8,8 @@ @submit.native.prevent > - + @@ -112,7 +114,8 @@ > - + @@ -169,16 +172,18 @@ import { navigationList, } from "@/api/website/innovate"; -import { tenantSelect } from "@/api/subPlatform/tenant"; import WangEditor from "@/components/WangEditor/index.vue"; import { ElMessage, ElMessageBox } from "element-plus"; import { reactive, ref } from "vue"; +import SiteOptions from "@/views/components/SiteOptions"; +import useDataStore from "@/store/modules/data"; +const dataStore = useDataStore(); +dataStore.setSiteList(); const loading = ref(true); // 是否正在加载 const showSearch = ref(true); // 是否显示搜索栏 const categoryList = ref([]); //导航列表 const queryFormRef = ref(null); const formRef = ref(null); -const siteList = ref([]); const total = ref(0); const dataList = ref([]); @@ -235,20 +240,6 @@ const getList = async () => { loading.value = false; }; -// 获取站点列表 -const getSiteList = async () => { - const resp = await tenantSelect(); - siteList.value = resp.rows; -}; - -// // 获取站点名称 -// const getSiteName = (tenantId) => { -// const item = siteList.value.find((el) => { -// return el.id === tenantId; -// }); -// return item ? item.name : "无"; -// }; - // 获取分类名称 const getCategoryName = (categoryId) => { const item = categoryList.value.find((el) => { @@ -327,35 +318,5 @@ const handleDelete = (row) => { }; getList(); -getSiteList(); getcategoryList(); - - diff --git a/src/views/website/message/index.vue b/src/views/website/message/index.vue index d7bd0e3..14067ee 100644 --- a/src/views/website/message/index.vue +++ b/src/views/website/message/index.vue @@ -11,7 +11,7 @@ v-model="queryParams.name" placeholder="请输入姓名" clearable - size="small" + size="default" style="width: 240px" @keyup.enter.native="handleQuery" /> @@ -21,7 +21,7 @@ v-model="queryParams.status" placeholder="用户状态" clearable - size="small" + size="default" style="width: 240px" @clear="delete queryParams.status" > @@ -38,7 +38,7 @@ v-model="queryParams.content" placeholder="请输入需求内容" clearable - size="small" + size="default" style="width: 240px" @keyup.enter.native="handleQuery" /> @@ -47,11 +47,11 @@ 搜索 - 重置 @@ -88,7 +88,7 @@ @@ -100,6 +100,7 @@