182 lines
5.3 KiB
Vue
182 lines
5.3 KiB
Vue
<template>
|
|
<el-form ref="form" :rules="rules" label-width="110px" :model="form">
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="班次名称" prop="name">
|
|
<el-input v-model="form.name"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="编码" prop="code">
|
|
<el-input v-model="form.code" disabled></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="生效时间" prop="enableTime">
|
|
<el-date-picker
|
|
v-model="form.enableTime"
|
|
type="datetime"
|
|
placeholder="选择日期时间"
|
|
label-format="yyyy-MM-dd HH:mm:ss"
|
|
value-format="timestamp"
|
|
style="width: 100%;">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="失效时间" prop="disableTime">
|
|
<el-date-picker
|
|
v-model="form.disableTime"
|
|
type="datetime"
|
|
placeholder="选择日期时间"
|
|
label-format="yyyy-MM-dd HH:mm:ss"
|
|
value-format="timestamp"
|
|
style="width: 100%;">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="班次开始时间" prop="startTime">
|
|
<el-time-picker
|
|
v-model="form.startTime"
|
|
format='HH:mm'
|
|
value-format='HH:mm'
|
|
style="width: 100%;"
|
|
@change="timeFun"
|
|
>
|
|
</el-time-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="班次结束时间" prop="endTime">
|
|
<el-time-picker
|
|
v-model="form.endTime"
|
|
format='HH:mm'
|
|
value-format='HH:mm'
|
|
style="width: 100%;"
|
|
@change="timeFun"
|
|
>
|
|
</el-time-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="form.remark"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="是否跨天" prop="daySpan">
|
|
<el-select v-model="form.daySpan" placeholder="请选择" disabled style="width: 100%;">
|
|
<el-option label="否" :value= '0' ></el-option>
|
|
<el-option label="是" :value= '1' ></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
</template>
|
|
<script>
|
|
import { getGroupClasses, updateGroupClasses, createGroupClasses, getCode } from '@/api/base/groupClasses'
|
|
export default {
|
|
name: 'groupClassAdd',
|
|
data() {
|
|
return {
|
|
form: {
|
|
id: '',
|
|
name: '',
|
|
code: '',
|
|
enableTime: '',
|
|
disableTime: '',
|
|
startTime: '',
|
|
endTime: '',
|
|
daySpan: '',
|
|
remark: ''
|
|
},
|
|
isEdit: false, //是否是编辑
|
|
rules: {
|
|
name: [{ required: true, message: '请输入班组名称', trigger: 'blur' }],
|
|
enableTime: [{ required: true, message: '请选择班次开始时间', trigger: 'change' }],
|
|
code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
|
|
startTime: [{ required: true, message: '请输入生效时间', trigger: 'change' }],
|
|
endTime: [{ required: true, message: '请选择班次结束时间', trigger: 'change' }]
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
init(id) {
|
|
if (id) {
|
|
this.isEdit = true
|
|
this.form.id = id
|
|
getGroupClasses(id).then((res) => {
|
|
if (res.code === 0) {
|
|
this.form = res.data
|
|
}
|
|
})
|
|
} else {
|
|
this.isEdit = false
|
|
this.form.id = ''
|
|
getCode().then((res) => {
|
|
this.form.code = res.data
|
|
})
|
|
}
|
|
},
|
|
timeFun() {
|
|
if (this.form.startTime && this.form.endTime) {
|
|
if (this.form.startTime > this.form.endTime) {
|
|
this.form.daySpan = 1
|
|
} else {
|
|
this.form.daySpan = 0
|
|
}
|
|
}
|
|
},
|
|
submitForm() {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (valid) {
|
|
let obj = {}
|
|
if (this.form.disableTime) {
|
|
obj = this.form
|
|
} else {
|
|
obj.id = this.form.id
|
|
obj.name = this.form.name
|
|
obj.code = this.form.code
|
|
obj.enableTime = this.form.enableTime
|
|
obj.startTime = this.form.startTime
|
|
obj.endTime = this.form.endTime
|
|
obj.daySpan = this.form.daySpan
|
|
obj.remark = this.form.remark
|
|
}
|
|
if (this.isEdit) {
|
|
//编辑
|
|
updateGroupClasses({ ...obj }).then((res) => {
|
|
if (res.code === 0) {
|
|
this.$modal.msgSuccess("操作成功");
|
|
this.$emit('successSubmit')
|
|
}
|
|
})
|
|
} else {
|
|
createGroupClasses({ ...obj }).then((res) => {
|
|
if (res.code === 0) {
|
|
this.$modal.msgSuccess("操作成功");
|
|
this.$emit('successSubmit')
|
|
}
|
|
})
|
|
}
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
formClear() {
|
|
this.$refs.form.resetFields()
|
|
this.isEdit = false
|
|
}
|
|
}
|
|
}
|
|
</script>
|