Przeglądaj źródła

feat:pageContent 新建\状态按钮 优先使用自定义显示规则

snow 2 lat temu
rodzic
commit
8e140c9c73

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

@@ -125,7 +125,6 @@ const PageContainer = defineComponent({
       () => innerModalRef,
       () => {
         const modalRef = unref(innerModalRef);
-        console.log(innerModalRef);
         const { getModalRef } = props;
         if (modalRef && getModalRef) getModalRef(modalRef);
       },

+ 26 - 16
src/components/PageContent/src/page-content.tsx

@@ -1,3 +1,4 @@
+/* eslint-disable prettier/prettier */
 import { defineComponent, ref } from "vue";
 import PureTable from "@pureadmin/table";
 import { pageContentProps } from "./types";
@@ -81,6 +82,7 @@ const PageConent = defineComponent({
         superUserNoAction,
         superUserNoPerview,
         showPayTagFn,
+        showStatus,
         showReturnTagFn
       } = contentConfig;
 
@@ -97,6 +99,13 @@ const PageConent = defineComponent({
       const showPay = showPayTagFn ? showPayTagFn(row, powers) : true;
       const showRerturn = showReturnTagFn ? showReturnTagFn(row, powers) : true;
 
+      const _showStatus = showStatus
+        ? showStatus(isSuperUser.value)
+        : action.status &&
+        noAction &&
+        ((powers.some(i => i == "003") && row.status + "" === "0") ||
+          (powers.some(i => i == "004") && row.status + "" === "1"));
+
       return (
         <>
           {!notPreview && view && noPerview && powers.some(i => i == "007") && (
@@ -132,20 +141,17 @@ const PageConent = defineComponent({
             />
           )}
 
-          {action.status &&
-            noAction &&
-            ((powers.some(i => i == "003") && row.status + "" === "0") ||
-              (powers.some(i => i == "004") && row.status + "" === "1")) && (
-              <Operation.Status
-                row={row}
-                prop={contentConfig.statusProp}
-                // eslint-disable-next-line prettier/prettier
-                statusRowProp={contentConfig.statusRowProp}
-                onReload={() => onSearch()}
-                isRequesetArray={isRequesetArray}
-                {...createActionProps("status", apis)}
-              />
-            )}
+          {_showStatus && (
+            <Operation.Status
+              row={row}
+              prop={contentConfig.statusProp}
+              // eslint-disable-next-line prettier/prettier
+              statusRowProp={contentConfig.statusRowProp}
+              onReload={() => onSearch()}
+              isRequesetArray={isRequesetArray}
+              {...createActionProps("status", apis)}
+            />
+          )}
 
           {del && noAction && action.delete && powers.some(i => i == "006") && (
             <Operation.Delete
@@ -162,8 +168,12 @@ const PageConent = defineComponent({
 
     function renderCreateButton() {
       const { contentConfig, powers } = props;
-      const { superUserNoAction } = contentConfig;
-      if (superUserNoAction && isSuperUser.value) {
+      const { superUserNoAction, showCreate } = contentConfig;
+
+      if (
+        (superUserNoAction && isSuperUser.value) ||
+        (showCreate && !showCreate(isSuperUser.value))
+      ) {
         return null;
       }
 

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

@@ -36,6 +36,8 @@ export interface ContentConfig {
   companyProp?: string;
   superUserNoAction?: boolean;
   superUserNoPerview?: boolean;
+  showCreate: (isSuperUser: boolean) => boolean;
+  showStatus: (isSuperUser) => boolean;
   statusRowProp?: (row: any) => any;
   showPreview?: (row: Record<string, string>) => boolean;
   showDelete?: (row: Record<string, string>) => boolean;

+ 2 - 0
src/components/PageModal/src/hooks/use-page-modal.ts

@@ -49,6 +49,8 @@ export function usePageModal({
 
   function handleConfrim(type: ActionType, data: any) {
     const result = confirmCallback ? confirmCallback(data) : {};
+
+    console.log(result);
     pageModalRef.value.confirmLoading = true;
 
     const params = {

+ 6 - 7
src/views/reportForm/reportApply/config/content.config.ts

@@ -1,9 +1,6 @@
 import { ContentConfig } from "/@/components/PageContent";
 
-import {
-  httpList
-  // , httpAdd, httpStatus
-} from "/@/api/reportForm/reportApply";
+import { httpList, httpAdd, httpStatus } from "/@/api/reportForm/reportApply";
 // import { useUserInfo } from "/@/hooks/core/useUser";
 import { h } from "vue";
 import dayjs from "dayjs";
@@ -91,11 +88,13 @@ const columns = [
 const contentConfig: ContentConfig = {
   title: "可申请报表",
   superUserNoAction: false,
+  showCreate: isSuperUser => isSuperUser,
+  showStatus: isSuperUser => isSuperUser,
   columns,
   apis: {
-    httpList
-    // httpAdd,
-    // httpStatus
+    httpList,
+    httpAdd,
+    httpStatus
   }
 };
 

+ 7 - 47
src/views/reportForm/reportApply/index.vue

@@ -4,28 +4,22 @@ import contentConfig from "./config/content.config";
 import searchConfig from "./config/search.config";
 import modalConfig from "./config/modal.config";
 import { usePageSearch, usePageModal, type PageHooks } from "/@/hooks/page";
-import { useCompany } from "/@/hooks/core/useCompany";
-import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
-import { useUserInfo } from "/@/hooks/core/useUser";
+// import { useCompany } from "/@/hooks/core/useCompany";
 const PageName = "reportApply";
 const refModel = ref(modalConfig);
 
 const modalRef = ref(null);
-const { currentCompany } = useCompany();
-const { isSuperUser } = useUserInfo();
+
+// const { currentCompany } = useCompany();
+// () => ({ companyNo: currentCompany.value.companyNo });
+
 const hooks: PageHooks = {
   pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig),
   pageModalHook: pageContentRef =>
     usePageModal({
-      pageContentRef,
-      confirmCallback: () => ({
-        companyNo: currentCompany.value.companyNo
-      })
+      pageContentRef
     })
 };
-const handleApproval = ({ logid }) => {
-  console.log(modalRef.value);
-};
 </script>
 
 <template>
@@ -36,40 +30,6 @@ const handleApproval = ({ logid }) => {
       :search-config="searchConfig"
       :modal-config="refModel"
       :get-modal-ref="ref => (modalRef = ref)"
-    >
-      <template #content_header>
-        <ElButton
-          size="small"
-          type="primary"
-          v-if="isSuperUser"
-          :icon="useRenderIcon('add')"
-          >新增</ElButton
-        ></template
-      >
-      <template #content_action="{ status, id }">
-        <ElPopconfirm
-          v-if="isSuperUser"
-          placement="top"
-          :title="String(status) === '1' ? '改为禁用?' : '改为启用?'"
-          :on-confirm="() => handleApproval({ id })"
-        >
-          <template #reference>
-            <ElButton
-              link
-              size="small"
-              class="fl"
-              type="primary"
-              :icon="
-                useRenderIcon(
-                  String(status) === '1'
-                    ? 'close-circle-line'
-                    : 'checkbox-circle-line'
-                )
-              "
-            />
-          </template>
-        </ElPopconfirm>
-      </template>
-    </PageContainer>
+    />
   </PageAuth>
 </template>