|
@@ -1,32 +1,31 @@
|
|
|
<template>
|
|
|
- <div id="window-judge" class="set-background">
|
|
|
- <div class="block">
|
|
|
- <el-form ref="form" :model="form" :rules="serviceDataRules">
|
|
|
+ <div class="set-background">
|
|
|
+ <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" />
|
|
|
- <div class="tip"><p>以VIR开头拼接13位数字 , 示例 : VIR0419070800454</p></div>
|
|
|
+ <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" />
|
|
|
- <div class="tip"><p>以BAA开头拼接13位数字 , 示例 : BAA3218101509005</p></div>
|
|
|
+ <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" />
|
|
|
- <div class="tip"><p>以9开头的8位数字 , 示例 : 92264605</p></div>
|
|
|
+ <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" />
|
|
|
- <div class="tip"><p>以9开头的15位数字 , 示例 : 967047046635466</p></div>
|
|
|
+ <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" />
|
|
|
- <div class="tip"><p>以9开头的15位数字 , 示例 : 960046550508466</p></div>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="VehicleVersion" prop="vehicleVersion" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.vehicleVersion" 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" 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,12 +34,36 @@
|
|
|
/>
|
|
|
</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" 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" 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" 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" 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" 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="primary" @click="createFormData(form)">确 认</el-button>
|
|
|
<el-button size="mini" type="danger" @click="$router.go(-1)">取 消</el-button>
|
|
|
</el-form-item>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -100,32 +123,97 @@ export default {
|
|
|
'lng': 117.26081489617174
|
|
|
},
|
|
|
serviceDataRules: {
|
|
|
- imei: [{ required: true, message: '终端IMEI码必须为十五位', trigger: 'change' }],
|
|
|
- ecuId: [{ required: true, message: '硬件中控ID不能为空', trigger: 'change' }],
|
|
|
- vehicleId: [{ required: true, message: '车辆ID不能为空', trigger: 'change' }],
|
|
|
- imsi: [{ required: true, message: '终端IMSI码不能为空', trigger: 'change' }],
|
|
|
- batteryId: [{ required: true, message: '电池ID不能为空', trigger: 'change' }],
|
|
|
- vehicleVersion: [{ required: true, message: '整车版本不能为空', trigger: 'change' }],
|
|
|
- cityName: [{ required: true, message: '城市名称不能为空', trigger: 'change' }]
|
|
|
+ imei: [{ required: true, message: '终端IMEI码必须为十五位', trigger: 'blur' }],
|
|
|
+ ecuId: [{ required: true, message: '硬件中控ID不能为空', trigger: 'blur' }],
|
|
|
+ vehicleId: [{ required: true, message: '车辆ID不能为空', trigger: 'blur' }],
|
|
|
+ imsi: [{ required: true, message: '终端IMSI码不能为空', trigger: 'blur' }],
|
|
|
+ batteryId: [{ required: true, message: '电池ID不能为空', trigger: 'blur' }],
|
|
|
+ cityName: [{ required: true, message: '城市名称不能为空', trigger: 'blur' }],
|
|
|
+ lat: [{ required: true, message: '纬度不能为空', trigger: 'blur' }],
|
|
|
+ lng: [{ required: true, message: '经度不能为空', trigger: 'blur' }]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ document.getElementsByClassName('app-main')[0].style.cssText = 'overflow:auto'
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 提交表单并且返回刷新
|
|
|
createFormData(form) {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- form.hmVehicleBaseInfo = this.hmVehicleBaseInfo
|
|
|
- form.hmVehicleBaseStationInfo = this.hmVehicleBaseStationInfo
|
|
|
- form.hmVehicleGpsInfo = this.hmVehicleGpsInfo
|
|
|
- createHmVirtualDevice(form).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.successFun('create')
|
|
|
- this.$router.go(-1)
|
|
|
- } else {
|
|
|
- this.errorFun('create')
|
|
|
- }
|
|
|
+ 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(this.form).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.successFun('create')
|
|
|
+ this.$router.go(-1)
|
|
|
+ } else {
|
|
|
+ this.errorFun(res.msg)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -133,7 +221,7 @@ export default {
|
|
|
this.$notify({ title: 'Success', message: `${successText} Successfully`, type: 'success', duration: 2000 })
|
|
|
},
|
|
|
errorFun(errorText) {
|
|
|
- this.$notify({ title: 'Failed', message: `${errorText} Failed`, type: 'error', duration: 2000 })
|
|
|
+ this.$notify({ title: 'Failed', message: errorText, type: 'error', duration: 2000 })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -145,32 +233,34 @@ export default {
|
|
|
display flex
|
|
|
justify-content center
|
|
|
min-width 700px
|
|
|
- .block
|
|
|
- background-color rgba(255,255,255,1)
|
|
|
- box-shadow 0px 0px 11px 0px rgba(238,240,245,1)
|
|
|
- border-radius 7px
|
|
|
- width 93%
|
|
|
- margin 25px 0
|
|
|
- padding 60px
|
|
|
- min-height calc(100vh - 100px)
|
|
|
- .block >>> .el-form-item__label
|
|
|
- display flex
|
|
|
- .block >>> .el-form-item__content
|
|
|
- display flex
|
|
|
- .tip
|
|
|
- width 60%
|
|
|
- position relative
|
|
|
- text-align center
|
|
|
- .tip p
|
|
|
- position absolute
|
|
|
- bottom 0px
|
|
|
- padding 0px
|
|
|
- margin 0px
|
|
|
- color grey
|
|
|
- height 30px
|
|
|
- margin-left 15px
|
|
|
- .submit
|
|
|
- display flex
|
|
|
- flex-direction row-reverse
|
|
|
- // margin-top 60px
|
|
|
+ .set-background >>> .el-form
|
|
|
+ width 100%
|
|
|
+ overflow auto
|
|
|
+ .block
|
|
|
+ background-color rgba(255,255,255,1)
|
|
|
+ box-shadow 0px 0px 11px 0px rgba(238,240,245,1)
|
|
|
+ border-radius 7px
|
|
|
+ width 96%
|
|
|
+ margin 20px auto
|
|
|
+ padding 29px 50px
|
|
|
+ .block >>> .el-form-item__label
|
|
|
+ display flex
|
|
|
+ .block >>> .el-form-item__content
|
|
|
+ display flex
|
|
|
+ .tip
|
|
|
+ width 60%
|
|
|
+ position relative
|
|
|
+ text-align center
|
|
|
+ .tip p
|
|
|
+ position absolute
|
|
|
+ bottom 0px
|
|
|
+ padding 0px
|
|
|
+ margin 0px
|
|
|
+ color grey
|
|
|
+ height 30px
|
|
|
+ margin-left 15px
|
|
|
+ .submit
|
|
|
+ display flex
|
|
|
+ flex-direction row-reverse
|
|
|
+ // margin-top 60px
|
|
|
</style>
|