security-appp/src/views/device-detail.vue

136 lines
4.7 KiB
Vue
Raw Normal View History

2024-03-14 14:26:50 +08:00
<!--设备信息-->
<template>
<div class="deviceDetail">
<van-nav-bar title="设备信息" left-text="返回" left-arrow @click-left="$router.back()" />
<van-form>
<van-field v-model="form.name" name="设备名称" label="设备名称" readonly/>
<van-field v-model="form.deviceNum" name="设备编号" label="设备编号" readonly/>
<van-field v-model="form.company" name="设备厂商" label="设备厂商" readonly/>
<van-field v-model="form.modelNum" name="设备型号" label="设备型号" readonly/>
<van-field v-model="form.typeName" name="设备分类" label="设备分类" readonly/>
<van-field v-model="form.depName" name="所属部门" label="所属部门" readonly/>
<van-field v-model="form.address" name="设备位置" label="设备位置" readonly/>
<van-field v-model="form.maintenanceDate" name="维保时间" label="维保时间" readonly/>
<van-field v-model="form.state" name="待检状态" label="待检状态" readonly/>
<div style="margin: 16px">
<van-button round block type="danger" @click="startCheck()" v-if="type==='1'">录入整改结果</van-button>
<van-button round block type="danger" @click="scanning()" v-if="type==='2'">扫描设备二维码录入检查结果</van-button>
<van-button round block type="danger" @click="startCheck()" v-if="type==='3'">录入持续整改结果</van-button>
<!-- pc端测试跳开二维码验证 -->
<!-- <van-button round block type="danger" @click="startCheck()" v-if="type==='2'">直接录入检查结果</van-button> -->
</div>
</van-form>
</div>
</template>
<script>
import { getDeviceDetail, getDeviceRectifyDetail, getDeviceContinuedDetail } from "../api";
export default {
name: "device-detail",
data() {
return {
form: {
id: "",
name: "",
deviceNum: "",
company: "",
modelNum: "",
typeName: "",
depName: "",
address: "",
maintenanceDate: "",
state: "",
},
deviceId: "",
pushFlag: false,
aimId: "",
type:"",//1-设备整改 2-设备检查 3-设备持续整改
};
},
mounted() {
this.getData();
window.aimThisData = this.aimThisData;
},
methods: {
//获取详情数据
getData() {
this.aimId = this.$route.params.dataId;
const type = this.$route.params.type;
this.type=type;
//设备整改详情
if (type === "1") {
getDeviceRectifyDetail(this.aimId).then((res) => {
if (res.data.code !== 200) {
return this.$dialog.alert({message: res.data.msg});
}
this.form = res.data.data;
});
}
//设备检查详情
if (type === "2") {
getDeviceDetail(this.aimId).then((res) => {
if (res.data.code !== 200) {
return this.$dialog.alert({message: res.data.msg});
}
this.form = res.data.data;
});
}
//设备持续整改详情
if (type === "3") {
getDeviceContinuedDetail(this.aimId).then((res) => {
if (res.data.code !== 200) {
return this.$dialog.alert({message: res.data.msg});
}
this.form = res.data.data;
});
}
},
//页面跳转
startCheck() {
//pc端测试挡板 上线去除
// this.pushFlag=true;
const type = this.$route.params.type;
if (type === "1") {
return this.$router.push({ name: "device-rectify", params: { dataId: this.aimId } });
}
if (type === "2" && this.pushFlag) {
return this.$router.push({ name: "device-check", params: { dataId: this.aimId } });
}
if (type === "3") {
return this.$router.push({ name: "device-continued-detail", params: { dataId: this.aimId } });
}
},
//唤起扫码功能
scanning() {
window.qing.call("scanQRCode", {
"needResult": 1,
"success": function (result) {
if(result.data && result.data.qrcode_str){
let deviceId = result.data.qrcode_str.substring(0, 19);
// eslint-disable-next-line no-undef
aimThisData(deviceId);
}else{
return this.$dialog.alert({message: "扫描结果无法获取设备信息,请确认二维码是否属于设备二维码!"});
}
},
"error": function (res) {
return this.$dialog.alert({message: res.errMsg});
}
})
},
aimThisData(deviceId) {
this.deviceId = deviceId;
if (this.form.id === this.deviceId) {
this.pushFlag = true;
this.startCheck();
} else {
return this.$dialog.alert({message:"二维码和检测目标设备不匹配,请重新扫码"});
}
}
},
};
</script>
<style scoped>
</style>