<template>
  <van-dialog @confirm="onConfirm" v-model="show" show-cancel-button>
    <div style="margin: 10px">
      <div>
        <div>是否登记{{ stateText }}时间?</div>
      </div>
      <time-cell
        v-if="show"
        required
        is-row
        title="时间"
        v-model="time"
        dateType="datetime"
        textFormatter="YYYY年M月D日H时m分"
        :max-date="new Date()"
      />
    </div>
  </van-dialog>
</template>

<script>
import dayjs from 'dayjs'
import TimeCell from '@/components/timeCell'

export default {
  components: { TimeCell },
  data() {
    return {
      show: false,
      subSystem: {},
      stateText: '',
      time: new Date()
    }
  },
  props: {},
  methods: {
    dayjs,
    onConfirm() {
      this.$emit('success', this.subSystem, this.state, this.time)
    },
    open(subSystem, state, stateText) {
      this.subSystem = subSystem
      this.state = state
      this.stateText = stateText
      this.time = new Date()
      this.show = true
    }
  }
}
</script>
