Explorar o código

feat(billing): 新增计费策略管理功能

- 修改接口地址配置,切换至新的开发环境地址
- 更新计费策略相关接口路径及参数传递方式
- 新增充电站下拉选择、企业下拉选择、渠道方下拉选择接口
- 新增获取计费策略、保存计费策略、设置提示语等接口
- 优化 PageModal 组件表单项显示控制逻辑
- 支持通过 visible 函数动态控制表单项是否可见
- 支持为表单组件绑定自定义事件处理函数
zouzexu hai 6 horas
pai
achega
42ce3d91b9

+ 2 - 2
.env.development

@@ -7,8 +7,8 @@ VITE_APP_BASE_API=/dev-api
 
 # 接口地址
 #VITE_APP_API_URL=https://api.youlai.tech # 线上
-VITE_APP_API_URL=http://192.168.0.11:8989    # 本地
-#VITE_APP_API_URL=http://192.168.0.217:8989    # 本地
+#VITE_APP_API_URL=http://192.168.0.11:8989    # 本地
+VITE_APP_API_URL=http://192.168.0.217:8989    # 本地
 
 # WebSocket 端点(不配置则关闭),线上 ws://api.youlai.tech/ws ,本地 ws://localhost:8989/ws
 VITE_APP_WS_ENDPOINT=

+ 67 - 5
src/api/operationsManage/billing-strategy-api.ts

@@ -1,25 +1,87 @@
 import request from "@/utils/request";
 
-const THIRDPARTYSTATIONINFO_BASE_URL = "/api/v1/price-policy";
+const THIRDPARTYSTATIONINFO_BASE_URL = "/api/v1/policy-fee";
 
 const BillingStrategyApi = {
   /** 获取第三方充电站信息分页数据 */
   getPage(data: ThirdPartyStationInfoForm) {
     return request<any, PageResult<ThirdPartyStationInfoPageVO[]>>({
-      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/page`,
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/getStationInfoPageByEquipment`,
       method: "post",
       data,
     });
   },
+  /**
+   * 获取充电站下拉选择信息
+   */
+  getChargingPileSelect() {
+    return request<any>({
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/getPartyStationInfo`,
+      method: "get",
+    });
+  },
+  /**
+   * 通过选择的站点获取策略信息并编辑
+   * @param stationId(站点id ) salesType(销售类型(0、平台 1、企业 2、渠道方)) thirdPartyId(销售类型为1、2时必填) firmId(企业ID(销售类型为1时必填)关联c_firm_info 企业ID(销售类型为1时必填)关联c_firm_info)
+   */
+  getBillingStrategy(stationId: any, salesType: number, thirdPartyId: number, firmId: number) {
+    return request<any, ThirdPartyStationInfoForm>({
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/getPolicyFee?stationId=${stationId}&salesType=${salesType}&thirdPartyId=${thirdPartyId}&firmId=${firmId}`,
+      method: "get",
+    });
+  },
+  /**
+   * 获取企业下拉选择信息
+   */
+  getFirmSelect() {
+    return request<any>({
+      url: `/api/v1/firmInfo/list`,
+      method: "get",
+    });
+  },
+  /**
+   * 获取渠道方下拉选择信息
+   */
+  getChannelSelect() {
+    return request<any>({
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/getPartyStationInfoList`,
+      method: "get",
+    });
+  },
+  /**
+   *新增/修改充电站信息策略信息
+   */
+  saveBillingStrategy(data: any) {
+    return request({
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/addPolicyFee`,
+      method: "post",
+      data,
+    });
+  },
+
+  /**
+   * 设置提示语
+   */
+  setTips(data: any) {
+    return request({
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/updateStationTips`,
+      method: "post",
+      data,
+    });
+  },
+
   /**
    * 获取第三方充电站信息表单数据
    *
-   * @param id 第三方充电站信息ID
+   * @param stationId 站点信息ID
+   * @param salesType 销售类型(0、平台 1、企业 2、渠道方)
+   * @param firmId 企业ID(销售类型为1时必填)关联c_firm_info
+   * @param thirdPartyId 销售类型为1、2时必填
    * @returns 第三方充电站信息表单数据
    */
-  getFormData(id: number) {
+  getFormData(stationId: any, salesType: any, firmId: any, thirdPartyId: any) {
     return request<any, ThirdPartyStationInfoForm>({
-      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/${id}/form`,
+      url: `${THIRDPARTYSTATIONINFO_BASE_URL}/getPolicyFee?stationId=${stationId}&salesType=${salesType}&firmId=${firmId}&thirdPartyId=${thirdPartyId}`,
       method: "get",
     });
   },

+ 19 - 3
src/components/CURD/PageModal.vue

@@ -10,7 +10,7 @@
         <el-form ref="formRef" v-bind="modalConfig.form" :model="formData" :rules="formRules">
           <el-row :gutter="20">
             <template v-for="item in formItems" :key="item.prop">
-              <el-col v-show="!item.hidden" v-bind="item.col">
+              <el-col v-show="isItemVisible(item)" v-bind="item.col">
                 <el-form-item :label="item.label" :prop="item.prop">
                   <!-- Label -->
                   <template #label>
@@ -75,7 +75,7 @@
           <el-scrollbar max-height="70vh" :view-style="{ overflowX: 'hidden' }">
             <el-row :gutter="20">
               <template v-for="item in formItems" :key="item.prop">
-                <el-col v-show="!item.hidden" v-bind="item.col">
+                <el-col v-show="isItemVisible(item)" v-bind="item.col">
                   <el-form-item :label="item.label" :prop="item.prop">
                     <template #label>
                       <span>
@@ -100,6 +100,7 @@
                       v-else
                       v-model.trim="formData[item.prop]"
                       v-bind="{ style: { width: '100%' }, ...item.attrs }"
+                      v-on="item.events || {}"
                     >
                       <template v-if="['select', 'radio', 'checkbox'].includes(item.type)">
                         <component
@@ -134,6 +135,7 @@
 
 <script setup lang="ts">
 import { useThrottleFn } from "@vueuse/core";
+import { computed } from "vue";
 import type { FormInstance, FormRules } from "element-plus";
 import type { IComponentType, IModalConfig, IObject } from "./types";
 import InputTag from "@/components/InputTag/index.vue";
@@ -175,11 +177,25 @@ const childrenMap = new Map<IComponentType, any>([
 const pk = props.modalConfig.pk ?? "id"; // 主键名,用于表单数据处理
 const modalVisible = ref(false); // 弹窗显示状态
 const formRef = ref<FormInstance>(); // 表单实例
-const formItems = reactive(props.modalConfig.formItems ?? []); // 表单配置项
 const formData = reactive<IObject>({}); // 表单数据
+const formItems = reactive(props.modalConfig.formItems ?? []); // 表单配置项
 const formRules: FormRules = {}; // 表单验证规则
 const formDisable = ref(false); // 表单禁用状态
 
+// 计算表单项是否可见
+const isItemVisible = (item: any) => {
+  // 如果设置了hidden为true,则隐藏
+  if (item.hidden === true) {
+    return false;
+  }
+  // 如果设置了visible函数,则根据函数返回值决定是否可见
+  if (typeof item.visible === "function") {
+    return item.visible(formData);
+  }
+  // 默认可见
+  return true;
+};
+
 // 获取tooltip提示框属性
 const getTooltipProps = (tips: string | IObject) => {
   return typeof tips === "string" ? { content: tips } : tips;

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

@@ -205,6 +205,8 @@ export type IFormItems<T = IComponentType> = Array<{
   slotName?: string;
   // 是否隐藏
   hidden?: boolean;
+  // 是否可见(函数形式)
+  visible?: (formData: IObject) => boolean;
   // layout组件Col属性
   col?: Partial<ColProps>;
   // 组件事件