import user from '@/state/user'

export const UN_REQ_NUM = -99999

// 弹框请求审核
export const EXAMINE_REQ_SELECT = [
  { name: '通过', value: 1 },
  { name: '不通过', value: -1 },
]

export const EXAMINE_VIEW_SELECT = [
  ...EXAMINE_REQ_SELECT,
  { name: '待审核', value: 0 },
]

// 全部状态（搜索用）
export const EXAMINE_ALL_STATUS = -2
// 草稿状态
export const EXAMINE_DRAFT_STATUS = 0
// 待集团审核状态
export const EXAMINE_NO_AUDIT_STATUS = 1
// 待地区审核状态
export const EXAMINE_NO_COM_AUDIT_STATUS = 3
// 集团审核不通过
export const EXAMINE_NO_ADOPT_STATUS = -1
// 地区审核不通过
export const EXAMINE_NO_COM_ADOPT_STATUS = -4
// 审核不通过
export const EXAMINE_NO_ADOPT_ALL_STATUS = -1
// 审核通过状态
export const EXAMINE_ADOPT_STATUS = 2
// 已经下线
export const EXAMINE_OFF_ONLINE_STATUS = -3

// 二手房专用，已上线
export const EXAMINE_UP_ONLINE_STATUS = 5

// 审核通过特殊查询flag
export const EXANINE_SUCCESS_STATUS = 10

// VR项目审核与审核页面公用
export const EXAMINE_PUBLIC_STATUS = [
  { name: "待地区审核", value: EXAMINE_NO_COM_AUDIT_STATUS },
  { name: "待集团审核", value: EXAMINE_NO_AUDIT_STATUS },
  { name: "已审核", value: EXANINE_SUCCESS_STATUS },
  { name: "已上线", value: EXAMINE_ADOPT_STATUS },
  { name: "未通过", value: EXAMINE_NO_ADOPT_ALL_STATUS },
]

// 二手房状态管理
export const COMMUNITY_PUBLIC_STATUS = [
  ...EXAMINE_PUBLIC_STATUS.map(item => 
    item.value === EXAMINE_ADOPT_STATUS
      ? { ...item, name: '审核已通过'}
      : item
  )
]

// 审核结果，审核页面不展示草稿
export const EXAMINE_SHOW_STATUS = [
  { name: "全部", value: EXAMINE_ALL_STATUS },
  ...EXAMINE_PUBLIC_STATUS
]

// 二手房审核结果
export const EXAMINE_SHOW_STATUS_1 = [
  { name: "全部", value: EXAMINE_ALL_STATUS },
  { name: "待地区审核", value: EXAMINE_NO_COM_AUDIT_STATUS },
  { name: "待集团审核", value: EXAMINE_NO_AUDIT_STATUS },
  { name: "已上线", value: EXAMINE_ADOPT_STATUS },
  { name: "未通过", value: EXAMINE_NO_ADOPT_ALL_STATUS },
]

// VR项目审核页面，展示草稿
export const EXAMINE_SHOW_SELECT_STATUS = [
  { name: "全部", value: UN_REQ_NUM },
  { name: "草稿", value: EXAMINE_DRAFT_STATUS },
  ...EXAMINE_PUBLIC_STATUS,
]

// VR二手房项目审核页面，展示草稿
export const EXAMINE_SHOW_SELECT_STATUS_2 = [
  { name: "全部", value: UN_REQ_NUM },
  { name: "草稿", value: EXAMINE_DRAFT_STATUS },
  { name: "待地区审核", value: EXAMINE_NO_COM_AUDIT_STATUS },
  { name: "待集团审核", value: EXAMINE_NO_AUDIT_STATUS },
  // { name: "已审核", value: EXAMINE_ADOPT_STATUS },
  { name: "已上线", value: EXAMINE_UP_ONLINE_STATUS },
  // { name: "已下线",value: EXAMINE_OFF_ONLINE_STATUS },
  { name: "未通过", value: EXAMINE_NO_ADOPT_ALL_STATUS },
]

export const EXAMINE_SHOW_SELECT_STATUS_3 = [
  { name: "全部", value: UN_REQ_NUM },
  { name: "草稿", value: EXAMINE_DRAFT_STATUS },
  { name: "待地区审核", value: EXAMINE_NO_COM_AUDIT_STATUS },
  { name: "待集团审核", value: EXAMINE_NO_AUDIT_STATUS },
  { name: "已审核", value: EXAMINE_ADOPT_STATUS },
  { name: "已上线", value: EXAMINE_UP_ONLINE_STATUS },
  { name: "已下线",value: EXAMINE_OFF_ONLINE_STATUS },
  { name: "未通过", value: EXAMINE_NO_ADOPT_ALL_STATUS },
]

// 审核记录弹出使用
export const AUTH_COM_VIEW = [
  { name: "已审核", value: 4 },
  { name: "待集团审核", value: 0 },
  { name: "已上线", value: 1 },
  { name: "待地区审核", value: 2 },
  { name: "地区审核通过", value: 3 },
  { name: "集团驳回", value: -1 },
  { name: "地区驳回", value: -4 },
]

// 房间类型
export const HOUSE_TYPE = [
  { name: "新房", value: 1 },
  // { name: "二手房", value: 2 }
]

// 请求展示需要带全部
export const HOUSE_TYPE_SELECT = [
  { name: '全部', value: UN_REQ_NUM },
  ...HOUSE_TYPE
]

// 场景类型
export const SCENE_TYPE = [
  { name: '其他', value: '0' },
  { name: '文博', value: 1 },
  { name: '地产', value: 2 },
  { name: '电商', value: 3 },
  { name: '餐饮', value: 4 },
  { name: '家居', value: 5 }
]

export const getName = (options, isVlog) => {
  if (options === EXAMINE_SHOW_STATUS || options === EXAMINE_SHOW_SELECT_STATUS || options === EXAMINE_SHOW_SELECT_STATUS_2 || options === EXAMINE_SHOW_SELECT_STATUS_3) {
    options = [
      ...options.filter(item => item.value !== EXAMINE_NO_ADOPT_ALL_STATUS),
      { name: "集团驳回", value: EXAMINE_NO_ADOPT_STATUS },
      { name: "地区驳回", value: EXAMINE_NO_COM_ADOPT_STATUS }
    ]
  }
  isVlog && console.log(options, options === EXAMINE_SHOW_SELECT_STATUS)
  return (val) => {
    let item = options.find(({value}) => Number(value) === Number(val))
    return item ? item.name : ''
  }
}




// 提审
export const REDIRECT_AUDIT_BRING_STATUS = 1
// 地区审核通过
export const REDIRECT_AUDIT_REGION_STATUS = 2
// 集团审核通过
export const REDIRECT_AUDIT_GROUP_STATUS = 3
// 上线
export const REDIRECT_AUDIT_UP_STATUS = 4
// 下线
export const REDIRECT_AUDIT_OFF_STATUS = 5
// 撤回
export const REDIRECT_AUDIT_RECALL_STATUS = 6
// 驳回
export const REDIRECT_AUDIT_REJECT_STATUS = 7

const EXAMINE_REDIRECT_BASE_SELECT = [
  { name: '不通过', value: REDIRECT_AUDIT_REJECT_STATUS }
]

// 二手房弹框集团请求审核
export const EXAMINE_REDIRECT_GROUP_SELECT = [
  { name: '通过', value: REDIRECT_AUDIT_GROUP_STATUS },
  ...EXAMINE_REDIRECT_BASE_SELECT
]

// 二手房弹框地区请求审核
export const EXAMINE_REDIRECT_REGION_SELECT = [
  { name: '通过', value: REDIRECT_AUDIT_REGION_STATUS },
  ...EXAMINE_REDIRECT_BASE_SELECT
]

export const getRedirectCommunityAuditBody = (data, status, mark) => ({
  updatorId: user.value.info.id,
  updatorName: user.value.info.nickName,
  vrGardenId: data.vrGardenId,
  operateType: status,
  vrUrl: data.vrUrl,
  vrCover: data.vrCover,
  remark: mark,
  
  reviewerId: user.value.info.id,
  reviewer: user.value.info.nickName,
  operatorCompanyId: user.value.info.departmentId,
  operatorCompanyName: '1',
  companyId: user.value.info.departmentId,
  companyName: '',
  maintenanceman: '',
  maintenancemanId: ''
})
// , id = data.id

export const getRedirectRoomAuditBody = (data, status, mark) => ({
  roomlistingId: data.roomlistingId || data.id,
  reviewerId: user.value.info.id,
  reviewer: user.value.info.nickName,
  reviewMark: mark,
  gardenName: data.gardenName,
  gardenId: data.gardenId,
  vrModelName: data.vrModelName,
  cityId: data.cityId,
  num: data.num,


  dataSource: data.dataSource,
  auditStatus: status,
  vRUrl: data.vRUrl,
  vrCover: data.vrCover,
  companyId: user.value.info.departmentId,
  companyName: '',
  maintenanceman: '',
  maintenancemanId: ''
})


// 审核记录弹出使用
export const AUTH_REDIRECT_COM_VIEW = [
  { name: "集团驳回", value: EXAMINE_NO_ADOPT_STATUS },
  { name: "草稿", value: EXAMINE_DRAFT_STATUS },
  { name: "地区驳回", value: EXAMINE_NO_COM_ADOPT_STATUS },
  { name: "已审核", value: EXAMINE_ADOPT_STATUS },
  { name: "已上线", value: EXAMINE_UP_ONLINE_STATUS },
  ...EXAMINE_PUBLIC_STATUS,
]