<template>
<!-- 借阅申请 -->
  <el-dialog v-dialogDrag ref="diaFrom" :title="'借阅申请'" :close-on-click-modal="false"
    :visible.sync="visible" width="40%" top="10px" :before-close="cancel">
    <el-form :model="borrowApply" ref="batchBorrowRef" label-width="100px" :rules="rules">
      <el-form-item label="申请人：">
        <el-input clearable size="mini" disabled v-model="borrowApply.apuserName" :title="borrowApply.apuserName"></el-input>
      </el-form-item>
      <el-form-item label="申请日期：">
        <el-date-picker size="mini" disabled v-model="borrowApply.apdate"
         value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="档案介质：" prop="medium">
        <el-select style="width:100%" clearable v-model="borrowApply.medium" size="mini">
          <el-option label="电子" value="0"></el-option>
          <el-option label="纸质" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="利用形式：" prop="utform">
        <el-select style="width:100%" clearable v-model="borrowApply.utform" size="mini">
          <el-option label="查看" value="0"></el-option>
          <el-option label="打印" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="到期日期：" prop="duedate">
        <el-date-picker style="width:100%" :picker-options="pickerOptions" size="mini" v-model="borrowApply.duedate"
          type="date" placeholder="选择日期" value-format="yyyy-MM-dd"></el-date-picker>
      </el-form-item>
      <el-form-item label="申请理由：" prop="fileaim">
        <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="borrowApply.fileaim">
        </el-input>
      </el-form-item>
      <el-form-item label=" ">
        <el-button  @click="submit('batchBorrowRef')" type="primary" size="mini">确定
        </el-button>
        <el-button @click="cancel" type="info" size="mini">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
import { submitApply } from "@/api/archives-management/fileManagement/notStoredArchives.js";
import { message,getCurrentTime} from "@/utils/common";
import { mapState } from "vuex";
export default {
  props: {
    visible: {
      type: Boolean,
      default: () => false,
    },
    borrowApply:{
      type:Object,
      default:()=>{}
    }
  },
  data() {
    return {
      applyNumberArr:[],
      btnLoading: false,
      rules: {
        medium:[
          {
            required: true,
            message: "请选择档案介质类型",
            trigger: "change",
          },
        ],
        duedate: [
          {
            required: true,
            message: "请选择到期日期",
            trigger: "change",
          },
        ],
        utform: [
          {
            required: true,
            message: "请选择利用方式",
            trigger: "change",
          },
        ],
        fileaim: [
          {
            required: true,
            message: "请输入借阅理由",
            trigger: "blur",
          },
        ],
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        },
      },
      options: [],
      value: [],
    };
  },
  computed: {
    ...mapState({
      EchoList: (state) => state.userRole.EchoList,
    }),
  },
  methods: {
    cancel() {
        this.$refs['batchBorrowRef'].resetFields(); 
        this.$emit("cancel");
    },
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
         // this.btnLoading = true;
            console.log(this.borrowApply)
            this.$emit("clickSubmit",this.borrowApply)
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    getQuanzongList() {
      console.log("初始化");
      this.$nextTick(() => {
        this.options = this.EchoList.map((item, index) => {
          return {
            fondsname: item.fondsname,
            fondscode: item.fondscode,
            id: item.fondscode,
          };
        });
      });
      this.value = [];
      this.EchoList.forEach((item, index) => {
        this.$nextTick(() => {
          this.value.push(item.fondsname);
        });
      });
      console.log(this.options, this.value);
    },
  },
  created() {
    
  },
  mounted() {
    //this.getQuanzongList();    
  },
};
</script>
