/*
 * @Author: tengmingxue 1473375109@qq.com
 * @Date: 2023-08-28 13:46:21
 * @LastEditors: tengmingxue 1473375109@qq.com
 * @LastEditTime: 2023-09-24 11:11:38
 * @FilePath: \xld-gis-admin\src\views\dataAdmin\dataAdmin\sysDic.ts
 * @Description: 系统字典
 */
import { getServiceTypes, queryServiceTags, queryDicsByName, queryCoors } from '/@/api/resource/map';
import { getVersionList } from '/@/api/sys/version';
import { session } from '/@/utils/Memory';

const resTag = await queryServiceTags()
let listTag = []
resTag.map(item => {
  listTag.push({
    label: item.name,
    value: item.code
  })
})
export const serviceTags = listTag;
console.log('serviceTags:', serviceTags)
/**
 * 密级字典
*/
const restSecretList = await queryDicsByName('密级')
let secretList = []
restSecretList.map(item => {
  secretList.push({ ...item, ...{ label: item.name, value: item.code } })
})
export const secrets = secretList;
console.log('secrets', secrets)
/**
 * 服务标签
*/
/**
 * 坐标系列表
*/
const coors = await queryCoors()
let coorList = []
coors.map(item => {
  coorList.push({
    label: item.GEOMNAME,
    value: item.GEOMTITLE,
    GEOMNAME: item.GEOMNAME,
    GEOMTITLE: item.GEOMTITLE,
  })
})
export const sysCoors = coorList
/**
 * 服务类型
*/
const resTypes = await getServiceTypes()
let listType = []
resTypes.map(item => {
  listType.push({
    label: item.name,
    value: item.id
  })
})
export const serviceTypes = listType
/**
 * 责任处室
*/
const respDepts = await queryDicsByName('责任科室')
let respList = []
respDepts.map(item => {
  respList.push({ ...item, ...{ label: item.name, value: item.code } })
})
export const respDept = respList

/**
 * 保管单位
*/
const collects = await queryDicsByName('管理部门')
let collectList = []
collects.map(item => {
  collectList.push({ ...item, ...{ label: item.name, value: item.code } })
})
export const collectDept = collectList
/**
 * EPSG code
*/
export const ECodes = await queryDicsByName('EPSG code')
let epsgList = []
ECodes.map(item => {
  epsgList.push({ ...item, ...{ label: item.name, value: item.code } })
})
export const EPSGCodes = epsgList

export const checkStatus = [
  // { label: '未提交', value: 1 },
  // { label: '审核中', value: 2 },
  // { label: '审核不通过', value: 3 },
  // { label: '被驳回', value: 4 },
  // { label: '审核通过', value: 5 },

  { label: '未提交', value: 3 },
  { label: '审核中', value: 0 },
  { label: '审核通过', value: 1 },
  { label: '审核不通过', value: 2 },
]

export const ApplProcesses = [
  { value: "ggdata", label: "国家秘密和工作秘密数据成果申请" },
  { value: "other", label: "其他数据成果申请" },
  { value: "mr", label: "地图资源申请" },
  { value: "interface", label: "接口服务申请" },
]

function getVersionData() {
  return new Promise((resolve, reject) => {
    getVersionList().then(res => {
      // let resData = JSON.parse(res.result)
      // resData.items.map(i => { i.label = i.name, i.value = i.vid });
      // console.log("版本管理列表:", resData.items)
      // resolve(resData.items)
      let resData = res.datas.pageData
      resolve(resData)
    })
  })
}

export const versionList = await getVersionData();