ソースを参照

SEO管理关键词管理重构

zq940222 5 ヶ月 前
コミット
34f004d01c

+ 64 - 0
src/views/adweb/keywords/SeoKeywords.api.ts

@@ -0,0 +1,64 @@
+import {defHttp} from '/@/utils/http/axios';
+import { useMessage } from "/@/hooks/web/useMessage";
+
+const { createConfirm } = useMessage();
+
+enum Api {
+  list = '/seo/seoKeywords/list',
+  save='/seo/seoKeywords/add',
+  edit='/seo/seoKeywords/edit',
+  deleteOne = '/seo/seoKeywords/delete',
+  deleteBatch = '/seo/seoKeywords/deleteBatch',
+  importExcel = '/seo/seoKeywords/importExcel',
+  exportXls = '/seo/seoKeywords/exportXls',
+}
+/**
+ * 导出api
+ * @param params
+ */
+export const getExportUrl = Api.exportXls;
+/**
+ * 导入api
+ */
+export const getImportUrl = Api.importExcel;
+/**
+ * 列表接口
+ * @param params
+ */
+export const list = (params) =>
+  defHttp.get({url: Api.list, params});
+
+/**
+ * 删除单个
+ */
+export const deleteOne = (params,handleSuccess) => {
+  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
+    handleSuccess();
+  });
+}
+/**
+ * 批量删除
+ * @param params
+ */
+export const batchDelete = (params, handleSuccess) => {
+  createConfirm({
+    iconType: 'warning',
+    title: '确认删除',
+    content: '是否删除选中数据',
+    okText: '确认',
+    cancelText: '取消',
+    onOk: () => {
+      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
+        handleSuccess();
+      });
+    }
+  });
+}
+/**
+ * 保存或者更新
+ * @param params
+ */
+export const saveOrUpdate = (params, isUpdate) => {
+  let url = isUpdate ? Api.edit : Api.save;
+  return defHttp.post({url: url, params});
+}

+ 302 - 0
src/views/adweb/keywords/SeoKeywords.data.ts

@@ -0,0 +1,302 @@
+import {BasicColumn} from '/@/components/Table';
+import {FormSchema} from '/@/components/Table';
+import { rules} from '/@/utils/helper/validator';
+import { render } from '/@/utils/common/renderUtils';
+import { getWeekMonthQuarterYear } from '/@/utils';
+//列表数据
+export const columns: BasicColumn[] = [
+   {
+    title: '平台标识',
+    align:"center",
+    dataIndex: 'appKey'
+   },
+   {
+    title: '用户标识',
+    align:"center",
+    dataIndex: 'siteCode'
+   },
+   {
+    title: '关键词',
+    align:"center",
+    dataIndex: 'keywords'
+   },
+   {
+    title: '关键词所属域名',
+    align:"center",
+    dataIndex: 'domain'
+   },
+   {
+    title: '语种',
+    align:"center",
+    dataIndex: 'lang'
+   },
+   {
+    title: '最新搜索时间',
+    align:"center",
+    dataIndex: 'lastSearchTime'
+   },
+   {
+    title: '定时器的最新搜索时间',
+    align:"center",
+    dataIndex: 'timerLastSearchTime'
+   },
+   {
+    title: '0删除,1有效,2过期',
+    align:"center",
+    dataIndex: 'status'
+   },
+   {
+    title: '数据复制源ID',
+    align:"center",
+    dataIndex: 'sourceId'
+   },
+   {
+    title: '关键词优先级(1:高;2:中;3:低)',
+    align:"center",
+    dataIndex: 'priority'
+   },
+   {
+    title: 'SEO关键词优化完成时间',
+    align:"center",
+    dataIndex: 'finishTime'
+   },
+   {
+    title: '优化进度(默认0)',
+    align:"center",
+    dataIndex: 'optimizeProcess'
+   },
+   {
+    title: '优化状态(0:未完成;1:已完成)',
+    align:"center",
+    dataIndex: 'optimizeStatus'
+   },
+   {
+    title: '关键词类型(1:指定;2:长尾)',
+    align:"center",
+    dataIndex: 'keywordType'
+   },
+   {
+    title: '最近一次搜索排名',
+    align:"center",
+    dataIndex: 'lastRank'
+   },
+   {
+    title: '搜索状态,0为普通状态,1为搜索进行中状态',
+    align:"center",
+    dataIndex: 'searchStatus'
+   },
+   {
+    title: '关键词所在URL',
+    align:"center",
+    dataIndex: 'positionUrl'
+   },
+   {
+    title: '相关关键词关联的关键词的id',
+    align:"center",
+    dataIndex: 'relatedKeywordId'
+   },
+   {
+    title: '关键词对应套餐的ID',
+    align:"center",
+    dataIndex: 'planId'
+   },
+   {
+    title: '订购表ID',
+    align:"center",
+    dataIndex: 'subscriptionId'
+   },
+   {
+    title: '网站表ID',
+    align:"center",
+    dataIndex: 'siteId'
+   },
+];
+//查询数据
+export const searchFormSchema: FormSchema[] = [
+];
+//表单数据
+export const formSchema: FormSchema[] = [
+  {
+    label: '平台标识',
+    field: 'appKey',
+    component: 'Input',
+    dynamicRules: ({model,schema}) => {
+          return [
+                 { required: true, message: '请输入平台标识!'},
+          ];
+     },
+  },
+  {
+    label: '用户标识',
+    field: 'siteCode',
+    component: 'Input',
+    dynamicRules: ({model,schema}) => {
+          return [
+                 { required: true, message: '请输入用户标识!'},
+          ];
+     },
+  },
+  {
+    label: '关键词',
+    field: 'keywords',
+    component: 'Input',
+    dynamicRules: ({model,schema}) => {
+          return [
+                 { required: true, message: '请输入关键词!'},
+          ];
+     },
+  },
+  {
+    label: '关键词所属域名',
+    field: 'domain',
+    component: 'Input',
+    dynamicRules: ({model,schema}) => {
+          return [
+                 { required: true, message: '请输入关键词所属域名!'},
+          ];
+     },
+  },
+  {
+    label: '语种',
+    field: 'lang',
+    component: 'Input',
+  },
+  {
+    label: '最新搜索时间',
+    field: 'lastSearchTime',
+    component: 'DatePicker',
+    componentProps: {
+       showTime: true,
+       valueFormat: 'YYYY-MM-DD HH:mm:ss'
+     },
+  },
+  {
+    label: '定时器的最新搜索时间',
+    field: 'timerLastSearchTime',
+    component: 'DatePicker',
+    componentProps: {
+       showTime: true,
+       valueFormat: 'YYYY-MM-DD HH:mm:ss'
+     },
+  },
+  {
+    label: '0删除,1有效,2过期',
+    field: 'status',
+    component: 'InputNumber',
+  },
+  {
+    label: '数据复制源ID',
+    field: 'sourceId',
+    component: 'InputNumber',
+  },
+  {
+    label: '关键词优先级(1:高;2:中;3:低)',
+    field: 'priority',
+    component: 'InputNumber',
+  },
+  {
+    label: 'SEO关键词优化完成时间',
+    field: 'finishTime',
+    component: 'DatePicker',
+    componentProps: {
+       showTime: true,
+       valueFormat: 'YYYY-MM-DD HH:mm:ss'
+     },
+  },
+  {
+    label: '优化进度(默认0)',
+    field: 'optimizeProcess',
+    component: 'InputNumber',
+  },
+  {
+    label: '优化状态(0:未完成;1:已完成)',
+    field: 'optimizeStatus',
+    component: 'InputNumber',
+  },
+  {
+    label: '关键词类型(1:指定;2:长尾)',
+    field: 'keywordType',
+    component: 'InputNumber',
+    dynamicRules: ({model,schema}) => {
+          return [
+                 { required: true, message: '请输入关键词类型(1:指定;2:长尾)!'},
+          ];
+     },
+  },
+  {
+    label: '最近一次搜索排名',
+    field: 'lastRank',
+    component: 'InputNumber',
+  },
+  {
+    label: '搜索状态,0为普通状态,1为搜索进行中状态',
+    field: 'searchStatus',
+    component: 'InputNumber',
+  },
+  {
+    label: '关键词所在URL',
+    field: 'positionUrl',
+    component: 'InputTextArea',
+  },
+  {
+    label: '相关关键词关联的关键词的id',
+    field: 'relatedKeywordId',
+    component: 'InputNumber',
+  },
+  {
+    label: '关键词对应套餐的ID',
+    field: 'planId',
+    component: 'Input',
+  },
+  {
+    label: '订购表ID',
+    field: 'subscriptionId',
+    component: 'Input',
+  },
+  {
+    label: '网站表ID',
+    field: 'siteId',
+    component: 'Input',
+  },
+	// TODO 主键隐藏字段,目前写死为ID
+	{
+	  label: '',
+	  field: 'id',
+	  component: 'Input',
+	  show: false
+	},
+];
+
+// 高级查询数据
+export const superQuerySchema = {
+  appKey: {title: '平台标识',order: 0,view: 'text', type: 'string',},
+  siteCode: {title: '用户标识',order: 1,view: 'text', type: 'string',},
+  keywords: {title: '关键词',order: 2,view: 'text', type: 'string',},
+  domain: {title: '关键词所属域名',order: 3,view: 'text', type: 'string',},
+  lang: {title: '语种',order: 4,view: 'text', type: 'string',},
+  lastSearchTime: {title: '最新搜索时间',order: 5,view: 'datetime', type: 'string',},
+  timerLastSearchTime: {title: '定时器的最新搜索时间',order: 6,view: 'datetime', type: 'string',},
+  status: {title: '0删除,1有效,2过期',order: 7,view: 'number', type: 'number',},
+  sourceId: {title: '数据复制源ID',order: 8,view: 'number', type: 'number',},
+  priority: {title: '关键词优先级(1:高;2:中;3:低)',order: 9,view: 'number', type: 'number',},
+  finishTime: {title: 'SEO关键词优化完成时间',order: 10,view: 'datetime', type: 'string',},
+  optimizeProcess: {title: '优化进度(默认0)',order: 11,view: 'number', type: 'number',},
+  optimizeStatus: {title: '优化状态(0:未完成;1:已完成)',order: 12,view: 'number', type: 'number',},
+  keywordType: {title: '关键词类型(1:指定;2:长尾)',order: 13,view: 'number', type: 'number',},
+  lastRank: {title: '最近一次搜索排名',order: 14,view: 'number', type: 'number',},
+  searchStatus: {title: '搜索状态,0为普通状态,1为搜索进行中状态',order: 15,view: 'number', type: 'number',},
+  positionUrl: {title: '关键词所在URL',order: 16,view: 'textarea', type: 'string',},
+  relatedKeywordId: {title: '相关关键词关联的关键词的id',order: 17,view: 'number', type: 'number',},
+  planId: {title: '关键词对应套餐的ID',order: 18,view: 'text', type: 'string',},
+  subscriptionId: {title: '订购表ID',order: 19,view: 'text', type: 'string',},
+  siteId: {title: '网站表ID',order: 20,view: 'text', type: 'string',},
+};
+
+/**
+* 流程表单调用这个方法获取formSchema
+* @param param
+*/
+export function getBpmFormSchema(_formData): FormSchema[]{
+  // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
+  return formSchema;
+}

+ 188 - 0
src/views/adweb/keywords/SeoKeywordsList.vue

@@ -0,0 +1,188 @@
+<template>
+  <div>
+    <!--引用表格-->
+   <BasicTable @register="registerTable" :rowSelection="rowSelection">
+     <!--插槽:table标题-->
+      <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-dropdown v-if="selectedRowKeys.length > 0">
+              <template #overlay>
+                <a-menu>
+                  <a-menu-item key="1" @click="batchHandleDelete">
+                    <Icon icon="ant-design:delete-outlined"></Icon>
+                    删除
+                  </a-menu-item>
+                </a-menu>
+              </template>
+              <a-button>批量操作
+                <Icon icon="mdi:chevron-down"></Icon>
+              </a-button>
+        </a-dropdown>
+        <!-- 高级查询 -->
+        <super-query :config="superQueryConfig" @search="handleSuperQuery" />
+      </template>
+       <!--操作栏-->
+      <template #action="{ record }">
+        <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
+      </template>
+      <!--字段回显插槽-->
+      <template v-slot:bodyCell="{ column, record, index, text }">
+      </template>
+    </BasicTable>
+    <!-- 表单区域 -->
+    <SeoKeywordsModal @register="registerModal" @success="handleSuccess"></SeoKeywordsModal>
+  </div>
+</template>
+
+<script lang="ts" name="serp-seoKeywords" setup>
+  import {ref, reactive, computed, unref} from 'vue';
+  import {BasicTable, useTable, TableAction} from '/@/components/Table';
+  import {useModal} from '/@/components/Modal';
+  import { useListPage } from '/@/hooks/system/useListPage'
+  import SeoKeywordsModal from './components/SeoKeywordsModal.vue'
+  import {columns, searchFormSchema, superQuerySchema} from './SeoKeywords.data';
+  import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './SeoKeywords.api';
+  import { downloadFile } from '/@/utils/common/renderUtils';
+  import { useUserStore } from '/@/store/modules/user';
+  const queryParam = reactive<any>({});
+  const checkedKeys = ref<Array<string | number>>([]);
+  const userStore = useUserStore();
+  //注册model
+  const [registerModal, {openModal}] = useModal();
+  //注册table数据
+  const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
+      tableProps:{
+           title: '关键词',
+           api: list,
+           columns,
+           canResize:false,
+           formConfig: {
+              //labelWidth: 120,
+              schemas: searchFormSchema,
+              autoSubmitOnEnter:true,
+              showAdvancedButton:true,
+              fieldMapToNumber: [
+              ],
+              fieldMapToTime: [
+              ],
+            },
+           actionColumn: {
+               width: 120,
+               fixed:'right'
+            },
+            beforeFetch: (params) => {
+              return Object.assign(params, queryParam);
+            },
+      },
+       exportConfig: {
+            name:"关键词",
+            url: getExportUrl,
+            params: queryParam,
+          },
+          importConfig: {
+            url: getImportUrl,
+            success: handleSuccess
+          },
+  })
+
+  const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
+
+  // 高级查询配置
+  const superQueryConfig = reactive(superQuerySchema);
+
+  /**
+   * 高级查询事件
+   */
+  function handleSuperQuery(params) {
+    Object.keys(params).map((k) => {
+      queryParam[k] = params[k];
+    });
+    reload();
+  }
+   /**
+    * 新增事件
+    */
+  function handleAdd() {
+     openModal(true, {
+       isUpdate: false,
+       showFooter: true,
+     });
+  }
+   /**
+    * 编辑事件
+    */
+  function handleEdit(record: Recordable) {
+     openModal(true, {
+       record,
+       isUpdate: true,
+       showFooter: true,
+     });
+   }
+   /**
+    * 详情
+   */
+  function handleDetail(record: Recordable) {
+     openModal(true, {
+       record,
+       isUpdate: true,
+       showFooter: false,
+     });
+   }
+   /**
+    * 删除事件
+    */
+  async function handleDelete(record) {
+     await deleteOne({id: record.id}, handleSuccess);
+   }
+   /**
+    * 批量删除事件
+    */
+  async function batchHandleDelete() {
+     await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
+   }
+   /**
+    * 成功回调
+    */
+  function handleSuccess() {
+      (selectedRowKeys.value = []) && reload();
+   }
+   /**
+      * 操作栏
+      */
+  function getTableAction(record){
+       return [
+         {
+           label: '编辑',
+           onClick: handleEdit.bind(null, record),
+         }
+       ]
+   }
+     /**
+        * 下拉操作栏
+        */
+  function getDropDownAction(record){
+       return [
+         {
+           label: '详情',
+           onClick: handleDetail.bind(null, record),
+         }, {
+           label: '删除',
+           popConfirm: {
+             title: '是否确认删除',
+             confirm: handleDelete.bind(null, record),
+             placement: 'topLeft',
+           }
+         }
+       ]
+   }
+
+
+</script>
+
+<style scoped>
+  :deep(.ant-picker),:deep(.ant-input-number){
+    width: 100%;
+  }
+</style>

+ 70 - 0
src/views/adweb/keywords/components/SeoKeywordsForm.vue

@@ -0,0 +1,70 @@
+<template>
+    <div style="min-height: 400px">
+        <BasicForm @register="registerForm"></BasicForm>
+        <div style="width: 100%;text-align: center" v-if="!formDisabled">
+            <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
+        </div>
+    </div>
+</template>
+
+<script lang="ts">
+    import {BasicForm, useForm} from '/@/components/Form/index';
+    import {computed, defineComponent} from 'vue';
+    import {defHttp} from '/@/utils/http/axios';
+    import { propTypes } from '/@/utils/propTypes';
+    import {getBpmFormSchema} from '../SeoKeywords.data';
+    import {saveOrUpdate} from '../SeoKeywords.api';
+    
+    export default defineComponent({
+        name: "SeoKeywordsForm",
+        components:{
+            BasicForm
+        },
+        props:{
+            formData: propTypes.object.def({}),
+            formBpm: propTypes.bool.def(true),
+        },
+        setup(props){
+            const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
+                labelWidth: 150,
+                schemas: getBpmFormSchema(props.formData),
+                showActionButtonGroup: false,
+                baseColProps: {span: 24}
+            });
+
+            const formDisabled = computed(()=>{
+                if(props.formData.disabled === false){
+                    return false;
+                }
+                return true;
+            });
+
+            let formData = {};
+            const queryByIdUrl = '/serp/seoKeywords/queryById';
+            async function initFormData(){
+                let params = {id: props.formData.dataId};
+                const data = await defHttp.get({url: queryByIdUrl, params});
+                formData = {...data}
+                //设置表单的值
+                await setFieldsValue(formData);
+                //默认是禁用
+                await setProps({disabled: formDisabled.value})
+            }
+
+            async function submitForm() {
+                let data = getFieldsValue();
+                let params = Object.assign({}, formData, data);
+                console.log('表单数据', params)
+                await saveOrUpdate(params, true)
+            }
+
+            initFormData();
+            
+            return {
+                registerForm,
+                formDisabled,
+                submitForm,
+            }
+        }
+    });
+</script>

+ 68 - 0
src/views/adweb/keywords/components/SeoKeywordsModal.vue

@@ -0,0 +1,68 @@
+<template>
+  <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
+      <BasicForm @register="registerForm"/>
+  </BasicModal>
+</template>
+
+<script lang="ts" setup>
+    import {ref, computed, unref} from 'vue';
+    import {BasicModal, useModalInner} from '/@/components/Modal';
+    import {BasicForm, useForm} from '/@/components/Form/index';
+    import {formSchema} from '../SeoKeywords.data';
+    import {saveOrUpdate} from '../SeoKeywords.api';
+    // Emits声明
+    const emit = defineEmits(['register','success']);
+    const isUpdate = ref(true);
+    const isDetail = ref(false);
+    //表单配置
+    const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({
+        //labelWidth: 150,
+        schemas: formSchema,
+        showActionButtonGroup: false,
+        baseColProps: {span: 24}
+    });
+    //表单赋值
+    const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
+        //重置表单
+        await resetFields();
+        setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
+        isUpdate.value = !!data?.isUpdate;
+        isDetail.value = !!data?.showFooter;
+        if (unref(isUpdate)) {
+            //表单赋值
+            await setFieldsValue({
+                ...data.record,
+            });
+        }
+        // 隐藏底部时禁用整个表单
+       setProps({ disabled: !data?.showFooter })
+    });
+    //设置标题
+    const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
+    //表单提交事件
+    async function handleSubmit(v) {
+        try {
+            let values = await validate();
+            setModalProps({confirmLoading: true});
+            //提交表单
+            await saveOrUpdate(values, isUpdate.value);
+            //关闭弹窗
+            closeModal();
+            //刷新列表
+            emit('success');
+        } finally {
+            setModalProps({confirmLoading: false});
+        }
+    }
+</script>
+
+<style lang="less" scoped>
+	/** 时间和数字输入框样式 */
+  :deep(.ant-input-number) {
+    width: 100%;
+  }
+
+  :deep(.ant-calendar-picker) {
+    width: 100%;
+  }
+</style>

+ 1 - 2
src/views/adweb/seo/SeoKeywordsRankList.vue

@@ -65,7 +65,7 @@
     </a-row>
 
     <a-row class="r3" type="flex"  :gutter="16">
-      <a-col :span="12" v-if="comprehenInfo.specifyKeywordNum != null ">
+      <a-col :span="12">
         <div class="wrap">
           <p class="t1">指定词排名</p>
           <div class="content">
@@ -1195,7 +1195,6 @@ export default {
   .wrap {
     padding: 20px;
     background: #fff;
-    margin-bottom: 10px;
 
     .t1 {
       color: #000;