/*
 *    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 {CURRENT_SCHOOL_TERM, CURRENT_SCHOOL_YEAR} from "../../../config/global";
import {isMobile, isPhone, isvalidatemobile} from "../../../util/validate";

var validatePhone = (rule, value, callback) => {

  if (!value) {
    return callback(new Error('请输入报修人联系电话'));
  }
  setTimeout(() => {
    if (!isMobile(value) && !isPhone(value)) {
      callback(new Error('请输入正确的手机号或固话'));
    } else {
        callback();
    }
  }, 1000);
};


export const tableOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  menuWidth: 150,
  menuBtn: true,
  // menuType: 'menu',
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  searchslot:true,
  searchShow:true,
  dialogClickModal:false,
  dialogWidth:'75%',
  lineHeight:20,
  headerHeight:20,
  expand:false,
  size:"small",
  idKey:'id',
  dic: [],
  column: [
    {
      label: '主键',
      prop: 'id',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '创建人',
      prop: 'createBy',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },

    {
      label: '更新人',
      prop: 'updateBy',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '更新时间',
      prop: 'updateTime',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '删除标记',
      prop: 'delFlag',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width:100,
      label: '学年',
      prop: 'xn',
      // search:true,
      type: 'select',
      valueDefault:CURRENT_SCHOOL_YEAR,
      searchDefault:CURRENT_SCHOOL_YEAR,
      dicUrl:'/basic/basicyear/queryAllSchoolYear',
      props:{
        label:'year',
        value:'year'
      },
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width:100,
      label: '学期',
      prop: 'xq',
      // search:true,
      type: 'select',
      valueDefault:CURRENT_SCHOOL_TERM,
      searchDefault:CURRENT_SCHOOL_TERM,
      dicData:global.LEARN_TERM,
      props:{
        label:'label',
        value:'value'
      },
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 180,
      label: '报修单单号',
      prop: 'orderNum',
      search: true,

      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 80,
      label: '报修人',
      prop: 'realName',
      search: true,

      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 150,
      label: '报修时间',
      prop: 'createTime',
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false,
      type:'datetime',
      format:'yyyy-MM-dd HH:mm'
    },
    {
      width:100,
      label: '报修人工号',
      prop: 'username',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false

    },

    {
      label: '报修区域',
      prop: 'cascaderArea',
      type:'cascader',
      changeoOnSelect:true,
      dicUrl:"/support/repairarea/cascader",
      placeholder:"请选择报修区域，不要选择与实际不符的区域",
      slot:true,
      search:true,
      align:'left',
      // hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修区域',
        trigger: 'change'
      }]
    },
    {
      label: '报修类型',
      prop: 'cascaderType',
      slot:true,
      search:false,
      searchslot:true,
      type:'cascader',
      align:'left',
      placeholder:"请选择报修类型，不要选择与实际不符的类型",
      dicUrl:"/support/repairtype/cascader",
      // hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修类型',
        trigger: 'change'
      }]
    },
    {
      label: '报修地点',
      prop: 'address',
      rules: [{
        required: true,
        message: '请输入报修地点',
        trigger: 'blur'
      }]
    },
    {
      width:115,
      label: '联系电话',
      prop: 'phone',
      search:true,
      // hide: true,
      rules: [{
        required: true,
        message: '请输入联系电话',
        trigger: 'blur'
      },{ validator: validatePhone, trigger: 'blur' }]
    },
    {
      width: 300,
      label: '报修图片',
      prop: 'imageUrl',
      hide:true,
      slot:true,
      formslot:true
    },
    {
      width:200,
      span: 24,
      label: '报修内容',
      prop: 'note',
      overHidden: false,
      type: 'textarea',
      minRows: 3,
      // hide:true,
      rules: [{
        required: true,
        message: '请输入具体的报修内容',
        trigger: 'blur'
      }]
    },
    {
      width:100,
      label: '接单人',
      prop: 'takeRealName',
      hide: true,
      search:true,
      addDisplay:false,
      editDisplay:false,
      visdiplay:false
    },

    {
      label: '维修人',
      prop: 'repairRealName',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false


    },
    {
      label: '维修时间',
      prop: 'repairDate',
      formslot:true,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false

    },
    {
      span:24,
      label: '维修描述',
      prop: 'repairDesc',
      overHidden: false,
      type: 'textarea',
      minRows: 3,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '评分',
      prop: 'score',
      formslot: true,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '状态',
      prop: 'state',
      type: 'select',
      slot: true,
      span: 24,
      dicUrl: '/admin/dict/type/support_repair_state',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
  ]
}

export const tableOption1 = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  menuWidth: 150,
  menuBtn: true,
  // menuType: 'menu',
  align: 'center',
  editBtn: false,
  delBtn: false,
  addBtn: false,
  searchslot:true,
  searchShow:true,
  dialogClickModal:false,
  dialogWidth:'75%',
  expand:false,
  size:"small",
  idKey:'id',

  dic: [],
  column: [
    {
      label: '主键',
      prop: 'id',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '创建人',
      prop: 'createBy',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },

    {
      label: '更新人',
      prop: 'updateBy',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '更新时间',
      prop: 'updateTime',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '删除标记',
      prop: 'delFlag',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width:100,
      label: '学年',
      prop: 'xn',
      search:true,
      type: 'select',
      valueDefault:CURRENT_SCHOOL_YEAR,
      searchDefault:CURRENT_SCHOOL_YEAR,
      dicUrl: '/admin/dict/type/xnList',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width:100,
      label: '学期',
      prop: 'xq',
      search:true,
      type: 'select',
      valueDefault:CURRENT_SCHOOL_TERM,
      searchDefault:CURRENT_SCHOOL_TERM,
      dicUrl: '/admin/dict/type/xqList',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 180,
      label: '报修单单号',
      prop: 'orderNum',
      search: true,

      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 80,
      label: '报修人',
      prop: 'realName',
      search: true,

      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      width: 160,
      label: '报修时间',
      prop: 'createTime',
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false,
      type:'datetime',
      format:'MM月dd日HH时mm分'
    },
    {
      width:100,
      label: '报修人工号',
      prop: 'username',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false

    },

    {
      label: '报修区域',
      prop: 'cascaderArea',
      type:'cascader',
      dicUrl:"/support/repairarea/cascader",
      placeholder:"请选择报修区域，不要选择与实际不符的区域",
      slot:true,
      search:true,
      align:'left',
      hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修区域',
        trigger: 'change'
      }]
    },
    {
      label: '报修类型',
      prop: 'cascaderType',
      slot:true,
      search:true,
      type:'cascader',
      align:'left',
      placeholder:"请选择报修类型，不要选择与实际不符的类型",
      dicUrl:"/support/repairtype/cascader",
      hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修类型',
        trigger: 'change'
      }]
    },
    {
      label: '报修地点',
      prop: 'address',
      rules: [{
        required: true,
        message: '请输入报修地点',
        trigger: 'blur'
      }]
    },
    {
      width:115,
      label: '联系电话',
      prop: 'phone',
      search:true,
      hide: true,
      rules: [{
        required: true,
        message: '请输入联系电话',
        trigger: 'blur'
      },{ validator: validatePhone, trigger: 'blur' }]
    },
    {
      width: 300,
      label: '报修图片',
      prop: 'imageUrl',
      slot:true,
      formslot:true
    },
    {
      width:200,
      span: 24,
      label: '报修内容',
      prop: 'note',
      overHidden: false,
      type: 'textarea',
      minRows: 3,
      hide:true,
      rules: [{
        required: true,
        message: '请输入具体的报修内容',
        trigger: 'blur'
      }]
    },
    {
      width:100,
      label: '接单人',
      prop: 'takeRealName',
      hide: false,
      search:true,
      addDisplay:false,
      editDisplay:false,
      visdiplay:false
    },

    {
      label: '维修人',
      prop: 'repairRealName',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false


    },
    {
      label: '维修时间',
      prop: 'repairDate',
      formslot:true,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false

    },
    {
      span:24,
      label: '维修描述',
      prop: 'repairDesc',
      overHidden: false,
      type: 'textarea',
      minRows: 3,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '评分',
      prop: 'score',
      formslot: true,
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
    {
      label: '状态',
      prop: 'state',
      type: 'select',
      slot: true,
      span: 24,
      dicUrl: '/admin/dict/type/support_repair_state',
      hide: true,
      addDisplay:false,
      editDisabled:true,
      editDisplay:false,
      visdiplay:false
    },
  ]
}

/*转单的form option*/
export const turnOrderFormOption = {
  submitBtn: false,
  emptyBtn: false,
  row: true,
  span: 12,

  column: [
    {
      label: '报修区域',
      prop: 'cascaderArea',
      type:'cascader',
      changeoOnSelect:true,
      dicUrl:"/support/repairarea/cascader",
      placeholder:"请选择报修区域，不要选择与实际不符的区域",
      slot:true,
      search:true,
      span:24,
      align:'left',
      // hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修区域',
        trigger: 'change'
      }]
    },
    {
      label: '报修类型',
      prop: 'cascaderType',
      slot:true,
      search:true,
      type:'cascader',
      align:'left',
      placeholder:"请选择报修类型，不要选择与实际不符的类型",
      dicUrl:"/support/repairtype/cascader",
      span:24,
      // hide:true,
      rules: [{
        type:'array',
        required: true,
        message: '请选择报修类型',
        trigger: 'change'
      }]
    },
  ]
}


