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.
130 lines
4.6 KiB
130 lines
4.6 KiB
1 month ago
|
<template>
|
||
|
<el-dialog
|
||
|
:title="!dataForm.carId ? '新增' : '修改'"
|
||
|
:close-on-click-modal="false"
|
||
|
:visible.sync="visible">
|
||
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||
|
<el-form-item label="车型名称" prop="carName">
|
||
|
<el-input v-model="dataForm.carName" placeholder="车型名称"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="导航类型" prop="navigationType">
|
||
|
<el-input v-model="dataForm.navigationType" placeholder="导航类型"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="备注" prop="remarks">
|
||
|
<el-input v-model="dataForm.remarks" placeholder="备注"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="是否启用" prop="isOn">
|
||
|
<el-input v-model="dataForm.isOn" placeholder="是否启用"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="创建者ID" prop="createUserId">
|
||
|
<el-input v-model="dataForm.createUserId" placeholder="创建者ID"></el-input>
|
||
|
</el-form-item>
|
||
|
<el-form-item label="创建时间" prop="createTime">
|
||
|
<el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
|
||
|
</el-form-item>
|
||
|
</el-form>
|
||
|
<span slot="footer" class="dialog-footer">
|
||
|
<el-button @click="visible = false">取消</el-button>
|
||
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||
|
</span>
|
||
|
</el-dialog>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data () {
|
||
|
return {
|
||
|
visible: false,
|
||
|
dataForm: {
|
||
|
carId: 0,
|
||
|
carName: '',
|
||
|
navigationType: '',
|
||
|
remarks: '',
|
||
|
isOn: '',
|
||
|
createUserId: '',
|
||
|
createTime: ''
|
||
|
},
|
||
|
dataRule: {
|
||
|
carName: [
|
||
|
{ required: true, message: '车型名称不能为空', trigger: 'blur' }
|
||
|
],
|
||
|
navigationType: [
|
||
|
{ required: true, message: '导航类型不能为空', trigger: 'blur' }
|
||
|
],
|
||
|
remarks: [
|
||
|
{ required: true, message: '备注不能为空', trigger: 'blur' }
|
||
|
],
|
||
|
isOn: [
|
||
|
{ required: true, message: '是否启用不能为空', trigger: 'blur' }
|
||
|
],
|
||
|
createUserId: [
|
||
|
{ required: true, message: '创建者ID不能为空', trigger: 'blur' }
|
||
|
],
|
||
|
createTime: [
|
||
|
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
init (id) {
|
||
|
this.dataForm.carId = id || 0
|
||
|
this.visible = true
|
||
|
this.$nextTick(() => {
|
||
|
this.$refs['dataForm'].resetFields()
|
||
|
if (this.dataForm.carId) {
|
||
|
this.$http({
|
||
|
url: this.$http.adornUrl(`/tickets/car/info/${this.dataForm.carId}`),
|
||
|
method: 'get',
|
||
|
params: this.$http.adornParams()
|
||
|
}).then(({data}) => {
|
||
|
if (data && data.code === 0) {
|
||
|
this.dataForm.carName = data.car.carName
|
||
|
this.dataForm.navigationType = data.car.navigationType
|
||
|
this.dataForm.remarks = data.car.remarks
|
||
|
this.dataForm.isOn = data.car.isOn
|
||
|
this.dataForm.createUserId = data.car.createUserId
|
||
|
this.dataForm.createTime = data.car.createTime
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
// 表单提交
|
||
|
dataFormSubmit () {
|
||
|
this.$refs['dataForm'].validate((valid) => {
|
||
|
if (valid) {
|
||
|
this.$http({
|
||
|
url: this.$http.adornUrl(`/tickets/car/${!this.dataForm.carId ? 'save' : 'update'}`),
|
||
|
method: 'post',
|
||
|
data: this.$http.adornData({
|
||
|
'carId': this.dataForm.carId || undefined,
|
||
|
'carName': this.dataForm.carName,
|
||
|
'navigationType': this.dataForm.navigationType,
|
||
|
'remarks': this.dataForm.remarks,
|
||
|
'isOn': this.dataForm.isOn,
|
||
|
'createUserId': this.dataForm.createUserId,
|
||
|
'createTime': this.dataForm.createTime
|
||
|
})
|
||
|
}).then(({data}) => {
|
||
|
if (data && data.code === 0) {
|
||
|
this.$message({
|
||
|
message: '操作成功',
|
||
|
type: 'success',
|
||
|
duration: 1500,
|
||
|
onClose: () => {
|
||
|
this.visible = false
|
||
|
this.$emit('refreshDataList')
|
||
|
}
|
||
|
})
|
||
|
} else {
|
||
|
this.$message.error(data.msg)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|