<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="diagnosisVisible"
      @close="cancel"
    >
      <!--            <el-row :gutter="30" class="row search" type="flex" style="margin-bottom:0;">-->
      <el-form
        ref="setForm"
        :rules="addRules"
        :model="model"
        label-width="250px"
        label-suffix=":"
        label-position="right"
        size="mini"
        style="width: 100%;"
      >
        <el-form-item label="助诊意向时间">
          <el-date-picker
            v-model="rangeTime"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions1"
          />
        </el-form-item>
        <el-form-item
          label="备注"
          class="required-label"
        >
          <el-col :span="15">
            <el-input
              v-model="model.userName"
              type="textarea"
              style="width: 130%;"
              size="small"
              minlength="2"
              maxlength="500"
              placeholder="请输入原因"
            />
          </el-col>
        </el-form-item>
      </el-form>
      <!--            </el-row>-->
      <span
        slot="footer"
        class="dialog-footer"
        style="text-align: center;"
      >
        <el-button @click="cancel">取 消</el-button>
        <el-button
          type="primary"
          @click="confirm"
        >确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    props:[
      'diagnosisVisible'
    ],
    data() {
      return {
        show: false,
        title: '设置预约时间（问诊时间）',
        confirmTxt: '确定',
        cancleTxt: '',
        _promise: null,
        model:{
          userName:'',
          title:''
        },
        rangeTime:'',
        addRules:{
          userName: [
            {required: true, message: '请输入稍后跟进原因', trigger: 'blur'}
          ]
        },
        pickerOptions1: {
          disabledDate: time => {
            return (
              time.getTime() > new Date().getTime()
            ); // 减去一天的时间代表可以选择同一天;
          }
        },
      };
    },
    created() {},
    methods: {
      reset() {
        this.title = '';
        this.confirmTxt = '确定';
        this.cancleTxt = '';
        this._promise = null;
      },
      init(obj = {}) {
        Object.assign(this, obj);
        this.show = true;
        return new Promise((resolve, reject) => {
          this._promise = {
            resolve,
            reject
          };
        });
      },
      async cancle() {
        this.show = false;
        await this._promise.reject && this._promise.reject();
        this.reset();
      },
      async confirm() {
        this.show = false;
        await this._promise.resolve && this._promise.resolve();
        this.reset();
      },
      hide() {
        this.show = false;
        this.reset();
      },
      cancel() {
        this.$emit('update:diagnosisVisible', false);
      }
    }
  };
</script>
                                         
<style lang="scss" scoped>

</style>
