Просмотр исходного кода

refactor(order): 优化订单管理页面数据处理逻辑

- 统一订单类型枚举说明,将个人订单/集团订单改为平台订单/企业订单
- 将手机号字段名从 phoneNum 统一改为 phone
- 为搜索表单添加手机号查询条件
- 优化登录页面默认账号密码为隐藏状态
- 添加空值参数过滤功能,避免无效查询参数传递
- 修复多个输入框的占位符文本和清除功能配置
- 调整表格列显示顺序并添加手机号显示字段
zouzexu 5 дней назад
Родитель
Сommit
f74e6e18a5

+ 29 - 5
src/components/CURD/usePage.ts

@@ -7,15 +7,36 @@ function usePage() {
   const addModalRef = ref<PageModalInstance>();
   const editModalRef = ref<PageModalInstance>();
 
+  // 过滤空值参数
+  function filterEmptyParams(params: IObject): IObject {
+    const filtered: IObject = {};
+    for (const key in params) {
+      const value = params[key];
+      // 过滤掉空字符串、null、undefined、空数组
+      if (value !== "" && value !== null && value !== undefined) {
+        if (Array.isArray(value)) {
+          if (value.length > 0) {
+            filtered[key] = value;
+          }
+        } else {
+          filtered[key] = value;
+        }
+      }
+    }
+    return filtered;
+  }
+
   // 搜索
   function handleQueryClick(queryParams: IObject) {
     const filterParams = contentRef.value?.getFilterParams();
-    contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true);
+    const filteredQuery = filterEmptyParams(queryParams);
+    contentRef.value?.fetchPageData({ ...filteredQuery, ...filterParams }, true);
   }
   // 重置
   function handleResetClick(queryParams: IObject) {
     const filterParams = contentRef.value?.getFilterParams();
-    contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true);
+    const filteredQuery = filterEmptyParams(queryParams);
+    contentRef.value?.fetchPageData({ ...filteredQuery, ...filterParams }, true);
   }
   // 新增
   function handleAddClick(RefImpl?: Ref<PageModalInstance>) {
@@ -67,13 +88,15 @@ function usePage() {
   function handleSubmitClick() {
     //根据检索条件刷新列表数据
     const queryParams = searchRef.value?.getQueryParams();
-    contentRef.value?.fetchPageData(queryParams, true);
+    const filteredQuery = filterEmptyParams(queryParams || {});
+    contentRef.value?.fetchPageData(filteredQuery, true);
   }
   // 导出
   function handleExportClick() {
     // 根据检索条件导出数据
     const queryParams = searchRef.value?.getQueryParams();
-    contentRef.value?.exportPageData(queryParams);
+    const filteredQuery = filterEmptyParams(queryParams || {});
+    contentRef.value?.exportPageData(filteredQuery);
   }
   // 搜索显隐
   function handleSearchClick() {
@@ -82,7 +105,8 @@ function usePage() {
   // 涮选数据
   function handleFilterChange(filterParams: IObject) {
     const queryParams = searchRef.value?.getQueryParams();
-    contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true);
+    const filteredQuery = filterEmptyParams(queryParams || {});
+    contentRef.value?.fetchPageData({ ...filteredQuery, ...filterParams }, true);
   }
 
   return {

+ 2 - 2
src/views/login/components/Login.vue

@@ -104,8 +104,8 @@ const captchaBase64 = ref();
 const rememberMe = AuthStorage.getRememberMe();
 
 const loginFormData = ref<LoginFormData>({
-  username: "root",
-  password: "123456",
+  username: "", //root
+  password: "", //123456
   captchaKey: "",
   captchaCode: "",
   rememberMe,

+ 3 - 3
src/views/orderManage/charge-order-info/index.vue

@@ -129,7 +129,7 @@ const searchConfig: ISearchConfig = reactive({
     {
       type: "custom",
       slotName: "orderType",
-      label: "订单类型", // 1 个人订单 2 集团订单
+      label: "订单类型", // 0 平台订单 1 企业订单
       prop: "orderType",
       attrs: {
         placeholder: "订单类型",
@@ -272,7 +272,7 @@ const contentConfig: IContentConfig<ChargeOrderInfoPageQuery> = reactive({
       templet: "custom",
       slotName: "stopType",
     },
-    { label: "请求启动充电的手机号", prop: "phoneNum" },
+    { label: "请求启动充电的手机号", prop: "phone" },
     {
       label: "车牌号", //( 停车减免必传,格式确保正确)
       prop: "plateNum",
@@ -453,7 +453,7 @@ const addModalConfig: IModalConfig<ChargeOrderInfoForm> = reactive({
         placeholder: "请求启动充电的手机号",
       },
       label: "请求启动充电的手机号",
-      prop: "phoneNum",
+      prop: "phone",
     },
     {
       type: "input",

+ 36 - 20
src/views/orderManage/user-order-info/index.vue

@@ -42,7 +42,11 @@
     </page-modal>
 
     <!-- 编辑 -->
-    <page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick">
+    <page-modal
+      ref="editModalRef"
+      :modal-config="editModalConfig"
+      @submit-click="handleSubmitClick"
+    >
       <template #orderStatus="scope">
         <Dict v-model="scope.formData[scope.prop]" code="order_status" v-bind="scope.attrs" />
       </template>
@@ -56,7 +60,10 @@
 <script setup lang="ts">
 defineOptions({ name: "UserOrderInfo" });
 
-import UserOrderInfoAPI, { UserOrderInfoForm, UserOrderInfoPageQuery } from "@/api/orderManage/user-order-info-api";
+import UserOrderInfoAPI, {
+  UserOrderInfoForm,
+  UserOrderInfoPageQuery,
+} from "@/api/orderManage/user-order-info-api";
 import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
 import usePage from "@/components/CURD/usePage";
 
@@ -86,7 +93,7 @@ const searchConfig: ISearchConfig = reactive({
       label: "订单状态", // 1 待支付  2 已支付 3 已取消 4 已退款
       prop: "orderStatus",
       attrs: {
-        placeholder: "订单状态",
+        placeholder: "选择订单状态",
         clearable: true,
         style: { width: "200px" },
       },
@@ -96,11 +103,21 @@ const searchConfig: ISearchConfig = reactive({
       label: "订单编号",
       prop: "orderNo",
       attrs: {
-        placeholder: "订单编号",
+        placeholder: "请输入订单编号",
         clearable: true,
         style: { width: "200px" },
       },
-    }
+    },
+    {
+      type: "input",
+      label: "手机号",
+      prop: "phone",
+      attrs: {
+        placeholder: "请输入手机号",
+        clearable: true,
+        style: { width: "200px" },
+      },
+    },
   ],
 });
 
@@ -143,23 +160,23 @@ const contentConfig: IContentConfig<UserOrderInfoPageQuery> = reactive({
     { label: "订单剩余金额", prop: "lastMoney" },
     { label: "支付时间", prop: "payTime" },
     { label: "第三方支付单号", prop: "outTradeNo" },
+    { label: "手机号", prop: "phone" },
     {
       label: "订单状态", // 1 待支付  2 已支付 3 已取消 4 已退款
       prop: "orderStatus",
       templet: "custom",
-      slotName: "orderStatus"
+      slotName: "orderStatus",
     },
     {
       label: "订单类型", //1 微信 2 第三方
       prop: "orderType",
       templet: "custom",
-      slotName: "orderType"
+      slotName: "orderType",
     },
     { label: "退款金额", prop: "refundMoney" },
     { label: "退款时间", prop: "refundTime" },
     { label: "备注", prop: "remark" },
     { label: "创建时间", prop: "createTime" },
-
   ],
 });
 
@@ -183,7 +200,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "订单编号"
+        placeholder: "订单编号",
       },
       label: "订单编号",
       prop: "orderNo",
@@ -191,7 +208,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "订单金额"
+        placeholder: "订单金额",
       },
       label: "订单金额",
       prop: "orderMoney",
@@ -199,7 +216,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "订单剩余金额"
+        placeholder: "订单剩余金额",
       },
       label: "订单剩余金额",
       prop: "lastMoney",
@@ -207,7 +224,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "支付时间"
+        placeholder: "支付时间",
       },
       label: "支付时间",
       prop: "payTime",
@@ -215,7 +232,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "第三方支付单号"
+        placeholder: "第三方支付单号",
       },
       label: "第三方支付单号",
       prop: "outTradeNo",
@@ -227,7 +244,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
       slotName: "orderStatus",
       attrs: {
         placeholder: "订单状态",
-        style: { width: "100%" }
+        style: { width: "100%" },
       },
     },
     {
@@ -237,13 +254,13 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
       slotName: "orderType",
       attrs: {
         placeholder: "订单类型",
-        style: { width: "100%" }
+        style: { width: "100%" },
       },
     },
     {
       type: "input",
       attrs: {
-        placeholder: "退款金额"
+        placeholder: "退款金额",
       },
       label: "退款金额",
       prop: "refundMoney",
@@ -251,7 +268,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "退款时间"
+        placeholder: "退款时间",
       },
       label: "退款时间",
       prop: "refundTime",
@@ -259,7 +276,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "备注"
+        placeholder: "备注",
       },
       label: "备注",
       prop: "remark",
@@ -267,7 +284,7 @@ const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
     {
       type: "input",
       attrs: {
-        placeholder: "创建时间"
+        placeholder: "创建时间",
       },
       label: "创建时间",
       prop: "createTime",
@@ -313,5 +330,4 @@ const handleOperateClick = (data: IObject) => {
 const handleToolbarClick = (name: string) => {
   console.log(name);
 };
-
 </script>