You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
7.2 KiB
218 lines
7.2 KiB
<template>
|
|
<el-form ref="deviceCreate" :model="data" :rules="rules" label-position="top">
|
|
<el-row :gutter="20">
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="设备ID号(6位)" prop="deviceId">
|
|
<el-input v-model="data.deviceId"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="设备完整ID" prop="deviceFullId">
|
|
<el-input v-model="data.deviceFullId"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="地区" prop="area">
|
|
<el-input v-model="data.area"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="安装地点名称" prop="address">
|
|
<el-input v-model="data.address"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="联系人" prop="contact">
|
|
<el-input v-model="data.contact"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="电话" prop="phone">
|
|
<el-input v-model="data.phone"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="经度" prop="lon">
|
|
<el-input v-model="data.lon"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="纬度" prop="lat">
|
|
<el-input v-model="data.lat"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="负责人" prop="head">
|
|
<el-input v-model="data.head"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="安装位置" prop="installLocation">
|
|
<el-input v-model="data.installLocation"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="安装时间" prop="installTime">
|
|
<el-date-picker v-model="data.installTime" placeholder="安装时间" style="width: 100%" type="datetime"></el-date-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="正式运行时间" prop="runTime">
|
|
<el-date-picker v-model="data.runTime" placeholder="正式运行时间" style="width: 100%" type="datetime"></el-date-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="链路地址" prop="linkAddress">
|
|
<el-input v-model="data.linkAddress"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="探头编号" prop="probNo">
|
|
<el-input v-model="data.probNo"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="试样" prop="simple">
|
|
<el-input v-model="data.simple"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="sim卡1" prop="sim1">
|
|
<el-input v-model="data.sim1"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="设备朝向" prop="deviceDirection">
|
|
<el-input v-model="data.deviceDirection"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="协议版本" prop="protocolVersion">
|
|
<el-input v-model="data.protocolVersion"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-row :gutter="20">
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="与主站后台联调情况" prop="joint">
|
|
<el-input v-model="data.joint" type="textarea"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="维修记录" prop="operationRecord">
|
|
<el-input v-model="data.operationRecord" type="textarea"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="8" :md="12" :span="12" :xl="6" :xs="24">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="data.remark" type="textarea"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-row :gutter="20" class="mt-5 pl-2">
|
|
<el-form-item>
|
|
<el-button type="primary" @click="onSubmit">提交</el-button>
|
|
<el-button @click="onReset">重置</el-button>
|
|
</el-form-item>
|
|
</el-row>
|
|
</el-form>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { defineEmits, reactive, ref } from 'vue';
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
import { useStore } from 'vuex';
|
|
import { createDevice } from 'apis';
|
|
|
|
const data = reactive({
|
|
deviceId: '', // 设备id
|
|
deviceFullId: '', // 设备完整id
|
|
deviceDirection: '', // 设备朝向
|
|
area: '', // 地区
|
|
address: '', // 安装地点名称
|
|
contact: '', // 联系人
|
|
phone: '', // 联系人电话
|
|
lon: '', // 经度
|
|
lat: '', // 纬度
|
|
head: '', // 负责人
|
|
installLocation: '', // 安装位置
|
|
installTime: '', // 安装时间
|
|
runTime: '', // 正式运行时间
|
|
linkAddress: '', // 链路地址
|
|
probNo: '', // 探头编号
|
|
simple: '', // 试样
|
|
sim1: '', // sim卡1
|
|
protocolVersion: '', // 协议版本
|
|
joint: '', // 主站后台联调情况
|
|
operationRecord: '', // 维修记录
|
|
remark: '', // 备注
|
|
});
|
|
|
|
const rules = {
|
|
deviceId: [
|
|
{
|
|
required: true,
|
|
message: '请输入设备ID号',
|
|
trigger: 'blur',
|
|
},
|
|
{
|
|
len: 6,
|
|
message: '请输入6位设备ID号',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
};
|
|
|
|
const deviceCreate = ref(null); // form
|
|
const store = useStore();
|
|
const emit = defineEmits(['hide']);
|
|
|
|
// 重置表单
|
|
const onReset = () => {
|
|
deviceCreate.value.resetFields();
|
|
};
|
|
|
|
// 提交表单
|
|
const onSubmit = () => {
|
|
deviceCreate.value.validate(async valid => {
|
|
if (!valid) return;
|
|
if (data.installTime) {
|
|
data.installTime = new Date(data.installTime).getTime();
|
|
}
|
|
if (data.runTime) {
|
|
data.runTime = new Date(data.runTime).getTime();
|
|
}
|
|
try {
|
|
await createDevice({ ...data });
|
|
store.commit('device/unshiftDevice', { ...data });
|
|
ElMessageBox.confirm('添加成功,是否继续添加', '提示', {
|
|
confirmButtonText: '继续添加',
|
|
cancelButtonText: '关闭',
|
|
type: 'success',
|
|
})
|
|
.then(() => {
|
|
// 确认继续添加
|
|
onReset();
|
|
})
|
|
.catch(() => {
|
|
onReset();
|
|
emit('on-hide');
|
|
});
|
|
await store.dispatch('device/getDevices'); // 更新站点列表
|
|
} catch (error) {
|
|
ElMessage.error(error);
|
|
throw new Error(error);
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
|