import {
  startStatus,
  WaybillStatus
} from '@/assets/js/blockSort'
export const employee = () => {
  return [{
    field: 'selection',
    label: '多选',
    align: 'center',
  }, {
    field: 'waybillNo',
    label: '运单号',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'orderNo',
    label: '订单号',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'status',
    label: '状态',
    align: 'center',
    options: WaybillStatus(),
    colWidth: '70px',
  }, {
    field: 'multistage',
    label: '复核人',
    children: [{
      field: 'reCheck.nickName',
      label: '姓名',
      align: 'center',
      colWidth: '120px',
    }, {
      field: 'reCheck.phone',
      label: '电话',
      align: 'center',
      colWidth: '140px',
    }, ]
  }, {
    field: 'multistage',
    label: '配送人',
    children: [{
      field: 'delivery.nickName',
      label: '姓名',
      align: 'center',
      colWidth: '120px',
    }, {
      field: 'delivery.phone',
      label: '电话',
      align: 'center',
      colWidth: '140px',
    }, ]
  }, {
    field: 'multistage',
    label: '收件人',
    children: [{
      field: 'consigneeAddressName',
      label: '姓名',
      align: 'center',
      colWidth: '120px',
    }, {
      field: 'consigneeAddressPhone',
      label: '电话',
      align: 'center',
      colWidth: '140px',
    }, {
      field: 'consigneeAddressDetails',
      label: '地址',
      align: 'center',
      colWidth: '220px',
    }, ]
  }, {
    field: 'tamperProofLabel',
    label: '防拆标签码',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'coolerBox.name',
    label: '保温箱',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'iceRaftCode',
    label: '冰排编号',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'deliveryTime',
    label: '出发时间',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'receiptTime',
    label: '签收时间',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'deliveryDuration',
    label: '配送耗时',
    align: 'center',
    colWidth: '180px',
  }, {
    field: 'assessStar',
    label: '服务评价',
    align: 'center',
    colWidth: '220px',
  }, {
    field: 'remark',
    label: '备注',
    align: 'center',
  }, {
    field: 'unpackBtn',
    label: '操作',
    colWidth: '370px',
    align: 'center',
    labelButton: [{
      type: 'logs',
      label: '详情',
      icon: 'el-icon-tickets',
      style: 'success',
    }, {
      type: 'edit',
      label: '编辑',
      icon: 'el-icon-edit',
      style: 'primary',
    }, {
      type: 'send',
      label: '派单',
      icon: 'el-icon-tickets',
      style: 'primary',
    }, {
      type: 'sign',
      label: '签收',
      icon: 'el-icon-folder-checked',
      style: 'warning',
    }, {
      type: 'del',
      label: '删除',
      icon: 'el-icon-delete',
      style: 'danger',
    }]
  }]
}
export const formRules = () => {
  return [{
    field: 'tamperProofLabelImg',
    label: '防拆标签图片',
    placeholder: '请上传防拆标签图片',
    type: 'upload',
    colWidth: 24,
    crosswise: true,
    rules: [{
      required: false,
      message: '请上传防拆标签图片',
      trigger: 'blur,change'
    }]
  }, {
    field: 'tamperProofLabel',
    label: '区块链防拆标签码',
    placeholder: '请输入区块链防拆标签码',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: false,
      message: '请输入区块链防拆标签码',
      trigger: 'blur'
    }]
  }, {
    field: 'remark',
    label: '备注',
    placeholder: '备注',
    type: 'textarea',
    colWidth: 24,
  }, ]
}

export const addressBook = () => {
  return [{
    field: 'name',
    label: '姓名',
    align: 'center',
  }, {
    field: 'phone',
    label: '电话',
    align: 'center',
  }, {
    field: 'address',
    label: '详细地址',
    align: 'center',
  }, ]
}
export const sendList = () => {
  return [{
    field: 'coolerBoxId',
    type: 'searchSelect',
    label: '保温箱',
    placeholder: '请选择保温箱',
    colWidth: 24,
    multiple: false,
    rules: [{
      required: true,
      message: '请选择保温箱',
      trigger: 'blur,change'
    }],
    options: [],
  }, {
    field: 'code',
    label: '冰排编号',
    placeholder: '请输入冰排编号',
    type: 'scan',
    colWidth: 24,
    rules: [{
      required: true,
      message: '请输入冰排编号',
      trigger: 'blur'
    }]
  }]
}
export const consignmentList = () => {
  return [{
    field: 'orderNo',
    label: '订单号',
    placeholder: '请输入订单号',
    type: 'input',
    colWidth: 24,
    rules: [{
      required: true,
      message: '请输入订单号',
      trigger: 'blur'
    }]
  }, {
    field: 'reCheckId',
    type: 'searchSelect',
    label: '复核人',
    placeholder: '请选择复核人',
    colWidth: 24,
    multiple: false,
    rules: [{
      required: true,
      message: '请选择复核人',
      trigger: 'blur,change'
    }],
    options: [],
  }, {
    field: 'deliveryId',
    type: 'searchSelect',
    label: '配送人',
    placeholder: '请选择配送人',
    colWidth: 24,
    multiple: false,
    rules: [{
      required: true,
      message: '请选择配送人',
      trigger: 'blur,change'
    }],
    options: [],
  }]
}

function validatePassword(rule, value, callback) {
  // 假设正确的密码是 '123456'
  if (value === 3 || value === 4) {
    callback(); // 验证通过
  } else {
    callback('请选择签收状态'); // 验证不通过
  }
}

export const signList = () => {
  return [{
    field: 'status',
    label: '签收状态',
    placeholder: '请选择签收状态',
    type: 'radio',
    colWidth: 24,
    rules: [{
      required: true,
      message: '请选择签收状态',
      trigger: 'blur,change'
    }, {
      validator: validatePassword,
      trigger: 'blur'
    }],
    options: [{
        label: '签收',
        value: 3,
      },
      {
        label: '拒收',
        value: 4,
      },
    ]
  }, {
    field: 'rejectionReason',
    label: '拒收原因',
    placeholder: '请输入拒收原因',
    type: 'textarea',
    colWidth: 24,
  }]
}
