Browse Source

fix:日报权限管理

snow 1 year ago
parent
commit
fee8a27889

+ 6 - 75
src/api/user.ts

@@ -3,6 +3,7 @@ import { loadEnv } from "@build/index";
 const { VITE_PROXY_DOMAIN_REAL, VITE_PROXY_USER_REAL } = loadEnv();
 const userAPi = VITE_PROXY_DOMAIN_REAL;
 const yewuApi = VITE_PROXY_USER_REAL + "/admin/";
+const accountApi = VITE_PROXY_USER_REAL + "/account/";
 
 interface userType extends Promise<any> {
   svg?: string;
@@ -30,80 +31,6 @@ export const getAsyncRoutes = async (data: object) => {
   const result = await http.request("post", `${yewuApi}role_action/menu`, {
     data
   });
-
-  // result.data[0].child = [
-  //   ...result.data[0].child,
-  //   {
-  //     id: 45,
-  //     menu_name: "功能权限设置",
-  //     menu_route: "actionSet",
-  //     menu_url: "system/actionSet/index",
-  //     menu_ico: "ep:add-location",
-  //     pid: 43,
-  //     weight: 1,
-  //     is_menu: 0,
-  //     status: 1,
-  //     createtime: "2023-08-10 09:01:45",
-  //     updatetime: "2023-08-10 10:45:59",
-  //     child: [
-  //       {
-  //         action_id: 3,
-  //         action_name: "列表"
-  //       },
-  //       {
-  //         action_id: 2,
-  //         action_name: "添加"
-  //       },
-  //       {
-  //         action_id: 6,
-  //         action_name: "启用"
-  //       },
-  //       {
-  //         action_id: 5,
-  //         action_name: "详情"
-  //       }
-  //     ]
-  //   },
-  //   {
-  //     id: 46,
-  //     menu_name: "按钮设置",
-  //     menu_route: "setBtn",
-  //     menu_url: "system/setBtn/index",
-  //     menu_ico: "ep:add-location",
-  //     pid: 43,
-  //     weight: 1,
-  //     is_menu: 0,
-  //     status: 1,
-  //     createtime: "2023-08-10 09:01:45",
-  //     updatetime: "2023-08-10 10:45:59",
-  //     child: [
-  //       {
-  //         action_id: 3,
-  //         action_name: "列表"
-  //       },
-  //       {
-  //         action_id: 2,
-  //         action_name: "添加"
-  //       },
-  //       {
-  //         action_id: 6,
-  //         action_name: "启用"
-  //       },
-  //       {
-  //         action_id: 7,
-  //         action_name: "启用"
-  //       },
-  //       {
-  //         action_id: 5,
-  //         action_name: "详情"
-  //       },
-  //       {
-  //         action_id: 8,
-  //         action_name: "删除"
-  //       }
-  //     ]
-  //   }
-  // ];
   return result;
 };
 
@@ -126,6 +53,10 @@ export const httpUserList = (data: object): any => {
   return http.request("post", `${yewuApi}userlist`, { data });
 };
 
+export const httpDepart = (data: object): any => {
+  return http.request("post", `${accountApi}depart`, { data });
+};
+
 export const httpSupplierall = (data: object): any => {
   return http.request("post", `${yewuApi}supplierlist`, {
     data
@@ -139,7 +70,7 @@ export const httpSupplierList = (data: object): any => {
 };
 
 export const httpBusinessList = (data: object): any => {
-  return http.request("post", `${yewuApi}companylist`, {
+  return http.request("post", `${accountApi}depart/business`, {
     data
   });
 };

+ 9 - 0
src/components/BasicForm/src/basic-form.vue

@@ -9,6 +9,7 @@ import { ImageSingleUpload } from "/@/components/ImageUpload";
 import SupplierQuery from "./fields/supplier-query.vue";
 import BusinessQuery from "./fields/business-query.vue";
 import BusinessPermission from "./fields/business-permission/index.vue";
+import DepartQuery from "./fields/depart.vue";
 
 const props = defineProps(basicFormProps);
 const emit = defineEmits(["trigger-blur"]);
@@ -212,6 +213,14 @@ defineExpose({
               />
             </template>
 
+            <template v-if="item.type === 'depart-query'">
+              <DepartQuery
+                v-model="formData[item.field]"
+                :placeholder="item.placeholder || '所在部门'"
+                @change="handleChange(item)"
+              />
+            </template>
+
             <template v-if="item.type === 'business-query'">
               <BusinessQuery
                 v-model="formData[item.field]"

+ 23 - 29
src/components/BasicForm/src/fields/business-permission/normal-user.vue

@@ -1,50 +1,44 @@
 <script setup lang="ts">
-import { ref, onMounted, shallowRef } from "vue";
+import { ref, onMounted, shallowRef, computed } from "vue";
 import { httpCompany } from "/@/api/user";
 import { useResponseHandle } from "/@/hooks/core/useAsync";
+import { useUserStore } from "/@/store/modules/user";
 
-const emit = defineEmits(["change"])
-const actived = shallowRef("")
+const emit = defineEmits(["change"]);
+const actived = shallowRef("");
 
-const list = ref<any[]>([]);
+// const list = ref<any[]>([]);
 const responseHandle = useResponseHandle();
 
-async function requesetCompanies(companyName: string, isIntial: boolean) {
-  const { data, message, code } = await httpCompany({
-    companyName,
-    size: 9999
-  });
+const userStore = useUserStore();
 
-  responseHandle({
-    code,
-    message,
-    handler: () => {
-      list.value = data.list;
-      if (isIntial) {
-        const { companyCode } = list.value[0] || {} 
-        actived.value = companyCode;
-        handleChange(companyCode)
-      }
-    }
-  });
-}
+const list = computed(() => userStore.business);
+
+async function requesetCompanies(isIntial: boolean) {
+  const [first] = userStore.business || [];
+  const { companyCode } = first || {};
 
-async function intialData() { 
-  requesetCompanies(undefined, true);
+  if (isIntial) {
+    actived.value = companyCode;
+    handleChange(companyCode);
+  }
 }
 
-onMounted(() => {
-  requesetCompanies("", true);
-});
+async function intialData() {
+  requesetCompanies(true);
+}
 
+// onMounted(() => {
+//   requesetCompanies("", true);
+// });
 
 async function handleChange(value) {
-  emit("change", value)
+  emit("change", value);
 }
 
 defineExpose({
   intialData
-})
+});
 </script>
 
 <template>

+ 19 - 17
src/components/BasicForm/src/fields/business-permission/super-admin.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, shallowRef, nextTick ,watch } from "vue";
+import { ref, shallowRef, watch } from "vue";
 import { httpBusinessList, httpSupplierList } from "/@/api/user";
 import { useResponseHandle } from "/@/hooks/core/useAsync";
 import { useUserInfo } from "/@/hooks/core/useUser";
@@ -10,14 +10,14 @@ const props = defineProps<{
   value?: string;
   placeholder?: string;
   isSupplier?: boolean;
-}>()
+}>();
 
 const responseHandle = useResponseHandle();
 
 const { userLevel } = useUserInfo();
 
 const value = shallowRef("");
-const list = ref<Record<string,string>[]>([]);
+const list = ref<Record<string, string>[]>([]);
 
 function convertList(list) {
   const isSupplier = userLevel.value === "3" || props.isSupplier;
@@ -25,17 +25,19 @@ function convertList(list) {
   return list.map(item => ({
     ...item,
     code: item.companyNo,
-    name: item.company_name
+    name: item.company
   }));
 }
 
-async function requesetCompanies(name: string, companyNo: string, isIntial?: boolean) {
-  const isSupplier = userLevel.value === "3" || props.isSupplier;
-  const api = isSupplier || props.isSupplier ? httpSupplierList : httpBusinessList;
+async function requesetCompanies(
+  name: string,
+  companyNo: string,
+  isIntial?: boolean
+) {
+  const api = httpBusinessList;
 
   const { data, message, code } = await api({
-    [isSupplier ? "name" : "company_name"]: name,
-    [isSupplier ? "code" : "companyNo"]: companyNo,
+    name,
     size: 99999
   });
 
@@ -43,18 +45,18 @@ async function requesetCompanies(name: string, companyNo: string, isIntial?: boo
     code,
     message,
     handler: () => {
-      list.value = convertList(data.list);
+      list.value = convertList(data);
 
-      if (isIntial) { 
-        const { companyNo } = list.value[0] || {} 
-        value.value = companyNo
-        handleChange(companyNo)
+      if (isIntial) {
+        const { companyNo } = list.value[0] || {};
+        value.value = companyNo;
+        handleChange(companyNo);
       }
     }
   });
 }
 
-const handleChange = value => emit('change', value)
+const handleChange = value => emit("change", value);
 
 watch(
   () => userLevel.value,
@@ -66,8 +68,8 @@ watch(
   }
 );
 
-async function intialData() { 
-  requesetCompanies(undefined, props.value,  true);
+async function intialData() {
+  requesetCompanies(undefined, props.value, true);
 }
 
 defineExpose({

+ 44 - 0
src/components/BasicForm/src/fields/depart.vue

@@ -0,0 +1,44 @@
+<script setup lang="ts">
+import { ref, onMounted } from "vue";
+import { useVModel } from "@vueuse/core";
+import RemoteSelect from "/@/components/RemoteSelect";
+import { httpDepart } from "/@/api/user";
+
+const props = defineProps<{
+  modelValue?: string;
+  disabled?: boolean;
+}>();
+
+const emit = defineEmits(["change"]);
+
+const value = useVModel(props, "modelValue");
+
+const RemoteSelectRef = ref<InstanceType<typeof RemoteSelect> | null>(null);
+
+onMounted(() => {
+  value.value && (RemoteSelectRef.value as any).initalData(value.value);
+});
+
+function handleChange() {
+  emit("change");
+}
+
+defineExpose({
+  initalData: data => (RemoteSelectRef.value as any).initalData(data)
+});
+</script>
+
+<template>
+  <RemoteSelect
+    ref="RemoteSelectRef"
+    :disabled="disabled"
+    :is-root="true"
+    v-model="value"
+    style="width: 100%"
+    :api="httpDepart"
+    request-prop="name"
+    response-label-prop="name"
+    response-val-prop="id"
+    @change="handleChange"
+  />
+</template>

+ 4 - 3
src/components/BasicForm/src/types.ts

@@ -17,7 +17,8 @@ export type FormItemType =
   | "remote-select"
   | "supplier-query"
   | "business-query"
-  | "business-permission";
+  | "business-permission"
+  | "depart-query";
 
 export type FormItem = {
   field: string;
@@ -32,10 +33,10 @@ export type FormItem = {
   span?: number;
   type_field?: string;
   slot?: string;
-  trigger?: 'change';
+  trigger?: "change";
   onChange?: Function;
   noRest?: boolean;
-  defaultValue?: Array<string> | string
+  defaultValue?: Array<string> | string;
 };
 
 export type FormGorup = {

+ 2 - 1
src/components/PageContent/src/page-content.tsx

@@ -56,9 +56,9 @@ const PageContent = defineComponent({
       initalData:intialData
     } = useRequest(props);
 
+    const { isSuperUser } = useUserInfo();
     const { selects } = useSelection();
     const { action } = useActions(props.contentConfig);
-    const { isSuperUser } = useUserInfo();
 
     const { columns, fixed, displayColumns, _raw, reset } = useColumns(
       props.contentConfig.columns
@@ -290,6 +290,7 @@ const PageContent = defineComponent({
       getPageData,
       getBasicParams,
       onBeforeAction,
+      getData:() => dataList.value
     });
 
     return () => {

+ 2 - 0
src/components/PageContent/src/types.ts

@@ -14,6 +14,7 @@ import PageContent from "./page-content";
  * @param treeProps
  */
 export interface ContentConfig {
+  all?: boolean;
   columns: any;
   root?: boolean;
   title?: string;
@@ -90,6 +91,7 @@ export type PageContentInstance = typeof PageContent & {
   ) => void;
   onSearch: () => void;
   getBasicParams: () => any;
+  getData: () => any;
 };
 
 export enum BeforeRequestType {

+ 1 - 0
src/store/modules/types.ts

@@ -54,6 +54,7 @@ export type userType = {
   disabledCompany: boolean;
   systemInfo: Record<string, string>;
   level: string;
+  business: Array<any>;
 };
 
 export type resType = {

+ 10 - 21
src/store/modules/user.ts

@@ -14,9 +14,7 @@ import {
   getAsyncRoutes,
   ddDetail,
   refreshToken,
-  httpCompany,
-  httpUserInfo,
-  httpSystemLast
+  httpUserInfo
 } from "/@/api/user";
 
 import {
@@ -49,7 +47,8 @@ export const useUserStore = defineStore({
     swithingCompany: false,
     disabledCompany: false,
     systemInfo: {},
-    info: {}
+    info: {},
+    business: []
   }),
   actions: {
     SET_TOKEN(token) {
@@ -123,11 +122,16 @@ export const useUserStore = defineStore({
       this.info = data;
       if (Number(code) === 1) {
         const { level } = data;
+
         /** 没有设置过level  */
         if (this.level === "0" || !this.level) {
           this.level = level;
         }
 
+        if (this.level === "2") {
+          this.business = data.company_relaton;
+        }
+
         if (this.level === "3") {
           throw new Error(
             JSON.stringify({ code: 10000, message: "供应商端账号无法登录" })
@@ -135,14 +139,6 @@ export const useUserStore = defineStore({
         }
 
         this.isSuperUser = level === "1";
-        //
-        // if (!this.isSuperUser && this.companyList.length === 0) {
-        //   const { data: companyData } = await httpCompany({ size: 10000 });
-        //   this.companyList = companyData.list;
-        //   if (!this.companyList || this.companyList.length === 0) {
-        //     return;
-        //   }
-        // }
 
         return data;
       } else {
@@ -150,16 +146,8 @@ export const useUserStore = defineStore({
       }
     },
 
-    async requsetSystemInfo() {
-      const { data, code } = await httpSystemLast({});
-      if (Number(code) === 0) {
-        this.systemInfo = data;
-      } else {
-        throw new Error();
-      }
-    },
     // 获取当前账号菜单数据
-    async postMenuList(form) {
+    async postMenuList() {
       try {
         const userinfo = await this.requesetUserInfo();
         return new Promise((resolve, reject) => {
@@ -229,6 +217,7 @@ export const useUserStore = defineStore({
       storageSession.clear();
       this.currentComapny = "";
       this.companyList = [];
+      this.business = [];
       removeRelaComNo();
       useMultiTagsStoreHook().handleTags("equal", routerArrays);
       router.push("/login");

+ 1 - 1
src/utils/export.ts

@@ -27,7 +27,7 @@ type Options<T> = {
 const EXCLUDE_COLUMNS = ["序号", "操作"];
 
 //纯前端导出
-function frontEndExport<T>(
+export function frontEndExport<T>(
   _options: Pick<Options<T>, "data" | "columns" | "name">
 ) {
   const { data, columns, name } = _options;

+ 26 - 20
src/views/reportCollection/frontDaily/components/business.vue

@@ -1,9 +1,9 @@
 <script setup lang="ts">
-import { shallowRef, ref } from "vue"
-import { ElMessage } from "element-plus"
-import sourceSearchConfig from './config/search.config'
-import sourceContentConfig from './config/content.config';
-import { httpRequsetExport } from '/@/utils/export';
+import { shallowRef, ref } from "vue";
+import { ElMessage } from "element-plus";
+import sourceSearchConfig from "./config/search.config";
+import sourceContentConfig from "./config/content.config";
+import { httpRequsetExport } from "/@/utils/export";
 import { usePageSearch, type PageHooks } from "/@/hooks/page";
 import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
 import { PageContentInstance } from "/@/components/PageContent";
@@ -11,37 +11,43 @@ import { useBusinessSearch, useBusinessContent } from "./../../_hooks";
 import { httpCompanyList } from "/@/api/dataDashboardNew/daily";
 
 const loading = shallowRef(false);
-const pageContentRef = ref<PageContentInstance | null>(null)
-const lockKey = "relaComNo"
+const pageContentRef = ref<PageContentInstance | null>(null);
+const lockKey = "relaComNo";
 
-const { searchConfig } = useBusinessSearch({ sourceConfig: sourceSearchConfig })
+const { searchConfig } = useBusinessSearch({
+  sourceConfig: sourceSearchConfig
+});
 const { contentConfig } = useBusinessContent({
-  sourceConfig: sourceContentConfig, apis: {
+  sourceConfig: sourceContentConfig,
+  apis: {
     httpList: httpCompanyList
   }
-})
+});
 
-const hooks: PageHooks = { pageSearchHook:() => usePageSearch(undefined, undefined, searchConfig, false ,lockKey) }
+const hooks: PageHooks = {
+  pageSearchHook: () =>
+    usePageSearch(undefined, undefined, searchConfig, false, lockKey)
+};
 
 const callback = {
   onSuccess: () => (loading.value = false),
   onStart: () => (loading.value = true),
   onFail: () => (loading.value = false)
-}
+};
 
 async function handleExportAllReport() {
-  const params = pageContentRef.value.getBasicParams() || {}
+  const params = pageContentRef.value.getBasicParams() || {};
 
-  console.log(params)
+  console.log(params);
 
-  if (!params.date) { 
+  if (!params.date) {
     ElMessage.warning("请选择导出文件的日期!");
-    return
+    return;
   }
 
   if (!params[lockKey]) {
     ElMessage.warning("请选择业务公司");
-    return
+    return;
   }
 
   await httpRequsetExport({
@@ -53,13 +59,12 @@ async function handleExportAllReport() {
     params
   });
 }
-
 </script>
 
 <template>
   <PageContainer
     :hooks="hooks"
-    :getContentRef="ref => pageContentRef = ref"
+    :getContentRef="ref => (pageContentRef = ref)"
     :content-config="contentConfig"
     :search-config="searchConfig"
     lockKey="relaComNo"
@@ -70,7 +75,8 @@ async function handleExportAllReport() {
         size="small"
         :icon="useRenderIcon('arrow-up-line')"
         type="primary"
-      >导出</el-button>
+        >导出</el-button
+      >
     </template>
   </PageContainer>
 </template>

+ 2 - 2
src/views/system/setBtn/components/menu-tree.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, nextTick } from "vue";
+import { ref } from "vue";
 import { httpList } from "/@/api/system/menuOperator";
 import { ElTree } from "element-plus";
 import type { IMenuTree } from "../types";
@@ -47,7 +47,7 @@ async function initMenuList() {
     const node = list[0];
     treeRef.value.setCurrentKey(node.id);
     emit("treeSelectChange", node);
-  },100)
+  }, 500);
 }
 
 async function load(row, resolve) {

+ 38 - 37
src/views/time/_hooks/useBusinessContent.ts

@@ -1,63 +1,64 @@
 import { computed, shallowRef } from "vue";
 import { ContentApis, ContentConfig } from "/@/components/PageContent";
 import { FormConfig } from "/@/components/PageSearch";
-import { cloneDeep } from "lodash"
+import { cloneDeep } from "lodash";
 
-interface InsertBusinessField{ 
-    index?: number
-    name?: string
-    code?:string
+interface InsertBusinessField {
+  index?: number;
+  name?: string;
+  code?: string;
 }
 
-interface IContentOptions { 
-  apis: ContentApis,
-  sourceConfig: ContentConfig,
-  insertBusinessField?:InsertBusinessField
+interface IContentOptions {
+  apis: ContentApis;
+  sourceConfig: ContentConfig;
+  insertBusinessField?: InsertBusinessField;
 }
 
 const defaultInsertBusinessField: InsertBusinessField = {
   index: 2,
   name: "relaComName",
   code: "relaComNo"
-}
+};
 
-export function useBusinessContent(options: IContentOptions) { 
-  const { sourceConfig, apis, insertBusinessField = defaultInsertBusinessField } = options;
+export function useBusinessContent(options: IContentOptions) {
+  const {
+    sourceConfig,
+    apis,
+    insertBusinessField = defaultInsertBusinessField
+  } = options;
   const contentConfig = cloneDeep(sourceConfig) as ContentConfig;
   const { columns: beforeColumns } = contentConfig;
 
-
   const {
     index = defaultInsertBusinessField.index,
     name = defaultInsertBusinessField.name,
     code = defaultInsertBusinessField.code
-  } = insertBusinessField
-  
-  const afterColumns = beforeColumns.splice(index)
-
-  function render(row: Record<string, string>, prop: string) { 
-    return row[prop] ? row[prop] : '--'
-  }
-
-  beforeColumns.push(  {
-    prop: code,
-    label: '业务公司编号',
-    minWidth: '155px',
-    cellRenderer: ({ row }) => render(row, code)
-  })
-
-  beforeColumns.push({
-    prop: name,
-    label: '业务公司名称',
-    minWidth: '155px',
-    cellRenderer: ({ row }) => render(row, name)
-  })
+  } = insertBusinessField;
 
-  contentConfig.apis = apis;
-  contentConfig.columns = beforeColumns.concat(afterColumns)
+  const afterColumns = beforeColumns.splice(index);
+
+  // function render(row: Record<string, string>, prop: string) {
+  //   return row[prop] ? row[prop] : "--";
+  // }
+  // beforeColumns.push({
+  //   prop: code,
+  //   label: "业务公司编号",
+  //   minWidth: "155px",
+  //   cellRenderer: ({ row }) => render(row, code)
+  // });
+  //
+  // beforeColumns.push({
+  //   prop: name,
+  //   label: "业务公司名称",
+  //   minWidth: "155px",
+  //   cellRenderer: ({ row }) => render(row, name)
+  // });
 
+  contentConfig.apis = apis;
+  contentConfig.columns = beforeColumns.concat(afterColumns);
 
   return {
     contentConfig
-  }
+  };
 }

+ 41 - 8
src/views/time/reportDaily/components/all.vue

@@ -5,22 +5,55 @@ import contentConfig from "./config/content.config";
 
 import { usePageSearch, type PageHooks } from "/@/hooks/page";
 import { PageContentInstance } from "/@/components/PageContent";
+import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
+import { isBeyondTime } from "/@/views/time/_utils";
+import { frontEndExport } from "/@/utils/export";
+import { usePermission } from "/@/hooks/core";
 
-const pagaName = "reportDaily";
+const pageName = "reportDaily";
+const { hasPermissionWithCode } = usePermission(pageName);
 
 const pageContentRef = ref<PageContentInstance | null>(null);
 
 const hooks: PageHooks = {
   pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
 };
+
+async function handleExportAllReport() {
+  const params = pageContentRef.value.getBasicParams() || {};
+  const { start, end } = params;
+  const beyondTime = isBeyondTime({ start, end, len: 30 });
+  if (beyondTime) return;
+
+  const data = pageContentRef.value.getData();
+
+  frontEndExport({
+    columns: contentConfig.columns,
+    name: "日报.xlsx",
+    data
+  });
+}
 </script>
 
 <template>
-  <PageContainer
-    :hooks="hooks"
-    :page-name="pagaName"
-    :getContentRef="ref => (pageContentRef = ref)"
-    :content-config="contentConfig"
-    :search-config="searchConfig"
-  />
+  <page-auth :page-name="pageName">
+    <page-container
+      :hooks="hooks"
+      :page-name="pageName"
+      :get-content-ref="ref => (pageContentRef = ref)"
+      :content-config="contentConfig"
+      :search-config="searchConfig"
+    >
+      <template #content_header>
+        <el-button
+          v-if="hasPermissionWithCode('9')"
+          @click="handleExportAllReport"
+          size="small"
+          :icon="useRenderIcon('arrow-up-line')"
+          type="primary"
+          >导出</el-button
+        >
+      </template>
+    </page-container>
+  </page-auth>
 </template>

+ 28 - 25
src/views/time/reportDaily/components/business.vue

@@ -1,27 +1,31 @@
 <script setup lang="ts">
-import { shallowRef, ref } from "vue";
+import { ref } from "vue";
+import apis from "./config/apis";
 import { ElMessage } from "element-plus";
+import { usePermission } from "/@/hooks/core";
+import { frontEndExport } from "/@/utils/export";
+import { isBeyondTime } from "/@/views/time/_utils";
 import sourceSearchConfig from "./config/search.config";
 import sourceContentConfig from "./config/content.config";
-import { httpRequsetExport } from "/@/utils/export";
 import { usePageSearch, type PageHooks } from "/@/hooks/page";
 import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
 import { PageContentInstance } from "/@/components/PageContent";
 import { useBusinessSearch, useBusinessContent } from "./../../_hooks";
-import { httpCompanyList } from "/@/api/dataDashboardNew/daily";
 
-const loading = shallowRef(false);
 const pageContentRef = ref<PageContentInstance | null>(null);
-const lockKey = "relaComNo";
+const lockKey = "companyNo";
+
+const pageName = "reportDaily";
+const { hasPermissionWithCode } = usePermission(pageName);
 
 const { searchConfig } = useBusinessSearch({
-  sourceConfig: sourceSearchConfig
+  sourceConfig: sourceSearchConfig,
+  queryField: "companyNo"
 });
+
 const { contentConfig } = useBusinessContent({
   sourceConfig: sourceContentConfig,
-  apis: {
-    httpList: httpCompanyList
-  }
+  apis: { httpList: apis.list }
 });
 
 const hooks: PageHooks = {
@@ -32,27 +36,25 @@ const hooks: PageHooks = {
 async function handleExportAllReport() {
   const params = pageContentRef.value.getBasicParams() || {};
 
-  console.log(params);
-
-  if (!params.date) {
-    ElMessage.warning("请选择导出文件的日期!");
-    return;
-  }
+  const { start, end } = params;
 
   if (!params[lockKey]) {
     ElMessage.warning("请选择业务公司");
     return;
   }
 
-  await httpRequsetExport({
-    url: "r_saleexportconsultdayexport",
-    fileType: "aplication/zip",
-    isPurchase: true,
-    name: "日报.zip",
-    onSuccess: () => (loading.value = false),
-    onStart: () => (loading.value = true),
-    onFail: () => (loading.value = false),
-    params
+  const beyondTime = isBeyondTime({
+    start,
+    end,
+    len: 30
+  });
+
+  if (beyondTime) return;
+  const data = pageContentRef.value.getData();
+  frontEndExport({
+    columns: contentConfig.columns,
+    name: "日报.xlsx",
+    data
   });
 }
 </script>
@@ -67,9 +69,10 @@ async function handleExportAllReport() {
   >
     <template #content_header>
       <el-button
+        v-if="hasPermissionWithCode('18')"
+        :icon="useRenderIcon('arrow-up-line')"
         @click="handleExportAllReport"
         size="small"
-        :icon="useRenderIcon('arrow-up-line')"
         type="primary"
         >导出</el-button
       >

+ 1 - 3
src/views/time/reportDaily/components/config/apis.ts

@@ -4,7 +4,5 @@ const baseUrl = "purchease/sale/";
 
 export default {
   list: createHttpRequest(`${baseUrl}orderInfoBySaler`),
-  export: createHttpRequest(""),
-  businessList: createHttpRequest(""),
-  businessExport: createHttpRequest("")
+  businessList: createHttpRequest("")
 };

+ 5 - 0
src/views/time/reportDaily/components/config/search.config.ts

@@ -20,6 +20,11 @@ const searchFormConfig: FormConfig = {
         startProp: "start",
         endProp: "end"
       }
+    },
+    {
+      field: "depart_id",
+      type: "depart-query",
+      trigger: "change"
     }
   ]
 };

+ 25 - 14
src/views/time/reportDaily/index.vue

@@ -1,29 +1,40 @@
 <script setup lang="ts">
-import { shallowRef } from "vue";
+import { shallowRef, onMounted } from "vue";
 import All from "./components/all.vue";
 import Business from "./components/business.vue";
 import { usePermission } from "/@/hooks/core";
+import NoAuth from "/@/components/NoAuth/NoAuth.vue";
 
-const actived = shallowRef("1");
+const actived = shallowRef("");
 
-const pageName = "reportDaily";
-const { permissions } = usePermission(pageName);
+const { hasPermissionWithCode } = usePermission("reportDaily");
 
-console.log(permissions.value);
+onMounted(() => {
+  if (hasPermissionWithCode("3")) {
+    actived.value = "3";
+  } else if (hasPermissionWithCode("11")) {
+    actived.value = "11";
+  }
+});
 </script>
 
 <template>
   <div class="report-container">
-    <all />
-    <!--    <el-tabs v-model="actived" style="color: #fff">-->
-    <!--      <el-tab-pane label="查看全部" name="1">-->
-    <!--        <all v-if="actived === '1'" />-->
-    <!--      </el-tab-pane>-->
+    <el-tabs v-model="actived" style="color: #fff" v-if="actived">
+      <el-tab-pane label="查看全部" name="3" v-if="hasPermissionWithCode('3')">
+        <all v-if="actived === '3'" />
+      </el-tab-pane>
+
+      <el-tab-pane
+        label="查看业务公司"
+        name="11"
+        v-if="hasPermissionWithCode('11')"
+      >
+        <business v-if="actived === '11'" />
+      </el-tab-pane>
+    </el-tabs>
 
-    <!--      <el-tab-pane label="查看业务公司" name="2">-->
-    <!--        <business v-if="actived === '2'" />-->
-    <!--      </el-tab-pane>-->
-    <!--    </el-tabs>-->
+    <no-auth v-else />
   </div>
 </template>