Sfoglia il codice sorgente

feat: 批量转移(未完成)

xiongyubin 1 mese fa
parent
commit
8e05a478e9

+ 27 - 0
src/api/deviceCfg.js

@@ -126,3 +126,30 @@ export function apiSearchRefreshChargerGroup(data) {
   })
 }
 
+// 充电桩批量转移
+export function apiBatchChrpannelTransfer(data) {
+  return request({
+    url: '?r=chrpannel/transfer',
+    method: 'post',
+    data
+  })
+}
+
+// 根据id集合查询列表
+export function apiQueryChrpannelBydevId(data) {
+  return request({
+    url: '?r=chrpannel/list-by-dev-id-list',
+    method: 'post',
+    data
+  })
+}
+
+// 刷新二维码
+export function apiRefreshQrCode(data) {
+  return request({
+    url: '?r=chrpannel/refresh-common-code',
+    method: 'post',
+    data
+  })
+}
+

+ 20 - 3
src/views/deviceCfg/chargingPiles.vue

@@ -27,6 +27,7 @@
           <el-tooltip :disabled="!!multipleSelection.length" content="请选择充电桩" placement="top" >
             <el-button :disabled="!multipleSelection.length" type="primary" size="mini" @click="associatedChargeHandle">关联收费标准</el-button>
           </el-tooltip>
+          <el-button type="primary" size="mini" @click="batchTransferHandle">批量转移</el-button>
         </el-form-item>
         <el-form-item>
           <el-tooltip content="表格字段设置" effect="dark">
@@ -69,13 +70,16 @@
               <div v-if="isWithinThreeMonths(scope.row.platform_expire_time)"> ( 即将到期 )</div>
             </div>
           </div>
-          <div v-else-if="item.prop === 'qr_common_img'">
+          <div v-else-if="item.prop === 'qr_common_img'" style="display: flex;align-items: center;">
             <el-image
               v-if="scope.row.qr_common_img"
               :src="scope.row.qr_common_img"
               :preview-src-list="tableData.map(v => v.qr_common_img)"
               style="width: 40px; height: 40px"
             />
+            <el-tooltip content="刷新二维码" placement="top">
+              <i class="el-icon-refresh" style="cursor: pointer;margin-left: 10px;" @click="refreshQrCode(scope)" />
+            </el-tooltip>
           </div>
           <div v-else-if="item.prop === 'chrpannel_name'">
             {{ scope.row.chrpannel_name }}
@@ -129,13 +133,15 @@
       @success="getTableListFieldDefs"
     />
     <CabinetSimCredit ref="CabinetSimCredit" />
+    <BatchTransfer ref="batchTransfer" @success="queryList" />
   </div>
 </template>
 
 <script>
 import { apiQueryChargerPilesList, apiQueryChargingPiles } from '@/api/deviceCfg'
 import { apiBindDeviceForBilling, apiQueryBillingStandard } from '@/api/billingCfg'
-import { apiQueryChargerGroupList } from '@/api/deviceCfg'
+import { apiQueryChargerGroupList, apiRefreshQrCode } from '@/api/deviceCfg'
+import BatchTransfer from './components/BatchTransfer.vue'
 import EditChargingPiles from './components/EditChargingPiles.vue'
 import CabinetSimCredit from '@/components/CabinetSimCredit/index.vue'
 import LazyTree from '@/components/LazyTree'
@@ -147,7 +153,8 @@ export default {
     LazyTree,
     TableFieldCfg,
     EditChargingPiles,
-    CabinetSimCredit
+    CabinetSimCredit,
+    BatchTransfer
   },
   mixins: [tableFields],
   data() {
@@ -186,6 +193,13 @@ export default {
     this.queryChargerStation()
   },
   methods: {
+    refreshQrCode({ row, $index }) {
+      apiRefreshQrCode({ dev_id: row.dev_id }).then(res => {
+        if (res.succeed) {
+          console.log(111, res)
+        }
+      })
+    },
     linkToRateCfg(row) {
       this.$router.push(`/edit-rateCfg?sn=${row.billing_standard_sn}`)
     },
@@ -216,6 +230,9 @@ export default {
       this.associatedChargeDialog = true
       this.queryBillingStandardList()
     },
+    batchTransferHandle() {
+      this.$refs.batchTransfer.open()
+    },
     queryBillingStandardList() {
       apiQueryBillingStandard({ limit: 500 }).then(res => {
         this.billingStandardList = res.body.list

+ 146 - 0
src/views/deviceCfg/components/BatchTransfer.vue

@@ -0,0 +1,146 @@
+<template>
+  <el-dialog
+    :modal-append-to-body="false"
+    :visible.sync="visible"
+    title="批量转移"
+    @close="closeDialog"
+  >
+    <main>
+      <el-form ref="form" :model="form" :rules="rules">
+        <el-form-item label="转移门店" prop="shop_id">
+          <lazy-tree
+            ref="addTree"
+            :tree="form.shop_name"
+            input-width="400px"
+            is-gap
+            @handleSelectGroup="selectGroup"
+          />
+        </el-form-item>
+        <el-form-item label="转移充电站" prop="group_id">
+          <el-select
+            v-model="form.group_id"
+            filterable
+            clearable
+            placeholder="充电站"
+            size="mini"
+            @change="changeGroup"
+          >
+            <el-option
+              v-for="item in chargeStationList"
+              :key="item.group_id"
+              :label="item.group_name"
+              :value="item.group_id"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="新增转移充电桩" prop="dev_id_list">
+          <el-input
+            :rows="5"
+            v-model="form.dev_id_list"
+            type="textarea"
+            placeholder="一行一个编号"
+            style="width: 50%;"
+            mini="size"
+            @input="changeDevId"
+          />
+        </el-form-item>
+      </el-form>
+      <el-table v-if="form.dev_id_list && chrpannelList.length" :data="chrpannelList">
+        <el-table-column label="充电桩名称" prop="chrpannel_name" />
+        <el-table-column label="充电桩编号" prop="dev_id" />
+        <el-table-column label="门店" prop="shop_name" />
+        <el-table-column label="充电站名称" prop="group_name" />
+      </el-table>
+    </main>
+    <div slot="footer">
+      <el-button type="info" @click="closeDialog">取 消</el-button>
+      <el-button type="primary" @click="submit">保 存</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import LazyTree from '@/components/LazyTree'
+import { apiQueryChargerGroupList, apiBatchChrpannelTransfer, apiQueryChrpannelBydevId } from '@/api/deviceCfg'
+export default {
+  components: {
+    LazyTree
+  },
+  data() {
+    return {
+      form: {},
+      visible: false,
+      chargeStationList: [],
+      chrpannelList: [],
+      rules: {
+        shop_id: [{ required: true, message: '请选择门店', trigger: 'blur' }],
+        group_id: [{ required: true, message: '请选择转移充电站', trigger: 'blur' }],
+        dev_id_list: [{ required: true, message: '请输入转移充电桩编号', trigger: 'blur' }]
+      }
+    }
+  },
+  methods: {
+    open() {
+      const data = { ...this.$options.data() }
+      delete data.rules
+      Object.assign(this.$data, data)
+      this.visible = true
+    },
+    queryChargerStationByShop(shop_id) {
+      apiQueryChargerGroupList({ shop_id, limit: 998 }).then(res => {
+        if (res.succeed) {
+          this.chargeStationList = res.body.list || []
+        }
+      })
+    },
+    selectGroup(group) {
+      this.$set(this.form, 'shop_name', group.shop_name)
+      this.$set(this.form, 'shop_id', group.shop_id)
+      this.queryChargerStationByShop(group.shop_id)
+    },
+    closeDialog() {
+      this.visible = false
+    },
+    changeGroup(val) {
+      const obj = this.chargeStationList.find(item => item.group_id === val)
+      if (obj) {
+        this.$set(this.form, 'groupName', obj.group_name)
+      }
+    },
+    changeDevId(str) {
+      const dev_id_list = str.split('\n')
+      this.queryChrpannelBydevId(dev_id_list)
+    },
+    queryChrpannelBydevId(dev_id_list) {
+      apiQueryChrpannelBydevId({ dev_id_list }).then(res => {
+        if (res.succeed) {
+          this.chrpannelList = res.body.list
+        }
+      })
+    },
+    submit() {
+      this.$refs.form.validate(valid => {
+        if (!valid) return
+        const form = { ...this.form }
+        const len = this.chrpannelList.length
+        this.$confirm(`是否确定将这 ${len} 个充电桩转移到【${form.shop_name}】门店下的【${form.groupName}】充电站`, '充电桩转移确认', {
+          type: 'warning'
+        }).then(() => {
+          apiBatchChrpannelTransfer(form).then(res => {
+            if (res.succeed) {
+              this.$message({
+                type: 'success',
+                message: '转移成功'
+              })
+              this.closeDialog()
+              this.$emit('success')
+            } else {
+              this.$message({ type: 'error', message: res.data.msg })
+            }
+          })
+        })
+      })
+    }
+  }
+}
+</script>