/*
 *    Copyright (c) 2018-2025, cyweb All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 */

import global from "@/components/tools/commondict"

const map={
  startYear:'',
  endYear:''
}

export const tableOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  dic: [],
  column: [
    {
      label: '学年',
      prop: 'year',
      display:false
    },
	  {
      label: '开始年',
      prop: 'startYear',
      type:'year',
      hide:true,
      valueFormat:'yyyy',
      rules: [
        { validator: function (rule, value, callback) {
            map['startYear']=value
            let endYear=map['endYear']
            if(value==''){
              callback(new Error('请选择开始年份'));
            }
            if(endYear!=''){
              if(global.compareDate(value,endYear)){
                callback(new Error('结束年份必须大于开始年份'));
              }else{
                callback()
              }
            }
          }, required:true, trigger: 'blur' }
      ]
    },
    {
      label: '结束年',
      prop: 'endYear',
      type:'year',
      hide:true,
      valueFormat:'yyyy',
      rules: [
        { validator: function (rule, value, callback) {
            map['endYear']=value
            let startYear=map['startYear']
            if(value==''){
              callback(new Error('请选择结束年份'));
            }
            if(startYear!=''){
              if(global.compareDate(startYear,value)){
                callback(new Error('结束年份必须大于开始年份'));
              }else{
                callback()
              }
            }
          }, required:true, trigger: 'blur' }
      ]
    },
    {
      label: '学期',
      prop: 'yearTerm',
      type:'radio',
      dicData:global.LEARN_TERM,
      props:{
        label:'label',
        value:'value'
      },
      rules: [
        {
          required: true,
          trigger: 'blur',
          message:"选择学期"
        }
      ]
    },

    {
      label: '当前学年',
      prop: 'isCurrent',
      type:'radio',
      dicData:global.YES_OR_NO,
      props:{
        label:'label',
        value:'value'
      },
      rules: [
        {
          required: true,
          trigger: 'blur',
          message:"是否当前学年"

        }
      ]
    },
    {
      label: '开启制定教学计划',
      prop: 'isNextTeach',
      type:'radio',
      dicData:global.YES_OR_NO,
      props:{
        label:'label',
        value:'value'
      },
      rules: [
        {
          required: true,
          trigger: 'blur',
          message:"请选择是否开启制定教学计划"

        }
      ]
    },
    {
      label: '备注',
      prop: 'remarks',
      span:24,
      row: true
    },
    {
      label: '创建时间',
      prop: 'createTime',
      display:false
    }
  ]
}
