Files
flowable_management/base-vue/src/views/modules/tickets/tickets-add-or-update.vue

150 lines
4.9 KiB
Vue
Raw Normal View History

2025-02-26 20:08:54 +08:00
<template>
<el-dialog
:title="!dataForm.ticketsId ? '新增' : '修改'"
:close-on-click-modal="false"
2025-03-14 17:56:05 +08:00
:visible.sync="visible"
width="500px">
<el-form :model="dataForm" :rules="dataRule" label-width="100px" size="mini" ref="dataForm" @keyup.enter.native="dataFormSubmit()">
2025-09-26 16:31:48 +08:00
<el-form-item label="项目编号" prop="contractCode">
<el-input v-model="dataForm.contractCode" placeholder="项目编号"></el-input>
</el-form-item>
<el-form-item label="客户" prop="clientId">
<el-select v-model="dataForm.clientId" placeholder="客户">
<el-option
v-for="item in dictData[3]"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="车型" prop="carType">
<el-select v-model="dataForm.carType" placeholder="车型">
2025-03-10 20:22:36 +08:00
<el-option
2025-03-18 14:48:46 +08:00
v-for="item in dictData[0]"
2025-03-10 20:22:36 +08:00
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
2025-02-26 20:08:54 +08:00
</el-form-item>
2025-09-26 16:31:48 +08:00
<el-form-item label="问题属性" prop="errorType">
<el-select v-model="dataForm.errorType" placeholder="问题属性">
2025-03-10 20:22:36 +08:00
<el-option
2025-03-18 14:48:46 +08:00
v-for="item in dictData[1]"
2025-03-10 20:22:36 +08:00
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
2025-02-26 20:08:54 +08:00
</el-form-item>
2025-03-20 09:03:10 +08:00
<el-form-item label="合同编号" prop="contractId">
<el-select v-model="dataForm.contractId" placeholder="合同编号">
2025-03-14 17:56:05 +08:00
<el-option
2025-03-18 14:48:46 +08:00
v-for="item in dictData[2]"
2025-03-14 17:56:05 +08:00
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
2025-02-26 20:08:54 +08:00
</el-form-item>
2025-09-26 16:31:48 +08:00
2025-02-26 20:08:54 +08:00
<el-form-item label="故障描述" prop="description">
2025-03-20 16:27:20 +08:00
<el-input type="textarea" :rows="4" placeholder="故障描述" v-model="dataForm.description"></el-input>
2025-02-26 20:08:54 +08:00
</el-form-item>
<el-form-item label="客户联系电话" prop="deptPhone">
<el-input v-model="dataForm.deptPhone" placeholder="客户联系电话"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
2025-03-14 17:56:05 +08:00
<el-button size="mini" @click="visible = false">取消</el-button>
<el-button size="mini" type="primary" @click="dataFormSubmit()">确定</el-button>
2025-02-26 20:08:54 +08:00
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
2025-03-05 15:27:30 +08:00
ticketsId: null,
2025-02-26 20:08:54 +08:00
carType: '',
errorType: '',
2025-09-26 16:31:48 +08:00
contractCode: '',
2025-02-26 20:08:54 +08:00
clientId: '',
description: '',
2025-03-14 17:56:05 +08:00
deptPhone: ''
2025-02-26 20:08:54 +08:00
},
dataRule: {
carType: [
{ required: true, message: '小车类型不能为空', trigger: 'blur' }
],
errorType: [
{ required: true, message: '异常类型不能为空', trigger: 'blur' }
],
clientId: [
{ required: true, message: '客户id不能为空', trigger: 'blur' }
]
}
}
},
2025-03-14 17:56:05 +08:00
props: {
2025-03-18 14:48:46 +08:00
dictData: Array
2025-03-05 15:27:30 +08:00
},
2025-02-26 20:08:54 +08:00
methods: {
init (id) {
2025-03-18 14:48:46 +08:00
console.log(this.dictData)
2025-02-26 20:08:54 +08:00
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
2025-03-18 14:48:46 +08:00
this.dataForm.errorType = String(data.tickets.errorType)
2025-03-20 09:03:10 +08:00
this.dataForm.contractId = String(data.tickets.contractId)
this.dataForm.clientId = String(data.tickets.clientId)
2025-02-26 20:08:54 +08:00
this.dataForm.description = data.tickets.description
this.dataForm.deptPhone = data.tickets.deptPhone
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/tickets/tickets/${!this.dataForm.ticketsId ? 'save' : 'update'}`),
method: 'post',
2025-03-10 20:22:36 +08:00
data: this.$http.adornData(this.dataForm)
2025-02-26 20:08:54 +08:00
}).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>