Files
energy_app/src/views/facilityManage/components/heatingSystem.vue
T

875 lines
30 KiB
Vue

<template>
<van-form ref="heat" :disabled="showForm">
<div class="focusAir">
<div class="focusItem">
<van-cell-group>
<van-field v-model="formColumns.heatModeName" required :rules="[{ required: true }]" label="采暖方式" input-align="right" is-link placeholder="请选择" readonly @click="handelHeatModeShow = !showForm" />
<van-field v-model="formColumns.heatTypeName" required :rules="[{ required: true }]" label="采暖设备类型" input-align="right" is-link placeholder="请选择" readonly @click="heatTypeShow = !showForm" />
<van-field v-model="formColumns.heatTypeListName" :rules="[{ required: false, message:'请选择并填写采暖机组' }]" label="采暖机组" input-align="right" is-link placeholder="" @click-input="handleClickInput(3)" readonly />
<van-field v-model="form.pumpNum" v-input.num :required="form.heatMode!='1'" :rules="[{ required: form.heatMode!='1',
validator:validateisData}]" label="输送泵组采暖泵台数" type="number" label-width="140" input-align="right" placeholder="请输入" @input="handelInput('pumpNum', form.pumpNum)" />
<van-field v-model="form.pumpTotalPower" v-input.float :required="form.heatMode!='1'" :rules="[{ required: form.heatMode!='1',
validator:validateisData}]" label="输送泵组总功率(kW)" type="number" label-width="140" input-align="right" placeholder="请输入" @input="handelInput('pumpTotalPower', form.pumpTotalPower)" />
<van-field v-model="form.pumpYear" :required="form.heatMode!='1'" :rules="[{ required: form.heatMode!='1'}]" label="输送泵组设备年份" label-width="140" input-align="right" placeholder="请选择" is-link readonly @click="handelClickYear('pumpYear', 'SET_HEAT_YEAR')" />
<van-field label="设备生产日期" v-model="form.produceDate" required :rules="[{ required: true }]" placeholder="请选择设备生产日期" input-align="right" is-link readonly @click="datePicker = true" />
<!-- 是否进行过设备改造 -->
<Whether required :rules="[{ required: true }]" :value="formColumns.heatEquipModiyName" @onConfirmTrueFalse="onConfirmTrueFalse" feildName="heatEquipModiy" special="1" />
<!-- 改造方式 -->
<ModifyMode
v-show="form.heatEquipModiy == 1"
:columns="formColumns"
:form="form"
:list="hetList"
:type="null"
type1="heat"
:required="form.heatEquipModiy == 1"
:list1="resultList"
:list2="spliceList"
@onConfirmCheckbox="onConfirmCheckbox"
/>
<van-field v-show="heatYear1" v-model="form.heatIntellectModifyYear" label="增加主机智能化集中控制系统年份" required :rules="[{ required: heatYear1, message:'请选择年份' }]" label-width="220" input-align="right" is-link placeholder="请选择" readonly @click="handelClickYear('heatIntellectModifyYear', 'SET_HEAT_YEAR')" />
<van-field v-show="heatYear2" v-model="form.heatModifyYear" label="更换高能效设备年份" required :rules="[{ required: heatYear2, message:'请选择年份' }]" label-width="140" input-align="right" is-link placeholder="请选择" readonly @click="handelClickYear('heatModifyYear', 'SET_HEAT_YEAR')" />
</van-cell-group>
</div>
<div :class="form.heatMode ? 'search-main' : ''" v-for="item in searchList" :key="item.type">
<div class="focusItem" v-if="form.heatMode">
<div class="title" v-if="item.type == '1'">
<div class="line" /> 运营类节能诊断问询
</div>
<div class="title" v-if="item.type == '2'">
<div class="line" /> 设备类节能诊断问询
</div>
<div class="wt" v-for="(ele, i) in item.child" :key="ele.enquireId">
<div class="wtItem">
<p>{{ ++i }}.{{ ele.enquireTitle }}</p>
<Radio :item="ele" :index="i" @handelClickOk="handelClickOk(ele, i)" @handelClickNo="handelClickNo(ele, item.child)" />
</div>
</div>
</div>
</div>
<VanPickerNew :show="show" :columns="list" :loading="loading" @onConfirm="onConfirm" @onCancel="onCancel" />
<Year :show="yearShow" :num="1" @onConfirmYear="onConfirmYear" @onCancelYear="onCancelYear" />
<!-- 采暖方式 -->
<VanPickerNew :show="handelHeatModeShow">
<div class="content">
<div class="content-head">
<div @click="onCancelHe">取消</div>
<div @click="onConfirmHe">确认</div>
</div>
<div class="content-main">
<van-cell v-for="(item, index) in heatList" clickable :key="index" :title="item.dict_label" style="font-weight: 400 !important; font-size: 15px !important">
<van-checkbox :name="item" checked-color="#009999" v-model="item.checked">
{{ item.text }}
</van-checkbox>
</van-cell>
</div>
</div>
</VanPickerNew>
<!-- 采暖设备 -->
<VanPickerNew :show="heatTypeShow">
<div class="content">
<div class="content-head">
<div @click="onCancelHet">取消</div>
<div @click="onConfirmHet">确认</div>
</div>
<div class="content-main">
<van-cell v-for="item in heatTypeList" clickable :key="item.value" :title="item.dict_label" style="font-weight: 400 !important; font-size: 15px !important">
<van-checkbox :name="item" checked-color="#009999" v-model="item.checked">
{{ item.text }}
</van-checkbox>
</van-cell>
</div>
</div>
</VanPickerNew>
<!-- 年份选择 -->
<van-popup v-model="datePicker" position="bottom">
<van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate" @confirm="onConfirmDate" @cancel="datePicker = false" />
</van-popup>
</div>
</van-form>
</template>
<script>
import VanPickerNew from '@/components/vanPickerNew'
import ModifyMode from '../common-vue/modifyMode.vue'
import Whether from '../common-vue/whether.vue'
import Year from '../common-vue/year.vue'
import mixin from '@/mixins/mixin'
import { dataMode } from '../common'
import Radio from '../common-vue/radio.vue'
import { pureDigital } from '../pattern'
import { getCodeCommon } from '@/views/facilityManage/common'
export default {
components: {
Radio,
Year,
ModifyMode,
Whether,
VanPickerNew,
},
mixins: [mixin],
data() {
let validateisData = (value, rule) => {
if(!rule.required){
return true
}else if (!value|| value <= 0) {
return false
} else{
return true
}
}
return {
validateisData,
typeId: this.$route.query.typeId,
tidCid: null,
//页面名称
page: {
name: '采暖系统',
title: 'heating',
},
eqid: '',
/**
* 采暖方式
*/
handelHeatModeShow: false,
resultCheckboxHeat: [],
resultSpliceHeat: [],
heatList: [],
/**
* 采暖设备
*/
heatTypeShow: false,
resultCheckboxHeatType: [],
resultSpliceHeatType: [],
heatTypeList: [],
form: {
heatMode: '', //采暖方式
heatType: '', //采暖设备类型
pumpNum: '', // 输送机组采暖泵台数
pumpTotalPower: '', // 输送机组总功率(kW)
pumpYear: '', //输送机组设备年份
heatEquipModiy: '', //是否进行过设备改造
modifyMode: '', //改造方式
heatIntellectModifyYear: '', //增加主机智能化集中控制系统年份
heatModifyYear: '', //更换高能效设备年份
produceDate: '',
},
//展示名称
formColumns: {
heatModeName: '', //改造方式名称
heatTypeName: '',
modifyModeName: '',
heatTypeListName: '', //采暖机组名称
},
//机组展示list
/**
* 询问
*/
useSearch: {
heatEnquireDevIds: '', //设备类
heatEnquireIds: '', //运营类
},
searchList: [],
heatEnquireDevIdsList: [], //设备类
heatEnquireIdsList: [], //运营类
/**
* 改造方式复选框
*/
hetList: [{
code: 1,
name: '增加机组智能化集中控制系统',
checked: false,
},
{
code: 2,
name: '更换高能效设备',
checked: false,
},
],
resultList: [],
spliceList: [],
//定时器
mouSetTimer: null,
setValTimer: null,
heatYear1: false,
heatYear2: false,
required: false,
}
},
computed: {
showForm() {
if(this.tidCid.taskId) {
return false
}
return true
},
pureDigital() {
return pureDigital
},
//如果选择为否,携带属性需要删除
notData() {
return {
heatEquipModiy: {
formColumnsField: ['modifyModeName'],
formField: ['modifyMode','heatIntellectModifyYear','heatModifyYear'],
isShow: ['heatYear1','heatYear2'],
setStore: 'SET_HEAT_YEAR',
list: this.hetList,
}
}
}
},
created() {
this.tidCid = JSON.parse(sessionStorage.getItem('tidCid'))
},
mounted() {
const path = sessionStorage.getItem('facilityManageParPath')
this.$store.commit('pageData/GET_HET', this.typeId)
if(path == '/TaskFilling' || path == '/Taskfilling' || path == '/useenergyadd') {
this.editData()
} else {
for (const key in this.$data) {
this.$data[key] = this.$store.getters.heaData[key]
}
this.setValTimer = setTimeout(()=>{
if(this.form.heatMode) {
this.onConfirmHe()
}
if(this.form.heatType) {
this.onConfirmHet()
}
const cn = this.$store.getters.heatingUnitList
if(cn.length > 0 ) {
this.formColumns.heatTypeListName = cn.map((ele) => ele.unitTypeName).join(',')
}
}, 500)
for (const key in this.form) {
this.form[key] = this.$store.getters[key]
}
}
},
beforeDestroy() {
clearTimeout(this.mouSetTimer)
clearTimeout(this.setValTimer)
this.setVuexData()
},
methods: {
//修改覆写数据
async editData() {
// console.log(this.$store.getters.heatingUnitList);
this.mouSetTimer = setTimeout(async () => {
//查询机组
this.searchHeatType()
//前页面存起来的数据
const data = this.$store.getters.editData
//采暖方式
this.editHt(data)
//采暖设备类型
this.editHm(data)
//问询问题
const searchInfo = this.$store.getters.searchInfo
if (searchInfo) {
// console.log(this.$store.getters.searchInfo);
const res = dataMode(searchInfo['sbcn'])
this.searchList = res
//运营类
if(data.info.heatEnquireIds == '') {
const list1 = res.find((ele)=> ele.type == 1)
const dataList1 = list1.child.map((item)=> item.enquireId)
this.useSearch.heatEnquireIds = dataList1.join(',')
this.heatEnquireIdsList = dataList1
}
//设备类
if(data.info.heatEnquireDevIds == '') {
const list1 = res.find((ele)=> ele.type == 2)
const dataList1 = list1.child.map((item)=> item.enquireId)
this.useSearch.heatEnquireDevIds = dataList1.join(',')
this.heatEnquireDevIdsList = dataList1
}
this.$store.commit('search/SET_HEAT', this.useSearch)
}
//判断如果为修改状态
if (data.pageKey) {
//获取当前用能设备id
this.eqid = data.info.equipId
//循环当前页面form和后端返回的公共data部分
for (const key in this.form) {
for (const keys in data.info) {
if (key == keys) {
this.form[key] = data.info[keys]
}
}
}
for (const key in this.form) {
if (!this.form[key]) {
this.formColumns[key + 'Name'] = ''
}
}
//设备改造
this.editModify(data)
//问询
this.editDataSearch(data)
return
}
}, 200)
},
setVuexData() {
this.$store.commit('pageData/CURRENT_HEA_DATA', this.$data)
for (const key in this.form) {
this.form[key] = ''
}
},
/**
* editData是否改造
*/
editModify(data) {
this.formColumns.heatEquipModiyName = data.info.heatEquipModiy == 1 ? '是' : '否'
this.spliceList = []
this.resultList = []
if (data.info.heatIntellectModifyYear) {
this.resultList.push({
code: 1,
name: '增加机组智能化集中控制系统',
checked: true,
// field: "cenWaterModifyYear",
})
}
if (data.info.heatModifyYear) {
this.resultList.push({
code: 2,
name: '更换高能效设备',
checked: true,
// field: "cenWaterModifyYear",
})
}
if (!data.info.heatIntellectModifyYear) {
this.spliceList.push({
code: 1,
name: '增加机组智能化集中控制系统',
checked: false,
// field: "cenWaterModifyYear",
})
}
if (!data.info.heatModifyYear) {
this.spliceList.push({
code: 2,
name: '更换高能效设备',
checked: false,
// field: "cenWaterModifyYear",
})
}
// this.hetList = this.resultList;
this.hetList.forEach((v) => {
v.checked = false
this.resultList.forEach((ev) => {
if (v.code == ev.code) {
v.checked = true
}
})
})
this.hetList.forEach((v) => {
v.checked = true
this.spliceList.forEach((ev) => {
if (v.code == ev.code) {
v.checked = false
}
})
})
const name = this.resultList.map((ele) => ele.name)
const id = this.resultList.map((ele) => ele.code)
const checkboxInfo = {
name,
id,
result: this.resultList,
}
this.onConfirmCheckbox(checkboxInfo)
},
/**
* editData 采暖方式
*/
async editHt(data) {
const heatInfo = {
id: 80000001018,
type: 'cnfs',
}
const heatList = await getCodeCommon(heatInfo)
heatList.forEach((v) => {
v.checked = false
})
this.heatList = heatList
if (heatList && heatList.length > 0) {
if (data.info.heatMode) {
const heatModeList = data.info.heatMode.split(',')
const heData = heatList.filter((ele) => {
return heatModeList.some((item) => item == ele.code)
})
this.form.heatMode = data.info.heatMode
this.formColumns.heatModeName = heData.map((ele) => {
ele.checked = true
return ele.name
}).join(',')
this.resultCheckboxHeat = heData
}
}
},
/**
* editData 采暖设备类型
*/
async editHm(data) {
const heatTypeInfo = {
id: 80000001019,
type: 'cnsblx',
}
// const heatTypeList = ;
const heatTypeList = await getCodeCommon(heatTypeInfo)
heatTypeList.forEach((v) => {
v.checked = false
})
this.heatTypeList = heatTypeList
if (heatTypeList && heatTypeList.length > 0) {
if (data.info.heatType) {
const heTypeList = data.info.heatType.split(',')
const hetData = heatTypeList.filter((ele) => {
return heTypeList.some((item) => item == ele.code)
})
this.formColumns.heatTypeName = hetData.map((ele) => {
ele.checked = true
return ele.name
}).join(',')
this.resultCheckboxHeatType = hetData
}
}
},
/**
* edit 问询
*/
editDataSearch(data) {
/**
* 询问回显
*/
//设备类
if (data.info.heatEnquireDevIds && this.searchList.length > 0) {
const devList = data.info.heatEnquireDevIds.split(',')
this.useSearch.heatEnquireDevIds = data.info.heatEnquireDevIds
this.heatEnquireDevIdsList = devList
this.searchList[1].child.forEach((ele) => {
ele.color = false
devList.forEach((item) => {
if (item == ele.enquireId) {
ele.color = true
}
})
})
}
//运营类
if (data.info.heatEnquireIds && this.searchList.length > 0) {
const devList = data.info.heatEnquireIds.split(',')
this.useSearch.heatEnquireIds = data.info.heatEnquireIds
this.heatEnquireIdsList = devList
this.searchList[0].child.forEach((ele) => {
ele.color = false
devList.forEach((v) => {
if (v == ele.enquireId) {
ele.color = true
}
})
})
}
this.$store.commit('search/SET_HEAT', this.useSearch)
},
//查询采暖机组
async searchHeatType() {
const arrCnList = this.$store.getters.heatingUnitList
const data = {
type: 'jzlx',
id: 80000001020,
}
const res = await getCodeCommon(data)
sessionStorage.setItem('heatCnLx', JSON.stringify(res))
const names = res.filter((ele) => {
return arrCnList.some((item) => ele.code == item.unitType)
})
if (arrCnList.length > 0) {
this.formColumns.heatTypeListName = names.map((ele) => ele.name).join(',')
}
},
/**
* 采暖方式
*/
onCancelHe() {
this.heatList.forEach((v)=>{
this.resultSpliceHeat.forEach((sv)=>{
if(v.value == sv.value) {
v.checked = false
}
})
this.resultCheckboxHeat.forEach((rv)=>{
if(v.value == rv.value) {
v.checked = true
}
})
})
this.handelHeatModeShow = false
},
onConfirmHe() {
const htName = this.heatList.filter((ele) => ele.checked)
const htameF = this.heatList.filter((ele) => !ele.checked)
this.resultCheckboxHeat = htName
this.resultSpliceHeat = htameF
this.formColumns.heatModeName = htName.map((ele)=> ele.name).join(',')
this.form.heatMode = htName.map((ele)=> ele.value).join(',')
const data = {
type: 'heatMode',
data: this.form.heatMode,
}
this.$store.commit('search/SET_HEAT_CHANGE', data)
this.handelHeatModeShow = false
},
/**
* 采暖设备
*/
onCancelHet() {
if(this.resultSpliceHeatType.length == 0) {
this.heatTypeList.forEach((v)=>{
v.checked = false
})
}
this.heatTypeList.forEach((v)=>{
this.resultSpliceHeatType.forEach((sv)=>{
if(v.value == sv.value) {
v.checked = false
}
})
this.resultCheckboxHeatType.forEach((rv)=>{
if(v.value == rv.value) {
v.checked = true
}
})
})
this.heatTypeShow = false
},
onConfirmHet() {
// this.formColumns.heatTypeName = this.resultCheckboxHeatType.map((ele) => ele.name).join(',')
// this.form.heatType = this.resultCheckboxHeatType.map((ele) => ele.value).join(',')
const hetName = this.heatTypeList.filter((ele) => ele.checked)
const hetameF = this.heatTypeList.filter((ele) => !ele.checked)
this.resultCheckboxHeatType = hetName
this.resultSpliceHeatType = hetameF
this.formColumns.heatTypeName = hetName.map((ele)=> ele.name).join(',')
this.form.heatType = hetName.map((ele)=> ele.value).join(',')
const data = {
type: 'heatType',
data: this.form.heatType,
}
this.$store.commit('search/SET_HEAT_CHANGE', data)
this.heatTypeShow = false
},
//机组展示
getArrCn() {
const arrCn = sessionStorage.getItem('arrCn') ?
sessionStorage.getItem('arrCn') :
sessionStorage.getItem('arrCnList')
if (arrCn) {
const list = JSON.parse(arrCn)
this.formColumns.heatType = list
.map((ele) => ele.unitTypeName)
.join(',')
}
},
/**
* 闻讯
*/
//询问选择为是
handelClickOk(ele, i) {
if(this.showForm) {
return
}
if (ele.enquireType == '2' && !ele.color) {
// const index = this.heatEnquireDevIdsList.findIndex((v) => {
// return v == 0
// })
this.heatEnquireDevIdsList.splice(i-1, 1, ele.enquireId)
ele.color = true
}
if (ele.enquireType == '1' && !ele.color) {
// const index = this.heatEnquireIdsList.findIndex((v) => {
// return v == 0
// })
this.heatEnquireIdsList.splice(i-1, 1, ele.enquireId)
ele.color = true
}
this.useSearch.heatEnquireDevIds = this.heatEnquireDevIdsList.join(',')
this.useSearch.heatEnquireIds = this.heatEnquireIdsList.join(',')
this.$store.commit('search/SET_HEAT', this.useSearch)
},
//询问选择为否
handelClickNo(ele, list) {
if(this.showForm) {
return
}
if (ele.enquireType == '2' && ele.color) {
const index = this.heatEnquireDevIdsList.findIndex((v) => v == ele.enquireId)
if(index == -1) {
this.heatEnquireDevIdsList = list.map((item)=> {
if(ele.enquireId == item.enquireId) {
return item.noId
}
return item.enquireId
})
this.useSearch.heatEnquireDevIds = this.heatEnquireDevIdsList.join(',')
const elseItem = this.searchList.find((ele)=> ele.type == '1')
this.useSearch.heatEnquireIds = elseItem.child.map((ele)=> {
if(ele.color) {
return ele.enquireId
} else {
return ele.noId
}
}).join(',')
ele.color = false
} else {
this.heatEnquireDevIdsList.splice(index, 1, ele.noId)
this.useSearch.heatEnquireDevIds = this.heatEnquireDevIdsList.join(',')
const elseItem = this.searchList.find((ele)=> ele.type == '1')
this.useSearch.heatEnquireIds = elseItem.child.map((ele)=> {
if(ele.color) {
return ele.enquireId
} else {
return ele.noId
}
}).join(',')
ele.color = false
}
}
if (ele.enquireType == '1' && ele.color) {
const index = this.heatEnquireIdsList.findIndex((v) => v == ele.enquireId)
if(index == -1) {
this.heatEnquireIdsList = list.map((item)=> {
if(ele.enquireId == item.enquireId) {
return item.noId
}
return item.enquireId
})
this.useSearch.heatEnquireIds = this.heatEnquireIdsList.join(',')
const elseItem = this.searchList.find((ele)=> ele.type == '2')
this.useSearch.heatEnquireDevIds = elseItem.child.map((ele)=> {
if(ele.color) {
return ele.enquireId
} else {
return ele.noId
}
}).join(',')
ele.color = false
} else {
this.heatEnquireIdsList.splice(index, 1, ele.noId)
this.useSearch.heatEnquireIds = this.heatEnquireIdsList.join(',')
const elseItem = this.searchList.find((ele)=> ele.type == '2')
this.useSearch.heatEnquireDevIds = elseItem.child.map((ele)=> {
if(ele.color) {
return ele.enquireId
} else {
return ele.noId
}
}).join(',')
ele.color = false
}
}
this.$store.commit('search/SET_HEAT', this.useSearch)
},
//点击改造方式确认
onConfirmCheckbox(data) {
this.heatYear1 = false
this.heatYear2 = false
this.hetList.forEach((v)=> {
if(!v.checked && v.code == 1) {
this.form.heatIntellectModifyYear = ''
}
if(!v.checked && v.code == 2) {
this.form.heatModifyYear = ''
}
})
this.$store.commit('search/SET_HEAT_YEAR', this.form)
data.id.forEach((v) => {
if (v == 1) {
this.heatYear1 = true
}
if (v == 2) {
this.heatYear2 = true
}
})
this.formColumns.modifyModeName = data.name.join(',')
this.form.modifyMode = data.id.join(',')
},
handelInput(type, num) {
if(!num) {
num = 0
}
const data = {
type,
data: num,
}
this.$store.commit('search/SET_NUM', data)
},
handleClickInput(val) {
this.$router.replace({
name: 'burstingList',
params: {
title: '采暖机组',
type: val,
},
})
const data = {
title: '采暖机组',
type: 3,
}
sessionStorage.setItem('routerData', JSON.stringify(data))
},
},
}
</script>
<style lang="less" scoped>
@import '../common-vue/common.less';
@import '../common-vue/checkbox.less';
.focusAir {
padding: 0 15px;
.bottom {
margin-top: 20px;
border-radius: 10px;
overflow: auto;
}
}
.focusItem {
border-radius: 8px;
overflow: auto;
.addTitleLeft {
flex: 0 0 220px;
}
}
.text-ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
/deep/ .van-field__error-message {
text-align: right;
}
</style>