能源2-1
This commit is contained in:
		@@ -0,0 +1,37 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="tableInner">
 | 
			
		||||
    <el-input-number v-model="list[itemProp]" @blur="changeInput" :min="0" :max="100000000" style="width: 100%" :controls='false'></el-input-number>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'InputArea',
 | 
			
		||||
  props: {
 | 
			
		||||
    injectData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    },
 | 
			
		||||
    itemProp: {
 | 
			
		||||
      type: String
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      list: this.injectData
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    changeInput() {
 | 
			
		||||
      console.log(this.list)
 | 
			
		||||
      this.$emit('emitData', this.list)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss">
 | 
			
		||||
.tableInner .el-input__inner {
 | 
			
		||||
  border: none;
 | 
			
		||||
  padding: 0;
 | 
			
		||||
  height: 33px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="tableInner">
 | 
			
		||||
    <el-time-picker
 | 
			
		||||
      v-model="list[itemProp]"
 | 
			
		||||
      @blur="changeInput"
 | 
			
		||||
      style="width: 100%"
 | 
			
		||||
      format='HH:mm:ss'
 | 
			
		||||
      value-format='HH:mm:ss'
 | 
			
		||||
    ></el-time-picker>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'TimePickerArea',
 | 
			
		||||
  props: {
 | 
			
		||||
    injectData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    },
 | 
			
		||||
    itemProp: {
 | 
			
		||||
      type: String
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      list: this.injectData
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    changeInput() {
 | 
			
		||||
      console.log(this.list)
 | 
			
		||||
      this.$emit('emitData', this.list)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss">
 | 
			
		||||
.tableInner .el-input--prefix .el-input__inner {
 | 
			
		||||
  border: none;
 | 
			
		||||
  padding-left: 30px;
 | 
			
		||||
  height: 33px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,250 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="110px" :model="form">
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="监控对象" prop="objectId">
 | 
			
		||||
          <el-cascader
 | 
			
		||||
            style='width: 100%;'
 | 
			
		||||
            v-model="objIds"
 | 
			
		||||
            :options="objList"
 | 
			
		||||
            :props="{ checkStrictly: true, value: 'id', label: 'name' }"
 | 
			
		||||
            popper-class="cascaderParent"
 | 
			
		||||
            @change="selectObj"
 | 
			
		||||
            clearable></el-cascader>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="能源类型" prop="energyTypeId">
 | 
			
		||||
          <el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" filterable @change="toggleType">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in this.energyTypeList"
 | 
			
		||||
              :key="item.id"
 | 
			
		||||
              :label="item.name"
 | 
			
		||||
              :value="item.id">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="指标类型" prop="limitType">
 | 
			
		||||
          <el-select v-model="form.limitType" placeholder="请选择" style="width: 100%;">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in getDictDatas(DICT_TYPE.MONITOR_INDEX_TYPE)"
 | 
			
		||||
              :key="item.value"
 | 
			
		||||
              :label="item.label"
 | 
			
		||||
              :value="item.value">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="监控模式" prop="type">
 | 
			
		||||
          <el-select v-model="form.type" placeholder="请选择" style="width: 100%;" @change="typeChange">
 | 
			
		||||
            <el-option label="合并" :value= "1" ></el-option>
 | 
			
		||||
            <el-option label="详细" :value= "2" ></el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="消耗量阈值">
 | 
			
		||||
          <el-input-number v-model="form.minValue" placeholder="最小值" :max="9999999" style="width: 50%;"></el-input-number>
 | 
			
		||||
          <el-input-number v-model="form.maxValue" placeholder="最大值" :max="9999999" style="width: 50%;"></el-input-number>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="监控详细参数" prop="type" v-if="form.type === 2">
 | 
			
		||||
          <el-select v-model="form.plcParamId" placeholder="请选择" style="width: 100%;" @change="selectDetail">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in detailList"
 | 
			
		||||
              :key="item.id"
 | 
			
		||||
              :label="item.name"
 | 
			
		||||
              :value="item.id">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyLimit, updateEnergyLimit, createEnergyLimit, getEnergyParamList } from '@/api/monitoring/energyLimit'
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'energyLimitAdd',
 | 
			
		||||
  props: {
 | 
			
		||||
    energyTypeList: {
 | 
			
		||||
      type: Array,
 | 
			
		||||
      required: true,
 | 
			
		||||
      default: () => {
 | 
			
		||||
        return []
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    objList: {
 | 
			
		||||
      type: Array,
 | 
			
		||||
      default: () => []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        objectId: '',
 | 
			
		||||
        objectType: '',
 | 
			
		||||
        energyTypeId: '',
 | 
			
		||||
        type: '',
 | 
			
		||||
        plcParamId: '',
 | 
			
		||||
        limitType: '',
 | 
			
		||||
        minValue: null,
 | 
			
		||||
        maxValue: null
 | 
			
		||||
      },
 | 
			
		||||
      objIds: [],// 回显数组
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        objectId: [{ required: true, message: '对象不能为空', trigger: 'change' }],
 | 
			
		||||
        energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }],
 | 
			
		||||
        type: [{ required: true, message: '监控模式不能为空', trigger: 'change' }],
 | 
			
		||||
        limitType: [{ required: true, message: '指标类型不能为空', trigger: 'change' }]
 | 
			
		||||
      },
 | 
			
		||||
      detailList: []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(id) {
 | 
			
		||||
      if (id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = id
 | 
			
		||||
        getEnergyLimit( id ).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            this.form.plcParamId = res.data.plcParamId || ''
 | 
			
		||||
            this.form.limitType = this.form.limitType ? this.form.limitType + '' : ''
 | 
			
		||||
            this.objIds = this.changeDetSelect(this.form.objectId, this.objList)
 | 
			
		||||
            if (this.form.type === 2) {
 | 
			
		||||
              this.getDetailList()
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 监控详细参数
 | 
			
		||||
    getDetailList() {
 | 
			
		||||
      getEnergyParamList({
 | 
			
		||||
        objId: this.form.objectId,
 | 
			
		||||
        energyTypeId: this.form.energyTypeId
 | 
			
		||||
      }).then((res) => {
 | 
			
		||||
        if (res.code === 0) {
 | 
			
		||||
          this.detailList = res.data
 | 
			
		||||
        } else {
 | 
			
		||||
          this.detailList = []
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    typeChange(val) {
 | 
			
		||||
      console.log(this.form)
 | 
			
		||||
      this.form.plcParamId = ''
 | 
			
		||||
      if (val === 2) {
 | 
			
		||||
        if (this.form.objectId && this.form.energyTypeId) {
 | 
			
		||||
          this.getDetailList()
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    toggleType() {
 | 
			
		||||
      if (this.form.energyTypeId && this.form.type) {
 | 
			
		||||
        this.getDetailList()
 | 
			
		||||
        this.form.plcParamId = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 递归处理分类回显问题
 | 
			
		||||
    changeDetSelect(key, treeData) {
 | 
			
		||||
      let arr = [] // 递归时操作的数组
 | 
			
		||||
      let returnArr = [] // 存放结果的数组
 | 
			
		||||
      let depth = 0 // 定义全局层级
 | 
			
		||||
      // 定义递归函数
 | 
			
		||||
      function childrenEach(childrendData, depthN) {
 | 
			
		||||
        for (var j = 0; j < childrendData.length; j++) {
 | 
			
		||||
          depth = depthN
 | 
			
		||||
          arr[depthN] = childrendData[j].id
 | 
			
		||||
          if (childrendData[j].id == key) {
 | 
			
		||||
            returnArr = arr.slice(0, depthN + 1)
 | 
			
		||||
            break
 | 
			
		||||
          } else {
 | 
			
		||||
            if (childrendData[j].children) {
 | 
			
		||||
              depth++
 | 
			
		||||
              childrenEach(childrendData[j].children, depth)
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        return returnArr
 | 
			
		||||
      }
 | 
			
		||||
      return childrenEach(treeData, depth)
 | 
			
		||||
    },
 | 
			
		||||
    selectObj(val) {
 | 
			
		||||
      this.form.objectId = val[val.length-1]
 | 
			
		||||
      this.form.objectType = val.length-1
 | 
			
		||||
      if (this.form.energyTypeId && this.form.type) {
 | 
			
		||||
        this.getDetailList()
 | 
			
		||||
        this.form.plcParamId = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    selectDetail() {
 | 
			
		||||
      this.$forceUpdate()
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          if (this.form.type === 2 && !this.form.plcParamId) {
 | 
			
		||||
            this.$modal.msgError("监控模式为详细时,详细参数为必填");
 | 
			
		||||
            return false
 | 
			
		||||
          }
 | 
			
		||||
          if (this.form.minValue && this.form.maxValue) {
 | 
			
		||||
            if (this.form.minValue > this.form.maxValue) {
 | 
			
		||||
              this.$modal.msgError("消耗量阈值,最小值不能大于最大值");
 | 
			
		||||
              return false
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          // this.form.limitType = Number(this.form.limitType)
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyLimit({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyLimit({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.$refs.form.resetFields()
 | 
			
		||||
      this.form.type = ''
 | 
			
		||||
      this.form.plcParamId = ''
 | 
			
		||||
      this.form.minValue = null
 | 
			
		||||
      this.form.maxValue = null
 | 
			
		||||
      this.objIds = ''
 | 
			
		||||
      this.detailList = []
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style>
 | 
			
		||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
 | 
			
		||||
  display: none;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
							
								
								
									
										259
									
								
								src/views/devConfig/energy/energyLimit/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										259
									
								
								src/views/devConfig/energy/energyLimit/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,259 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
 | 
			
		||||
    <!-- 搜索工作栏 -->
 | 
			
		||||
    <search-bar
 | 
			
		||||
      :formConfigs="formConfig"
 | 
			
		||||
      ref="searchBarForm"
 | 
			
		||||
      @headBtnClick="buttonClick"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 列表 -->
 | 
			
		||||
    <base-table
 | 
			
		||||
      :page="queryParams.pageNo"
 | 
			
		||||
      :limit="queryParams.pageSize"
 | 
			
		||||
      :table-props="tableProps"
 | 
			
		||||
      :table-data="list"
 | 
			
		||||
      :max-height="tableH"
 | 
			
		||||
    >
 | 
			
		||||
      <method-btn
 | 
			
		||||
        v-if="tableBtn.length"
 | 
			
		||||
        slot="handleBtn"
 | 
			
		||||
        :width="80"
 | 
			
		||||
        label="操作"
 | 
			
		||||
        :method-list="tableBtn"
 | 
			
		||||
        @clickBtn="handleClick"
 | 
			
		||||
      />
 | 
			
		||||
    </base-table>
 | 
			
		||||
    <pagination
 | 
			
		||||
      :page.sync="queryParams.pageNo"
 | 
			
		||||
      :limit.sync="queryParams.pageSize"
 | 
			
		||||
      :total="total"
 | 
			
		||||
      @pagination="getList"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
      width='50%'
 | 
			
		||||
    >
 | 
			
		||||
      <energy-limit-add ref="energyLimit" @successSubmit="successSubmit" :energyTypeList="energyTypeList" :objList="objList"/>
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyLimitPage, deleteEnergyLimit } from "@/api/monitoring/energyLimit";
 | 
			
		||||
import { getEnergyTypeListAll } from "@/api/base/energyType";
 | 
			
		||||
import { getTree } from '@/api/base/factory'
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
import EnergyLimitAdd from './components/energyLimitAdd'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objName',
 | 
			
		||||
    label: '监控对象'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objCode',
 | 
			
		||||
    label: '对象编码'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'energyType',
 | 
			
		||||
    label: '能源类型'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'type',
 | 
			
		||||
    label: '监控模式',
 | 
			
		||||
    filter: (val) => (val != null ? ['合并', '详细'][val-1] : '-'),
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'plcParamName',
 | 
			
		||||
    label: '监控参数'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'limitType',
 | 
			
		||||
    label: '指标类型',
 | 
			
		||||
    filter: publicFormatter('monitor_index_type')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'limitValue',
 | 
			
		||||
    label: '阈值'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: "EnergyLimit",
 | 
			
		||||
  components: { EnergyLimitAdd },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'select',
 | 
			
		||||
          label: '能源类型',
 | 
			
		||||
          selectOptions: [],
 | 
			
		||||
          param: 'energyTypeId'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'select',
 | 
			
		||||
          label: '指标类型',
 | 
			
		||||
          selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE),
 | 
			
		||||
          labelField: 'label',
 | 
			
		||||
          valueField: 'value',
 | 
			
		||||
          param: 'limitType'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'separate'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('monitoring:energy-limit:create') ? 'button' : '',
 | 
			
		||||
          btnName: '新增',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'success',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        this.$auth.hasPermi('monitoring:energy-limit:update')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'edit',
 | 
			
		||||
              btnName: '编辑'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        this.$auth.hasPermi('monitoring:energy-limit:delete')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'delete',
 | 
			
		||||
              btnName: '删除'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined
 | 
			
		||||
      ].filter((v) => v),
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 班次基础信息列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        energyTypeId: null,
 | 
			
		||||
        limitType: null
 | 
			
		||||
      },
 | 
			
		||||
      energyTypeList: [],
 | 
			
		||||
      typeList: [
 | 
			
		||||
        {label: '合并', value: '1'},
 | 
			
		||||
        {label: '详细', value: '2'}
 | 
			
		||||
      ],
 | 
			
		||||
      objList: []
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(260)
 | 
			
		||||
    })
 | 
			
		||||
    this.getList();
 | 
			
		||||
    this.getTypeList()
 | 
			
		||||
    // 获取对象树形结构
 | 
			
		||||
    this.getObjTree()
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    getTypeList() {
 | 
			
		||||
      getEnergyTypeListAll().then((res) => {
 | 
			
		||||
        this.formConfig[0].selectOptions = res.data || []
 | 
			
		||||
        this.energyTypeList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.energyTypeId = val.energyTypeId
 | 
			
		||||
          this.queryParams.limitType = val.limitType
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.addOrEditTitle = '新增'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyLimit.init()
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 查询列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyLimitPage(this.queryParams).then(response => {
 | 
			
		||||
        let arr = response.data.list || [];
 | 
			
		||||
        arr&&arr.map(item => {
 | 
			
		||||
          this.typeList.map(i => {
 | 
			
		||||
            if (item.type === i.value) {
 | 
			
		||||
              item.type = i.label
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
          if (item.minValue && item.maxValue) {
 | 
			
		||||
            item.limitValue = item.minValue + '-' + item.maxValue
 | 
			
		||||
          } else if(item.minValue){
 | 
			
		||||
            item.limitValue = '最小值' + item.minValue
 | 
			
		||||
          }else if(item.maxValue){
 | 
			
		||||
            item.limitValue = '最大值' + item.maxValue
 | 
			
		||||
          } else {
 | 
			
		||||
            item.limitValue = ''
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        this.list = arr
 | 
			
		||||
        this.total = response.data.total;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyLimit.init(val.data.id)
 | 
			
		||||
          })
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
        this.handleDelete(val.data)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyLimit.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyLimit.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除监控对象为"' + row.objName + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyLimit(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    },
 | 
			
		||||
    getObjTree() {
 | 
			
		||||
      getTree().then(res => {
 | 
			
		||||
        this.objList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										114
									
								
								src/views/devConfig/energy/energyPlc/components/energyPlcAdd.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								src/views/devConfig/energy/energyPlc/components/energyPlcAdd.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="100px" :model="form">
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="关联表名" prop="plcTableName">
 | 
			
		||||
          <el-input v-model="form.plcTableName"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="关联表编码" prop="code">
 | 
			
		||||
          <el-input v-model="form.code" disabled></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="标识名" prop="name">
 | 
			
		||||
          <el-input v-model="form.name"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="英文标识名" prop="enName">
 | 
			
		||||
          <el-input v-model="form.enName"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="是否采集" prop="collection">
 | 
			
		||||
          <el-switch v-model="form.collection"></el-switch>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="描述" prop="description">
 | 
			
		||||
          <el-input v-model="form.description"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlc, updateEnergyPlc, createEnergyPlc, getCode } from '@/api/base/energyPlc'
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'energyPlcAdd',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        plcTableName: '',
 | 
			
		||||
        code: '',
 | 
			
		||||
        name: '',
 | 
			
		||||
        enName: '',
 | 
			
		||||
        description: '',
 | 
			
		||||
        collection: true
 | 
			
		||||
      },
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        plcTableName: [{ required: true, message: '关联表名不能为空', trigger: 'blur' }],
 | 
			
		||||
        code: [{ required: true, message: '关联表编码不能为空', trigger: 'blur' }],
 | 
			
		||||
        name: [{ required: true, message: '标识名称不能为空', trigger: 'blur' }]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(id) {
 | 
			
		||||
      if (id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = id
 | 
			
		||||
        getEnergyPlc( id ).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            this.form.collection = this.form.collection === 0 ? false : true
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
        getCode().then((res) => {
 | 
			
		||||
          this.form.code = res.data
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          this.form.collection = this.form.collection === false ? 0 : 1
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyPlc({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyPlc({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.$refs.form.resetFields()
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										218
									
								
								src/views/devConfig/energy/energyPlc/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										218
									
								
								src/views/devConfig/energy/energyPlc/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,218 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
 | 
			
		||||
    <!-- 搜索工作栏 -->
 | 
			
		||||
    <search-bar
 | 
			
		||||
      :formConfigs="formConfig"
 | 
			
		||||
      ref="searchBarForm"
 | 
			
		||||
      @headBtnClick="buttonClick"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 列表 -->
 | 
			
		||||
    <base-table
 | 
			
		||||
      :page="queryParams.pageNo"
 | 
			
		||||
      :limit="queryParams.pageSize"
 | 
			
		||||
      :table-props="tableProps"
 | 
			
		||||
      :table-data="list"
 | 
			
		||||
      :max-height="tableH"
 | 
			
		||||
    >
 | 
			
		||||
      <method-btn
 | 
			
		||||
        v-if="tableBtn.length"
 | 
			
		||||
        slot="handleBtn"
 | 
			
		||||
        :width="80"
 | 
			
		||||
        label="操作"
 | 
			
		||||
        :method-list="tableBtn"
 | 
			
		||||
        @clickBtn="handleClick"
 | 
			
		||||
      />
 | 
			
		||||
    </base-table>
 | 
			
		||||
    <pagination
 | 
			
		||||
      :page.sync="queryParams.pageNo"
 | 
			
		||||
      :limit.sync="queryParams.pageSize"
 | 
			
		||||
      :total="total"
 | 
			
		||||
      @pagination="getList"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
    >
 | 
			
		||||
      <energy-plc-add ref="energyPlc" @successSubmit="successSubmit" />
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlcPage, deleteEnergyPlc } from "@/api/base/energyPlc";
 | 
			
		||||
// import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
import EnergyPlcAdd from './components/energyPlcAdd.vue'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'plcTableName',
 | 
			
		||||
    label: '关联表名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'code',
 | 
			
		||||
    label: '关联表编码',
 | 
			
		||||
    minWidth: 150,
 | 
			
		||||
    showOverflowtooltip: true
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'name',
 | 
			
		||||
    label: '标识名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'enName',
 | 
			
		||||
    label: '英文标识名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'collection',
 | 
			
		||||
    label: '是否采集'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'description',
 | 
			
		||||
    label: '描述',
 | 
			
		||||
    showOverflowtooltip: true
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: "EnergyPlc",
 | 
			
		||||
  components: { EnergyPlcAdd },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'input',
 | 
			
		||||
          label: '标识名',
 | 
			
		||||
          placeholder: '标识名',
 | 
			
		||||
          param: 'name'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'separate'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('base:energy-plc:create') ? 'button' : '',
 | 
			
		||||
          btnName: '新增',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'success',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        this.$auth.hasPermi('base:energy-plc:update')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'edit',
 | 
			
		||||
              btnName: '编辑'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        this.$auth.hasPermi('base:energy-plc:delete')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'delete',
 | 
			
		||||
              btnName: '删除'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined
 | 
			
		||||
      ].filter((v) => v),
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      collectionList: [
 | 
			
		||||
        {value: 0,label: '否'},
 | 
			
		||||
        {value: 1,label: '是'}
 | 
			
		||||
      ],
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 班次基础信息列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        name: null
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(260)
 | 
			
		||||
    })
 | 
			
		||||
    this.getList();
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.name = val.name
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.addOrEditTitle = '新增'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyPlc.init()
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 查询列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyPlcPage(this.queryParams).then(response => {
 | 
			
		||||
        let arr = response.data.list || [];
 | 
			
		||||
        arr&&arr.map(item => {
 | 
			
		||||
          this.collectionList.map(i => {
 | 
			
		||||
            if (item.collection === i.value) {
 | 
			
		||||
              item.collection = i.label
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        })
 | 
			
		||||
        this.list = arr
 | 
			
		||||
        this.total = response.data.total;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyPlc.init(val.data.id)
 | 
			
		||||
          })
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
        this.handleDelete(val.data)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyPlc.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyPlc.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除关联表名为"' + row.name + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyPlc(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
@@ -0,0 +1,139 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="100px" :model="form">
 | 
			
		||||
    <el-form-item label="关联表名" prop="plcId">
 | 
			
		||||
      <el-select v-model="form.plcId" placeholder="请选择" style="width: 100%;" filterable>
 | 
			
		||||
        <el-option
 | 
			
		||||
          v-for="item in plcList"
 | 
			
		||||
          :key="item.id"
 | 
			
		||||
          :label="item.plcTableName"
 | 
			
		||||
          :value="item.id">
 | 
			
		||||
        </el-option>
 | 
			
		||||
      </el-select>
 | 
			
		||||
    </el-form-item>
 | 
			
		||||
    <el-form-item label="对象" prop="bindObjectId">
 | 
			
		||||
      <el-cascader
 | 
			
		||||
        style='width: 100%;'
 | 
			
		||||
        v-model="objIds"
 | 
			
		||||
        :options="objList"
 | 
			
		||||
        :props="{ checkStrictly: true, value: 'id', label: 'name' }"
 | 
			
		||||
        popper-class="cascaderParent"
 | 
			
		||||
        @change="selectObj"
 | 
			
		||||
        clearable></el-cascader>
 | 
			
		||||
    </el-form-item>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlcConnect, updateEnergyPlcConnect, createEnergyPlcConnect } from '@/api/base/energyPlcConnect'
 | 
			
		||||
import { getEnergyPlcAll } from '@/api/base/energyPlc'
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyPlcConnectAdd',
 | 
			
		||||
  props: {
 | 
			
		||||
    objList: {
 | 
			
		||||
      type: Array,
 | 
			
		||||
      default: () => []
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        plcId: '',
 | 
			
		||||
        bindObjectId: '',
 | 
			
		||||
        bindObjectType: ''
 | 
			
		||||
      },
 | 
			
		||||
      objIds: [],// 回显数组
 | 
			
		||||
      plcList: [],
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        plcId: [{ required: true, message: '关联表名不能为空', trigger: 'change' }],
 | 
			
		||||
        bindObjectId: [{ required: true, message: '对象不能为空', trigger: 'change' }]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(id) {
 | 
			
		||||
      getEnergyPlcAll().then((res) => {
 | 
			
		||||
        this.plcList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
      if (id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = id
 | 
			
		||||
        getEnergyPlcConnect( id ).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            this.objIds = this.changeDetSelect(this.form.bindObjectId, this.objList)
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 递归处理分类回显问题
 | 
			
		||||
    changeDetSelect(key, treeData) {
 | 
			
		||||
      let arr = [] // 递归时操作的数组
 | 
			
		||||
      let returnArr = [] // 存放结果的数组
 | 
			
		||||
      let depth = 0 // 定义全局层级
 | 
			
		||||
      // 定义递归函数
 | 
			
		||||
      function childrenEach(childrendData, depthN) {
 | 
			
		||||
        for (var j = 0; j < childrendData.length; j++) {
 | 
			
		||||
          depth = depthN
 | 
			
		||||
          arr[depthN] = childrendData[j].id
 | 
			
		||||
          if (childrendData[j].id == key) {
 | 
			
		||||
            returnArr = arr.slice(0, depthN + 1)
 | 
			
		||||
            break
 | 
			
		||||
          } else {
 | 
			
		||||
            if (childrendData[j].children) {
 | 
			
		||||
              depth++
 | 
			
		||||
              childrenEach(childrendData[j].children, depth)
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        return returnArr
 | 
			
		||||
      }
 | 
			
		||||
      return childrenEach(treeData, depth)
 | 
			
		||||
    },
 | 
			
		||||
    selectObj(val) {
 | 
			
		||||
      this.form.bindObjectId = val[val.length-1]
 | 
			
		||||
      this.form.bindObjectType = val.length-1
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyPlcConnect({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyPlcConnect({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.form.id = ''
 | 
			
		||||
      this.form.plcId = ''
 | 
			
		||||
      this.form.bindObjectId = ''
 | 
			
		||||
      this.form.bindObjectType = ''
 | 
			
		||||
      this.objIds = []
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style>
 | 
			
		||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
 | 
			
		||||
  display: none;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,226 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <el-drawer :title="drawerTitle" :visible.sync="visible" size="70%" @close='closeD' :show-close='false'>
 | 
			
		||||
      <div class="box">
 | 
			
		||||
        <el-form :inline="true">
 | 
			
		||||
          <el-form-item label="关联表名">
 | 
			
		||||
            <el-input v-model="plcTableName" size='small' readonly></el-input>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
          <el-form-item label="对象">
 | 
			
		||||
            <el-input v-model="objName" size='small' readonly></el-input>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
          <el-form-item v-if="showBtn">
 | 
			
		||||
            <el-button type="success" size='small' plain @click="addNew">新增</el-button>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
        </el-form>
 | 
			
		||||
        <base-table
 | 
			
		||||
          :page="queryParams.pageNo"
 | 
			
		||||
          :limit="queryParams.pageSize"
 | 
			
		||||
          :table-props="tableProps"
 | 
			
		||||
          :table-data="tableData"
 | 
			
		||||
          :max-height="tableH"
 | 
			
		||||
        >
 | 
			
		||||
          <method-btn
 | 
			
		||||
            v-if="tableBtn.length"
 | 
			
		||||
            slot="handleBtn"
 | 
			
		||||
            :width="100"
 | 
			
		||||
            label="操作"
 | 
			
		||||
            :method-list="tableBtn"
 | 
			
		||||
            @clickBtn="handleClick"
 | 
			
		||||
          />
 | 
			
		||||
        </base-table>
 | 
			
		||||
        <pagination
 | 
			
		||||
          :page.sync="queryParams.pageNo"
 | 
			
		||||
          :limit.sync="queryParams.pageSize"
 | 
			
		||||
          :total="total"
 | 
			
		||||
          @pagination="getList"
 | 
			
		||||
        />
 | 
			
		||||
      </div>
 | 
			
		||||
    </el-drawer>
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
    >
 | 
			
		||||
      <energy-plc-param-add ref="energyPlcParam" @successSubmit="successSubmit" />
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlcParamPage, deleteEnergyPlcParam } from '@/api/base/energyPlcParam'
 | 
			
		||||
import EnergyPlcParamAdd from './energyPlcParamAdd'
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'typeId',
 | 
			
		||||
    label: '能源类型'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'plcParamName',
 | 
			
		||||
    label: '参数列名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'name',
 | 
			
		||||
    label: '参数名称'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'unit',
 | 
			
		||||
    label: '单位',
 | 
			
		||||
    filter: publicFormatter('energy_unit')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'collection',
 | 
			
		||||
    label: '是否采集'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'description',
 | 
			
		||||
    label: '描述'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyPlcParam',
 | 
			
		||||
  props: {
 | 
			
		||||
    energyTypeList: {
 | 
			
		||||
      type: Array,
 | 
			
		||||
      required: true,
 | 
			
		||||
      default: () => {
 | 
			
		||||
        return []
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      visible: false,
 | 
			
		||||
      drawerTitle: '',
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableData: [],
 | 
			
		||||
      tableBtn: [],
 | 
			
		||||
      tableH: this.tableHeight(115),
 | 
			
		||||
      total: 0,
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 30,
 | 
			
		||||
        connectId: null
 | 
			
		||||
      },
 | 
			
		||||
      plcTableName: '',
 | 
			
		||||
      objName: '',
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      collectionList: [
 | 
			
		||||
        {value: 0,label: '否'},
 | 
			
		||||
        {value: 1,label: '是'}
 | 
			
		||||
      ],
 | 
			
		||||
      showBtn: true
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  components: { EnergyPlcParamAdd },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(115)
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(data,title) {
 | 
			
		||||
      this.visible = true
 | 
			
		||||
      this.queryParams.connectId = data.id
 | 
			
		||||
      this.plcTableName = data.plcTableName
 | 
			
		||||
      this.objName = data.objName
 | 
			
		||||
      this.getList()
 | 
			
		||||
      if (title === 'detail') {
 | 
			
		||||
        this.drawerTitle = '查看参数'
 | 
			
		||||
        this.showBtn = false
 | 
			
		||||
        this.tableBtn = []
 | 
			
		||||
      } else {
 | 
			
		||||
        this.drawerTitle = '参数绑定'
 | 
			
		||||
        this.showBtn = true
 | 
			
		||||
        this.tableBtn = [
 | 
			
		||||
          {
 | 
			
		||||
            type: 'edit',
 | 
			
		||||
            btnName: '编辑'
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            type: 'delete',
 | 
			
		||||
            btnName: '删除'
 | 
			
		||||
          }
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyPlcParamPage({...this.queryParams}).then((res) => {
 | 
			
		||||
        let arr = res.data.list || []
 | 
			
		||||
        arr&&arr.map(item => {
 | 
			
		||||
          this.collectionList.map(i => {
 | 
			
		||||
            if (item.collection === i.value) {
 | 
			
		||||
              item.collection = i.label
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
          this.energyTypeList.map(j => {
 | 
			
		||||
            if (item.typeId === j.id) {
 | 
			
		||||
              item.typeId = j.name
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        })
 | 
			
		||||
        this.tableData = arr
 | 
			
		||||
        this.total = res.data.total;
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    // 新增
 | 
			
		||||
    addNew() {
 | 
			
		||||
      this.addOrEditTitle = '新增'
 | 
			
		||||
      this.centervisible = true
 | 
			
		||||
      this.$nextTick(() => {
 | 
			
		||||
        this.$refs.energyPlcParam.init({'connectId': this.queryParams.connectId, id: ''})
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyPlcParam.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyPlcParam.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      console.log(val)
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyPlcParam.init({'connectId': this.queryParams.connectId, id: val.data.id})
 | 
			
		||||
          })
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.handleDelete(val.data)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除参数列名为"' + row.plcParamName + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyPlcParam(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    },
 | 
			
		||||
    closeD() {
 | 
			
		||||
      this.$emit('closeDrawer')
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.box {
 | 
			
		||||
  padding: 0 32px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,132 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="100px" :model="form">
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="能源类型" prop="typeId">
 | 
			
		||||
          <el-select v-model="form.typeId" placeholder="请选择" style="width: 100%;" filterable>
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in energyListType"
 | 
			
		||||
              :key="item.id"
 | 
			
		||||
              :label="item.name"
 | 
			
		||||
              :value="item.id">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="参数列名" prop="plcParamName">
 | 
			
		||||
          <el-input v-model="form.plcParamName"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="参数名称" prop="name">
 | 
			
		||||
          <el-input v-model="form.name"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="单位" prop="unit">
 | 
			
		||||
          <el-select v-model="form.unit" placeholder="请选择" style="width: 100%;">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)"
 | 
			
		||||
              :key="item.value"
 | 
			
		||||
              :label="item.label"
 | 
			
		||||
              :value="item.value">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="是否采集" prop="collection">
 | 
			
		||||
          <el-switch v-model="form.collection"></el-switch>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="描述" prop="description">
 | 
			
		||||
          <el-input v-model="form.description"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlcParam, updateEnergyPlcParam, createEnergyPlcParam } from '@/api/base/energyPlcParam'
 | 
			
		||||
import { getEnergyTypeListAll } from '@/api/base/energyType'
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyPlcParamAdd',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        typeId: '',
 | 
			
		||||
        plcParamName: '',
 | 
			
		||||
        name: '',
 | 
			
		||||
        unit: '',
 | 
			
		||||
        description: '',
 | 
			
		||||
        collection: true,
 | 
			
		||||
        connectId: ''
 | 
			
		||||
      },
 | 
			
		||||
      energyListType: [],
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        typeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }],
 | 
			
		||||
        plcParamName: [{ required: true, message: '参数列名不能为空', trigger: 'blur' }],
 | 
			
		||||
        name: [{ required: true, message: '参数名称不能为空', trigger: 'blur' }]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(param) {
 | 
			
		||||
      this.form.connectId = param.connectId
 | 
			
		||||
      getEnergyTypeListAll().then((res) => {
 | 
			
		||||
        this.energyListType = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
      if (param.id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = param.id
 | 
			
		||||
        getEnergyPlcParam(this.form.id).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            this.form.collection = this.form.collection === 0 ? false : true
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          this.form.collection = this.form.collection === false ? 0 : 1
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyPlcParam({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyPlcParam({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.$refs.form.resetFields()
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										256
									
								
								src/views/devConfig/energy/energyPlcConnect/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										256
									
								
								src/views/devConfig/energy/energyPlcConnect/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,256 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
 | 
			
		||||
    <!-- 搜索工作栏 -->
 | 
			
		||||
    <search-bar
 | 
			
		||||
      :formConfigs="formConfig"
 | 
			
		||||
      ref="searchBarForm"
 | 
			
		||||
      @headBtnClick="buttonClick"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 列表 -->
 | 
			
		||||
    <base-table
 | 
			
		||||
      :page="queryParams.pageNo"
 | 
			
		||||
      :limit="queryParams.pageSize"
 | 
			
		||||
      :table-props="tableProps"
 | 
			
		||||
      :table-data="list"
 | 
			
		||||
      :max-height="tableH"
 | 
			
		||||
    >
 | 
			
		||||
      <method-btn
 | 
			
		||||
        v-if="tableBtn.length"
 | 
			
		||||
        slot="handleBtn"
 | 
			
		||||
        :width="160"
 | 
			
		||||
        label="操作"
 | 
			
		||||
        :method-list="tableBtn"
 | 
			
		||||
        @clickBtn="handleClick"
 | 
			
		||||
      />
 | 
			
		||||
    </base-table>
 | 
			
		||||
    <pagination
 | 
			
		||||
      :page.sync="queryParams.pageNo"
 | 
			
		||||
      :limit.sync="queryParams.pageSize"
 | 
			
		||||
      :total="total"
 | 
			
		||||
      @pagination="getList"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
      width='30%'
 | 
			
		||||
    >
 | 
			
		||||
      <energy-plc-connect-add ref="energyPlcConnect" :objList="objList" @successSubmit="successSubmit" />
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
    <!-- 参数绑定/查看 -->
 | 
			
		||||
    <energy-plc-param v-if="paramVisible" ref="plcParam" @closeDrawer="closeDrawer" :energyTypeList="energyTypeList"></energy-plc-param>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyPlcConnectPage, deleteEnergyPlcConnect } from "@/api/base/energyPlcConnect";
 | 
			
		||||
// import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
import { getTree } from '@/api/base/factory'
 | 
			
		||||
import { getEnergyTypeListAll } from '@/api/base/energyType'
 | 
			
		||||
import EnergyPlcConnectAdd from './components/energyPlcConnectAdd'
 | 
			
		||||
import EnergyPlcParam from './components/energyPlcParam'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objName',
 | 
			
		||||
    label: '对象'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objCode',
 | 
			
		||||
    label: '对象编码'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'plcTableName', 
 | 
			
		||||
    label: '关联表名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'plcTableCode',
 | 
			
		||||
    label: '关联表编码',
 | 
			
		||||
    showOverflowtooltip: true
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'cnName',
 | 
			
		||||
    label: '标识名'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'varNum',
 | 
			
		||||
    label: '绑定参数数量'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: "EnergyPlcConnect",
 | 
			
		||||
  components: { EnergyPlcConnectAdd, EnergyPlcParam },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'input',
 | 
			
		||||
          label: '标识名',
 | 
			
		||||
          placeholder: '标识名',
 | 
			
		||||
          param: 'cnName'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'separate'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('base:energy-plc-connect:create') ? 'button' : '',
 | 
			
		||||
          btnName: '新增',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'success',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        this.$auth.hasPermi('base:energy-plc-connect:bind')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'connect',
 | 
			
		||||
              btnName: '绑定'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        {
 | 
			
		||||
          type: 'detail',
 | 
			
		||||
          btnName: '详情'
 | 
			
		||||
        },
 | 
			
		||||
        this.$auth.hasPermi('base:energy-plc-connect:update')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'edit',
 | 
			
		||||
              btnName: '编辑'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        this.$auth.hasPermi('base:energy-plc-connect:delete')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'delete',
 | 
			
		||||
              btnName: '删除'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined
 | 
			
		||||
      ].filter((v) => v),
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 班次基础信息列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        cnName: null
 | 
			
		||||
      },
 | 
			
		||||
      paramVisible: false,
 | 
			
		||||
      energyTypeList: [],
 | 
			
		||||
      objList: []
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(260)
 | 
			
		||||
    })
 | 
			
		||||
    this.getList();
 | 
			
		||||
  },
 | 
			
		||||
  mounted() {
 | 
			
		||||
    // 获取能源列表
 | 
			
		||||
    this.getEnergyTypeList()
 | 
			
		||||
    // 获取对象树形结构
 | 
			
		||||
    this.getObjTree()
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.cnName = val.cnName
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.addOrEditTitle = '新增'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyPlcConnect.init()
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 查询列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyPlcConnectPage(this.queryParams).then(response => {
 | 
			
		||||
        let arr = response.data.list || [];
 | 
			
		||||
        this.list = arr
 | 
			
		||||
        this.total = response.data.total;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      console.log(val)
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyPlcConnect.init(val.data.id)
 | 
			
		||||
          })
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          break
 | 
			
		||||
        case 'delete':
 | 
			
		||||
          this.handleDelete(val.data)
 | 
			
		||||
          break
 | 
			
		||||
        case 'detail':
 | 
			
		||||
          this.paramVisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.plcParam.init(val.data, 'detail')
 | 
			
		||||
          })
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.paramVisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.plcParam.init(val.data, 'connect')
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyPlcConnect.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyPlcConnect.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除对象为"' + row.objName + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyPlcConnect(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    },
 | 
			
		||||
    closeDrawer() {
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    getEnergyTypeList() {
 | 
			
		||||
      getEnergyTypeListAll().then((res) => {
 | 
			
		||||
        this.energyTypeList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    getObjTree() {
 | 
			
		||||
      getTree().then(res => {
 | 
			
		||||
        this.objList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
@@ -0,0 +1,128 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="100px" :model="form">
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="方案名称" prop="name">
 | 
			
		||||
          <el-input v-model="form.name"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="方案编码" prop="code">
 | 
			
		||||
          <el-input v-model="form.code" disabled></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="统计类型" prop="type">
 | 
			
		||||
          <el-select v-model="form.type" placeholder="请选择" style="width: 100%;">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in getDictDatas(DICT_TYPE.STATISTIC_TYPE)"
 | 
			
		||||
              :key="item.value"
 | 
			
		||||
              :label="item.label"
 | 
			
		||||
              :value="item.value">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="能源类型" prop="energyTypeId">
 | 
			
		||||
          <el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" filterable>
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in energyListType"
 | 
			
		||||
              :key="item.id"
 | 
			
		||||
              :label="item.name"
 | 
			
		||||
              :value="item.id">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="备注" prop="remark">
 | 
			
		||||
          <el-input v-model="form.remark"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getCode, createEnergyStatistics, updateEnergyStatistics, getEnergyStatistics } from "@/api/monitoring/energyStatistics";
 | 
			
		||||
import { getEnergyTypeListAll } from '@/api/base/energyType'
 | 
			
		||||
import { number } from 'echarts';
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyStatisticsAdd',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        name: '',
 | 
			
		||||
        code: '',
 | 
			
		||||
        type: '',
 | 
			
		||||
        energyTypeId: ''
 | 
			
		||||
      },
 | 
			
		||||
      plcList: [],
 | 
			
		||||
      objList: [],
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        name: [{ required: true, message: '方案名称不能为空', trigger: 'blur' }],
 | 
			
		||||
        type: [{ required: true, message: '统计类型不能为空', trigger: 'change' }],
 | 
			
		||||
        energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }]
 | 
			
		||||
      },
 | 
			
		||||
      energyListType: [],
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(id) {
 | 
			
		||||
      getEnergyTypeListAll().then((res) => {
 | 
			
		||||
        this.energyListType = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
      if (id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = id
 | 
			
		||||
        getEnergyStatistics( id ).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            this.form.type = this.form.type + ''
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        getCode().then((res) => {
 | 
			
		||||
          this.form.code = res.data
 | 
			
		||||
        })
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyStatistics({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyStatistics({...this.form}).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.$refs.form.resetFields()
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
@@ -0,0 +1,230 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <el-drawer :title="drawerTitle" :visible.sync="visible" size="70%" @close='closeD' :show-close='false'>
 | 
			
		||||
      <div class="box">
 | 
			
		||||
        <el-form :inline="true">
 | 
			
		||||
          <el-form-item label="方案名称">
 | 
			
		||||
            <el-input v-model="name" size='small' readonly></el-input>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
          <el-form-item label="能源类型">
 | 
			
		||||
            <el-input v-model="energyType" size='small' readonly></el-input>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
          <el-form-item>
 | 
			
		||||
            <el-button type="success" size='small' v-if="showBtn" plain @click="addNew">新增</el-button>
 | 
			
		||||
            <el-button type="danger" size='small' v-if="showBtn" plain @click="deleteAll">批量删除</el-button>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
        </el-form>
 | 
			
		||||
        <base-table
 | 
			
		||||
          :page="queryParams.pageNo"
 | 
			
		||||
          :limit="queryParams.pageSize"
 | 
			
		||||
          :table-props="tableProps"
 | 
			
		||||
          :table-data="tableData"
 | 
			
		||||
          :max-height="tableH"
 | 
			
		||||
          :selectWidth="55"
 | 
			
		||||
          @selection-change="selectChange"
 | 
			
		||||
        >
 | 
			
		||||
          <method-btn
 | 
			
		||||
            v-if="tableBtn.length"
 | 
			
		||||
            slot="handleBtn"
 | 
			
		||||
            :width="80"
 | 
			
		||||
            label="操作"
 | 
			
		||||
            :method-list="tableBtn"
 | 
			
		||||
            @clickBtn="handleClick"
 | 
			
		||||
          />
 | 
			
		||||
        </base-table>
 | 
			
		||||
        <pagination
 | 
			
		||||
          :page.sync="queryParams.pageNo"
 | 
			
		||||
          :limit.sync="queryParams.pageSize"
 | 
			
		||||
          :total="total"
 | 
			
		||||
          @pagination="getList"
 | 
			
		||||
        />
 | 
			
		||||
      </div>
 | 
			
		||||
    </el-drawer>
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <energy-statistics-det-add ref="energyStatistics" @closeDet="closeDet" />
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyStatisticsDetPage, deleteEnergyStatisticsDet, deleteMany } from '@/api/monitoring/energyStatisticsDet'
 | 
			
		||||
import EnergyStatisticsDetAdd from './energyStatisticsDetAdd'
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objName',
 | 
			
		||||
    label: '所属对象'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objCode',
 | 
			
		||||
    label: '对象编码'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'paramName',
 | 
			
		||||
    label: '参数名称'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'unit',
 | 
			
		||||
    label: '单位',
 | 
			
		||||
    filter: publicFormatter('energy_unit')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'desc',
 | 
			
		||||
    label: '描述'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyStatisticsDet',
 | 
			
		||||
  props: {
 | 
			
		||||
    energyTypeList: {
 | 
			
		||||
      type: Array,
 | 
			
		||||
      required: true,
 | 
			
		||||
      default: () => {
 | 
			
		||||
        return []
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      visible: false,
 | 
			
		||||
      drawerTitle: '',
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableData: [],
 | 
			
		||||
      tableBtn: [],
 | 
			
		||||
      tableH: this.tableHeight(115),
 | 
			
		||||
      total: 0,
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 30,
 | 
			
		||||
        statisticsId: null
 | 
			
		||||
      },
 | 
			
		||||
      name: '',
 | 
			
		||||
      energyType: '',
 | 
			
		||||
      energyTypeId: '',
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      collectionList: [
 | 
			
		||||
        {value: 0,label: '否'},
 | 
			
		||||
        {value: 1,label: '是'}
 | 
			
		||||
      ],
 | 
			
		||||
      showBtn: true,
 | 
			
		||||
      selectedList: []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  components: { EnergyStatisticsDetAdd },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(115)
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(data,title) {
 | 
			
		||||
      this.visible = true
 | 
			
		||||
      this.queryParams.statisticsId = data.id
 | 
			
		||||
      this.name = data.name
 | 
			
		||||
      this.energyType = data.energyType
 | 
			
		||||
      this.energyTypeId = data.energyTypeId
 | 
			
		||||
      this.getList()
 | 
			
		||||
      if (title === 'detail') {
 | 
			
		||||
        this.drawerTitle = '查看参数'
 | 
			
		||||
        this.showBtn = false
 | 
			
		||||
        this.tableBtn = []
 | 
			
		||||
      } else {
 | 
			
		||||
        this.drawerTitle = '参数绑定'
 | 
			
		||||
        this.showBtn = true
 | 
			
		||||
        this.tableBtn = [
 | 
			
		||||
          {
 | 
			
		||||
            type: 'delete',
 | 
			
		||||
            btnName: '删除'
 | 
			
		||||
          }
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    getList() {
 | 
			
		||||
      console.log(this.queryParams)
 | 
			
		||||
      getEnergyStatisticsDetPage({...this.queryParams}).then((res) => {
 | 
			
		||||
        let arr = res.data.list || []
 | 
			
		||||
        arr&&arr.map(item => {
 | 
			
		||||
          this.collectionList.map(i => {
 | 
			
		||||
            if (item.collection === i.value) {
 | 
			
		||||
              item.collection = i.label
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
          this.energyTypeList.map(j => {
 | 
			
		||||
            if (item.typeId === j.id) {
 | 
			
		||||
              item.typeId = j.name
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        })
 | 
			
		||||
        this.tableData = arr
 | 
			
		||||
        this.total = res.data.total;
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    // 新增
 | 
			
		||||
    addNew() {
 | 
			
		||||
      this.$nextTick(() => {
 | 
			
		||||
        this.$refs.energyStatistics.init({'statisticsId': this.queryParams.statisticsId, energyTypeId:this.energyTypeId})
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    selectChange(val) {
 | 
			
		||||
      console.log(val)
 | 
			
		||||
      this.selectedList = val
 | 
			
		||||
    },
 | 
			
		||||
    // 批量删除
 | 
			
		||||
    deleteAll() {
 | 
			
		||||
      let arr = []
 | 
			
		||||
      if (this.selectedList.length === 0) {
 | 
			
		||||
        this.$modal.msgWarning("请选勾选数据")
 | 
			
		||||
        return false
 | 
			
		||||
      } else {
 | 
			
		||||
        this.selectedList.map((item) => {
 | 
			
		||||
          arr.push(item.id)
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
      this.$modal.confirm('是否确认删除所有勾选的数据项?').then(function() {
 | 
			
		||||
          return deleteMany(arr);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1
 | 
			
		||||
          this.getList()
 | 
			
		||||
          this.$modal.msgSuccess("删除成功")
 | 
			
		||||
        }).catch(() => {})
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyStatistics.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyStatistics.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      this.handleDelete(val.data)
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除参数列名为"' + row.paramName + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyStatisticsDet(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1
 | 
			
		||||
          this.getList()
 | 
			
		||||
          this.$modal.msgSuccess("删除成功")
 | 
			
		||||
        }).catch(() => {})
 | 
			
		||||
    },
 | 
			
		||||
    closeD() {
 | 
			
		||||
      this.$emit('closeDrawer')
 | 
			
		||||
    },
 | 
			
		||||
    closeDet() {  // 关闭新增框
 | 
			
		||||
      this.getList()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.box {
 | 
			
		||||
  padding: 0 32px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,179 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-drawer
 | 
			
		||||
    title="新增"
 | 
			
		||||
    :visible.sync="centervisible"
 | 
			
		||||
    size="60%"
 | 
			
		||||
    @close='closeA'
 | 
			
		||||
    :show-close='false'>
 | 
			
		||||
    <div class="box">
 | 
			
		||||
      <!-- 搜索工作栏 -->
 | 
			
		||||
      <search-bar
 | 
			
		||||
        :formConfigs="formConfig"
 | 
			
		||||
        ref="searchBarForm"
 | 
			
		||||
        :removeBlue='true'
 | 
			
		||||
        @headBtnClick="buttonClick"
 | 
			
		||||
      />
 | 
			
		||||
      <!-- 列表 -->
 | 
			
		||||
      <base-table
 | 
			
		||||
        :page="queryParams.pageNo"
 | 
			
		||||
        :limit="queryParams.pageSize"
 | 
			
		||||
        :table-props="tableProps"
 | 
			
		||||
        :table-data="list"
 | 
			
		||||
        :max-height="tableH"
 | 
			
		||||
        :selectWidth="55"
 | 
			
		||||
        @selection-change="selectChange"
 | 
			
		||||
      >
 | 
			
		||||
      </base-table>
 | 
			
		||||
      <pagination
 | 
			
		||||
        :page.sync="queryParams.pageNo"
 | 
			
		||||
        :limit.sync="queryParams.pageSize"
 | 
			
		||||
        :total="total"
 | 
			
		||||
        @pagination="getList"
 | 
			
		||||
      />
 | 
			
		||||
    </div>
 | 
			
		||||
  </el-drawer>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { addParamPage, createEnergyStatisticsDet } from '@/api/monitoring/energyStatisticsDet'
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objName',
 | 
			
		||||
    label: '所属对象'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'objCode',
 | 
			
		||||
    label: '对象编码'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'paramName',
 | 
			
		||||
    label: '参数名称'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'unit',
 | 
			
		||||
    label: '单位',
 | 
			
		||||
    filter: publicFormatter('energy_unit')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'desc',
 | 
			
		||||
    label: '描述'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'EnergyStatisticsDetAdd',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'select',
 | 
			
		||||
          label: '对象类型',
 | 
			
		||||
          selectOptions: this.getDictDatas(this.DICT_TYPE.OBJECT_TYPE),
 | 
			
		||||
          labelField: 'label',
 | 
			
		||||
          valueField: 'value',
 | 
			
		||||
          param: 'objType'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'input',
 | 
			
		||||
          label: '参数名称',
 | 
			
		||||
          placeholder: '参数名称',
 | 
			
		||||
          param: 'paramName'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'separate'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '关联',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'primary',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        energyTypeId: null,
 | 
			
		||||
        statisticId: null,
 | 
			
		||||
        paramName: '',
 | 
			
		||||
        objType: ''
 | 
			
		||||
      },
 | 
			
		||||
      tableProps,
 | 
			
		||||
      list: [],
 | 
			
		||||
      total: 0,
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      selectedList: []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(param) {
 | 
			
		||||
      this.queryParams.statisticId = param.statisticsId
 | 
			
		||||
      this.queryParams.energyTypeId = param.energyTypeId
 | 
			
		||||
      window.addEventListener('resize', () => {
 | 
			
		||||
        this.tableH = this.tableHeight(260)
 | 
			
		||||
      })
 | 
			
		||||
      this.centervisible = true
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    getList() {
 | 
			
		||||
      addParamPage({...this.queryParams}).then((res) => {
 | 
			
		||||
        this.list = res.data.list || []
 | 
			
		||||
        this.total = res.data.total
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.objType = val.objType
 | 
			
		||||
          this.queryParams.paramName = val.paramName
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          // 关联
 | 
			
		||||
          this.connectParam()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 选中数据
 | 
			
		||||
    selectChange(val) {
 | 
			
		||||
      this.selectedList = val
 | 
			
		||||
    },
 | 
			
		||||
    // 关联
 | 
			
		||||
    connectParam() {
 | 
			
		||||
      let param = {
 | 
			
		||||
        statisticsId: this.queryParams.statisticId,
 | 
			
		||||
        plcParamIds: []
 | 
			
		||||
      }
 | 
			
		||||
      if (this.selectedList.length === 0) {
 | 
			
		||||
        this.$modal.msgWarning("请选勾选数据")
 | 
			
		||||
        return false
 | 
			
		||||
      } else {
 | 
			
		||||
        this.selectedList.map((item) => {
 | 
			
		||||
          param.plcParamIds.push(item.id)
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
      createEnergyStatisticsDet({...param}).then((res) => {
 | 
			
		||||
        if (res.code === 0) {
 | 
			
		||||
          this.$modal.msgSuccess("操作成功");
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList()
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    closeA() {
 | 
			
		||||
      this.$emit('closeDet')
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.box {
 | 
			
		||||
  padding: 0 32px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
							
								
								
									
										245
									
								
								src/views/devConfig/energy/energyStatistics/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										245
									
								
								src/views/devConfig/energy/energyStatistics/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,245 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
 | 
			
		||||
    <!-- 搜索工作栏 -->
 | 
			
		||||
    <search-bar
 | 
			
		||||
      :formConfigs="formConfig"
 | 
			
		||||
      ref="searchBarForm"
 | 
			
		||||
      @headBtnClick="buttonClick"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 列表 -->
 | 
			
		||||
    <base-table
 | 
			
		||||
      :page="queryParams.pageNo"
 | 
			
		||||
      :limit="queryParams.pageSize"
 | 
			
		||||
      :table-props="tableProps"
 | 
			
		||||
      :table-data="list"
 | 
			
		||||
      :max-height="tableH"
 | 
			
		||||
    >
 | 
			
		||||
      <method-btn
 | 
			
		||||
        v-if="tableBtn.length"
 | 
			
		||||
        slot="handleBtn"
 | 
			
		||||
        :width="160"
 | 
			
		||||
        label="操作"
 | 
			
		||||
        :method-list="tableBtn"
 | 
			
		||||
        @clickBtn="handleClick"
 | 
			
		||||
      />
 | 
			
		||||
    </base-table>
 | 
			
		||||
    <pagination
 | 
			
		||||
      :page.sync="queryParams.pageNo"
 | 
			
		||||
      :limit.sync="queryParams.pageSize"
 | 
			
		||||
      :total="total"
 | 
			
		||||
      @pagination="getList"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
    >
 | 
			
		||||
      <energy-statistics-add ref="energyStatistics" @successSubmit="successSubmit" />
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
    <!-- 参数绑定/查看 -->
 | 
			
		||||
    <energy-statistics-det ref="plcParam" @closeDrawer="closeDrawer" :energyTypeList="energyTypeList"></energy-statistics-det>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyStatisticsPage, deleteEnergyStatistics } from "@/api/monitoring/energyStatistics";
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
import { getEnergyTypeListAll } from '@/api/base/energyType'
 | 
			
		||||
import EnergyStatisticsAdd from './components/energyStatisticsAdd'
 | 
			
		||||
import EnergyStatisticsDet from './components/energyStatisticsDet'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'name',
 | 
			
		||||
    label: '方案名称'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'code',
 | 
			
		||||
    label: '方案编码',
 | 
			
		||||
    minWidth: 120,
 | 
			
		||||
    showOverflowtooltip: true
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'type', 
 | 
			
		||||
    label: '统计类型',
 | 
			
		||||
    filter: publicFormatter('statistic_type')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'energyType',
 | 
			
		||||
    label: '能源类型'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'paramNum',
 | 
			
		||||
    label: '统计参数数量'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'remark',
 | 
			
		||||
    label: '备注'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: "energyStatistics",
 | 
			
		||||
  components: { EnergyStatisticsAdd, EnergyStatisticsDet },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'input',
 | 
			
		||||
          label: '方案名称',
 | 
			
		||||
          placeholder: '方案名称',
 | 
			
		||||
          param: 'name'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'separate'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('monitoring:energy-statistics:create') ? 'button' : '',
 | 
			
		||||
          btnName: '新增',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'success',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        this.$auth.hasPermi('monitoring:energy-statistics:bind')
 | 
			
		||||
        ? {
 | 
			
		||||
            type: 'connect',
 | 
			
		||||
            btnName: '绑定'
 | 
			
		||||
          }
 | 
			
		||||
        : undefined,
 | 
			
		||||
        {
 | 
			
		||||
          type: 'detail',
 | 
			
		||||
          btnName: '详情'
 | 
			
		||||
        },
 | 
			
		||||
        this.$auth.hasPermi('monitoring:energy-statistics:update')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'edit',
 | 
			
		||||
              btnName: '编辑'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        this.$auth.hasPermi('monitoring:energy-statistics:delete')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'delete',
 | 
			
		||||
              btnName: '删除'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined
 | 
			
		||||
      ].filter((v) => v),
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 班次基础信息列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        name: null
 | 
			
		||||
      },
 | 
			
		||||
      energyTypeList: []
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(260)
 | 
			
		||||
    })
 | 
			
		||||
    this.getList();
 | 
			
		||||
  },
 | 
			
		||||
  mounted() {
 | 
			
		||||
    // 获取能源列表
 | 
			
		||||
    this.getEnergyTypeList()
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.name = val.name
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.addOrEditTitle = '新增'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyStatistics.init()
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 查询列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyStatisticsPage(this.queryParams).then(response => {
 | 
			
		||||
        let arr = response.data.list || [];
 | 
			
		||||
        this.list = arr
 | 
			
		||||
        this.total = response.data.total;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      console.log(val)
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyStatistics.init(val.data.id)
 | 
			
		||||
          })
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          break
 | 
			
		||||
        case 'delete':
 | 
			
		||||
          this.handleDelete(val.data)
 | 
			
		||||
          break
 | 
			
		||||
        case 'detail':
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.plcParam.init(val.data, 'detail')
 | 
			
		||||
          })
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.plcParam.init(val.data, 'connect')
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyStatistics.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyStatistics.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除方案名称为"' + row.name + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyStatistics(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    },
 | 
			
		||||
    closeDrawer() {
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    getEnergyTypeList() {
 | 
			
		||||
      getEnergyTypeListAll().then((res) => {
 | 
			
		||||
        this.energyTypeList = res.data || []
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										118
									
								
								src/views/devConfig/energy/energyType/components/InnerTable.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								src/views/devConfig/energy/energyType/components/InnerTable.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-popover placement="right" width="400" trigger="click">
 | 
			
		||||
    <el-table :data="tableData" v-if='tableProps.length'>
 | 
			
		||||
      <el-table-column
 | 
			
		||||
        v-for='item in tableProps'
 | 
			
		||||
        :key="item.prop"
 | 
			
		||||
        :prop="item.prop" 
 | 
			
		||||
        :label="item.label"
 | 
			
		||||
        :align="item.align ? item.align : 'left'" 
 | 
			
		||||
        width="120">
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
    </el-table>
 | 
			
		||||
    <span v-if='singlePrice'><span class='priceTitle'>单价(元): </span>{{ singlePrice.toFixed(2) }}</span>
 | 
			
		||||
    <el-button
 | 
			
		||||
      slot="reference"
 | 
			
		||||
      type="text"
 | 
			
		||||
      class="tableInnerButton"
 | 
			
		||||
      @click="showInnerTable(injectData)"
 | 
			
		||||
      >详情</el-button
 | 
			
		||||
    >
 | 
			
		||||
  </el-popover>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyType } from '@/api/base/energyType'
 | 
			
		||||
const temp1 = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'startTime',
 | 
			
		||||
    label: '开始时间'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'endTime',
 | 
			
		||||
    label: '结束时间'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'price',
 | 
			
		||||
    label: '单价(元)',
 | 
			
		||||
    align: 'right'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
const temp2 = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'startUsed',
 | 
			
		||||
    label: '下限值'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'endUsed',
 | 
			
		||||
    label: '上限值'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'price',
 | 
			
		||||
    label: '单价(元)',
 | 
			
		||||
    align: 'right'
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'InnerTable',
 | 
			
		||||
  props: {
 | 
			
		||||
    injectData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    },
 | 
			
		||||
    itemProp: {
 | 
			
		||||
      type: String
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      list: this.injectData,
 | 
			
		||||
      tableData: [],
 | 
			
		||||
      tableProps: [],
 | 
			
		||||
      singlePrice:'',
 | 
			
		||||
      temp1,
 | 
			
		||||
      temp2
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    showInnerTable(data) {
 | 
			
		||||
      let id = data.id
 | 
			
		||||
      getEnergyType(id).then((res) => {
 | 
			
		||||
        if (res.code === 0) {
 | 
			
		||||
          console.log(res)
 | 
			
		||||
          if (res.data.pricingMethod === 0) {
 | 
			
		||||
            this.tableProps = this.temp1
 | 
			
		||||
            this.singlePrice = ''
 | 
			
		||||
            let arr1 = res.data.segPriceList
 | 
			
		||||
            for (let item of arr1) {
 | 
			
		||||
              item.price = item.price.toFixed(2)
 | 
			
		||||
            }
 | 
			
		||||
            this.tableData = arr1
 | 
			
		||||
          } else if (res.data.pricingMethod === 1) {
 | 
			
		||||
            this.tableProps = this.temp2
 | 
			
		||||
            this.singlePrice = ''
 | 
			
		||||
            let arr2 = res.data.usedPriceList
 | 
			
		||||
            for (let item of arr2) {
 | 
			
		||||
              item.price = item.price.toFixed(2)
 | 
			
		||||
            }
 | 
			
		||||
            this.tableData = arr2
 | 
			
		||||
          } else {
 | 
			
		||||
            this.tableProps = []
 | 
			
		||||
            this.tableData = []
 | 
			
		||||
            this.singlePrice = res.data.singlePrice
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.tableInnerButton {
 | 
			
		||||
  padding: 0;
 | 
			
		||||
}
 | 
			
		||||
.priceTitle {
 | 
			
		||||
  color: #515A5E;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  margin-right: 10px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,37 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="tableInner">
 | 
			
		||||
    <el-input-number v-model="list[itemProp]" @blur="changeInput" :min="0" :max="100000000" style="width: 100%" :controls='false'></el-input-number>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'InputArea',
 | 
			
		||||
  props: {
 | 
			
		||||
    injectData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    },
 | 
			
		||||
    itemProp: {
 | 
			
		||||
      type: String
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      list: this.injectData
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    changeInput() {
 | 
			
		||||
      console.log(this.list)
 | 
			
		||||
      this.$emit('emitData', this.list)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss">
 | 
			
		||||
.tableInner .el-input__inner {
 | 
			
		||||
  border: none;
 | 
			
		||||
  padding: 0;
 | 
			
		||||
  height: 33px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="tableInner">
 | 
			
		||||
    <el-time-picker
 | 
			
		||||
      v-model="list[itemProp]"
 | 
			
		||||
      @blur="changeInput"
 | 
			
		||||
      style="width: 100%"
 | 
			
		||||
      format='HH:mm:ss'
 | 
			
		||||
      value-format='HH:mm:ss'
 | 
			
		||||
    ></el-time-picker>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'TimePickerArea',
 | 
			
		||||
  props: {
 | 
			
		||||
    injectData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    },
 | 
			
		||||
    itemProp: {
 | 
			
		||||
      type: String
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      list: this.injectData
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    changeInput() {
 | 
			
		||||
      console.log(this.list)
 | 
			
		||||
      this.$emit('emitData', this.list)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss">
 | 
			
		||||
.tableInner .el-input--prefix .el-input__inner {
 | 
			
		||||
  border: none;
 | 
			
		||||
  padding-left: 30px;
 | 
			
		||||
  height: 33px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,334 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <el-form ref="form" :rules="rules" label-width="100px" :model="form">
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="能源类型" prop="name">
 | 
			
		||||
          <el-input v-model="form.name"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="类型编码" prop="code">
 | 
			
		||||
          <el-input v-model="form.code" disabled></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="单位" prop="unit">
 | 
			
		||||
          <el-select v-model="form.unit" placeholder="请选择" style="width: 100%;">
 | 
			
		||||
            <el-option
 | 
			
		||||
              v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)"
 | 
			
		||||
              :key="item.value"
 | 
			
		||||
              :label="item.label"
 | 
			
		||||
              :value="item.value">
 | 
			
		||||
            </el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="12">
 | 
			
		||||
        <el-form-item label="计价方式" prop="pricingMethod">
 | 
			
		||||
          <el-select v-model="form.pricingMethod" placeholder="请选择" style="width: 100%;">
 | 
			
		||||
            <el-option label="时间段" :value= '0' ></el-option>
 | 
			
		||||
            <el-option label="使用量" :value= '1' ></el-option>
 | 
			
		||||
            <el-option label="固定价位" :value= '2' ></el-option>
 | 
			
		||||
          </el-select>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="12" v-show="form.pricingMethod === 2">
 | 
			
		||||
        <el-form-item label="单价(元)" prop="pricingMethod">
 | 
			
		||||
          <el-input-number v-model="form.singlePrice" :precision="2" :min="0" :max="999999999" style="width: 100%;"></el-input-number>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="24"  v-show="form.pricingMethod === 0">
 | 
			
		||||
        <el-form-item label="时间段" prop="pricingMethod">
 | 
			
		||||
          <base-table
 | 
			
		||||
            :key='timeKye'
 | 
			
		||||
            :table-props="tableProps1"
 | 
			
		||||
            :table-data="tableData1"
 | 
			
		||||
            :add-button-show="addButtonShow"
 | 
			
		||||
            @emitButtonClick="emitButtonClick1"
 | 
			
		||||
            @emitFun="inputChange1"
 | 
			
		||||
          >
 | 
			
		||||
            <method-btn
 | 
			
		||||
              v-if="tableBtn.length"
 | 
			
		||||
              slot="handleBtn"
 | 
			
		||||
              :width="80"
 | 
			
		||||
              label="操作"
 | 
			
		||||
              :method-list="tableBtn"
 | 
			
		||||
              @clickBtn="handleClick1"
 | 
			
		||||
            />
 | 
			
		||||
          </base-table>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="24" v-show="form.pricingMethod === 1">
 | 
			
		||||
        <el-form-item label="使用量" prop="pricingMethod">
 | 
			
		||||
          <base-table
 | 
			
		||||
            :key='usedKye'
 | 
			
		||||
            :table-props="tableProps2"
 | 
			
		||||
            :table-data="tableData2"
 | 
			
		||||
            :add-button-show="addButtonShow"
 | 
			
		||||
            @emitButtonClick="emitButtonClick2"
 | 
			
		||||
            @emitFun="inputChange2"
 | 
			
		||||
          >
 | 
			
		||||
            <method-btn
 | 
			
		||||
              v-if="tableBtn.length"
 | 
			
		||||
              slot="handleBtn"
 | 
			
		||||
              :width="80"
 | 
			
		||||
              label="操作"
 | 
			
		||||
              :method-list="tableBtn"
 | 
			
		||||
              @clickBtn="handleClick2"
 | 
			
		||||
            />
 | 
			
		||||
          </base-table>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-row>
 | 
			
		||||
      <el-col :span="24">
 | 
			
		||||
        <el-form-item label="描述" prop="description">
 | 
			
		||||
          <el-input v-model="form.description"></el-input>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </el-form>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyType, updateEnergyType, createEnergyType, getEnergyTypeCode } from '@/api/base/energyType'
 | 
			
		||||
import inputArea from './InputArea.vue'
 | 
			
		||||
import timePickerArea from './TimePickerArea.vue'
 | 
			
		||||
const tableProps1 = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'startTime',
 | 
			
		||||
    label: '开始时间',
 | 
			
		||||
    subcomponent: timePickerArea
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'endTime',
 | 
			
		||||
    label: '结束时间',
 | 
			
		||||
    subcomponent: timePickerArea
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'price',
 | 
			
		||||
    label: '单价(元)',
 | 
			
		||||
    subcomponent: inputArea
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
const tableProps2 = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'startUsed',
 | 
			
		||||
    label: '下限值',
 | 
			
		||||
    // subcomponent: inputArea
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'endUsed',
 | 
			
		||||
    label: '上限量',
 | 
			
		||||
    subcomponent: inputArea
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'price',
 | 
			
		||||
    label: '单价(元)',
 | 
			
		||||
    subcomponent: inputArea
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'energyTypeAdd',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {
 | 
			
		||||
        id: '',
 | 
			
		||||
        name: '',
 | 
			
		||||
        code: '',
 | 
			
		||||
        nuit: '',
 | 
			
		||||
        pricingMethod: 2,
 | 
			
		||||
        leaderName: ''
 | 
			
		||||
      },
 | 
			
		||||
      isEdit: false, //是否是编辑
 | 
			
		||||
      rules: {
 | 
			
		||||
        name: [{ required: true, message: '能源类型不能为空', trigger: 'blur' }],
 | 
			
		||||
        pricingMethod: [{ required: true, message: '计价方式不能为空', trigger: 'change' }]
 | 
			
		||||
      },
 | 
			
		||||
      timeKye: 0,
 | 
			
		||||
      usedKye: 0,
 | 
			
		||||
      tableProps1,
 | 
			
		||||
      tableProps2,
 | 
			
		||||
      tableData1: [],
 | 
			
		||||
      tableData2: [],
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'delete',
 | 
			
		||||
          name: '删除'
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      addButtonShow: '新增'
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    init(id) {
 | 
			
		||||
      if (id) {
 | 
			
		||||
        this.isEdit = true
 | 
			
		||||
        this.form.id = id
 | 
			
		||||
        getEnergyType( id ).then((res) => {
 | 
			
		||||
          if (res.code === 0) {
 | 
			
		||||
            this.form = res.data
 | 
			
		||||
            switch(this.form.pricingMethod) {
 | 
			
		||||
              case 0:
 | 
			
		||||
                this.tableData1 = this.form.segPriceList
 | 
			
		||||
                break;
 | 
			
		||||
              case 1:
 | 
			
		||||
                this.tableData2 = this.form.usedPriceList
 | 
			
		||||
                break;
 | 
			
		||||
              default:
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.isEdit = false
 | 
			
		||||
        this.form.id = ''
 | 
			
		||||
        getEnergyTypeCode().then((res) => {
 | 
			
		||||
          this.form.code = res.data
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 输入框失去焦点
 | 
			
		||||
    inputChange1(val) {
 | 
			
		||||
      this.tableData1[val._pageIndex - 1][val.prop] = val[val.prop]
 | 
			
		||||
      if ((this.tableData1.length > val._pageIndex) && val.prop === 'endTime') {
 | 
			
		||||
        this.tableData1[val._pageIndex].startTime = val[val.prop]
 | 
			
		||||
      }
 | 
			
		||||
      this.timeKye++
 | 
			
		||||
    },
 | 
			
		||||
    inputChange2(val) {
 | 
			
		||||
      // 上限值必须大于下限值
 | 
			
		||||
      if (!!val.endUsed && (val.endUsed <= val.startUsed)) {
 | 
			
		||||
        this.$modal.msgError('上限值不能等于或者小于下限值')
 | 
			
		||||
        return false
 | 
			
		||||
      }
 | 
			
		||||
      this.tableData2[val._pageIndex - 1][val.prop] = val[val.prop]
 | 
			
		||||
      if ((this.tableData2.length > val._pageIndex) && val.prop === 'endUsed') {
 | 
			
		||||
        this.tableData2[val._pageIndex].startUsed = val[val.prop]
 | 
			
		||||
      }
 | 
			
		||||
      this.usedKye++
 | 
			
		||||
    },
 | 
			
		||||
    // 增加
 | 
			
		||||
    emitButtonClick1() {
 | 
			
		||||
      let n = this.tableData1.length
 | 
			
		||||
      if (n >=3) {
 | 
			
		||||
        this.$modal.msgWarning('最多可添加3档计价')
 | 
			
		||||
        return false
 | 
			
		||||
      }
 | 
			
		||||
      let obj = {}
 | 
			
		||||
      obj.startTime = n === 0 ? '' : this.tableData1[n-1].endTime
 | 
			
		||||
      obj.endTime = ''
 | 
			
		||||
      obj.price = 0
 | 
			
		||||
      this.tableData1.push(obj)
 | 
			
		||||
    },
 | 
			
		||||
    emitButtonClick2() {
 | 
			
		||||
      let n = this.tableData2.length
 | 
			
		||||
      if (n >=3) {
 | 
			
		||||
        this.$modal.msgWarning('最多可添加3档计价')
 | 
			
		||||
        return false
 | 
			
		||||
      }
 | 
			
		||||
      let obj = {}
 | 
			
		||||
      obj.startUsed = n === 0 ? 0 : this.tableData2[n-1].endUsed
 | 
			
		||||
      obj.endUsed = 0
 | 
			
		||||
      obj.price = 0
 | 
			
		||||
      this.tableData2.push(obj)
 | 
			
		||||
    },
 | 
			
		||||
    // 删除
 | 
			
		||||
    handleClick1(val) {
 | 
			
		||||
      this.tableData1.splice(val.data._pageIndex - 1, 1)
 | 
			
		||||
      this.timeKye++
 | 
			
		||||
    },
 | 
			
		||||
    handleClick2(val) {
 | 
			
		||||
      this.tableData2.splice(val.data._pageIndex - 1, 1)
 | 
			
		||||
      this.usedKye++
 | 
			
		||||
    },
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs['form'].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          switch(this.form.pricingMethod) {
 | 
			
		||||
            case 0:// 时间段
 | 
			
		||||
              if (this.tableData1.length === 0) {
 | 
			
		||||
                this.$modal.msgError('时间段表格数据不能为空')
 | 
			
		||||
                return false
 | 
			
		||||
              } else {
 | 
			
		||||
                this.tableData1.map(item => {
 | 
			
		||||
                  if (item.price <= 0) {
 | 
			
		||||
                    this.$modal.msgError('单价有误请检查,请检查')
 | 
			
		||||
                    return false
 | 
			
		||||
                  }
 | 
			
		||||
                })
 | 
			
		||||
              }
 | 
			
		||||
              break;
 | 
			
		||||
            case 1:// 使用量
 | 
			
		||||
              if (this.tableData2.length === 0) {
 | 
			
		||||
                this.$modal.msgError('使用量表格数据不能为空')
 | 
			
		||||
                return false
 | 
			
		||||
              } else {
 | 
			
		||||
                this.tableData1.map(item => {
 | 
			
		||||
                  if (item.price <= 0) {
 | 
			
		||||
                    this.$modal.msgError('单价有误请检查,请检查')
 | 
			
		||||
                    return false
 | 
			
		||||
                  }
 | 
			
		||||
                })
 | 
			
		||||
              }
 | 
			
		||||
              break;
 | 
			
		||||
            default:// 固定单价
 | 
			
		||||
              if (!this.form.singlePrice) {
 | 
			
		||||
                this.$modal.msgError('单价有误请检查,请检查')
 | 
			
		||||
                  return false
 | 
			
		||||
              }
 | 
			
		||||
          }
 | 
			
		||||
          if (this.isEdit) {
 | 
			
		||||
            // 编辑
 | 
			
		||||
            updateEnergyType({
 | 
			
		||||
              id: this.form.id,
 | 
			
		||||
              code: this.form.code,
 | 
			
		||||
              name: this.form.name,
 | 
			
		||||
              unit: this.form.unit,
 | 
			
		||||
              pricingMethod: this.form.pricingMethod,
 | 
			
		||||
              description: this.form.description,
 | 
			
		||||
              singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
 | 
			
		||||
              segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [],
 | 
			
		||||
              usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: []
 | 
			
		||||
            }).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
            createEnergyType({
 | 
			
		||||
              code: this.form.code,
 | 
			
		||||
              name: this.form.name,
 | 
			
		||||
              unit: this.form.unit,
 | 
			
		||||
              pricingMethod: this.form.pricingMethod,
 | 
			
		||||
              description: this.form.description,
 | 
			
		||||
              singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
 | 
			
		||||
              segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [],
 | 
			
		||||
              usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: []
 | 
			
		||||
            }).then((res) => {
 | 
			
		||||
              if (res.code === 0) {
 | 
			
		||||
                this.$modal.msgSuccess("操作成功");
 | 
			
		||||
                this.$emit('successSubmit')
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    formClear() {
 | 
			
		||||
      this.$refs.form.resetFields()
 | 
			
		||||
      this.form.singlePrice = 0
 | 
			
		||||
      this.isEdit = false
 | 
			
		||||
      this.timeKye = 0
 | 
			
		||||
      this.usedKye = 0
 | 
			
		||||
      this.tableData1 = []
 | 
			
		||||
      this.tableData2 = []
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										218
									
								
								src/views/devConfig/energy/energyType/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										218
									
								
								src/views/devConfig/energy/energyType/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,218 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
 | 
			
		||||
    <!-- 搜索工作栏 -->
 | 
			
		||||
    <search-bar
 | 
			
		||||
      :formConfigs="formConfig"
 | 
			
		||||
      ref="searchBarForm"
 | 
			
		||||
      @headBtnClick="buttonClick"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 列表 -->
 | 
			
		||||
    <base-table
 | 
			
		||||
      :page="queryParams.pageNo"
 | 
			
		||||
      :limit="queryParams.pageSize"
 | 
			
		||||
      :table-props="tableProps"
 | 
			
		||||
      :table-data="list"
 | 
			
		||||
      :max-height="tableH"
 | 
			
		||||
    >
 | 
			
		||||
      <method-btn
 | 
			
		||||
        v-if="tableBtn.length"
 | 
			
		||||
        slot="handleBtn"
 | 
			
		||||
        :width="80"
 | 
			
		||||
        label="操作"
 | 
			
		||||
        :method-list="tableBtn"
 | 
			
		||||
        @clickBtn="handleClick"
 | 
			
		||||
      />
 | 
			
		||||
    </base-table>
 | 
			
		||||
    <pagination
 | 
			
		||||
      :page.sync="queryParams.pageNo"
 | 
			
		||||
      :limit.sync="queryParams.pageSize"
 | 
			
		||||
      :total="total"
 | 
			
		||||
      @pagination="getList"
 | 
			
		||||
    />
 | 
			
		||||
    <!-- 新增 -->
 | 
			
		||||
    <base-dialog
 | 
			
		||||
      :dialogTitle="addOrEditTitle"
 | 
			
		||||
      :dialogVisible="centervisible"
 | 
			
		||||
      @cancel="handleCancel"
 | 
			
		||||
      @confirm="handleConfirm"
 | 
			
		||||
      :before-close="handleCancel"
 | 
			
		||||
    >
 | 
			
		||||
      <energy-type-add ref="energyType" @successSubmit="successSubmit" />
 | 
			
		||||
    </base-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { getEnergyTypePage, deleteEnergyType } from "@/api/base/energyType";
 | 
			
		||||
import { publicFormatter } from '@/utils/dict'
 | 
			
		||||
import InnerTable from './components/InnerTable'
 | 
			
		||||
import EnergyTypeAdd from './components/energyTypeAdd'
 | 
			
		||||
const tableProps = [
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'code',
 | 
			
		||||
    label: '类型编码',
 | 
			
		||||
    showOverflowtooltip: true
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'name',
 | 
			
		||||
    label: '能源类型'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'unit',
 | 
			
		||||
    label: '单位',
 | 
			
		||||
    filter: publicFormatter('energy_unit')
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'pricingMethod',
 | 
			
		||||
    label: '计价方式'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    prop: 'price',
 | 
			
		||||
    label: '价格(元)',
 | 
			
		||||
    subcomponent: InnerTable
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
export default {
 | 
			
		||||
  name: "EnergyType",
 | 
			
		||||
  components: { EnergyTypeAdd },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      formConfig: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'input',
 | 
			
		||||
          label: '能源类型',
 | 
			
		||||
          placeholder: '能源类型',
 | 
			
		||||
          param: 'name'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: 'button',
 | 
			
		||||
          btnName: '查询',
 | 
			
		||||
          name: 'search',
 | 
			
		||||
          color: 'primary'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('base:energy-type:create') ? 'separate' : '',
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          type: this.$auth.hasPermi('base:energy-type:create') ? 'button' : '',
 | 
			
		||||
          btnName: '新增',
 | 
			
		||||
          name: 'add',
 | 
			
		||||
          color: 'success',
 | 
			
		||||
          plain: true
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      tableProps,
 | 
			
		||||
      tableBtn: [
 | 
			
		||||
        this.$auth.hasPermi('base:energy-type:update')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'edit',
 | 
			
		||||
              btnName: '编辑'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined,
 | 
			
		||||
        this.$auth.hasPermi('base:energy-type:delete')
 | 
			
		||||
          ? {
 | 
			
		||||
              type: 'delete',
 | 
			
		||||
              btnName: '删除'
 | 
			
		||||
            }
 | 
			
		||||
          : undefined
 | 
			
		||||
      ].filter((v) => v),
 | 
			
		||||
      tableH: this.tableHeight(260),
 | 
			
		||||
      pricingMethodList: [
 | 
			
		||||
        {value: 0,label: '分时间段计价'},
 | 
			
		||||
        {value: 1,label: '分使用量计价'},
 | 
			
		||||
        {value: 2,label: '单一计价'}
 | 
			
		||||
      ],
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 班次基础信息列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      addOrEditTitle: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      centervisible: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 20,
 | 
			
		||||
        name: null,
 | 
			
		||||
        code: null
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    window.addEventListener('resize', () => {
 | 
			
		||||
      this.tableH = this.tableHeight(260)
 | 
			
		||||
    })
 | 
			
		||||
    this.getList();
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    buttonClick(val) {
 | 
			
		||||
      switch (val.btnName) {
 | 
			
		||||
        case 'search':
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.queryParams.name = val.name
 | 
			
		||||
          this.queryParams.code = val.code
 | 
			
		||||
          this.getList()
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
          this.addOrEditTitle = '新增'
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyType.init()
 | 
			
		||||
          })
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 查询列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      getEnergyTypePage(this.queryParams).then(response => {
 | 
			
		||||
        let arr = response.data.list || [];
 | 
			
		||||
        arr&&arr.map(item => {
 | 
			
		||||
          this.pricingMethodList.map(i => {
 | 
			
		||||
            if (item.pricingMethod === i.value) {
 | 
			
		||||
              item.pricingMethod = i.label
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        })
 | 
			
		||||
        this.list = arr
 | 
			
		||||
        this.total = response.data.total;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleClick(val) {
 | 
			
		||||
      switch (val.type) {
 | 
			
		||||
        case 'edit':
 | 
			
		||||
          this.addOrEditTitle = '编辑'
 | 
			
		||||
          this.$nextTick(() => {
 | 
			
		||||
            this.$refs.energyType.init(val.data.id)
 | 
			
		||||
          })
 | 
			
		||||
          this.centervisible = true
 | 
			
		||||
          break
 | 
			
		||||
        default:
 | 
			
		||||
        this.handleDelete(val.data)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    handleCancel() {
 | 
			
		||||
      this.$refs.energyType.formClear()
 | 
			
		||||
      this.centervisible = false
 | 
			
		||||
      this.addOrEditTitle = ''
 | 
			
		||||
    },
 | 
			
		||||
    handleConfirm() {
 | 
			
		||||
      this.$refs.energyType.submitForm()
 | 
			
		||||
    },
 | 
			
		||||
    successSubmit() {
 | 
			
		||||
      this.handleCancel()
 | 
			
		||||
      this.getList()
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$modal.confirm('是否确认删除能源类型为"' + row.name + '"的数据项?').then(function() {
 | 
			
		||||
          return deleteEnergyType(row.id);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.queryParams.pageNo = 1;
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.$modal.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(() => {});
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
		Reference in New Issue
	
	Block a user