import {
  iceraftStatus,
  freezingRequirement
} from '@/assets/js/blockSort'
export const employee = () => {
  return [{
    field: 'selection',
    label: '多选',
    align: 'center',
  }, {
    field: 'code',
    label: '编号',
    align: 'center',
  }, {
    field: 'label',
    label: '冰排备注',
    align: 'center',
  }, {
    field: 'status',
    label: '状态',
    align: 'center',
    options: iceraftStatus()
  }, {
    field: 'freezeClaim',
    label: '冷冻要求',
    align: 'center',
  }, {
    field: 'coolerBoxName',
    label: '绑定保温箱',
    align: 'center',
  }, {
    field: 'action',
    label: '操作',
    colWidth: '260px',
    align: 'center',
    labelButton: [{
      type: 'logs',
      label: '详情',
      icon: 'el-icon-tickets',
      style: 'success',
    }, {
      type: 'edit',
      label: '编辑',
      icon: 'el-icon-edit',
      style: 'primary',
    }, {
      type: 'del',
      label: '删除',
      icon: 'el-icon-delete',
      style: 'danger',
    }]
  }]
}
export const employeeCold = () => {
  return [{
    field: 'selection',
    label: '多选',
    align: 'center',
  }, {
    field: 'code',
    label: '编号',
    align: 'center',
  }, {
    field: 'label',
    label: '冰排备注',
    align: 'center',
  }, {
    field: 'status',
    label: '状态',
    align: 'center',
    options: iceraftStatus()
  }, {
    field: 'freezeClaim',
    label: '冷冻要求',
    align: 'center',
  }, {
    field: 'suitableForCold',
    label: '释冷温度',
    align: 'center',
  }, {
    field: 'forColdTime',
    label: '释冷要求',
    align: 'center',
  }, {
    field: 'iceColdAddress',
    label: '释冷地点',
    align: 'center',
  }, {
    field: 'coolerBoxName',
    label: '绑定保温箱',
    align: 'center',
  }, {
    field: 'action',
    label: '操作',
    colWidth: '260px',
    align: 'center',
    labelButton: [{
      type: 'logs',
      label: '详情',
      icon: 'el-icon-tickets',
      style: 'success',
    }, {
      type: 'edit',
      label: '编辑',
      icon: 'el-icon-edit',
      style: 'primary',
    }, {
      type: 'del',
      label: '删除',
      icon: 'el-icon-delete',
      style: 'danger',
    }]
  }]
}
export const formRules = () => {
  return [{
    field: 'code',
    label: '编号',
    placeholder: '请输入编号',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: true,
      message: '请输入编号',
      trigger: 'blur'
    }]
  }, {
    field: 'label',
    label: '冰排备注',
    placeholder: '请输入冰排备注',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入冰排备注',
      trigger: 'blur'
    }]
  }, {
    field: 'status',
    label: '状态',
    placeholder: '状态',
    type: 'radio',
    colWidth: 24,
    rules: [{
      required: true,
      message: '选择状态',
      trigger: 'change'
    }],
    options: iceraftStatus()
  }, {
    field: 'freezeClaim',
    label: '冷冻要求',
    placeholder: '请输入冷冻时间',
    type: 'select',
    colWidth: 24,
    multiple: true,
    createEntry: true,
    options: freezingRequirement(),
    rules: [{
      required: true,
      message: '请输入冷冻时间',
      trigger: 'blur'
    }]
  }, {
    field: 'sort',
    label: '排序',
    placeholder: '请输入排序编号',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入排序编号',
      trigger: 'blur'
    }, {
      required: false,
      validator: (rule, value, callback) => {
        if (!value && rule.required) {
          return callback(new Error('请输入排序编号'));
        }
        if (value) {
          if (!/^(\d+)?(\.\d+)?$/.test(value)) {
            return callback(new Error('请输入有效的数值'));
          }
        }
        return callback();
      },
      trigger: ['blur', 'change']
    }]
  }]
}
export const formRulesCold = () => {
  return [{
    field: 'code',
    label: '编号',
    placeholder: '请输入编号',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: true,
      message: '请输入编号',
      trigger: 'blur'
    }]
  }, {
    field: 'label',
    label: '冰排备注',
    placeholder: '请输入冰排备注',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入冰排备注',
      trigger: 'blur'
    }]
  }, {
    field: 'status',
    label: '状态',
    placeholder: '状态',
    type: 'radio',
    colWidth: 24,
    rules: [{
      required: true,
      message: '选择状态',
      trigger: 'change'
    }],
    options: iceraftStatus()
  }, {
    field: 'freezeClaim',
    label: '冷冻要求',
    placeholder: '请输入冷冻时间',
    type: 'select',
    colWidth: 24,
    multiple: true,
    createEntry: true,
    options: freezingRequirement(),
    rules: [{
      required: true,
      message: '请输入冷冻时间',
      trigger: 'blur'
    }]
  }, {
    field: 'suitableForCold',
    label: '释冷温度',
    placeholder: '请输入冰排释冷温度',
    type: 'input',
    colWidth: 24,
    unit: '℃',
    rules: [{
      required: false,
      message: '请输入冰排释冷温度',
      trigger: 'blur'
    }]
  }, {
    field: 'forColdTime',
    label: '释冷要求',
    placeholder: '请输入冰排释冷要求',
    type: 'input',
    colWidth: 24,
    unit: '小时',
    rules: [{
      required: false,
      message: '请输入冰排释冷要求',
      trigger: 'blur'
    }, {
      required: false,
      validator: (rule, value, callback) => {
        if (!value && rule.required) {
          return callback(new Error('请输入释冷要求'));
        }
        if (value) {
          if (!/^(\d+)?(\.\d+)?$/.test(value)) {
            return callback(new Error('请输入有效的数值'));
          }
        }
        return callback();
      },
      trigger: ['blur', 'change']
    }]
  }, {
    field: 'iceColdAddress',
    label: '释冷地点',
    placeholder: '请输入释冷地点',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入释冷地点',
      trigger: 'blur'
    }]
  }, {
    field: 'sort',
    label: '排序',
    placeholder: '请输入排序编号',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入排序编号',
      trigger: 'blur'
    }, {
      required: false,
      validator: (rule, value, callback) => {
        if (!value && rule.required) {
          return callback(new Error('请输入排序编号'));
        }
        if (value) {
          if (!/^(\d+)?(\.\d+)?$/.test(value)) {
            return callback(new Error('请输入有效的数值'));
          }
        }
        return callback();
      },
      trigger: ['blur', 'change']
    }]
  }]
}
// 绑定保温箱
export const bindingIncubator = () => {
  return [{
    field: 'coolerBoxId',
    label: '保温箱',
    placeholder: '请选择保温箱',
    type: 'searchSelect',
    colWidth: 24,
    // createEntry: true,
    options: [],
    rules: [{
      required: true,
      message: '请选择保温箱',
      trigger: 'blur'
    }]
  }]
}
