Browse Source

关键词组件调整

zq940222 4 months ago
parent
commit
a825304bf1
1 changed files with 26 additions and 27 deletions
  1. 26 27
      src/views/adweb/keywords/SeoKeywordsList.vue

+ 26 - 27
src/views/adweb/keywords/SeoKeywordsList.vue

@@ -6,7 +6,7 @@
         <a-col :span="8">
           <div class="choose-site">
             <span class="t1">站点:</span>
-            <select-site @set-site-info="changeSite" selectWidth="300px"/>
+            <select-site @set-site-info="changeSite" selectWidth="300px" />
           </div>
         </a-col>
       </a-row>
@@ -18,19 +18,14 @@
       <template #tableTitle>
         <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增关键词
         </a-button>
-<!--        <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出-->
-<!--        </a-button>-->
-<!--        <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">-->
-<!--          导入-->
-<!--        </j-upload-button>-->
+        <!--        <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出-->
+        <!--        </a-button>-->
         <a-button type="primary" preIcon="ant-design:download-outlined" @click="downloadTemplate">
           模板下载
         </a-button>
-        <a-upload style="margin-left: 8px" name="file" :showUploadList="false" :multiple="false"
-                  :action="importExcelUrl" @change="handleImportExcel2">
-          <a-button type="primary" preIcon="ant-design:import-outlined">关键词导入</a-button>
-        </a-upload>
-
+        <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">
+          关键词导入
+        </j-upload-button>
         <a-dropdown v-if="selectedRowKeys.length > 0">
           <template #overlay>
             <a-menu>
@@ -110,9 +105,11 @@ import { columns, searchFormSchema, superQuerySchema } from "./SeoKeywords.data"
 import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from "./SeoKeywords.api";
 import SelectSite from "@/components/Adweb/selectSite.vue";
 import { downloadFile } from "@/utils/common/renderUtils";
+import { useMethods } from "@/hooks/system/useMethods";
+import { useMessage } from "@/hooks/web/useMessage";
 
 const queryParam = reactive<any>({});
-queryParam.siteCode = localStorage.getItem('siteCode')!;
+queryParam.siteCode = localStorage.getItem("siteCode")!;
 //注册model
 const [registerModal, { openModal }] = useModal();
 //注册table数据
@@ -135,7 +132,7 @@ const { prefixCls, tableContext } = useListPage({
       fixed: "right"
     },
     beforeFetch: (params) => {
-      params.siteCode = localStorage.getItem('siteCode')!;
+      params.siteCode = localStorage.getItem("siteCode");
       return Object.assign(params, queryParam);
     }
   },
@@ -263,28 +260,29 @@ function onchange($event, id) {
 //切换站点
 function changeSite(selectedSiteInfo: any) {
   queryParam.siteCode = selectedSiteInfo.code;
-  handleSuccess()
+  handleSuccess();
 }
 
 //下载模板
 function downloadTemplate() {
-  downloadFile('关键词导入模版表.xlsx')
+  downloadFile("关键词导入模版表.xlsx");
 }
 
 // 导入关键词
-const fileStatus = ref('');
-const fileResponse = ref(null);
-
-function handleImportExcel2(info) {
-  fileStatus.value = info.file.status;
-
-  if (fileStatus.value!== 'uploading') {
-    console.log(info.file, info.fileList);
-  }
-
-  if (fileStatus.value === 'done') {
-    fileResponse.value = info.file.response;
+const { handleImportXls } = useMethods();
+const importExcelUrl = ref("");
+onBeforeMount(() => {
+  importExcelUrl.value = `${import.meta.env.VITE_GLOB_DOMAIN_URL}/seo/seoKeywords/importExcel?siteCode=` + queryParam.siteCode;
+});
+const $message = useMessage();
 
+function onImportXls(file) {
+  let realUrl = importExcelUrl.value;
+  if (realUrl) {
+    return handleImportXls(file, realUrl, reload);
+  } else {
+    $message.createMessage.warn("没有传递 importConfig.url 参数");
+    return Promise.reject();
   }
 }
 </script>
@@ -293,6 +291,7 @@ function handleImportExcel2(info) {
 .r1 {
   margin-left: 20px;
   margin-top: 20px;
+
   .choose-site {
     display: flex;
   }