Explorar el Código

fix: 修复10个文件中的TypeScript类型错误

- admin/hook: dialogForm使用独立reactive替代搜索form,补全password/realName/email/remark字段
- menu/enums: boolean值OptionsType数组使用as unknown转型
- operation-log/hook: 添加SearchFormProps接口定义
- role/form: formInline默认值添加status字段
- user/hook: form添加name和roleId字段
- timed-discount/hook: 移除ElInputNumber的无效clearable属性,修复PriceAdjustmentTable类型
- new-apply/hook: 添加defineComponent导入
- replenisher/hook: 添加PaginationProps导入
- order/types: OrderSearchForm和RefundApplicationSearchForm添加dateRange字段
- order/hook: 退款成功兼容code===0和code===200

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline hace 2 semanas
padre
commit
29fb1af340

+ 1 - 1
haha-admin-web/src/views/order/utils/hook.tsx

@@ -624,7 +624,7 @@ export function useOrder(tableRef: Ref) {
 
         try {
           const res = await refundOrder(row.id, { reason: refundState.reason, products });
-          if (res.code === 200) {
+          if (res.code === 200 || res.code === 0) {
             message(`订单 ${row.orderNo} 退款成功`, { type: "success" });
             done();
             onSearch();

+ 2 - 0
haha-admin-web/src/views/order/utils/types.ts

@@ -55,6 +55,7 @@ export interface OrderSearchForm {
   status: number | string;
   startDate: string;
   endDate: string;
+  dateRange?: any;
 }
 
 // 退款商品项
@@ -88,4 +89,5 @@ export interface RefundApplicationSearchForm {
   status: number | string;
   startDate: string;
   endDate: string;
+  dateRange?: any;
 }

+ 1 - 0
haha-admin-web/src/views/product/new-apply/utils/hook.tsx

@@ -29,6 +29,7 @@ import {
   ref,
   toRaw,
   reactive,
+  defineComponent,
   onMounted
 } from "vue";
 

+ 1 - 0
haha-admin-web/src/views/replenisher/utils/hook.tsx

@@ -4,6 +4,7 @@ import { addDialog } from "@/components/ReDialog";
 import { usePublicHooks } from "@/views/system/hooks";
 import QRCode from "qrcode";
 import { deviceDetection } from "@pureadmin/utils";
+import type { PaginationProps } from "@pureadmin/table";
 import { getReplenisherList,
   createReplenisher,
   updateReplenisher,

+ 25 - 26
haha-admin-web/src/views/system/admin/utils/hook.tsx

@@ -237,35 +237,34 @@ export function useAdmin(tableRef: Ref) {
 
   // 打开弹窗
   function openDialog(title = "新增", row?: AdminFormItem) {
+    const dialogForm = reactive<AdminFormItem>({
+      id: row?.id,
+      username: row?.username ?? "",
+      password: "",
+      realName: row?.realName ?? "",
+      phone: row?.phone ?? "",
+      email: row?.email ?? "",
+      roleIds: row?.roleIds ?? "",
+      status: row?.status ?? 1,
+      remark: row?.remark ?? ""
+    });
+
     addDialog({
       title: `${title}管理员`,
-      props: {
-        formInline: {
-          id: row?.id,
-          username: row?.username ?? "",
-          password: "",
-          realName: row?.realName ?? "",
-          phone: row?.phone ?? "",
-          email: row?.email ?? "",
-          roleIds: row?.roleIds ?? "",
-          status: row?.status ?? 1,
-          remark: row?.remark ?? ""
-        }
-      },
       width: "46%",
       draggable: true,
       fullscreen: deviceDetection(),
       fullscreenIcon: true,
       closeOnClickModal: false,
       contentRenderer: () => (
-        <ElForm ref={ruleFormRef} model={form} label-width="100px">
+        <ElForm ref={ruleFormRef} model={dialogForm} label-width="100px">
           <ElFormItem
             label="用户名"
             prop="username"
             rules={[{ required: true, message: "请输入用户名", trigger: "blur" }]}
           >
             <ElInput
-              v-model={form.username}
+              v-model={dialogForm.username}
               placeholder="请输入用户名"
               clearable
               disabled={title === "修改"}
@@ -278,7 +277,7 @@ export function useAdmin(tableRef: Ref) {
               rules={[{ required: true, message: "请输入密码", trigger: "blur" }]}
             >
               <ElInput
-                v-model={form.password}
+                v-model={dialogForm.password}
                 type="password"
                 placeholder="请输入密码"
                 show-password
@@ -291,7 +290,7 @@ export function useAdmin(tableRef: Ref) {
             prop="realName"
             rules={[{ required: true, message: "请输入真实姓名", trigger: "blur" }]}
           >
-            <ElInput v-model={form.realName} placeholder="请输入真实姓名" clearable />
+            <ElInput v-model={dialogForm.realName} placeholder="请输入真实姓名" clearable />
           </ElFormItem>
           <ElFormItem
             label="手机号"
@@ -301,31 +300,31 @@ export function useAdmin(tableRef: Ref) {
               { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号", trigger: "blur" }
             ]}
           >
-            <ElInput v-model={form.phone} placeholder="请输入手机号" clearable />
+            <ElInput v-model={dialogForm.phone} placeholder="请输入手机号" clearable />
           </ElFormItem>
           <ElFormItem label="邮箱" prop="email">
-            <ElInput v-model={form.email} placeholder="请输入邮箱" clearable />
+            <ElInput v-model={dialogForm.email} placeholder="请输入邮箱" clearable />
           </ElFormItem>
           <ElFormItem
             label="角色"
             prop="roleIds"
             rules={[{ required: true, message: "请选择角色", trigger: "change" }]}
           >
-            <ElSelect v-model={form.roleIds} placeholder="请选择角色" class="w-full">
+            <ElSelect v-model={dialogForm.roleIds} placeholder="请选择角色" class="w-full">
               {roleOptions.value.map(item => (
                 <ElOption key={item.id} label={item.name} value={item.id} />
               ))}
             </ElSelect>
           </ElFormItem>
           <ElFormItem label="状态" prop="status">
-            <ElRadioGroup v-model={form.status}>
+            <ElRadioGroup v-model={dialogForm.status}>
               <ElRadioButton value={1}>启用</ElRadioButton>
               <ElRadioButton value={2}>停用</ElRadioButton>
             </ElRadioGroup>
           </ElFormItem>
           <ElFormItem label="备注" prop="remark">
             <ElInput
-              v-model={form.remark}
+              v-model={dialogForm.remark}
               type="textarea"
               placeholder="请输入备注"
               rows={3}
@@ -339,14 +338,14 @@ export function useAdmin(tableRef: Ref) {
 
         try {
           const submitData = {
-            ...toRaw(form),
-            password: title === "新增" ? form.password : undefined
+            ...toRaw(dialogForm),
+            password: title === "新增" ? dialogForm.password : undefined
           };
 
           if (title === "新增") {
             const res = await addAdmin(submitData);
             if (res.code === 0) {
-              message(`新增管理员 ${form.username} 成功`, { type: "success" });
+              message(`新增管理员 ${dialogForm.username} 成功`, { type: "success" });
               done();
               onSearch();
             } else {
@@ -355,7 +354,7 @@ export function useAdmin(tableRef: Ref) {
           } else {
             const res = await updateAdmin({ ...submitData, id: row.id });
             if (res.code === 0) {
-              message(`修改管理员 ${form.username} 成功`, { type: "success" });
+              message(`修改管理员 ${dialogForm.username} 成功`, { type: "success" });
               done();
               onSearch();
             } else {

+ 36 - 93
haha-admin-web/src/views/system/menu/utils/enums.ts

@@ -1,101 +1,44 @@
 import type { OptionsType } from "@/components/ReSegmented";
 
-const menuTypeOptions: Array<OptionsType> = [
-  {
-    label: "菜单",
-    value: 0
-  },
-  {
-    label: "iframe",
-    value: 1
-  },
-  {
-    label: "外链",
-    value: 2
-  },
-  {
-    label: "按钮",
-    value: 3
-  }
-];
-
-const showLinkOptions: Array<OptionsType> = [
-  {
-    label: "显示",
-    tip: "会在菜单中显示",
-    value: true
-  },
-  {
-    label: "隐藏",
-    tip: "不会在菜单中显示",
-    value: false
-  }
-];
-
-const fixedTagOptions: Array<OptionsType> = [
-  {
-    label: "固定",
-    tip: "当前菜单名称固定显示在标签页且不可关闭",
-    value: true
-  },
-  {
-    label: "不固定",
-    tip: "当前菜单名称不固定显示在标签页且可关闭",
-    value: false
-  }
-];
+// Use type assertion to allow boolean values as options
+type AnyOption = { label: string; tip?: string; value: string | number | boolean };
 
-const keepAliveOptions: Array<OptionsType> = [
-  {
-    label: "缓存",
-    tip: "会保存该页面的整体状态,刷新后会清空状态",
-    value: true
-  },
-  {
-    label: "不缓存",
-    tip: "不会保存该页面的整体状态",
-    value: false
-  }
-];
-
-const hiddenTagOptions: Array<OptionsType> = [
-  {
-    label: "允许",
-    tip: "当前菜单名称或自定义信息允许添加到标签页",
-    value: false
-  },
-  {
-    label: "禁止",
-    tip: "当前菜单名称或自定义信息禁止添加到标签页",
-    value: true
-  }
-];
-
-const showParentOptions: Array<OptionsType> = [
-  {
-    label: "显示",
-    tip: "会显示父级菜单",
-    value: true
-  },
-  {
-    label: "隐藏",
-    tip: "不会显示父级菜单",
-    value: false
-  }
+const menuTypeOptions: Array<OptionsType> = [
+  { label: "菜单", value: 0 },
+  { label: "iframe", value: 1 },
+  { label: "外链", value: 2 },
+  { label: "按钮", value: 3 }
 ];
 
-const frameLoadingOptions: Array<OptionsType> = [
-  {
-    label: "开启",
-    tip: "有首次加载动画",
-    value: true
-  },
-  {
-    label: "关闭",
-    tip: "无首次加载动画",
-    value: false
-  }
-];
+const showLinkOptions = [
+  { label: "显示", tip: "会在菜单中显示", value: true },
+  { label: "隐藏", tip: "不会在菜单中显示", value: false }
+] as unknown as Array<OptionsType>;
+
+const fixedTagOptions = [
+  { label: "固定", tip: "当前菜单名称固定显示在标签页且不可关闭", value: true },
+  { label: "不固定", tip: "当前菜单名称不固定显示在标签页且不可关闭", value: false }
+] as unknown as Array<OptionsType>;
+
+const keepAliveOptions = [
+  { label: "缓存", tip: "会保存该页面的整体状态,刷新后会清空状态", value: true },
+  { label: "不缓存", tip: "不会保存该页面的整体状态", value: false }
+] as unknown as Array<OptionsType>;
+
+const hiddenTagOptions = [
+  { label: "允许", tip: "当前菜单名称或自定义信息允许添加到标签页", value: false },
+  { label: "禁止", tip: "当前菜单名称或自定义信息禁止添加到标签页", value: true }
+] as unknown as Array<OptionsType>;
+
+const showParentOptions = [
+  { label: "显示", tip: "会显示父级菜单", value: true },
+  { label: "隐藏", tip: "不会显示父级菜单", value: false }
+] as unknown as Array<OptionsType>;
+
+const frameLoadingOptions = [
+  { label: "开启", tip: "有首次加载动画", value: true },
+  { label: "关闭", tip: "无首次加载动画", value: false }
+] as unknown as Array<OptionsType>;
 
 export {
   menuTypeOptions,

+ 8 - 0
haha-admin-web/src/views/system/operation-log/utils/hook.tsx

@@ -10,6 +10,14 @@ import {
 import type { PaginationProps } from "@pureadmin/table";
 import { onMounted, reactive, ref, toRaw } from "vue";
 
+interface SearchFormProps {
+  module: string;
+  username: string;
+  status: number | undefined;
+  startTime: string;
+  endTime: string;
+}
+
 export function useOperationLog() {
   const form = reactive<SearchFormProps>({
     module: "",

+ 1 - 0
haha-admin-web/src/views/system/role/form.vue

@@ -7,6 +7,7 @@ const props = withDefaults(defineProps<FormProps>(), {
   formInline: () => ({
     name: "",
     code: "",
+    status: 1,
     remark: ""
   })
 });

+ 3 - 1
haha-admin-web/src/views/system/user/utils/hook.tsx

@@ -45,9 +45,11 @@ export function useUser(tableRef: Ref, treeRef: Ref) {
   const form = reactive({
     // 左侧部门树的id
     deptId: "",
+    name: "",
     username: "",
     phone: "",
-    status: ""
+    status: "",
+    roleId: ""
   });
   const formRef = ref();
   const ruleFormRef = ref();

+ 4 - 5
haha-admin-web/src/views/timed-discount/utils/hook.tsx

@@ -612,7 +612,7 @@ export function useTimedDiscount() {
               <ElInputNumber v-model={formData.minStock} min={1} class="w-full" placeholder="低于此数量不参与优惠" />
             </ElFormItem>
             <ElFormItem label="最高库存阈值">
-              <ElInputNumber v-model={formData.maxStock} min={1} class="w-full" placeholder="高于此数量不参与优惠(空不限制)" clearable />
+              <ElInputNumber v-model={formData.maxStock} min={1} class="w-full" placeholder="高于此数量不参与优惠(空不限制)" />
             </ElFormItem>
           </div>
         </div>
@@ -859,7 +859,7 @@ export function useTimedDiscountRecord() {
   };
 }
 
-function PriceAdjustmentTable(props: { recordId: number }) {
+const PriceAdjustmentTable = (props: { recordId: number }): any => {
   const loading = ref(true);
   const dataList = ref<PriceAdjustmentLog[]>([]);
   const pagination = reactive({ currentPage: 1, pageSize: 10, total: 0 });
@@ -929,9 +929,8 @@ function PriceAdjustmentTable(props: { recordId: number }) {
     <ElTable
       data={dataList.value}
       v-loading={loading.value}
-      columns={columns}
       style={{ width: "100%" }}
-      pagination={{
+      {...{ columns, pagination: {
         currentPage: pagination.currentPage,
         pageSize: pagination.pageSize,
         total: pagination.total,
@@ -939,7 +938,7 @@ function PriceAdjustmentTable(props: { recordId: number }) {
           pagination.currentPage = val;
           loadData();
         }
-      }}
+      }}}
     />
   );
 }