<template>
|
<div>
|
<a-modal
|
width="60%"
|
title="配置校准值"
|
destroyOnClose
|
:visible="wFlag"
|
@cancel="handleCancel"
|
@ok="handleOk"
|
>
|
<!---->
|
<a-form style="margin-top: 8px">
|
<a-form-item>
|
<a-collapse accordion @change="turnState($event)">
|
<a-collapse-panel
|
v-for="(item, key) in dataSensors"
|
:key="item.id"
|
:header="'名称:' + item.name"
|
>
|
<span
|
v
|
slot="extra"
|
style="
|
position: absolute;
|
left: 26%;
|
width: 10%;
|
text-align: center;
|
"
|
>下限值:{{ item.lower }}</span
|
>
|
<span
|
v
|
slot="extra"
|
style="
|
position: absolute;
|
left: 50%;
|
width: 10%;
|
text-align: center;
|
"
|
>上限值:{{ item.upper }}</span
|
>
|
<span
|
v
|
slot="extra"
|
style="
|
position: absolute;
|
left: 75%;
|
width: 10%;
|
text-align: center;
|
"
|
>单位:{{ item.unit }}</span
|
>
|
<a-button
|
icon="plus"
|
type="primary"
|
style="margin-left: 25px"
|
@click="addCalib"
|
>
|
新建校准值
|
</a-button>
|
<a-table
|
:columns="columns"
|
:dataSource="dataSource"
|
@change="handleTableChange"
|
:pagination="pagination"
|
/>
|
</a-collapse-panel>
|
</a-collapse>
|
</a-form-item>
|
|
<a-form-item style="">
|
<a-pagination
|
style="margin-right: 0"
|
:pageSize="size"
|
:pageSizeOptions="pageSizeOptions"
|
@showSizeChange="onShowSizeChange"
|
:total="total"
|
@change="turnPage"
|
show-quick-jumper
|
showSizeChanger
|
:show-total="(total) => `共有 ${total} 条数据`"
|
/>
|
</a-form-item>
|
</a-form>
|
</a-modal>
|
|
<a-modal
|
title="添加-校准值"
|
destroyOnClose
|
:visible="addFlag"
|
@ok="handleAddlOk"
|
@cancel="handleAddCancel"
|
>
|
<!---->
|
<a-form-model
|
style="margin-top: 8px"
|
:rules="caliRules"
|
:model="addData"
|
ref="addCaliForm"
|
>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="开始时间"
|
prop="startTime"
|
>
|
<a-time-picker
|
:allow-clear="false"
|
format="HH:mm"
|
v-model="addData.startTime"
|
@change="turnStartTime"
|
/>
|
</a-form-model-item>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="结束时间"
|
prop="endTime"
|
>
|
<a-time-picker
|
:allow-clear="false"
|
format="HH:mm"
|
v-model="addData.endTime"
|
@change="turnEndTime"
|
/>
|
</a-form-model-item>
|
<a-form-model-item
|
v-if="this.sensorCode === 'a40001'"
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="烟气流速" />
|
<a-select
|
v-model="addData.formula1"
|
style="width: 30%"
|
placeholder="请选择"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
placeholder=""
|
v-model="addData.val1"
|
>
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
v-else-if="this.sensorCode === 'a01011'"
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="烟气流速" />
|
<a-select
|
style="width: 30%"
|
placeholder="请选择"
|
v-model="addData.formula2"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input style="width: 40%; margin-top: 1px" v-model="addData.val2">
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
v-else
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-select
|
style="width: 30%"
|
defaultValue="AQI值"
|
v-model="addData.type1"
|
>
|
<a-select-option
|
:value="item.key"
|
:key="key"
|
v-for="(item, key) in selectType"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-select
|
v-model="addData.formula1"
|
style="width: 30%"
|
placeholder="请选择"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
placeholder=""
|
v-model="addData.val1"
|
>
|
<a-icon slot="addonAfter" type="plus" />
|
</a-input>
|
</a-input-group>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="测量值" />
|
<a-select
|
style="width: 30%"
|
placeholder="请选择"
|
v-model="addData.formula2"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
|
<a-input style="width: 40%; margin-top: 1px" v-model="addData.val2">
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="公式"
|
prop="cel"
|
>
|
<a-input type="string" read-only v-model="addData.cel">
|
<a-icon slot="addonAfter" type="close" @click="clearCel" />
|
</a-input>
|
</a-form-model-item>
|
</a-form-model>
|
</a-modal>
|
|
<a-modal
|
title="编辑-校准值"
|
destroyOnClose
|
:visible="editFlag"
|
@ok="handleEditlOk"
|
@cancel="handleEditCancel"
|
>
|
<!---->
|
<a-form-model
|
style="margin-top: 8px"
|
:rules="caliRules"
|
:model="editData"
|
ref="editCaliForm"
|
>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="开始时间"
|
prop="startTime"
|
>
|
<a-time-picker
|
format="HH:mm"
|
v-model="editData.startTime"
|
@change="turnStartTime"
|
/>
|
</a-form-model-item>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="结束时间"
|
prop="endTime"
|
>
|
<a-time-picker
|
format="HH:mm"
|
v-model="editData.endTime"
|
@change="turnEndTime"
|
/>
|
</a-form-model-item>
|
<a-form-model-item
|
v-if="this.sensorCode === 'a40001'"
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="烟气流速" />
|
<a-select
|
v-model="editData.formula1"
|
style="width: 30%"
|
placeholder="请选择"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
placeholder=""
|
v-model="editData.val1"
|
>
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
v-else-if="this.sensorCode === 'a01011'"
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="烟气流速" />
|
<a-select
|
style="width: 30%"
|
placeholder="请选择"
|
v-model="editData.formula1"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
v-model="editData.val1"
|
>
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
v-else
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="校准公式"
|
>
|
<a-input-group compact>
|
<a-select
|
style="width: 30%"
|
defaultValue="AQI值"
|
v-model="editData.type1"
|
>
|
<a-select-option
|
:value="item.key"
|
:key="key"
|
v-for="(item, key) in selectType"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-select
|
v-model="editData.formula1"
|
style="width: 30%"
|
placeholder="请选择"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
placeholder=""
|
v-model="editData.val1"
|
>
|
<a-icon slot="addonAfter" type="plus" />
|
</a-input>
|
</a-input-group>
|
<a-input-group compact>
|
<a-input style="width: 30%" read-only value="测量值" />
|
<a-select
|
style="width: 30%"
|
placeholder="请选择"
|
v-model="editData.formula2"
|
>
|
<a-select-option
|
:value="item.key"
|
v-for="(item, key) in selectSymbol"
|
>
|
{{ item.value }}
|
</a-select-option>
|
</a-select>
|
|
<a-input
|
style="width: 40%; margin-top: 1px"
|
v-model="editData.val2"
|
>
|
<a-icon slot="addonAfter" type="arrow-right" @click="gFormula" />
|
</a-input>
|
</a-input-group>
|
</a-form-model-item>
|
<a-form-model-item
|
:labelCol="{ span: 5 }"
|
:wrapperCol="{ span: 15 }"
|
label="公式"
|
prop="cel"
|
>
|
<a-input type="string" read-only v-model="editData.cel">
|
<a-icon slot="addonAfter" type="close" @click="clearCel" />
|
</a-input>
|
</a-form-model-item>
|
</a-form-model>
|
</a-modal>
|
</div>
|
</template>
|
|
<script lang="tsx">
|
import { Component, Prop, Vue, Emit, Watch } from "vue-property-decorator";
|
import moment from "moment";
|
import { get, post } from "@/util/request";
|
|
@Component({})
|
export default class Calibration extends Vue {
|
private flueOfSensor: string = "";
|
@Prop({
|
type: Boolean,
|
default: false,
|
})
|
private wFlag: boolean;
|
|
@Prop({
|
type: Object,
|
default: () => {},
|
})
|
private caliRecord: any;
|
|
@Watch("wFlag", {
|
deep: true,
|
})
|
private watchFlag(newVal: boolean, oldVal: boolean) {
|
this.getSensorByVersionId();
|
}
|
|
// 内部分页
|
private pagination: any = {
|
total: 0,
|
current: 1,
|
pageSize: 5,
|
showSizeChanger: false,
|
showQuickJumper: false,
|
};
|
|
private handleTableChange(pagination: any, filters: any, sorter: any): void {
|
this.pagination.current = pagination.current;
|
this.getSersorFomule();
|
}
|
// 公式生成=========================================
|
private gFormula() {
|
if (this.addFlag === false && this.editFlag === true) {
|
if (this.sensorCode === "a40001") {
|
const yanqi = JSON.parse(this.caliRecord.extend);
|
this.editData.cel =
|
this.editData.val1 !== ""
|
? "(currentSpeed" +
|
this.editData.formula1 +
|
"" +
|
this.editData.val1 +
|
")" +
|
"*" +
|
yanqi.area
|
: "";
|
} else if (this.sensorCode === "a01011") {
|
this.editData.cel =
|
this.editData.val1 !== ""
|
? "cel" + this.editData.formula1 + "" + this.editData.val1
|
: this.editData.cel;
|
} else {
|
if (this.editData.val1 === "" && this.editData.val2 !== "") {
|
this.editData.cel =
|
"cel" + this.editData.formula2 + "" + this.editData.val2;
|
} else if (this.editData.val1 !== "" && this.editData.val2 !== "") {
|
this.editData.cel =
|
this.editData.type1 +
|
"" +
|
this.editData.formula1 +
|
"" +
|
this.editData.val1 +
|
"+cel" +
|
this.editData.formula2 +
|
"" +
|
this.editData.val2;
|
} else if (this.editData.val1 !== "" && this.editData.val2 === "") {
|
this.editData.cel =
|
this.editData.type1 +
|
"" +
|
this.editData.formula1 +
|
"" +
|
this.editData.val1;
|
} else {
|
this.editData.cel = "";
|
}
|
}
|
} else {
|
if (this.sensorCode === "a40001") {
|
if (this.caliRecord.extend !== null) {
|
const yanqi = JSON.parse(this.caliRecord.extend);
|
if (yanqi.area) {
|
this.addData.cel =
|
this.addData.val1 !== ""
|
? "(currentSpeed" +
|
this.addData.formula1 +
|
"" +
|
this.addData.val1 +
|
")" +
|
"*" +
|
yanqi.area
|
: "";
|
} else {
|
this.$message.warning("请给该设备配置烟道面积!");
|
}
|
} else {
|
this.$message.warning("请给该设备配置烟道面积!");
|
}
|
} else {
|
if (this.addData.val1 === "" && this.addData.val2 !== "") {
|
this.addData.cel =
|
"cel" + this.addData.formula2 + "" + this.addData.val2;
|
} else if (this.addData.val1 !== "" && this.addData.val2 !== "") {
|
this.addData.cel =
|
this.addData.type1 +
|
"" +
|
this.addData.formula1 +
|
"" +
|
this.addData.val1 +
|
"+cel" +
|
this.addData.formula2 +
|
"" +
|
this.addData.val2;
|
} else if (this.addData.val1 !== "" && this.addData.val2 === "") {
|
this.addData.cel =
|
this.addData.type1 +
|
"" +
|
this.addData.formula1 +
|
"" +
|
this.addData.val1;
|
} else {
|
this.addData.cel = "";
|
}
|
}
|
}
|
}
|
|
// selectData
|
private selectType: any[] = [
|
{ key: "aqi", value: "AQI值" },
|
{ key: "vocs", value: "Vocs值" },
|
];
|
private selectSymbol: any[] = [
|
{ key: "+", value: "加" },
|
{ key: "-", value: "减" },
|
{ key: "*", value: "乘" },
|
{ key: "/", value: "除" },
|
];
|
|
//添加数据
|
private addData: any = {
|
startTime: moment("00:00:00", "HH:mm:ss"),
|
endTime: moment("23:59:59", "HH:mm:ss"),
|
type1: "aqi",
|
formula1: "+",
|
formula2: "+",
|
val1: "",
|
val2: "",
|
cel: "",
|
};
|
private pageSizeOptions: any = ["10", "30", "60", "100"];
|
|
private onShowSizeChange(current: any, pageSize: any) {
|
this.size = pageSize;
|
this.getSensorByVersionId();
|
}
|
// 存放数据
|
private dataSource: any = null;
|
// 存放sensorCode
|
private sensorCode: any = "";
|
|
//监听面板状态
|
private turnState(event: any) {
|
if (event !== undefined) {
|
this.sensorCode = "";
|
let code = "";
|
for (let i = 0; i < this.dataSensors.length; i++) {
|
if (this.dataSensors[i].id === Number(event)) {
|
code = this.dataSensors[i].code;
|
}
|
}
|
this.sensorCode = code;
|
this.getTimeArea();
|
this.getSersorFomule();
|
}
|
}
|
|
//存放所有时间段数据
|
private savaTimeArea: any = null;
|
// 获取时间段
|
private getTimeArea() {
|
get("deviceAdjustValue/getTimeSlot", {
|
mac: this.caliRecord.mac,
|
sensor_code: this.sensorCode,
|
}).then((res: any) => {
|
this.savaTimeArea = res.data.data.timeSlotList;
|
});
|
}
|
|
// 获取因子公式数据
|
private getSersorFomule() {
|
get("deviceAdjustValue/getDeviceAdjustValueByCondition", {
|
mac: this.caliRecord.mac,
|
current: this.pagination.current,
|
sensor_code: this.sensorCode,
|
size: this.pagination.pageSize,
|
orderType: 0,
|
}).then((res: any) => {
|
this.pagination.total = res.data.data.totalNumber;
|
this.dataSource = res.data.data.deviceAdjustValues;
|
console.log(parseInt(res.data.data.deviceAdjustValues[0].value));
|
});
|
}
|
|
//规则指定
|
private caliRules: any = {
|
startTime: [
|
{
|
required: true,
|
message: "请输入开始时间",
|
trigger: ["change", "blur"],
|
},
|
{ validator: this.vali(), trigger: ["change", "blur"] },
|
],
|
endTime: [
|
{ required: true, message: "请输入结束时间" },
|
{ validator: this.vali(), trigger: ["change", "blur"] },
|
],
|
cel: [
|
{
|
required: true,
|
message: "请生成校准公式",
|
trigger: ["change", "blur"],
|
},
|
],
|
};
|
|
private vali() {
|
let ru = (rule: any, value: any, callback: any) => {
|
if (this.addFlag === true) {
|
if (this.addData.endTime < this.addData.startTime) {
|
callback(new Error("开始时间需小于结束时间"));
|
} else {
|
callback();
|
}
|
} else {
|
if (this.editData.endTime < this.editData.startTime) {
|
callback(new Error("开始时间需小于结束时间"));
|
} else {
|
callback();
|
}
|
}
|
};
|
return ru;
|
}
|
|
// 判断时间是否在多个区间内
|
private judgeTime(startTime: any, endTime: any) {
|
let arr1 = [];
|
// 开始时间秒数
|
let sTime = new Date(startTime);
|
let sSecondNum = "";
|
let sHour =
|
sTime.getHours().toString().length === 2
|
? sTime.getHours()
|
: "0" + sTime.getHours();
|
let sMinutes =
|
sTime.getMinutes().toString().length === 2
|
? sTime.getMinutes()
|
: "0" + sTime.getMinutes();
|
sSecondNum = Number(sHour) * 60 * 60 + Number(sMinutes) * 60;
|
// 结束时间秒数
|
let eTime = new Date(endTime);
|
let eSecondNum = "";
|
let eHour =
|
eTime.getHours().toString().length === 2
|
? eTime.getHours()
|
: "0" + eTime.getHours();
|
let eMinutes =
|
eTime.getMinutes().toString().length === 2
|
? eTime.getMinutes()
|
: "0" + eTime.getMinutes();
|
eSecondNum = Number(eHour) * 60 * 60 + Number(eMinutes) * 60;
|
arr1.push(sSecondNum);
|
arr1.push(eSecondNum);
|
let arrFlag = [];
|
// 判断区间
|
for (let i = 0; i < this.savaTimeArea.length; i++) {
|
if (this.editRecord) {
|
if (this.savaTimeArea[i].id === this.editRecord.id) {
|
continue;
|
}
|
}
|
let arr2 = [];
|
let perStartTime = this.savaTimeArea[i].startTime;
|
let startArray = perStartTime.split(":");
|
let sNum = Number(startArray[0]) * 3600 + Number(startArray[1]) * 60;
|
arr2.push(sNum);
|
let perEndTime = this.savaTimeArea[i].endTime;
|
let endArray = perEndTime.split(":");
|
let eNum = Number(endArray[0]) * 3600 + Number(endArray[1]) * 60;
|
arr2.push(eNum);
|
let flag = this.isIntersect(arr1, arr2);
|
arrFlag.push(flag);
|
}
|
return arrFlag;
|
}
|
|
// 判断两个集合是否有交集
|
private isIntersect(arr1: Array, arr2: Array) {
|
let start = [Math.min(...arr1), Math.min(...arr2)]; //区间的两个最小值
|
let end = [Math.max(...arr1), Math.max(...arr2)]; //区间的两个最大值
|
return Math.max(...start) < Math.min(...end); //最大值里的最小值 是否 小于等于 最大值的最小值
|
}
|
|
// 清空公式
|
private clearCel() {
|
this.addData.cel = "";
|
this.editData.cel = "";
|
}
|
|
private created() {}
|
|
// 不同时间的校准列表
|
private columns: any[] = [
|
{
|
title: "开始时间",
|
dataIndex: "startTime",
|
},
|
{
|
title: "结束时间",
|
dataIndex: "endTime",
|
},
|
{
|
title: "公式",
|
dataIndex: "value",
|
},
|
{
|
title: "操作",
|
customRender: this.opRender,
|
},
|
];
|
|
// 时间字符串
|
private startTimeString: any = "";
|
private endTimeString: any = "";
|
|
//监听时间变化
|
private turnStartTime(time: any) {
|
let d = new Date(time._d);
|
let hour =
|
d.getHours().toString().length === 2 ? d.getHours() : "0" + d.getHours();
|
let minutes =
|
d.getMinutes().toString().length === 2
|
? d.getMinutes()
|
: "0" + d.getMinutes();
|
this.startTimeString = hour + ":" + minutes + ":00";
|
}
|
|
private turnEndTime(time: any) {
|
let d = new Date(time._d);
|
let hour =
|
d.getHours().toString().length === 2 ? d.getHours() : "0" + d.getHours();
|
let minutes =
|
d.getMinutes().toString().length === 2
|
? d.getMinutes()
|
: "0" + d.getMinutes();
|
this.endTimeString = hour + ":" + minutes + ":00";
|
}
|
|
// 分页组件所需数据--------------------------------------------------
|
private currentPage: number = 1;
|
private total: number = 0;
|
private size: number = 10;
|
|
private turnPage(current: any) {
|
this.currentPage = current;
|
this.getSensorByVersionId();
|
}
|
|
// 因子数据
|
private dataSensors: any = null;
|
|
// 根据型号id获取因子
|
private getSensorByVersionId() {
|
get("version/queryById", {
|
id: this.caliRecord.version.id,
|
page: this.currentPage,
|
size: this.size,
|
})
|
.then((res: any) => {
|
this.dataSensors = res.data.data.versions[0].sensors;
|
this.total = res.data.data.total;
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
}
|
|
private handleCancel() {
|
this.sendFlag(false);
|
this.currentPage = 1;
|
}
|
|
private handleOk() {
|
this.sendFlag(false);
|
this.currentPage = 1;
|
}
|
|
@Emit("cFlag")
|
private sendFlag(flag: boolean) {
|
return flag;
|
}
|
|
// 新建校准值-----------------------------------------------------------------------------
|
|
private addFlag: boolean = false;
|
|
private addCalib() {
|
this.addFlag = true;
|
}
|
|
private handleAddlOk() {
|
this.$refs.addCaliForm.validate((valid: any) => {
|
if (valid) {
|
let flag = this.judgeTime(this.addData.startTime, this.addData.endTime);
|
if (flag.indexOf(true) !== -1) {
|
this.$message.warning("新建时间区间不能与已经存在的时间段交叉", 2);
|
} else {
|
post("deviceAdjustValue/insertOneDeviceAdjustValue", {
|
mac: this.caliRecord.mac,
|
startTime:
|
this.startTimeString === "" ? "00:00:00" : this.startTimeString,
|
endTime:
|
this.endTimeString === "" ? "23:59:00" : this.endTimeString,
|
value: this.addData.cel,
|
sensorCode: this.sensorCode,
|
}).then((res: any) => {
|
if (res.data.code === 0) {
|
this.addData.val1 = "";
|
this.addData.val2 = "";
|
this.addData.formula1 = "+";
|
this.addData.formula2 = "+";
|
this.addData.type1 = "aqi";
|
this.getSersorFomule();
|
this.$message.success(res.data.message);
|
this.startTimeString = "";
|
this.endTimeString = "";
|
this.addData.startTime = moment("00:00:00", "HH:mm:ss");
|
this.addData.endTime = moment("23:59:59", "HH:mm:ss");
|
this.addData.cel = "";
|
this.addFlag = false;
|
this.getTimeArea();
|
} else {
|
this.$message.warning(res.data.message);
|
}
|
});
|
}
|
}
|
});
|
}
|
private handleAddCancel() {
|
this.addData.startTime = moment("00:00:00", "HH:mm:ss");
|
this.addData.endTime = moment("23:59:59", "HH:mm:ss");
|
this.addData.val1 = "";
|
this.addData.val2 = "";
|
this.addData.formula1 = "+";
|
this.addData.formula2 = "+";
|
this.addData.type1 = "aqi";
|
this.addData.cel = "";
|
this.startTimeString = "";
|
this.endTimeString = "";
|
this.addFlag = false;
|
}
|
// 编辑------------------------------------------------------------------------------------------------
|
private editData: any = {
|
startTime: null,
|
endTime: null,
|
type1: "aqi",
|
formula1: "+",
|
formula2: "+",
|
val1: "",
|
val2: "",
|
cel: "",
|
};
|
private editFlag: boolean = false;
|
private editRecord: any = null;
|
|
// 编辑保存
|
private handleEditlOk() {
|
this.$refs.editCaliForm.validate((valid: any) => {
|
if (valid) {
|
let flag = this.judgeTime(
|
this.editData.startTime,
|
this.editData.endTime
|
);
|
if (flag.indexOf(true) !== -1) {
|
this.$message.warning("编辑时间区间不能与已经存在的时间段交叉", 2);
|
} else {
|
let startTime =
|
this.startTimeString === this.editRecord.startTime
|
? null
|
: this.startTimeString === ""
|
? null
|
: this.startTimeString;
|
let endTime =
|
this.endTimeString === this.editRecord.endTime
|
? null
|
: this.endTimeString === ""
|
? null
|
: this.endTimeString;
|
let fomule =
|
this.editData.cel === this.editRecord.value
|
? null
|
: this.editData.cel;
|
if (startTime || endTime || fomule) {
|
post("deviceAdjustValue/updateOneDeviceAdjustValue", {
|
id: this.editRecord.id,
|
start_time: startTime,
|
end_time: endTime,
|
value: fomule,
|
}).then((res: any) => {
|
if (res.data.code === 0) {
|
this.getSersorFomule();
|
this.$message.success(res.data.message);
|
this.editFlag = false;
|
this.startTimeString = "";
|
this.endTimeString = "";
|
this.editRecord = null;
|
this.editData.val1 = "";
|
this.editData.val2 = "";
|
this.editData.formula1 = "+";
|
this.editData.formula2 = "+";
|
this.getTimeArea();
|
}
|
});
|
} else {
|
this.$message.warning("未修改");
|
}
|
}
|
}
|
});
|
}
|
|
private handleEditCancel() {
|
this.editFlag = false;
|
}
|
|
private handleEditModalVisible(flag: boolean, record: any) {
|
this.editFlag = flag;
|
this.editRecord = record;
|
this.editData.startTime = moment(record.startTime, "HH:mm:ss");
|
this.editData.endTime = moment(record.endTime, "HH:mm:ss");
|
this.editData.cel = record.value;
|
}
|
|
// 删除------------------------------------------------------------------------------------------------
|
private deleteDevice(record: any) {
|
post("deviceAdjustValue/deleteOneDeviceAdjustValue", {
|
id: record.id,
|
}).then((res: any) => {
|
if (res.data.code === 0) {
|
this.getSersorFomule();
|
this.getTimeArea();
|
this.$message.success(res.data.message);
|
}
|
});
|
}
|
|
// 操作===============================================================================================
|
private opRender(text: string, record: any, index: number) {
|
return (
|
<div>
|
<a onClick={() => this.handleEditModalVisible(true, record)}> 编辑 </a>
|
<a-divider type="vertical" />
|
<a-popconfirm
|
title="确认删除吗?"
|
ok-text="确定"
|
cancel-text="取消"
|
onConfirm={() => this.deleteDevice(record)}
|
>
|
<a href="#">删除</a>
|
</a-popconfirm>
|
</div>
|
);
|
}
|
}
|
</script>
|
|
<style lang="less">
|
.modalStyle {
|
.ant-modal {
|
margin-left: 25%;
|
}
|
|
.ant-modal-content {
|
width: 800px;
|
}
|
}
|
</style>
|