import { getWebList,deleteWebList,getwebsiteColumn,
getcityList,uploadFile,getTemplate,addWebsite,getWebsiteInfo,
updateWebsite,getDepartment,getCategoryList,delCategory,
getCategoryInfo,categoryList,addCategory,updateCategory,
getNavWebList,addWebsiteCategory,getWebsiteCategoryList,
getAdminWebsiteCategory,upWebsiteCategory,delWebsiteCategory,
getWebsiteAllCategory,getWebsiteCategoryOnes,upWebsiteCategoryones,
checkWebsiteUrl,checkWebsiteName} from '@/api/pool'

const state = {

}

const mutations = {

}

const actions = {
  //1.网站列表 end ---------------------------------------->
  //获取网站管理列表
  getWebList({commit},data) {
    return new Promise((resolve, reject) => {
      getWebList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //删除网站列表中的网站
  deleteWebList({commit},data) {
    return new Promise((resolve, reject) => {
      deleteWebList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获得所有网系
  getwebsiteColumn({commit},data) {
    return new Promise((resolve, reject) => {
      getwebsiteColumn(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取城市列表
  getcityList({commit},data) {
    return new Promise((resolve, reject) => {
      getcityList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //上传文件
  uploadFile({commit},data) {
    return new Promise((resolve, reject) => {
      uploadFile(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取模板列表
  getTemplate({commit},data) {
    return new Promise((resolve, reject) => {
      getTemplate(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加网站
  addWebsite({commit},data) {
    return new Promise((resolve, reject) => {
      addWebsite(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取网站详情
  getWebsiteInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getWebsiteInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改网站
  updateWebsite({commit},data) {
    return new Promise((resolve, reject) => {
      updateWebsite(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //检测网站url是否存在
  checkWebsiteUrl({commit},data) {
    return new Promise((resolve, reject) => {
      checkWebsiteUrl(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //检测网站名称是否存在
  checkWebsiteName({commit},data) {
    return new Promise((resolve, reject) => {
      checkWebsiteName(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //网站列表 end ---------------------------------------->

  //2.导航池 start ---------------------------------------->
  //获得导航池列表
  getCategoryList({commit},data) {
    return new Promise((resolve, reject) => {
      getCategoryList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获得职能部门
  getDepartment({commit},data) {
    return new Promise((resolve, reject) => {
      getDepartment(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //删除导航池
  delCategory({commit},data) {
    return new Promise((resolve, reject) => {
      delCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取导航池详情
  getCategoryInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getCategoryInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取父级导航
  categoryList({commit},data) {
    return new Promise((resolve, reject) => {
      categoryList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加导航池
  addCategory({commit},data) {
    return new Promise((resolve, reject) => {
      addCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //更新导航池
  updateCategory({commit},data) {
    return new Promise((resolve, reject) => {
      updateCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //导航池 end ---------------------------------------->

  //3.网站导航管理 start ---------------------------------------->
  //获取导航列表
  getNavWebList({commit},data) {
    return new Promise((resolve, reject) => {
      getNavWebList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加导航
  addWebsiteCategory({commit},data) {
    return new Promise((resolve, reject) => {
      addWebsiteCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加导航
  getWebsiteCategoryList({commit},data) {
    return new Promise((resolve, reject) => {
      getWebsiteCategoryList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //查询网站下的导航
  getAdminWebsiteCategory({commit},data) {
    return new Promise((resolve, reject) => {
      getAdminWebsiteCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //编辑网站导航
  upWebsiteCategory({commit},data) {
    return new Promise((resolve, reject) => {
      upWebsiteCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //删除网站导航
  delWebsiteCategory({commit},data) {
    return new Promise((resolve, reject) => {
      delWebsiteCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //网站导航管理 end ---------------------------------------->

  //4.关联导航池 start ---------------------------------------->
  //导航列表
  getWebsiteAllCategory({commit},data) {
    return new Promise((resolve, reject) => {
      getWebsiteAllCategory(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //查询单个导航信息
  getWebsiteCategoryOnes({commit},data) {
    return new Promise((resolve, reject) => {
      getWebsiteCategoryOnes(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //编辑导航
  upWebsiteCategoryones({commit},data) {
    return new Promise((resolve, reject) => {
      upWebsiteCategoryones(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
  //关联导航池 end ---------------------------------------->
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
