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.

157 lines
6.0 KiB

<template>
<el-dialog
:title="!dataForm.ticketsId ? '新增' : '修改'"
: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="carType">
<el-input v-model="dataForm.carType" placeholder="小车类型"></el-input>
</el-form-item>
<el-form-item label="异常类型" prop="errorType">
<el-input v-model="dataForm.errorType" placeholder="异常类型"></el-input>
</el-form-item>
<el-form-item label="合同编号" prop="contractNumber">
<el-input v-model="dataForm.contractNumber" placeholder="合同编号"></el-input>
</el-form-item>
<el-form-item label="客户id" prop="clientId">
<el-input v-model="dataForm.clientId" placeholder="客户id"></el-input>
</el-form-item>
<el-form-item label="故障描述" prop="description">
<el-input v-model="dataForm.description" placeholder="故障描述"></el-input>
</el-form-item>
<el-form-item label="部门对接人" prop="deptPeople">
<el-input v-model="dataForm.deptPeople" placeholder="部门对接人"></el-input>
</el-form-item>
<el-form-item label="客户联系电话" prop="deptPhone">
<el-input v-model="dataForm.deptPhone" 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: {
ticketsId: 0,
carType: '',
errorType: '',
contractNumber: '',
clientId: '',
description: '',
deptPeople: '',
deptPhone: '',
createUserId: '',
createTime: ''
},
dataRule: {
carType: [
{ required: true, message: '小车类型不能为空', trigger: 'blur' }
],
errorType: [
{ required: true, message: '异常类型不能为空', trigger: 'blur' }
],
contractNumber: [
{ required: true, message: '合同编号不能为空', trigger: 'blur' }
],
clientId: [
{ required: true, message: '客户id不能为空', trigger: 'blur' }
],
description: [
{ required: true, message: '故障描述不能为空', trigger: 'blur' }
],
deptPeople: [
{ required: true, message: '部门对接人不能为空', trigger: 'blur' }
],
deptPhone: [
{ required: true, message: '客户联系电话不能为空', trigger: 'blur' }
],
createUserId: [
{ required: true, message: '创建者ID不能为空', trigger: 'blur' }
],
createTime: [
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.ticketsId = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.ticketsId) {
this.$http({
url: this.$http.adornUrl(`/tickets/tickets/info/${this.dataForm.ticketsId}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.carType = data.tickets.carType
this.dataForm.errorType = data.tickets.errorType
this.dataForm.contractNumber = data.tickets.contractNumber
this.dataForm.clientId = data.tickets.clientId
this.dataForm.description = data.tickets.description
this.dataForm.deptPeople = data.tickets.deptPeople
this.dataForm.deptPhone = data.tickets.deptPhone
this.dataForm.createUserId = data.tickets.createUserId
this.dataForm.createTime = data.tickets.createTime
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/tickets/tickets/${!this.dataForm.ticketsId ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'ticketsId': this.dataForm.ticketsId || undefined,
'carType': this.dataForm.carType,
'errorType': this.dataForm.errorType,
'contractNumber': this.dataForm.contractNumber,
'clientId': this.dataForm.clientId,
'description': this.dataForm.description,
'deptPeople': this.dataForm.deptPeople,
'deptPhone': this.dataForm.deptPhone,
'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>