Explorar o código

feat(third-party-equipment): 新增充电提示语编辑与导出功能

- 在第三方充电设备管理新增“编辑提示语”弹窗支持单条及批量修改充电提示语
- 实现“按站点一键修改提示语”弹窗,可批量修改指定站点下所有充电桩提示语
- 后台接口新增修改充电桩提示语接口,支持单个、批量及按站点修改
- 新增充电桩信息导出功能,支持导出包含提示语的详细设备信息Excel文件
- 前端页面优化,增加充电提示语列及相关操作按钮
- 充电设备实体类新增connectorTips字段,数据库查询语句及mapper更新支持提示语字段
- 充电桩价格同步任务调整为一分钟执行一次,提升实时性
SheepHy hai 2 días
pai
achega
da5dbbe148

+ 42 - 0
src/api/equipmentManage/third-party-equipment-info-api.ts

@@ -11,6 +11,36 @@ const ThirdPartyEquipmentInfoAPI = {
       data,
     });
   },
+
+  /**
+   * 导出充电桩信息
+   *
+   * @param params 查询参数
+   * @returns Excel文件流
+   */
+  export(params: ThirdPartyEquipmentInfoPageQuery) {
+    return request({
+      url: `${THIRDPARTYEQUIPMENTINFO_BASE_URL}/export`,
+      method: "get",
+      params,
+      responseType: "arraybuffer",
+    });
+  },
+
+  /**
+   * 修改充电桩提示语
+   *
+   * @param data 修改参数
+   * @returns 影响行数
+   */
+  updateTips(data: ConnectorTipsUpdateDTO) {
+    return request<any, number>({
+      url: `${THIRDPARTYEQUIPMENTINFO_BASE_URL}/tips/update`,
+      method: "post",
+      data,
+    });
+  },
+
   /**
    * 获取第三方充电设备信息表单数据
    *
@@ -66,6 +96,18 @@ const ThirdPartyEquipmentInfoAPI = {
 
 export default ThirdPartyEquipmentInfoAPI;
 
+/** 充电桩提示语修改参数 */
+export interface ConnectorTipsUpdateDTO {
+  /** 充电桩ID(单个修改时使用) */
+  id?: number;
+  /** 充电桩ID列表(批量修改时使用) */
+  ids?: number[];
+  /** 充电站ID(按站点批量修改时使用) */
+  stationInfoId?: number;
+  /** 充电提示语 */
+  connectorTips?: string;
+}
+
 /** 第三方充电设备信息分页查询参数 */
 export interface ThirdPartyEquipmentInfoPageQuery extends PageQuery {
   /** 设备编码 */

+ 212 - 89
src/views/equipmentManage/third-party-equipment-info/index.vue

@@ -20,19 +20,70 @@
       @filter-change="handleFilterChange"
     ></page-content>
 
-    <!-- 新增 -->
-    <page-modal
-      ref="addModalRef"
-      :modal-config="addModalConfig"
-      @submit-click="handleSubmitClick"
-    ></page-modal>
-
-    <!-- 编辑 -->
-    <page-modal
-      ref="editModalRef"
-      :modal-config="editModalConfig"
-      @submit-click="handleSubmitClick"
-    ></page-modal>
+    <!-- 编辑提示语弹窗 -->
+    <el-dialog
+      v-model="tipsDialogVisible"
+      :title="tipsDialogTitle"
+      width="500px"
+      draggable
+    >
+      <el-form :model="tipsForm" label-width="100px">
+        <el-form-item label="充电提示语">
+          <el-input
+            v-model="tipsForm.connectorTips"
+            type="textarea"
+            :rows="4"
+            maxlength="500"
+            show-word-limit
+            placeholder="请输入充电提示语,如:充电减免2小时停车费"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="tipsDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="handleTipsSubmit">确定</el-button>
+      </template>
+    </el-dialog>
+
+    <!-- 按站点一键修改弹窗 -->
+    <el-dialog
+      v-model="stationTipsDialogVisible"
+      title="按站点一键修改提示语"
+      width="500px"
+      draggable
+    >
+      <el-form :model="stationTipsForm" label-width="100px">
+        <el-form-item label="选择站点">
+          <el-select
+            v-model="stationTipsForm.stationInfoId"
+            placeholder="请选择站点"
+            filterable
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in stationOptions"
+              :key="item.id"
+              :label="item.stationName"
+              :value="item.id"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="充电提示语">
+          <el-input
+            v-model="stationTipsForm.connectorTips"
+            type="textarea"
+            :rows="4"
+            maxlength="500"
+            show-word-limit
+            placeholder="请输入充电提示语"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="stationTipsDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="handleStationTipsSubmit">确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -40,32 +91,140 @@
 defineOptions({ name: "ThirdPartyEquipmentInfo" });
 
 import ThirdPartyEquipmentInfoAPI, {
-  ThirdPartyEquipmentInfoForm,
   ThirdPartyEquipmentInfoPageQuery,
+  ConnectorTipsUpdateDTO,
 } from "@/api/equipmentManage/third-party-equipment-info-api";
-import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
+import BillingStrategyAPI from "@/api/operationsManage/billing-strategy-api";
+import type { IObject, IContentConfig, ISearchConfig } from "@/components/CURD/types";
 import usePage from "@/components/CURD/usePage";
+import { ElMessage } from "element-plus";
 
 // 组合式 CRUD
 const {
   searchRef,
   contentRef,
-  addModalRef,
-  editModalRef,
   handleQueryClick,
   handleResetClick,
   handleAddClick,
-  handleEditClick,
-  handleSubmitClick,
   handleExportClick,
   handleSearchClick,
   handleFilterChange,
 } = usePage();
 
+// 站点选项
+const stationOptions = ref<any[]>([]);
+
+// 获取站点列表
+const loadStationOptions = async () => {
+  try {
+    const data = await BillingStrategyAPI.getChargingPileSelect();
+    stationOptions.value = data || [];
+  } catch (error) {
+    console.error("获取站点列表失败", error);
+  }
+};
+
+onMounted(() => {
+  loadStationOptions();
+});
+
+// ============== 编辑提示语弹窗 ==============
+const tipsDialogVisible = ref(false);
+const tipsDialogTitle = ref("编辑提示语");
+const tipsForm = reactive<ConnectorTipsUpdateDTO>({
+  id: undefined,
+  ids: undefined,
+  connectorTips: "",
+});
+
+// 打开单个编辑弹窗
+const openEditTipsDialog = (row: any) => {
+  tipsDialogTitle.value = "编辑提示语";
+  tipsForm.id = row.id;
+  tipsForm.ids = undefined;
+  tipsForm.connectorTips = row.connectorTips || "";
+  tipsDialogVisible.value = true;
+};
+
+// 打开批量编辑弹窗
+const openBatchEditTipsDialog = () => {
+  const selectedData = contentRef.value?.getSelectionData() || [];
+  if (selectedData.length === 0) {
+    ElMessage.warning("请先选择要修改的充电桩");
+    return;
+  }
+  tipsDialogTitle.value = `批量修改提示语(已选${selectedData.length}条)`;
+  tipsForm.id = undefined;
+  tipsForm.ids = selectedData.map((item: any) => item.id);
+  tipsForm.connectorTips = "";
+  tipsDialogVisible.value = true;
+};
+
+// 提交提示语修改
+const handleTipsSubmit = async () => {
+  try {
+    await ThirdPartyEquipmentInfoAPI.updateTips(tipsForm);
+    ElMessage.success("修改成功");
+    tipsDialogVisible.value = false;
+    contentRef.value?.handleRefresh();
+  } catch (error) {
+    console.error("修改失败", error);
+  }
+};
+
+// ============== 按站点一键修改弹窗 ==============
+const stationTipsDialogVisible = ref(false);
+const stationTipsForm = reactive<ConnectorTipsUpdateDTO>({
+  stationInfoId: undefined,
+  connectorTips: "",
+});
+
+// 打开按站点修改弹窗
+const openStationTipsDialog = () => {
+  stationTipsForm.stationInfoId = undefined;
+  stationTipsForm.connectorTips = "";
+  stationTipsDialogVisible.value = true;
+};
+
+// 提交按站点修改
+const handleStationTipsSubmit = async () => {
+  if (!stationTipsForm.stationInfoId) {
+    ElMessage.warning("请选择站点");
+    return;
+  }
+  try {
+    const count = await ThirdPartyEquipmentInfoAPI.updateTips(stationTipsForm);
+    ElMessage.success(`修改成功,共更新${count}条记录`);
+    stationTipsDialogVisible.value = false;
+    contentRef.value?.handleRefresh();
+  } catch (error) {
+    console.error("修改失败", error);
+  }
+};
+
 // 搜索配置
 const searchConfig: ISearchConfig = reactive({
   permPrefix: "system:third-party-equipment-info",
   formItems: [
+    {
+      type: "select",
+      label: "所属站点",
+      prop: "stationName",
+      attrs: {
+        placeholder: "请选择站点",
+        clearable: true,
+        filterable: true,
+        style: { width: "200px" },
+      },
+      options: [],
+      async initFn(formItem) {
+        const data = await BillingStrategyAPI.getChargingPileSelect();
+        formItem.options = (data || []).map((item: any) => ({
+          label: item.stationName,
+          value: item.stationName,
+        }));
+      },
+    },
     {
       type: "input",
       label: "设备编码",
@@ -118,8 +277,24 @@ const contentConfig: IContentConfig<ThirdPartyEquipmentInfoPageQuery> = reactive
     pageSizes: [10, 20, 30, 50],
   },
   // 工具栏配置
-  toolbar: ["export"],
+  toolbar: [
+    "export",
+    {
+      name: "batchEditTips",
+      text: "批量修改提示语",
+      perm: "edit",
+      attrs: { icon: "edit", type: "warning" },
+    },
+    {
+      name: "stationEditTips",
+      text: "按站点一键修改",
+      perm: "edit",
+      attrs: { icon: "setting", type: "primary" },
+    },
+  ],
   defaultToolbar: ["refresh", "filter"],
+  // 导出接口
+  exportAction: ThirdPartyEquipmentInfoAPI.export,
   // 表格列配置
   cols: [
     { type: "selection", width: 55, align: "center" },
@@ -145,90 +320,38 @@ const contentConfig: IContentConfig<ThirdPartyEquipmentInfoPageQuery> = reactive
         return row.nationalStandard == 1 ? "2011" : "2015";
       },
     },
+    {
+      label: "充电提示语",
+      prop: "connectorTips",
+      minWidth: 150,
+      templet: "format",
+      formatter: (row: any) => {
+        return row.connectorTips || "--";
+      },
+    },
     {
       label: "操作",
       prop: "operation",
-      width: 220,
+      width: 120,
       templet: "tool",
       operat: ["edit"],
     },
   ],
 });
 
-// 新增配置
-const addModalConfig: IModalConfig<ThirdPartyEquipmentInfoForm> = reactive({
-  // 权限前缀
-  permPrefix: "system:third-party-equipment-info",
-  // 主键
-  pk: "id",
-  // 弹窗配置
-  dialog: {
-    title: "新增",
-    width: 800,
-    draggable: true,
-  },
-  form: {
-    labelWidth: 100,
-  },
-  // 表单项配置
-  formItems: [
-    {
-      type: "input",
-      attrs: {
-        placeholder: "设备编码",
-        disabled: true,
-      },
-      label: "设备编码",
-      prop: "equipmentId",
-    },
-    {
-      type: "input",
-      attrs: {
-        placeholder: "设备名称",
-        disabled: true,
-      },
-      label: "设备名称",
-      prop: "equipmentName",
-    },
-  ],
-  // 提交函数
-  formAction: (data: ThirdPartyEquipmentInfoForm) => {
-    if (data.id) {
-      // 编辑
-      return ThirdPartyEquipmentInfoAPI.update(data.id as string, data);
-    } else {
-      // 新增
-      return ThirdPartyEquipmentInfoAPI.create(data);
-    }
-  },
-});
-
-// 编辑配置
-const editModalConfig: IModalConfig<ThirdPartyEquipmentInfoForm> = reactive({
-  permPrefix: "system:third-party-equipment-info",
-  component: "drawer",
-  drawer: {
-    title: "编辑",
-    size: 500,
-  },
-  pk: "id",
-  formAction(data: any) {
-    return ThirdPartyEquipmentInfoAPI.update(data.id as string, data);
-  },
-  formItems: addModalConfig.formItems, // 复用新增的表单项
-});
-
 // 处理操作按钮点击
 const handleOperateClick = (data: IObject) => {
   if (data.name === "edit") {
-    handleEditClick(data.row, async () => {
-      return await ThirdPartyEquipmentInfoAPI.getFormData(data.row.id);
-    });
+    openEditTipsDialog(data.row);
   }
 };
 
-// 处理工具栏按钮点击(删除等)
+// 处理工具栏按钮点击
 const handleToolbarClick = (name: string) => {
-  console.log(name);
+  if (name === "batchEditTips") {
+    openBatchEditTipsDialog();
+  } else if (name === "stationEditTips") {
+    openStationTipsDialog();
+  }
 };
 </script>