Browse Source

feat:供应商账号查询添加公司筛选

snow 2 years ago
parent
commit
573cd5fae4

+ 4 - 0
src/api/supplierManage/supplierAccoutQuery/index.ts

@@ -50,3 +50,7 @@ export const httpRoleAll = (data: object): ResponseType => {
 export const httpSetRole = (data: object): ResponseType => {
   return http.request("post", `${yewuApi}setrole`, { data });
 };
+
+export const httpSupplierlist = (data: object): ResponseType => {
+  return http.request("post", `${yewuApi}supplier_by_super`, { data });
+};

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

@@ -200,6 +200,10 @@ defineExpose({
         </el-col>
       </template>
 
+      <el-col v-bind="colLayout">
+        <el-form-item> <slot name="custom" /></el-form-item>
+      </el-col>
+
       <el-form-item>
         <slot name="action" />
       </el-form-item>

+ 3 - 0
src/components/PageContainer/src/page-container.tsx

@@ -91,6 +91,9 @@ const PageContainer = defineComponent({
           formConfig={searchConfig}
           onResetBtnClick={search.handleResetClick}
           onSearchBtnClick={search.handleSearchClick}
+          v-slots={{
+            custom: () => slots.search_field && slots.search_field()
+          }}
         />
       );
     }

+ 3 - 2
src/components/PageSearch/src/hooks/use-page-search.ts

@@ -10,7 +10,8 @@ const convertDateVal = val => (val ? dayjs(val).format("YYYY-MM-DD") : "");
 export function usePageSearch(
   searchCallback?: Fn,
   resetCallback?: Fn,
-  searchFormConfig?: FormConfig
+  searchFormConfig?: FormConfig,
+  resetEmpty?: boolean
 ) {
   const pageContentRef = ref<PageContentInstance>(null);
 
@@ -59,7 +60,7 @@ export function usePageSearch(
   function handleResetClick(params?: any) {
     const { result } = searchCallback ? searchCallback(params) : { result: {} };
 
-    pageContentRef.value?.getPageData(result);
+    pageContentRef.value?.getPageData(resetEmpty ? {} : result);
     resetCallback && resetCallback();
   }
 

+ 4 - 0
src/components/PageSearch/src/page-search.vue

@@ -71,6 +71,10 @@ if (searchParams.basic) {
 <template>
   <div class="bg-white pl-4 pt-4 page-search">
     <BasicForm v-bind="formConfig" v-model:form-data="formData" size="small">
+      <template #custom>
+        <slot name="custom" />
+      </template>
+
       <template #action>
         <div style="width: 100%" flex gap-2>
           <el-button

+ 23 - 10
src/layout/components/company/super.vue

@@ -13,6 +13,8 @@ const props = withDefaults(
     noAll?: boolean;
     noSet?: boolean;
     code?: string;
+    isSupplier?: boolean;
+    placeholder?: string;
   }>(),
   {
     code: ""
@@ -40,9 +42,11 @@ let scrollWrapper: HTMLDivElement | null = null;
 
 const debouceScroll = useDebounceFn(handleScroll, 500);
 
-function convertList(list){
-  const isSupplier = userLevel.value === "3"
-  if (isSupplier) return list
+function convertList(list) {
+  const isSupplier = userLevel.value === "3" || props.isSupplier;
+
+  if (isSupplier) return list;
+
   return list.map(item => ({
     ...item,
     code: item.companyNo,
@@ -54,12 +58,13 @@ async function requesetSupplierAll(name: string, companyNo: string) {
   state.name = name;
   state.page = 1;
   state.noMore = false;
-  const isSupplier = userLevel.value === "3"
-  const api = isSupplier ? httpSupplierList : httpBusinessList;
+  const isSupplier = userLevel.value === "3" || props.isSupplier;
+  const api =
+    isSupplier || props.isSupplier ? httpSupplierList : httpBusinessList;
   const { data, message, code } = await api({
-    [isSupplier ? "name" : 'companyName']: state.name,
-    [isSupplier ? "code" : 'companyNo']: companyNo,
-    page: state.page,
+    [isSupplier ? "name" : "companyName"]: state.name,
+    [isSupplier ? "code" : "companyNo"]: companyNo,
+    page: state.page
   });
 
   responseHandle({
@@ -92,7 +97,10 @@ async function handleScroll() {
     state.page++;
     state.loading = true;
 
-    const api = userLevel.value === "3" ? httpSupplierList : httpBusinessList;
+    const api =
+      userLevel.value === "3" || props.isSupplier
+        ? httpSupplierList
+        : httpBusinessList;
 
     const { data, message, code } = await api({
       name: state.name,
@@ -177,9 +185,14 @@ defineExpose({
     :remote-method="requesetSupplierAll"
     @change="handleChange"
     style="width: 450px"
+    :placeholder="placeholder"
     ref="selectRef"
   >
-    <ElOption v-if="!noAll" label="所有公司" :value="''" />
+    <ElOption
+      v-if="!noAll"
+      :label="userLevel === '3' ? '所有供应商公司' : '所有业务公司'"
+      :value="''"
+    />
     <ElOption
       class="super-item"
       v-for="c in list"

+ 2 - 2
src/views/supplierManage/supplierAccoutQuery/components/role-modal.vue

@@ -107,8 +107,8 @@ defineExpose({
         />
       </ElFormItem>
 
-      <ElFormItem label="业务公司" prop="companyName" v-if="company">
-        <ElInput placeholder="请输入业务公司" :value="company" disabled />
+      <ElFormItem label="供应商公司" prop="companyName" v-if="company">
+        <ElInput placeholder="请输入供应商公司" :value="company" disabled />
       </ElFormItem>
 
       <ElFormItem label="角色" prop="roleid">

+ 27 - 3
src/views/supplierManage/supplierAccoutQuery/index.vue

@@ -4,16 +4,29 @@ import RoleModal from "./components/role-modal.vue";
 import contentConfig from "./config/content.config";
 import searchConfig from "./config/search.config";
 import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
-import { httpSetRole } from "/@/api/supplierManage/supplierAccoutQuery";
 import { useAsync } from "/@/hooks/core/useAsync";
 import { ModalTypes } from "./types";
 
+import { httpSetRole } from "/@/api/supplierManage/supplierAccoutQuery";
+
+import SupplierSelect from "/@/layout/components/company/super.vue";
+
 const PageName = "supplierAccoutQuery";
 const roleModalRef = ref<InstanceType<typeof RoleModal> | null>(null);
 const instance = ref(null);
 
+const companyNo = ref("");
+
+const searchFunc = () => {
+  return {
+    result: { companyNo: companyNo.value },
+    deleteProps: []
+  };
+};
+
 const hooks: PageHooks = {
-  pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
+  pageSearchHook: () =>
+    usePageSearch(searchFunc, () => (companyNo.value = ""), searchConfig, true)
 };
 
 const { run } = useAsync({
@@ -56,7 +69,18 @@ function handleSave(data: any, type: ModalTypes) {
       :contentConfig="contentConfig"
       :search-config="searchConfig"
       :get-content-ref="ref => (instance = ref)"
-    />
+    >
+      <template #search_field>
+        <SupplierSelect
+          style="margin-right: 20px; width: 100%"
+          v-model="companyNo"
+          placeholder="供应商公司"
+          no-all
+          no-set
+          is-supplier
+        />
+      </template>
+    </PageContainer>
     <RoleModal ref="roleModalRef" @finance-save="handleSave" />
   </PageAuth>
 </template>