Files
energy_app/src/views/enterprise/kongyajiSystem.vue
T
jiangyinzhi ee500763de 修改
2024-08-05 19:21:29 +08:00

666 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<!-- 头部 -->
<!-- <Header :title="title" @onClickLeft="onClickLeft" /> -->
<div class="container">
<div>
<!-- <div class="title" style="margin-top: 20px;margin-left: 5px;">通用能源系统</div> -->
<div class="partTwo-box">
<div class="partTwo-content">
<!-- 单机额定功率≥50kW 电网让改 ≥5kW -->
<div class="title">空压机系统基本信息 <span style="font-size: 14px; color: #bbbbbb;">单机额定功率≥5kW</span></div>
<van-swipe-cell :right-width="65" v-for="(item, index) in list" :key="index">
<div class="msg-card" @click="kongyajisystemaddedit(item.id)">
<div>
<div style="text-align: center;margin-top: 3px;"><van-icon name="credit-pay" color="#fff"
size="22px" /></div>
<div>x {{ item.systemNum }} 台</div>
</div>
<div>
<div class="space-between">
<span>空压机 {{ item.systemModel }} / 电机 {{ item.motorModel }} </span><span><van-icon name="arrow" color="#fff" /></span>
</div>
<div class="space-between" style="margin-top: 10px;font-size: 12px;">
<span>单台额定功率:{{ item.ratedPowerValue }} kVA</span><span>变频占比: {{ item.frequencyPerValue }} %</span>
</div>
</div>
</div>
<span slot="right" @click="remove(item.id)">删除</span>
</van-swipe-cell>
<div class="add-box" @click="kongyajisystemaddedit('')">
+ 新增
</div>
</div>
</div>
<div>
<div class="title" style="margin-top: 20px;margin-left: 5px;margin-bottom: 15px;">能效问卷</div>
<div class="partThree-question" v-for="(item, index) in askList" :key="index" >
<div>{{ index + 1 }} 、 {{ item.enquireTitle }}</div>
<div class="btn2">
<div class="btn-click2" @click="buttonClick(item, index)">
<div :class="item.color ? 'round-out yes-out' : 'round-out no-out'">
<div :class="item.color ? 'round-in yes-in' : 'round-in no-in'"></div>
</div>
<span>是</span>
</div>
<div class="btn-click2" @click="buttonNoClick(item, index)">
<div :class="item.color ? 'round-out no-out' : 'round-out yes-out'">
<div :class="item.color ? 'round-in no-in' : 'round-in yes-in'"></div>
</div>
<span>否</span>
</div>
</div>
</div>
</div>
<div class="upload-group">
<van-cell class="title" title="设备外观" :required="$store.getters.cityType"/>
<Uploader type="text1" :value="text1"
@afterRead="afterRead"
@delImg="delImg"
@onUpload="onUpload" />
<div class="tips tipImage" v-if="$store.getters.cityType&&text1.length<1">请上传设备外观照片</div>
<!-- <div class="picStyle borderBot">
<div class="title">设备外观</div>
<div class="pic">
<Uploader
type="text1"
:value="text1"
@afterRead="afterRead"
@delImg="delImg"
@onUpload="onUpload"
/>
</div>
</div> -->
<div class="picStyle borderBot">
<van-cell class="title" title="设备铭牌" :required="$store.getters.cityType"/>
<div class="pic">
<Uploader
type="text2"
:value="text2"
@afterRead="afterRead"
@delImg="delImg"
@onUpload="onUpload"
/>
</div>
<div class="tips tipImage" v-if="$store.getters.cityType&&text2.length<1">请上传设备铭牌</div>
</div>
<div class="picStyle">
<van-cell class="title" title="设备能效标识" :required="$store.getters.cityType"/>
<div class="pic">
<Uploader
type="text3"
:value="text3"
@afterRead="afterRead"
@delImg="delImg"
@onUpload="onUpload"
/>
</div>
<div class="tips tipImage" v-if="$store.getters.cityType&&text3.length<1">请上传设备能效标识</div>
</div>
</div>
<div class="footer-btn" @click="save">
<div>保存</div>
</div>
</div>
</div>
<van-overlay :show="show">
<div class="wrapper" @click.stop>
<div class="block">
<van-loading size="24px" color="#34baae" vertical>加载中...</van-loading>
</div>
</div>
</van-overlay>
</div>
</template>
<script>
import {
buildAsk,
} from '@/api/api.js'
import { airList, airRemove, enterprisGetInfo, enterprisEdit, enterprisAdd } from "@/api/universalEnergy.js";
import { Notify } from "vant";
import Uploader from '@/views/facilityManage/common-vue/uploader.vue'
import { downloadUrl } from '@/settings'
// import Header from "@/components/headerNew"
export default {
components: {
// Header,
Uploader
},
data() {
return {
newAnswer: [], // 问答题存
title: '空压机系统',
userMsg: {}, // 任务列表单条数据
list: [], // 列表
item: {
type: Object,
default: () => { },
},
aarr: [],
aarr1: [],
airEnquireIds: '',
id: '',
customerId: '',
askList: [], // 问询列表
show: false,
tidCid: null,
text1:[],
text2:[],
text3:[],
img1:'0,0,0',
img2:'0,0,0',
img3:'0,0,0',
}
},
created() {
this.tidCid = JSON.parse(sessionStorage.getItem('tidCid'))
this.getAsk()
this.enterpriseSystemId = sessionStorage.getItem('enterpriseSystemId');
let msg2 = JSON.parse(localStorage.getItem('customerItem'));
if(msg2) {
this.getid = msg2.id
}
this.getList();
},
activated() {
// let objMsg2 = JSON.parse(msg2);
// if (msg) {
// this.userMsg = JSON.parse(msg);
// } else {
// this.userMsg = objMsg2;
// }
},
computed: {
showForm() {
if(this.tidCid.taskId) {
return false
}
return true
},
},
methods: {
/**
* 图片方法
*/
//浏览器 ios 会走这个方法
afterRead(data, type) {
this[type] = [data.attach_id]
data.type = type
},
//安卓会调用的方法
onUpload(data, type) {
this[type] = [data[0].url]
},
delImg(file, detail, type) {
if(type == 'text1') {
this.delIsObj(this.text1)
this.text1 = []
}
if(type == 'text2') {
this.delIsObj(this.text2)
this.text2 = []
}
if(type == 'text3') {
this.delIsObj(this.text3)
this.text3 = []
}
},
//判断删除的list中是否为对象格式
delIsObj(delList) {
const list = delList.map((ele) => {
if(ele instanceof Object) {
return ele.url
}
return ele
})
return list
},
// 图片格式化
fomattPic() {
if(this.text1.length == 0) {
this.text1 = ['0']
}
if(this.text2.length == 0) {
this.text2 = ['0']
}
if(this.text3.length == 0) {
this.text3 = ['0']
}
if(this.text1.length > 0 && this.text1[0] instanceof Object) {
this.text1 = [this.text1[0].url.split('download/')[1]]
} else if(this.text1.length > 0 && this.text1[0].split('download/').length > 1) {
this.text1 = [this.text1[0].split('download/')[1]]
}
if(this.text2.length > 0 && this.text2[0] instanceof Object) {
this.text2 = [this.text2[0].url.split('download/')[1]]
} else if(this.text2.length > 0 && this.text2[0].split('download/').length > 1) {
this.text2 = [this.text2[0].split('download/')[1]]
}
if(this.text3.length > 0 && this.text3[0] instanceof Object) {
this.text3 = [this.text3[0].url.split('download/')[1]]
} else if(this.text3.length > 0 && this.text3[0].split('download/').length > 1) {
this.text3 = [this.text3[0].split('download/')[1]]
}
const text = this.text1.concat(this.text2, this.text3)
return text
},
//判断是否为对象格式
ifObj(imgList) {
imgList.forEach((v) => {
if(v instanceof Object && v.url.split('download/').length > 1) {
v.url = v.url.split('download/')[1]
}
})
const list = imgList.map((ele)=>{
if(ele instanceof Object) {
return ele.url
}
return ele
})
return list
},
// 获取问询信息
getAsk() {
buildAsk({ enquireMode: 'gykyjwx' })
.then((res) => {
if (res.code == 0) {
res.data.forEach((v) => {
if(v.enquireId == 73) {
v.color = false
} else {
v.color = true
}
})
this.askList = res.data
this.newAnswer = res.data.map((item) => {
if(item.enquireId == 73) {
return 0
}
return item.enquireId
})
this.getEnterprisGetInfo()
}
})
},
// 获取内容信息
async getEnterprisGetInfo() {
this.show = true
let tidCid = JSON.parse(sessionStorage.getItem('tidCid'))
let customerId = tidCid.customerId;
let taskId = tidCid.taskId;
const res = await enterprisGetInfo({customerId, taskId});
if (res.code == 0) {
this.show = false
this.airEnquireIds = res.data.airEnquireIds;
this.customerId = res.data.customerId;
this.id = res.data.id;
if(res.data.airEnquireIds) {
this.newAnswer = res.data.airEnquireIds.split(',')
}
if(this.askList && this.askList.length > 0) {
const list = this.newAnswer.filter((ele) => ele != 0)
this.askList.forEach((v)=>{
v.color = false
list.forEach((ev)=>{
if(v.enquireId == ev) {
v.color = true
}
})
})
}
if(res.data.text4) {
if(res.data.text4.split(',')[0] != 0) {
this.text1.push({
url:`${downloadUrl}${res.data.text4.split(',')[0]}`
})
}
if(res.data.text4.split(',')[1] != 0) {
this.text2.push({
url:`${downloadUrl}${res.data.text4.split(',')[1]}`
})
}
if(res.data.text4.split(',')[2] != 0) {
this.text3.push({
url:`${downloadUrl}${res.data.text4.split(',')[2]}`
})
}
if(res.data.text1) {
this.img1 = res.data.text1
}
if(res.data.text2) {
this.img2 = res.data.text2
}
if(res.data.text3) {
this.img3 = res.data.text3
}
}
} else {
this.show = false
}
},
buttonClick(item, index) {
if(this.showForm) {
return
}
this.newAnswer[index] = item.enquireId
if (!item.color) {
item.color = true
this.aarr.push(item.enquireId)
this.aarr = [...new Set(this.aarr)]
if(item.enquireId == 72 || item.enquireId == 73) {
this.changeId(item, [72, 73])
}
}
},
buttonNoClick(item, index) {
if(this.showForm) {
return
}
this.newAnswer[index] = 0
item.color = false
this.aarr.splice(this.aarr.indexOf(item.enquireId), 1)
const i = this.aarr1.findIndex((ele) => ele == item.enquireId)
this.aarr1.splice(i, 1)
},
changeId(item, numList) {
const num = numList.find((ele)=> ele != item.enquireId)
const enqIndex = this.newAnswer.findIndex((ele)=> ele == num)
if(enqIndex > -1) {
this.newAnswer.splice(enqIndex, 1, 0)
}
this.askList.forEach((v)=> {
if(v.enquireId == num) {
v.color = false
}
})
},
save() {
if(this.showForm||(this.$store.getters.cityType&&(this.text1.length<1||this.text2.length<1||this.text3.length<1))) {
return
}
const text4 = this.fomattPic()
let enterpriseId = sessionStorage.getItem('enId')
let formIds = this.newAnswer.toString();
if (enterpriseId) {
let params = {
customerId: this.customerId,
// id: this.id,
id: this.enterpriseSystemId,
taskId: this.tidCid.taskId,
enterpriseId: enterpriseId,
airEnquireIds: formIds,
systemTypes: this.$route.query.item,
text4: this.ifObj(text4).join(','),
text1: this.img1,
text3: this.img3,
text2: this.img2
}
enterprisEdit(params).then((res) => {
if (res.code == 0) {
Notify({ type: "success", background: '#34baae', message: "保存成功" });
} else {
this.$toast(res.msg)
}
})
} else {
let params = {
customerId: this.customerId,
id: this.tidCid.taskId,
enterpriseId: enterpriseId,
airEnquireIds: formIds,
systemTypes: this.$route.query.item,
text4: this.ifObj(text4).join(','),
text1: this.img1,
text3: this.img3,
text2: this.img2
}
enterprisAdd(params).then((res) => {
if (res.code == 0) {
Notify({ type: "success", background: '#34baae', message: "保存成功" });
} else {
this.$toast(res.msg)
}
})
}
this.$router.push('./acquisition')
},
// 跳转
kongyajisystemaddedit(id) {
if(this.showForm) {
return
}
this.$router.push({ path: './kongyajisystemaddedit', query: { id: id } })
},
// 列表
async getList() {
const params = {
customerId: this.userMsg.customerId,
systemId: this.enterpriseSystemId ? this.enterpriseSystemId : this.getid
}
const res = await airList(params);
if (res.code == 0) {
this.list = res.data
}
},
// 删除
remove(ids) {
if(this.showForm) {
return
}
airRemove(ids).then((res) => {
if (res.code == 0) {
this.getList();
Notify({ type: 'success', background: '#34baae', message: '删除成功' })
} else {
Notify({ type: 'error', background: 'red', message: res.msg })
}
})
}
}
}
</script>
<style lang="less" scoped>
.container {
padding: 0 20px;
}
.title {
font-size: 15px;
color: #000;
}
.partTwo-box {
width: 100%;
border-radius: 8px;
padding: 0 15px 10px;
box-sizing: border-box;
background-color: #fff;
overflow: hidden;
margin-top: 15px;
.partTwo-content {
margin-top: 10px;
.add-box {
width: 100%;
padding: 10px 0;
box-sizing: border-box;
border-radius: 5px;
border: 1px solid #63cbb6;
background-color: #e0f5f0;
color: #63cbb6;
text-align: center;
margin-top: 15px;
}
}
}
.msg-card {
margin-top: 10px;
background: #63cbb6;
padding: 15px;
border-radius: 6px;
color: #fff;
display: flex;
justify-content: space-between;
}
.space-between {
width: 230px;
display: flex;
justify-content: space-between;
}
::v-deep .van-swipe-cell__right {
right: -20px;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
display: flex;
align-items: center;
color: red;
}
.partThree-question {
width: 100%;
background-color: #fff;
border-radius: 8px;
padding: 20px 10px;
box-sizing: border-box;
font-size: 14px;
color: #000;
.btn2 {
display: flex;
justify-content: flex-end;
}
}
.btn2 {
margin-top: 20px;
display: flex;
.btn-click2 {
display: flex;
align-items: center;
span {
color: #9d9d9d;
font-size: 14px;
}
}
.round-out {
width: 12px;
height: 12px;
border-radius: 50%;
margin: 0 7px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
.round-in {
width: 8px;
height: 8px;
border-radius: 50%;
}
}
.yes-out {
border: 2.5px solid #34baae;
.yes-in {
background: #34baae;
}
}
.no-out {
border: 2px solid #b3b3b3;
}
}
.footer-btn {
margin-top: 180px;
height: 35px;
// padding: 0 0.4rem;
>div {
position: fixed;
bottom: 0.533333rem;
width: 90%;
background: #34baae;
border-radius: 0.266667rem;
line-height: 0.933333rem;
text-align: center;
color: #fff;
z-index: 99999;
}
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.upload-group {
background: #fff;
margin-top: 0.2rem;
padding: 0.2rem;
border-radius: 0.2rem;
}
.borderBot {
position: relative;
&::after {
position: absolute;
box-sizing: border-box;
content: ' ';
pointer-events: none;
right: 0.426667rem;
bottom: 0;
left: 0.426667rem;
border-bottom: 0.026667rem solid #ebedf0;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
}
.tips {
padding: 0 16px;
display: flex;
justify-content: flex-end;
color: #ee0a24;
font-size: 12px;
}
.tipImage{
justify-content: flex-start
}
</style>