import {getDetails} from "@/api/asset/assetcode/assetcode";
import {validateUpperCase} from "../../../../util/validate";
import global from "@/components/tools/commondict";
import fa from "element-ui/src/locale/lang/fa";

var validateUsername = (rule, value, callback) => {
  getDetails(value).then(response => {
    if (!validateUpperCase(value)) {
      callback(new Error('请输入大写字母'));
    }
    if (window.boxType === 'edit') callback()
    let result = response.data.data;
    if (result != null && result != undefined) {
      callback(new Error('类别编码已经存在'))
    } else {
      callback()
    }
  });
};
export const tableOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  dic: [],
  column: [
	  // {
    //   label: '主键',
    //   prop: 'id'
    // },
	  // {
    //   label: '创建人',
    //   prop: 'createBy',
    //   type: 'input',  // 控件类型
    //   maxlength: 20,   //长度限制  0/n
    //   addDisplay:false, //添加是否显示
    //   editDisplay:false, //修改是否显示
    //   rules: [{          //自定义规则
    //     required: false,
    //     trigger: 'blur',
    //     message:"请填写创建人"
    //   }]
    // },
	  // {
    //   label: '更新人',
    //   prop: 'updateBy',
    //   type: 'input',  // 控件类型
    //   maxlength: 20,   //长度限制  0/n
    //   addDisplay:false, //添加是否显示
    //   editDisplay:false, //修改是否显示
    //   rules: [{          //自定义规则
    //     required: false,
    //     trigger: 'blur',
    //     message:"请填写更新人"
    //   }]
    // },
	  // {
    //   label: '开始年限',
    //   prop: 'startYear',
    //   maxlength: 4,   //长度限制  0/n
    //   rules: [{          //自定义规则
    //     required: true,
    //     trigger: 'blur',
    //     message:"请填写开始年限(例:2020)"
    //   }]
    // },
	  {
      label: '包含类型',
      prop: 'codeName',
      type: 'input',  // 控件类型
      span: 24,
      search:true,
      maxlength: 100,   //长度限制  0/n
      addDisplay:true, //添加是否显示
      editDisplay:true, //修改是否显示
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写包含类型"
      }]
    },
	  {
      label: '类别编码',
      prop: 'codeEnName',
      span: 24,
      search:true,
      addDisplay:true, //添加是否显示
      editDisplay:true, //修改是否显示
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写类别编码"
      },
        {
          min: 3,
          max: 3,
          message: "长度在 3 个字符",
          trigger: "blur"
        },
        // {validator: validateUsername, trigger: 'blur'}
       ]
    },
	  {
      label: '报废时间',
      prop: 'expireTime',
      type:"select",
      span: 24,
      dicUrl:'/admin/dict/item/type/scrap_time',
      props:{
        label:'label',
        value:'value'
      },
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写报废时间"
      }]
    },
    {
      label: '类型',
      prop: 'type',
      type: 'select',
      span: 24,
      dicUrl:'/admin/dict/item/type/assets_code',
      props:{
        label:'label',
        value:'value'
      },
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请选择类型"
      }]
    },
    {
      label: '编码备注',
      prop: 'remarks',
      type: 'textarea',
      span: 24,
      minRows: 2,
      maxlength: 250,   //长度限制  0/n
      addDisplay:true, //添加是否显示
      editDisplay:true, //修改是否显示
    },
    // {
    //   label: '创建时间',
    //   prop: 'createTime',
    //   addDisplay:false, //添加是否显示
    //   editDisplay:false, //修改是否显示
    // },
    // {
    //   label: '更新时间',
    //   prop: 'updateTime',
    //   addDisplay:false, //添加是否显示
    //   editDisplay:false, //修改是否显示
    // },
  ]
}
export const tableOption2 = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  dic: [],
  column: [
    {
      label: '类别编码',
      prop: 'codeEnName',
      span: 24,
      search:true,
      addDisplay:true, //添加是否显示
      editDisplay:true, //修改是否显示
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写类别编码"
      },
        {
          min: 3,
          max: 3,
          message: "长度在 3 个字符",
          trigger: "blur"
        },
        // {validator: validateUsername, trigger: 'blur'}
      ]
    },
    {
      label: '包含类型',
      prop: 'codeName',
      type: 'input',  // 控件类型
      span: 24,
      search:true,
      maxlength: 100,   //长度限制  0/n
      addDisplay:true, //添加是否显示
      editDisplay:true, //修改是否显示
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写包含类型"
      }]
    },
    {
      label: '报废时间',
      prop: 'expireTime',
      type:"select",
      span: 24,
      dicUrl:'/admin/dict/item/type/scrap_time',
      props:{
        label:'label',
        value:'value'
      },
      rules: [{          //自定义规则
        required: true,
        trigger: 'blur',
        message:"请填写报废时间"
      }]
    },
    {
      label: '资产数量',
      prop: 'num'
    }

  ]
}
export const tableStaticOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  menu: false,
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  showSummary:true,
  sumColumnList: [
    {
      name: 'num',
      type: 'sum'
    }, {
      name: 'price',
      type: 'sum'
    }
  ],
  dic: [],
  column: [
    {
      label: '资产分布',
      prop: 'times',
      search:true,
      hide:true,
      type:'year',
      valueFormat:'yyyy'
    },
    {
      label: '部门名称',
      prop: 'deptName'
    },
    {
      label: '数量合计',
      prop: 'num'
    },{
      label: '金额合计',
      prop: 'price'
    }
  ]
}

export const tableStatictypeOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  menu: false,
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  showSummary:true,
  sumColumnList: [
    {
      name: 'num',
      type: 'sum'
    }, {
      name: 'price',
      type: 'sum'
    }
  ],
  dic: [],
  column: [
    {
      label: '资产分布',
      prop: 'times',
      search:tableOption,
      hide:true,
      type:'year',
      valueFormat:'yyyy'
    },
    {
      label: '部门名称',
      prop: 'deptName'
    },
    {
      label: '数量合计',
      prop: 'num'
    },{
      label: '金额合计',
      prop: 'price'
    }
  ]
}
