|
@@ -3,29 +3,29 @@
|
|
|
<el-form ref="form" :model="form" hide-required-asterisk :rules="serviceDataRules">
|
|
|
<div class="block">
|
|
|
<el-form-item label="Eculd" prop="ecuId" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.ecuId" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.ecuId" style="width: 35%;" autocomplete="off" placeholder="硬件中控ID" />
|
|
|
<div class="tip"><p>13位数字 , 示例 : ECA0419070800454</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="BatteryId" prop="batteryId" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.batteryId" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.batteryId" style="width: 35%;" autocomplete="off" placeholder="电池ID" />
|
|
|
<div class="tip"><p>13位数字 , 示例 : BAA3218101509005</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="VehicleId" prop="vehicleId" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.vehicleId" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.vehicleId" style="width: 35%;" autocomplete="off" placeholder="车辆ID" />
|
|
|
<div class="tip"><p>8位数字 , 示例 : 92264605</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="Imei" prop="imei" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.imei" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.imei" style="width: 35%;" autocomplete="off" placeholder="终端IMEI码" />
|
|
|
<div class="tip"><p>15位数字 , 示例 : 967047046635466</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="Imsi" prop="imsi" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.imsi" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.imsi" style="width: 35%;" autocomplete="off" placeholder="终端IMSI码" />
|
|
|
<div class="tip"><p>15位数字 , 示例 : 960046550508466</p></div>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<div class="block">
|
|
|
<el-form-item label="City" prop="cityName" :label-width="formLabelWidth">
|
|
|
- <el-select v-model="form.cityName" style="width: 35%;" filterable placeholder="请选择">
|
|
|
+ <el-select v-model="form.cityName" style="width: 35%;" filterable clearable placeholder="请选择城市">
|
|
|
<el-option
|
|
|
v-for="item in city"
|
|
|
:key="item.CityID"
|
|
@@ -35,27 +35,31 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="Lat" prop="lat" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.lat" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.lat" style="width: 35%;" autocomplete="off" placeholder="纬度" />
|
|
|
<div class="tip"><p>保留15位小数 , 示例 : 30.290707717493753</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="Lng" prop="lng" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.lng" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.lng" style="width: 35%;" autocomplete="off" placeholder="经度" />
|
|
|
<div class="tip"><p>保留15位小数 , 示例 : 120.07451533496764</p></div>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<div class="block">
|
|
|
<el-form-item label="VehicleVersion" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.vehicleVersion" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.vehicleVersion" style="width: 35%;" autocomplete="off" placeholder="整车版本" />
|
|
|
+ <div class="tip"><p>H1、H2等等,默认给H1</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="VehicleStatus" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.vehicleStatus" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.vehicleStatus" style="width: 35%;" autocomplete="off" placeholder="车辆状态" />
|
|
|
+ <div class="tip"><p>默认给0,0-正常;1-故障;2-高危不可用;10-低危;11-高危可用</p></div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="OperationStatus" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.operationStatus" style="width: 35%;" autocomplete="off" />
|
|
|
+ <el-input v-model="form.operationStatus" style="width: 35%;" autocomplete="off" placeholder="运营状态" />
|
|
|
+ <el-tooltip effect="dark" content="默认给100,100:运营中; 200:待运营-出厂; 201:待运营-库存; 202:待运营-移库; 301:停运-调度中; 304:停运-没收; 306:停运-已返厂; 307:停运-在库; 400:退出运营-报废" placement="top">
|
|
|
+ <div class="tip"><p>默认给100,100:运营中; 200:待运营-出厂; 201:待运营-库存 ...</p></div>
|
|
|
+ </el-tooltip>
|
|
|
</el-form-item>
|
|
|
<el-form-item class="submit">
|
|
|
<el-button size="mini" type="primary" @click="createFormData(form)">确 认</el-button>
|
|
|
- <el-button size="mini" type="success" @click="oneKeyCreate()">一键创建</el-button>
|
|
|
<el-button size="mini" type="danger" @click="$router.go(-1)">取 消</el-button>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
@@ -89,24 +93,75 @@ export default {
|
|
|
methods: {
|
|
|
// 提交表单并且返回刷新
|
|
|
createFormData(form) {
|
|
|
- if (this.form.ecuId || this.form.batteryId || this.form.imei || this.form.imsi || this.form.vehicleId) {
|
|
|
- this.$refs.form.validateField(['ecuId', 'batteryId', 'imei', 'imsi', 'vehicleId'], (valid) => {
|
|
|
- if (!valid) {
|
|
|
- console.log('Timer')
|
|
|
- // createHmVirtualDevice(form).then(res => {
|
|
|
- // if (res.code === 200) {
|
|
|
- // this.successFun('create')
|
|
|
- // this.$router.go(-1)
|
|
|
- // } else {
|
|
|
- // this.errorFun(res.msg)
|
|
|
- // }
|
|
|
- // })
|
|
|
+ if (!this.form.cityName && !this.form.lat && !this.form.lng && (this.form.ecuId || this.form.batteryId || this.form.imei || this.form.imsi || this.form.vehicleId)) {
|
|
|
+ console.log(1)
|
|
|
+ const fieldsToValidate = ['ecuId', 'batteryId', 'imei', 'imsi', 'vehicleId']
|
|
|
+ const _self = this
|
|
|
+ Promise.all(fieldsToValidate.map(item => {
|
|
|
+ const p = new Promise(function(resolve, reject) {
|
|
|
+ _self.$refs.form.validateField(item, (error) => {
|
|
|
+ resolve(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return p
|
|
|
+ })).then((data) => {
|
|
|
+ if (JSON.stringify(data) === '["","","","",""]') {
|
|
|
+ this.oneKeyCreate()
|
|
|
+ } else {
|
|
|
+ this.errorFun('还有未填写的数据')
|
|
|
}
|
|
|
+ // data 里是各个字段的验证错误信息, 如果为空串则认为验证通过, 如果数组里全为空串则所有验证通过
|
|
|
+ // 判断data 里是否全是空串
|
|
|
})
|
|
|
+ return
|
|
|
+ } else if (!this.form.ecuId && !this.form.batteryId && !this.form.imei && !this.form.imsi && !this.form.vehicleId && (this.form.cityName || this.form.lat || this.form.lng)) {
|
|
|
+ console.log(2)
|
|
|
+ const fieldsToValidate = ['cityName', 'lat', 'lng']
|
|
|
+ const _self = this
|
|
|
+ Promise.all(fieldsToValidate.map(item => {
|
|
|
+ const p = new Promise(function(resolve, reject) {
|
|
|
+ _self.$refs.form.validateField(item, (error) => {
|
|
|
+ resolve(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return p
|
|
|
+ })).then((data) => {
|
|
|
+ if (JSON.stringify(data) === '["","",""]') {
|
|
|
+ this.oneKeyCreate()
|
|
|
+ } else {
|
|
|
+ this.errorFun('还有未填写的数据')
|
|
|
+ }
|
|
|
+ // data 里是各个字段的验证错误信息, 如果为空串则认为验证通过, 如果数组里全为空串则所有验证通过
|
|
|
+ // 判断data 里是否全是空串
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } else if ((this.form.ecuId || this.form.batteryId || this.form.imei || this.form.imsi || this.form.vehicleId) && (this.form.cityName || this.form.lat || this.form.lng)) {
|
|
|
+ console.log(3)
|
|
|
+ const fieldsToValidate = ['ecuId', 'batteryId', 'imei', 'imsi', 'vehicleId', 'cityName', 'lat', 'lng']
|
|
|
+ const _self = this
|
|
|
+ Promise.all(fieldsToValidate.map(item => {
|
|
|
+ const p = new Promise(function(resolve, reject) {
|
|
|
+ _self.$refs.form.validateField(item, (error) => {
|
|
|
+ resolve(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return p
|
|
|
+ })).then((data) => {
|
|
|
+ if (JSON.stringify(data) === '["","","","","","","",""]') {
|
|
|
+ this.oneKeyCreate()
|
|
|
+ } else {
|
|
|
+ this.errorFun('还有未填写的数据')
|
|
|
+ }
|
|
|
+ // data 里是各个字段的验证错误信息, 如果为空串则认为验证通过, 如果数组里全为空串则所有验证通过
|
|
|
+ // 判断data 里是否全是空串
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ this.oneKeyCreate()
|
|
|
}
|
|
|
},
|
|
|
oneKeyCreate() {
|
|
|
- createHmVirtualDevice({}).then(res => {
|
|
|
+ createHmVirtualDevice(this.form).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.successFun('create')
|
|
|
this.$router.go(-1)
|
|
@@ -131,12 +186,6 @@ export default {
|
|
|
display flex
|
|
|
justify-content center
|
|
|
min-width 700px
|
|
|
- position: absolute
|
|
|
- z-index: 2000
|
|
|
- left 0
|
|
|
- right 0
|
|
|
- bottom 0
|
|
|
- top 0
|
|
|
.set-background >>> .el-form
|
|
|
width 100%
|
|
|
overflow auto
|