<template>
  <div>
    <el-dialog :title="canEdit ? '编辑使用期限' : '查看使用期限'" :visible.sync="visible" width="600px" @close="onClose">
      <el-row type="flex" justify="end" v-if="canEdit">
        <el-button @click="onClose">取消</el-button>
        <el-button type="primary" @click="submit()">确定</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
const ONE_M = 60 * 1000;
const ONE_HOUR = 60 * ONE_M;
const ONE_DAY = 24 * ONE_HOUR;
const ONE_YEAR = 365 * ONE_DAY;

export default {
  name: 'EditDialog',
  components: {
  },
  props: {
    visible: false,

  },
  data() {
    return {
      showLog: false,
    };
  },
  methods: {
    onClose() {
      this.$emit('update:visible', false);
    },
    submit() {
      // console.log(this.dateValue,getTime(this.dateValue[0]));
    }
  },
  watch: {
    detailItem: {
      immediate: true,
      deep: true,
      handler(detailItem) {
        this.serviceList.map((item, index) => {
          if (!detailItem.enterpriseServices) {
            return;
          }
          let service = detailItem.enterpriseServices[item.key] || {};
          item = Object.assign(item, service);
          if (service.serviceEndDate && service.serviceStartDate) {
            this.$set(item, 'dateValue', [new Date(service.serviceStartDate), new Date(service.serviceEndDate)]);
          } else {
            this.$set(item, 'dateValue', ['', '']);
          }
          this.serviceList[index] = item;
        });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
