export const transportTypeOptions = [
  { label: '公路运输', value: '公路运输' },
  { label: '铁路运输', value: '铁路运输' },
  { label: '水路运输', value: '水路运输' },
  { label: '航空运输', value: '航空运输' },
];

export const packageOptions = [
  { label: '袋装', value: '袋装' },
  { label: '散装', value: '散装' },
  { label: '桶装', value: '桶装' },
  { label: '箱装', value: '箱装' },
  { label: '托盘', value: '托盘' },
];

export const priceUnitOptions = [
  { label: '元/吨', value: '元/吨' },
  { label: '元/立方米', value: '元/立方米' },
  { label: '元/件', value: '元/件' },
  { label: '元/车', value: '元/车' },
];

export const templateTypeOptions = [
  { label: '运输计划', value: '运输计划' },
  { label: '常规运单', value: '常规运单' },
];

export const processStatusOptions = [
  { label: '草稿', value: 0 },
  { label: '启用', value: 1 },
  { label: '停用', value: 2 },
];

export const planStatusOptions = [
  { label: '草稿', value: 'draft' },
  { label: '待调度', value: 'waiting_dispatch' },
  { label: '调度中', value: 'dispatching' },
  { label: '已完成', value: 'completed' },
  { label: '已取消', value: 'cancelled' },
];

export const waybillStatusOptions = [
  { label: '草稿', value: 'draft' },
  { label: '待执行', value: 'pending' },
  { label: '进行中', value: 'processing' },
  { label: '已完成', value: 'completed' },
  { label: '已取消', value: 'cancelled' },
];

export const dataSourceOptions = [
  { label: '手工创建', value: '手工创建' },
  { label: '批量导入', value: '批量导入' },
  { label: '模板生成', value: '模板生成' },
  { label: '计划调度', value: '计划调度' },
];

export const projectTypeOptions = [
  { label: '普通项目', value: '普通项目' },
  { label: '重大项目', value: '重大项目' },
];

export const projectSourceOptions = [
  { label: '商务洽谈', value: '商务洽谈' },
  { label: '招投标', value: '招投标' },
  { label: '客户委托', value: '客户委托' },
  { label: '其它', value: '其它' },
];

export const projectApprovalStatusOptions = [
  { label: '草稿', value: 'draft' },
  { label: '审批中', value: 'reviewing' },
  { label: '已撤回', value: 'withdrawn' },
  { label: '审批通过', value: 'approved' },
  { label: '已驳回', value: 'rejected' },
  { label: '变更审批中', value: 'change_reviewing' },
  { label: '变更驳回', value: 'change_rejected' },
  { label: '变更审批通过', value: 'change_approved' },
  { label: '已作废', value: 'voided' },
];

export const approvalStatusOptions = [
  { label: '草稿', value: 'draft' },
  { label: '审批中', value: 'reviewing' },
  { label: '已撤回', value: 'withdrawn' },
  { label: '审批通过', value: 'approved' },
  { label: '已驳回', value: 'rejected' },
];

export const effectiveTypeOptions = [
  { label: '未生效', value: 'not_effective' },
  { label: '临时生效', value: 'temporary_effective' },
  { label: '正式生效', value: 'formal_effective' },
  { label: '已过期', value: 'expired' },
];

export const businessTypeOptions = [
  { label: '一类规模业务', value: '一类规模业务' },
  { label: '二类规模业务', value: '二类规模业务' },
  { label: '普通业务', value: '普通业务' },
];

export const settlementModeOptions = [
  { label: '先票后款', value: '先票后款' },
  { label: '先款后票', value: '先款后票' },
  { label: '月结', value: '月结' },
];

export const contractCategoryOptions = [
  { label: '客户合同', value: '客户合同' },
  { label: '承运商合同', value: '承运商合同' },
  { label: '补充协议', value: '补充协议' },
];

export const signTypeOptions = [
  { label: '新签', value: '新签' },
  { label: '续签', value: '续签' },
];

export const contractStageOptions = [
  { label: '草稿', value: 'draft' },
  { label: '临时合同', value: 'temporary' },
  { label: '正式合同', value: 'formal' },
  { label: '已终止', value: 'terminated' },
];

export const contractApprovalStatusOptions = [
  { label: '草稿', value: 'draft' },
  { label: '审批中', value: 'reviewing' },
  { label: '已驳回', value: 'rejected' },
  { label: '审批通过', value: 'approved' },
  { label: '变更审批中', value: 'change_reviewing' },
  { label: '变更驳回', value: 'change_rejected' },
  { label: '变更审批通过', value: 'change_approved' },
];

export const nodeOptions = [
  { label: '接单', value: '接单' },
  { label: '到场', value: '到场' },
  { label: '装货', value: '装货' },
  { label: '发货', value: '发货' },
  { label: '在途', value: '在途' },
  { label: '到货', value: '到货' },
  { label: '卸货', value: '卸货' },
  { label: '签收', value: '签收' },
  { label: '回单', value: '回单' },
];

export const textRule = (label, max, required = false) => {
  const rules = [];
  if (required) {
    rules.push({ required: true, message: `请输入${label}`, trigger: 'blur' });
  }
  if (max) {
    rules.push({ max, message: `${label}不能超过${max}个字符`, trigger: 'blur' });
  }
  return rules;
};

export const selectRule = label => [
  { required: true, message: `请选择${label}`, trigger: 'change' },
];

export const nonNegativeRule = label => ({
  validator: (rule, value, callback) => {
    if (value !== undefined && value !== null && value !== '' && Number(value) < 0) {
      callback(new Error(`${label}不能小于0`));
      return;
    }
    callback();
  },
  trigger: 'blur',
});

export const phoneRule = label => ({
  pattern: /^(1\d{10}|0\d{2,3}-?\d{7,8})$/,
  message: `${label}格式不正确`,
  trigger: 'blur',
});

export const createCrudOption = columns => ({
  height: 'auto',
  calcHeight: 32,
  dialogWidth: 980,
  labelPosition: 'right',
  labelWidth: 'auto',
  tip: false,
  searchBtnText: '查询',
  emptyBtnText: '重置',
  saveBtnText: '提交',
  updateBtnText: '提交',
  searchShow: true,
  searchMenuSpan: 24,
  searchIcon: true,
  searchIndex: 4,
  searchMenuPosition: 'right',
  border: true,
  index: true,
  indexLabel: '序号',
  indexWidth: 70,
  selection: true,
  addBtn: false,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  dialogClickModal: false,
  menuFixed: 'right',
  menuWidth: 180,
  showOverflowTooltip: true,
  column: columns,
});

export const auditColumns = [
  {
    label: '创建人',
    prop: 'createUserName',
    minWidth: 120,
    addDisplay: false,
    editDisplay: false,
  },
  {
    label: '更新人',
    prop: 'updateUserName',
    minWidth: 120,
    addDisplay: false,
    editDisplay: false,
  },
  {
    label: '创建时间',
    prop: 'createTime',
    sortable: true,
    type: 'datetime',
    format: 'YYYY-MM-DD HH:mm:ss',
    valueFormat: 'YYYY-MM-DD HH:mm:ss',
    minWidth: 160,
    addDisplay: false,
    editDisplay: false,
  },
  {
    label: '更新时间',
    prop: 'updateTime',
    sortable: true,
    type: 'datetime',
    format: 'YYYY-MM-DD HH:mm:ss',
    valueFormat: 'YYYY-MM-DD HH:mm:ss',
    minWidth: 160,
    addDisplay: false,
    editDisplay: false,
  },
];
