<template>
  <div>
    <el-dialog
      title="修改服务单日期"
      :visible.sync="isShow"
      :show-close="false"
      width="400px"
      :close-on-click-modal="false"
    >
      <el-form ref="dateForm" :model="dateForm" :rules="dateFormRules" label-position="left" label-width="80px">
        <el-form-item label="选择日期" prop="date">
          <el-date-picker
            v-model="dateForm.date"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            default-time="00:00:00"
            style="width: 100%"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelDateForm">取 消</el-button>
        <el-button type="primary" @click="submitDateForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'EditDateTimeDialog',
  props: {
    isShow: {
      type: Boolean,
      default: false
    },
    dateForm: {
      type: Object,
      default: {
        date: ''
      }
    }
  },
  data() {
    return {
      dateFormRules: {
        date: [{ required: true, message: '请选择服务单日期', trigger: 'change' }]
      }
    }
  },
  methods: {
    cancelDateForm() {
      this.$emit('update:isShow', false)
    },

    submitDateForm() {
      this.$refs.dateForm.validate(valid => {
        if (valid) {
          this.$parent.submitDateForm()
        }
      })
    }
  }
}
</script>

<style></style>
