Ver Fonte

Merge remote-tracking branch 'origin/dev' into dev

skyline há 1 ano atrás
pai
commit
6f39fcc4ae

+ 137 - 0
admin-web/src/views/admin/station/endpoint/batch.vue

@@ -0,0 +1,137 @@
+<style scoped lang="scss">
+
+</style>
+<template>
+  <div class="system-dialog-container">
+    <el-dialog
+        :title="state.dialog.title"
+        v-model="state.dialog.visible"
+        width="380px"
+        draggable
+        destroy-on-close
+        :close-on-click-modal="false"
+        align-center>
+      <el-form
+          inline
+          :model="state.ruleForm"
+          :rules="state.rules"
+          label-position="top"
+          ref="formRef"
+          size="default"
+          label-width="100px"
+          class="mt5">
+        <!--        <el-form-item label="充电桩序列号" prop="equipmentId" class="wd300">
+                  <el-input
+                      v-model="state.ruleForm.equipmentId"
+                      placeholder="充电桩序列号"
+                      clearable
+                      readonly
+                      class="w100">
+                  </el-input>
+                </el-form-item>-->
+        <el-form-item label="" prop="platformName" class="wd300">
+
+          <ext-select
+              v-model="state.ruleForm.platformName"
+              placeholder="请选择平台"
+              clearable
+              url="platform/list"
+              urlMethod="get"
+              data-key="list"
+              label-key="platformName"
+              value-key="platformName"
+              class="w100 mr10">
+          </ext-select>
+        </el-form-item>
+
+      </el-form>
+
+      <template #footer>
+				<span class="dialog-footer">
+					<el-button @click="onCancel" size="default">取 消</el-button>
+					<el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
+				</span>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup lang="ts" name="EquipmentInfoDialog">
+import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
+import {Msg} from "/@/utils/message";
+import {$body, $get} from "/@/utils/request";
+import u from '/@/utils/u'
+import ExtSelect from "/@/components/form/ExtSelect.vue";
+
+// 引入组件
+
+// 定义子组件向父组件传值/事件
+const emit = defineEmits(['refresh']);
+const formRef = ref();
+//定义初始变量,重置使用
+const initState = () => ({
+  ruleForm: {
+    equipmentIds: [],
+    platformName: '',
+  },
+  btnLoading: false,
+  dialog: {
+    visible: false,
+    type: '',
+    title: '',
+    submitTxt: '',
+  },
+  rules: {},
+  relation: {}
+})
+
+// 定义变量内容
+const state = reactive(initState());
+
+
+// 打开弹窗
+const open = ( equipmentIds: any) => {
+  state.dialog.title = "批量绑定平台"
+  state.dialog.submitTxt = "确定"
+  state.dialog.visible = true;
+  state.ruleForm.equipmentIds = equipmentIds;
+};
+// 关闭弹窗
+const onClose = () => {
+  state.dialog.visible = false;
+  Object.assign(state, initState())
+};
+// 取消
+const onCancel = () => {
+  onClose();
+};
+// 提交
+const onSubmit = () => {
+  formRef.value.validate((v: boolean) => {
+    if (v) {
+      state.btnLoading = true;
+      $body(`equipment-relation/batchBind`, state.ruleForm).then(() => {
+        state.btnLoading = false;
+        Msg.message('操作成功');
+        onClose();
+        emit('refresh');
+      })
+    } else {
+      state.btnLoading = false;
+      Msg.message('请先完整填写表单', 'error');
+    }
+  })
+};
+
+const handleFormChange = (formData: any) => {
+  console.log(formData)
+}
+
+
+// 暴露变量
+defineExpose({
+  open
+});
+
+
+</script>

+ 1 - 1
admin-web/src/views/admin/station/endpoint/dialog.vue

@@ -122,7 +122,7 @@ const onSubmit = () => {
   formRef.value.validate((v: boolean) => {
     if (v) {
       state.btnLoading = true;
-      const url = state.ruleForm.id > 0 ? "equipment-relation/modify" : "equipmentInfo/add"
+      const url = state.ruleForm.id > 0 ? "equipment-relation/bind" : "equipmentInfo/add"
       let data ={
         equipmentId:state.ruleForm.equipmentId,
         connectorId:state.ruleForm.connectorId,

+ 34 - 4
admin-web/src/views/admin/station/endpoint/index.vue

@@ -68,6 +68,10 @@
           <SvgIcon name="ele-Search"/>
           查询
         </el-button>
+        <el-button :disabled="state.checkedList.length===0" class="ml10" plain size="default"
+                   type="success" @click="handleBatchBind">
+          批量绑定平台
+        </el-button>
 
         <!--        <el-button class="ml10" plain size="default" type="success" @click="handleUploadVisible">-->
         <!--          <SvgIcon name="ele-Upload"/>-->
@@ -76,7 +80,7 @@
       </el-form>
 
       <el-table
-          border
+          ref="table_ref"
           stripe="stripe"
           :height="state.tableData.height"
           highlight-current-row
@@ -89,6 +93,7 @@
         <template #empty>
           <el-empty></el-empty>
         </template>
+        <el-table-column type="selection"  width="55" />
         <el-table-column
             v-for="field in state.tableData.columns"
             :key="field.prop"
@@ -136,6 +141,7 @@
   <!--  <EquipmentInfoDialog ref="equipmentInfoDialogRef" @refresh="loadData(true)"/>-->
   <endpoint-upload ref="endpoint_upload_ref"></endpoint-upload>
   <endpoint-dialog ref="endpoint_dialog_ref"></endpoint-dialog>
+  <EndpointBatchBindDialog ref="endpoint_batch_bind_ref" @refresh="handleBindFinish"></EndpointBatchBindDialog>
 </template>
 
 <script setup lang="ts" name="EquipmentInfoList">
@@ -153,15 +159,19 @@ import ExtDSelect from "/@/components/form/ExtDSelect.vue";
 import ExtSelect from "/@/components/form/ExtSelect.vue";
 
 import {useRouter} from "vue-router";
+import {Msg} from "/@/utils/message";
 
 const router = useRouter();
 const EndpointUpload = defineAsyncComponent(() => import("/@/views/admin/station/endpoint/upload.vue"));
 const EndpointDialog = defineAsyncComponent(() => import("/@/views/admin/station/endpoint/dialog.vue"));
+const EndpointBatchBindDialog = defineAsyncComponent(() => import("/@/views/admin/station/endpoint/batch.vue"));
 
 //定义引用
 const queryRef = ref();
 const endpoint_upload_ref = ref();
 const endpoint_dialog_ref = ref();
+const table_ref = ref();
+const endpoint_batch_bind_ref = ref();
 
 //定义变量
 const state = reactive({
@@ -197,11 +207,12 @@ const state = reactive({
       // {label: '设备生产商名称', prop: 'manufacturerName', width: 160, resizable: true},
       // {label: '设备生产日期', prop: 'productionDate', width: 160, resizable: true},
       {label: '更新时间', prop: 'updateTime', sortable: 'custom', resizable: true, width: 180},
-      {
-        label: '操作', prop: 'action', width: 120, align: 'center', fixed: 'right',
-      }
+      // {
+      //   label: '操作', prop: 'action', width: 120, align: 'center', fixed: 'right',
+      // }
     ],
   },
+  checkedList:[]
 })
 
 
@@ -241,6 +252,21 @@ const handleGotoOrder = (row: any) => {
   router.push(`/ordering?connectorId=${row.equipmentId}`)
 }
 
+const handleBatchBind = () => {
+  if(state.checkedList.length<=0){
+    return;
+  }
+  endpoint_batch_bind_ref.value?.open(state.checkedList.map(k=>k.equipmentId))
+
+}
+
+const handleBindFinish = () => {
+  state.checkedList =[];
+  table_ref.value?.clearSelection();
+  Msg.showLoading()
+  loadData(true);
+}
+
 
 // 初始化表格数据
 const loadData = (refresh: boolean = false) => {
@@ -253,8 +279,10 @@ const loadData = (refresh: boolean = false) => {
     state.tableData.data = list;
     state.pageQuery.total = total;
     state.tableData.loading = false;
+    Msg.hideLoading();
   }).catch(e => {
     console.error(e)
+    Msg.hideLoading();
     state.tableData.loading = false;
   })
 };
@@ -267,11 +295,13 @@ const handleRowClick = (type: string, row: any) => {
 const handleTableSelectionChange = (selection: any) => {
   console.log("handleTableSelectionChange>>", selection)
   // emit("on-check-change", selection)
+  state.checkedList = selection;
 }
 
 const handleTableSortChange = (column, prop, order) => {
   console.log("handleTableSortChange>>", column, prop, order)
   // emit("on-sort-change", column)
+
 }
 
 const handleUploadVisible = () => {

+ 9 - 1
admin/src/main/java/com/kym/admin/controller/EquipmentRelationController.java

@@ -5,6 +5,7 @@ import com.kym.common.R;
 import com.kym.common.controller.IController;
 import com.kym.entity.admin.EquipmentRelation;
 import com.kym.entity.admin.Platform;
+import com.kym.entity.admin.dto.BatchBindEquipmentRelation;
 import com.kym.service.admin.EquipmentRelationService;
 import jakarta.annotation.Resource;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -29,12 +30,19 @@ public class EquipmentRelationController extends IController {
     @Resource
     private EquipmentRelationService equipmentRelationService;
 
-    @PostMapping("modify")
+    @PostMapping("bind")
     R<?> modify(@RequestBody EquipmentRelation equipmentRelation) {
         return resp((t) -> equipmentRelationService.modifyRelation(equipmentRelation));
     }
 
 
+    @PostMapping("batchBind")
+    R<?> batchBind(@RequestBody BatchBindEquipmentRelation equipmentRelation) {
+        return resp((t) -> equipmentRelationService.batchBind(equipmentRelation));
+    }
+
+
+
     @GetMapping("detail/{id}")
     public R<?> detail(@PathVariable(name = "id") String equipmentId) {
         return resp(() -> equipmentRelationService.getByEquipmentId(equipmentId));

+ 11 - 0
entity/src/main/java/com/kym/entity/admin/dto/BatchBindEquipmentRelation.java

@@ -0,0 +1,11 @@
+package com.kym.entity.admin.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class BatchBindEquipmentRelation {
+    private String platformName;
+    private List<String> equipmentIds;
+}

+ 3 - 0
service/src/main/java/com/kym/service/admin/EquipmentRelationService.java

@@ -2,6 +2,7 @@ package com.kym.service.admin;
 
 import com.github.yulichang.base.MPJBaseService;
 import com.kym.entity.admin.EquipmentRelation;
+import com.kym.entity.admin.dto.BatchBindEquipmentRelation;
 
 /**
  * <p>
@@ -17,4 +18,6 @@ public interface EquipmentRelationService extends MPJBaseService<EquipmentRelati
     EquipmentRelation getByEquipmentId(String equipmentId);
 
     void modifyRelation(EquipmentRelation equipmentRelation);
+
+    void batchBind(BatchBindEquipmentRelation equipmentRelation);
 }

+ 10 - 1
service/src/main/java/com/kym/service/admin/impl/EquipmentRelationServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.admin.EquipmentRelation;
+import com.kym.entity.admin.dto.BatchBindEquipmentRelation;
 import com.kym.entity.miniapp.ChargeOrder;
 import com.kym.mapper.admin.EquipmentRelationMapper;
 import com.kym.service.admin.EquipmentRelationService;
@@ -43,7 +44,15 @@ public class EquipmentRelationServiceImpl extends MPJBaseServiceImpl<EquipmentRe
     public void modifyRelation(EquipmentRelation equipmentRelation) {
 //        CommUtil.assertsNonNull(equipmentRelation.getPlatformName(), "平台名称不能为空");
         UpdateWrapper<EquipmentRelation> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.eq("connector_id", equipmentRelation.getConnectorId());
+        updateWrapper.eq("equipment_id", equipmentRelation.getEquipmentId());
+        updateWrapper.set("platform_name", equipmentRelation.getPlatformName());
+        update(updateWrapper);
+    }
+
+    @Override
+    public void batchBind(BatchBindEquipmentRelation equipmentRelation) {
+        UpdateWrapper<EquipmentRelation> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.in("equipment_id", equipmentRelation.getEquipmentIds());
         updateWrapper.set("platform_name", equipmentRelation.getPlatformName());
         update(updateWrapper);
     }