123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import AntModal from '@/components/pt/dialog/AntModal'
- import { getSysReservationConfig, addSysReservationConfig, updateSysReservationConfig, batchAddSysReservationConfig } from '@/api/system/sysReservationConfig'
- export default {
- name: 'CreateForm',
- props: {
- statusOptions: {
- type: Array,
- required: true
- }
- },
- components: {
- AntModal
- },
- data () {
- return {
- open: false,
- closeDialog: true,
- spinning: false,
- delayTime: 100,
- labelCol: { span: 4 },
- wrapperCol: { span: 14 },
- loading: false,
- disabled: false,
- total: 0,
- id: undefined,
- formTitle: '预约配置',
- // 表单参数
- form: {},
- batchForm: {
- dateRange: []
- },
- rules: {
- reservationDate: [{ required: true, message: '预约日期不能为空', trigger: 'blur' }],
- reservationStartTime: [{ required: true, message: '预约开始时段不能为空', trigger: 'blur' }],
- reservationEndTime: [{ required: true, message: '预约结束时段不能为空', trigger: 'blur' }],
- enableNum: [{ required: true, message: '可预约人数不能为空', trigger: 'blur' }]
- },
- batchAddRules: {
- dateRange: [{ required: true, message: '预约日期不能为空', trigger: 'blur' }],
- duration: [{ required: true, message: '班次时长不能为空', trigger: 'blur' }],
- enableNum: [{ required: true, message: '可预约人数不能为空', trigger: 'blur' }]
- }
- }
- },
- filters: {},
- created () {},
- computed: {},
- watch: {},
- mounted () {},
- methods: {
- onClose () {
- this.open = false
- this.reset()
- this.$emit('close')
- },
- // 取消按钮
- cancel () {
- this.open = false
- this.reset()
- this.$emit('close')
- },
- // 表单重置
- reset () {
- this.form = {
- id: undefined,
- reservationDate: undefined,
- reservationStartTime: undefined,
- reservationEndTime: undefined,
- enableNum: undefined,
- status: '0'
- }
- },
- /** 新增按钮操作 */
- handleAdd () {
- this.reset()
- this.open = true
- this.formTitle = '预约配置'
- },
- /** 修改按钮操作 */
- handleUpdate (row) {
- this.reset()
- this.open = true
- this.spinning = !this.spinning
- const sysReservationConfigId = row.id
- getSysReservationConfig(sysReservationConfigId).then(response => {
- this.form = response.data
- this.formTitle = '修改预约配置'
- this.spinning = !this.spinning
- })
- },
- batchSave: function (closeDialog, status) {
- this.closeDialog = closeDialog
- this.disabled = true
- this.$refs.batchForm.validate(valid => {
- if (valid) {
- const saveForm = {
- startDate: this.batchForm.dateRange[0],
- endDate: this.batchForm.dateRange[1],
- duration: this.batchForm.duration,
- enableNum: this.batchForm.enableNum,
- status: status
- }
- batchAddSysReservationConfig(saveForm).then(response => {
- this.$message.success('配置成功', 3)
- this.open = false
- this.$emit('ok')
- this.$emit('close')
- this.disabled = false
- })
- } else {
- this.disabled = false
- return false
- }
- })
- },
- /** 提交按钮 */
- submitForm: function (closeDialog) {
- this.closeDialog = closeDialog
- this.disabled = true
- this.$refs.form.validate(valid => {
- if (valid) {
- const saveForm = JSON.parse(JSON.stringify(this.form))
- if (this.form.id !== undefined) {
- updateSysReservationConfig(saveForm).then(response => {
- this.$message.success('更新成功', 3)
- this.open = false
- this.$emit('ok')
- this.$emit('close')
- this.disabled = false
- })
- } else {
- addSysReservationConfig(saveForm).then(response => {
- this.$message.success('新增成功', 3)
- this.open = false
- this.$emit('ok')
- this.$emit('close')
- this.disabled = false
- })
- }
- } else {
- this.disabled = false
- return false
- }
- })
- },
- back () {
- const index = '/system/sysreservationconfig/index'
- this.$router.push(index)
- }
- }
- }
|