<template>
  <div>
    <Modal v-model="maintainEndTimeModal" width="430">
      <p slot="header">
        {{ modalTitle }}
      </p>
      <Row>
        <!--维护实际时间-->
        <Col span="24" />
        <Form
          id="edit-time-end-forms"
          ref="formObj"
          :model="formObj"
          :rules="ruleValidate"
          inline
          onsubmit="return false"
          :label-width="130"
        >
          <Form-item label="维护实际结束时间" prop="checkEndTimeAct">
            <DatePicker
              v-model="formObj.checkEndTimeAct"
              format="yyyy-MM-dd HH:mm"
              type="datetime"
              placement="bottom"
              placeholder="请选择有效期"
              style="width:245px"
              @on-change="_dateChange"
            />
          </Form-item>
        </Form>
        </Col>
      </Row>
      <div slot="footer">
        <Button type="ghost" style="margin-left: 8px" @click="_cancel">
          取消
        </Button>
        <Button type="info" @click="_ok">
          确定
        </Button>
      </div>
    </Modal>
  </div>
</template>

<script>
const defVal = {
  checkEndTimeAct: ''
}
export default {
  name: 'LmsMaintainStartTimeAct',

  data() {
    return {
      maintainEndTimeModal: false,
      modalTitle: '',
      types: '',
      actTime: true,
      selectIds: [],
      formObj: defVal,
      checkId: '',
      ruleValidate: {
        checkEndTimeAct: [
          {
            required: true,
            message: '维护实际结束时间不能为空',
            trigger: 'change'
          }
        ]
      }
    }
  },
  methods: {
    _open(ids, checkId) {
      this.$refs.formObj.resetFields()
      this.checkId = checkId
      this.modalTitle = '维护实际结束时间'
      this.maintainEndTimeModal = true
      this.selectIds = ids
    },
    _cancel() {
      this.maintainEndTimeModal = false
    },
    _ok() {
      this.$refs.formObj.validate(valid => {
        if (valid) {
          this._resultChange('保存成功!')
        }
      })
    },
    _resultChange(msg) {
      this.maintainEndTimeModal = false
      this.$Message.success(msg)
      this.$emit(
        'on-result-change',
        this.formObj.checkEndTimeAct,
        'checkEndTimeAct'
      )
    },
    _dateChange(data) {
      this.formObj.checkEndTimeAct = data
    }
  }
}
</script>

<style scoped>
</style>
