Browse Source

价格策略

Signed-off-by: hsshuxian <3049816743@qq.com>
hsshuxian 8 tháng trước cách đây
mục cha
commit
944482ea08

+ 12 - 0
ems-ui-cloud/src/api/basecfg/elecAttr.js

@@ -10,6 +10,18 @@ export function listAttr(query) {
 }
 
 // 查询服务区用电属性详细
+export function getEffectiveListByArea(areaCode) {
+  return request({
+    url: '/ems/basecfg/elec/attr/getEffectiveListByArea?areaCode=' + areaCode,
+    method: 'get'
+  })
+}
+export function getEffectiveByArea(areaCode) {
+  return request({
+    url: '/ems/basecfg/elec/attr/getEffectiveByArea?areaCode=' + areaCode,
+    method: 'get'
+  })
+}
 export function getAttr(id) {
   return request({
     url: '/ems/basecfg/elec/attr/' + id,

+ 95 - 16
ems-ui-cloud/src/views/basecfg/price/index.vue

@@ -2,12 +2,27 @@
   <div class="app-container">
     <el-tabs v-model="activeTab">
       <el-tab-pane label="服务区用电" name="first">
+        <el-row :gutter="20">
+        <el-col :span="4" :xs="24">
+          <div class="head-container">
+            <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small" prefix-icon="el-icon-search"
+                      style="margin-bottom: 20px"
+            />
+          </div>
+          <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
+            <el-tree :data="treeAreaOptions" :props="defaultProps" :expand-on-click-node="false"
+                     :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
+                     @node-click="handleNodeClick" style="height: calc(100vh - 50px); overflow-y: auto;"
+            />
+          </div>
+        </el-col>
+        <el-col :span="20" :xs="24">
         <el-row :gutter="10" class="mb8">
           <el-col :span="1.5">
             <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAttrAdd" v-hasPermi="['basecfg:price:add']">新增
             </el-button>
           </el-col>
-          <right-toolbar :showSearch.sync="showSearch" :search="false" @queryTable="getAttrList"></right-toolbar>
+<!--          <right-toolbar :showSearch.sync="showSearch" :search="false" @queryTable="getAttrList"></right-toolbar>-->
         </el-row>
 
         <el-table v-loading="loading" :data="attrList">
@@ -21,24 +36,24 @@
           </el-table-column>
           <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
             <template slot-scope="scope">
-              <el-button size="mini" type="text"  icon="el-icon-edit" @click="handleAttrUpdate(scope.row)" v-hasPermi="['basecfg:price:edit']">
+              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleAttrUpdate(scope.row)" v-hasPermi="['basecfg:price:edit']" v-if="scope.row.areaCode === currentAreaCode">
                 修改</el-button>
-              <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn" @click="handleAttrDelete(scope.row)" v-hasPermi="['basecfg:price:remove']">
+              <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn" @click="handleAttrDelete(scope.row)" v-hasPermi="['basecfg:price:remove']" v-if="scope.row.areaCode === currentAreaCode">
                 删除</el-button>
-
             </template>
           </el-table-column>
         </el-table>
 
-        <pagination v-show="total>0" :total="total" :page.sync="queryAttrParams.pageNum" :limit.sync="queryAttrParams.pageSize"
-          @pagination="getAttrList" />
+          <pagination v-show="total > 0 || total === 0" :total="total || 0" :page.sync="queryAttrParams.pageNum" :limit.sync="queryAttrParams.pageSize"
+                      @pagination="refreshCurrentAreaData" />
+<!--          <pagination v-show="total>0" :total="total" :page.sync="queryAttrParams.pageNum" :limit.sync="queryAttrParams.pageSize"-->
+<!--                      @pagination="getAttrList" />-->
         <!-- 添加或修改服务区用电属性对话框 -->
         <el-dialog :title="title" :visible.sync="attrOpen" width="500px" append-to-body>
           <el-form ref="attrForm" :model="attrForm" :rules="attrRules" label-width="150px">
             <el-form-item label="园区" prop="areaCode">
-              <el-select v-model="attrForm.areaCode" :disabled="title.includes('修改')">
-                <el-option v-for="item in areaOptions" :label="item.label" :value="item.id" :key="item.id" />
-              </el-select>
+              <el-input v-model="currentAreaName" disabled placeholder="园区名称" />
+              <input type="hidden" v-model="attrForm.areaCode" />
             </el-form-item>
             <el-form-item label="价格策略" prop="priceCode">
               <el-select v-model="attrForm.priceCode">
@@ -63,7 +78,11 @@
             <el-button @click="attrCancel">取 消</el-button>
           </div>
         </el-dialog>
+        </el-col>
+        </el-row>
       </el-tab-pane>
+
+
       <el-tab-pane label="国网电价" name="second">
         <el-row :gutter="10" class="mb8">
           <el-col :span="1.5">
@@ -399,7 +418,9 @@ import {
   listCharging,
   updateCharging,
   addCharging,
-  delCharging
+  delCharging,
+  getEffectiveByArea,
+  getEffectiveListByArea
 } from '@/api/basecfg/elecAttr'
 import {
   listGwPriceConfig,
@@ -442,6 +463,19 @@ export default {
       chargingList: [],
       // 弹出层标题
       title: '',
+
+      // 区域名称
+      areaName: undefined,
+      // 区域树选项
+      treeAreaOptions: undefined,
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
+      // 当前选中的区域代码
+      currentAreaCode: null,
+       // 当前选中的区域名称
+      currentAreaName: '',
       // 是否显示弹出层
       attrOpen: false,
       gwPriceCfgOpen: false,
@@ -548,6 +582,7 @@ export default {
   },
   created() {
     this.getAreaList('0', false)
+    this.getAreaTree('0', true)
     this.getAttrList()
     this.getGwPriceList()
     this.getPvPriceList()
@@ -557,6 +592,45 @@ export default {
     this.getRelateShopList('0')
   },
   methods: {
+    /** 查询区域树结构 */
+    getAreaTree(areaCode, recursion) {
+      areaTreeSelect(areaCode, recursion).then(response => {
+        this.treeAreaOptions =  response.data
+
+        // 自动选中并触发点击第一个节点
+        if (response.data && response.data.length > 0) {
+          const firstNode = response.data[0];
+          this.$refs.tree.setCurrentKey(firstNode.id); // 设置当前选中节点
+          this.handleNodeClick(firstNode); // 触发点击事件
+        }
+      });
+    },
+    // 筛选节点
+    filterNode(value, data) {
+      if (!value) return true
+      return data.label.indexOf(value) !== -1
+    },
+    // 节点单击事件
+    handleNodeClick(data) {
+      this.currentAreaCode = data.id; // 更新当前选中的区域代码
+      this.currentAreaName = data.label; // 更新当前选中的区域名称
+      this.attrForm.areaCode = data.id; // 确保 attrForm.areaCode 被赋值
+      console.log("data",data)
+      this.refreshCurrentAreaData();
+    },
+    refreshCurrentAreaData() {
+      if (this.currentAreaCode) {
+        this.loading = true;
+        getEffectiveListByArea(this.currentAreaCode).then(res => {
+          this.attrList = res.data;
+          this.loading = false;
+        }).catch(error => {
+          console.error("Error fetching data:", error);
+          this.loading = false;
+        });
+      }
+    },
+
     formatDict(value, options, key = 'value', name = 'name') {
       let text = ''
       this[options].forEach(item => {
@@ -651,7 +725,7 @@ export default {
       this.loading = true
       listAttr(this.queryAttrParams).then(response => {
         this.attrList = response.rows
-        this.total = response.total
+        this.total = response.total !== undefined ? response.total : 0; // 提供默认值0
         this.loading = false
       })
     },
@@ -693,6 +767,7 @@ export default {
     handleAttrAdd() {
       this.attrReset()
       this.getGwPriceAll()
+      this.attrForm.areaCode = this.currentAreaCode;
       this.attrOpen = true
       this.title = '添加服务区用电属性'
     },
@@ -711,6 +786,7 @@ export default {
     submitAttrForm() {
       this.$refs['attrForm'].validate(valid => {
         if (valid) {
+          console.log("Submitting form with areaCode:", this.attrForm.areaCode);
           if(this.attrList.some(item=>item.areaCode===this.attrForm.areaCode)){
             return this.$modal.msgError('当前园区已存在')
           }
@@ -718,13 +794,15 @@ export default {
             updateAttr(this.attrForm).then(response => {
               this.$modal.msgSuccess('修改成功')
               this.attrOpen = false
-              this.getAttrList()
+              // this.getAttrList()
+              this.refreshCurrentAreaData();
             })
           } else {
             addAttr(this.attrForm).then(response => {
               this.$modal.msgSuccess('新增成功')
               this.attrOpen = false
-              this.getAttrList()
+              // this.getAttrList()
+              this.refreshCurrentAreaData();
             })
           }
         }
@@ -739,7 +817,8 @@ export default {
           return delAttr(ids)
         })
         .then(() => {
-          this.getAttrList()
+          // this.getAttrList()
+          this.refreshCurrentAreaData();
           this.$modal.msgSuccess('删除成功')
         })
         .catch(() => {})
@@ -1012,7 +1091,7 @@ export default {
     handleChargingUpdate(row) {
       this.resetForm('chargingForm')
       Object.assign(this.chargingForm, row)
-      this.chargingForm.relCoList = this.chargingForm.relCoList.map(item => item.zoningCode)
+      this.chargingForm.relCoList = this.chargingForm.relCoList.map(item => item.areaCode)
       this.getRelateShopList(this.chargingForm.areaCode)
       this.chargingDialog = true
       this.title = '修改商户计费配置'
@@ -1033,7 +1112,7 @@ export default {
     submitChargingForm() {
       this.$refs['chargingForm'].validate(valid => {
         if (valid) {
-          this.chargingForm.relCoList = this.chargingForm.relCoList.map(item => ({ priceCfgId: this.chargingForm.id, zoningCode: item }))
+          this.chargingForm.relCoList = this.chargingForm.relCoList.map(item => ({ priceCfgId: this.chargingForm.id, areaCode: item }))
           if (this.chargingForm.id) {
             updateCharging(this.chargingForm).then(() => {
               this.$modal.msgSuccess('修改成功')

+ 5 - 0
ems-ui-cloud/src/views/basecfg/tag/index.vue

@@ -61,6 +61,11 @@
 
     <el-table v-loading="loading" :data="tagList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="标签分类" align="center" prop="tagModel">
+        <template>
+
+        </template>
+      </el-table-column>
 <!--      <el-table-column label="标签分类" align="center" prop="tagModel" >-->
 <!--        <template slot-scope="scope">-->
 <!--          <span>{{ getTagModelName(scope.row.tagModel)}}</span>-->