123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 |
- import $http from '../script/http';
- import code from './code';
- import {
- Message
- } from "element-ui";
- import cookieStorage from 'js-cookie';
- //统一处理
- const res = (res) => {
- const {
- retBody = {}, retHead = {}
- } = res.data,
- codeFun = code[retHead.errCode];
- typeof codeFun == "function" ? codeFun(retHead.errMsg) : Message.error(retHead.errMsg || '未知错误');
- if (!(retHead.errCode == 0 ? 0 : 1)) {
- return retBody || {};
- } else {
- return {
- code: 1
- };
- }
- };
- //统一处理默认数据
- const resD = (res) => {
- const {
- msg,
- errCode,
- data
- } = res.data,
- codeFun = code[errCode];
- typeof codeFun == "function" ? codeFun(msg) : Message.error(msg || '未知错误');
- if (!(errCode == 0 ? 0 : 1)) {
- return data || {};
- } else {
- return {
- code: 1
- };
- }
- };
- export default {
- res,
- resD,
- //登录
- login(data) {
- return $http.post('/htdata/user/pcLogin', data).then(this.res);
- },
- //大屏框架
- findMapTemplate(data) {
- return $http.get('/htdata/map/findMapTemplate').then(this.res);
- },
- //新增大屏
- addMap(data) {
- return $http.post('/htdata/map', data).then(this.res);
- },
- //删除大屏
- delMap(data) {
- return $http.delete('/htdata/map', {
- data
- }).then(this.res);
- },
- //发布大屏
- releaseMap(data) {
- return $http.post('/htdata/map/updateState', {
- id: data.id,
- state: 1
- }).then(this.res);
- },
- //获取大屏列表
- getMap(data) {
- return $http.get('/htdata/map/findMapAll', {
- params: {
- pageNum: 1,
- pageSize: 10,
- ...data
- }
- }).then(this.res);
- },
- //保存组件数据 参数( 大屏ID、组件ID )
- //删除大屏时通过ID清空组件数据
- //通过大屏ID 查询 发布状态 控制大屏展示数据是否返回
- addModuleData(data) {
- /**
- * data 对象
- * id 大屏ID
- * moduleCode 组件ID
- * dataType 数据类型 1-API 2-数据库 3-CSV数据表 4-静态数据
- * sourceName 数据源名称,当静态数据时,此字段为空
- * content 组件数据
- */
- return $http.post('/htdata/map/addModuleData', data).then(this.res);
- },
- //统一上传接口
- upIuccess(data) {
- return new Promise(r => {
- r(this.res({
- data
- }));
- });
- },
- //获取token
- getMonitorToken() {
- //过期验证
- const atName = "accessToken",
- at = cookieStorage.get(atName);
- if (!at) {
- let body = new FormData();
- body.append("appKey", "519cce9165e94f56a6f30c927a1699f7");
- body.append("appSecret", "bbfaacaf9ffebb0210f866c035fe81fb");
- //取得监控token
- return fetch('https://open.ys7.com/api/lapp/token/get', {
- method: 'post',
- body
- }).then(res => res.json()).then(res => {
- if (res.code == 200) {
- const accessToken = (res.data || {}).accessToken || '';
- cookieStorage.set(atName, accessToken, {
- expires: 6
- })
- return {
- accessToken
- }
- } else {
- return {
- code: 200
- }
- }
- });
- }
- return new Promise(r => {
- r({
- accessToken: at
- });
- });
- },
- //海康监控列表
- getMonitorList() {
- return this.getMonitorToken().then(res => {
- //获取列表
- let body = new FormData(), accessToken = res.accessToken || "";
- body.append("accessToken", res.accessToken);
- body.append("pageStart", 0);
- body.append("pageSize", 50);
- //获取摄像头监控列表
- return fetch("https://open.ys7.com/api/lapp/camera/list", {
- method: 'post',
- body
- }).then(res => res.json()).then(res => {
- //组装监控地址
- return Array.isArray(res.data) ? res.data.map(x => {
- return {
- ...x,
- //wss播放模式
- //“ezopen://open.ys7.com/440912260/1.hd.live”,可以播放序列号为“440912260”设备“1通道”“高清”的“实时视频”
- url: `ezopen://open.ys7.com/${x.deviceSerial}/${x.channelNo}.hd.live`,
- accessToken
- }
- }) : [];
- })
- /*.then(res => {
- //筛选掉不能用的摄像头
- return res.filter(x => {
- return !!x.status;
- });
- });*/
- });
- },
- /*********系统管理->用户列表接口**********/
- getUserList(data) {
- return $http.get('/htdata/user/findAll', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********系统管理->获取用户角色**********/
- getRolesList() {
- return $http.get('/htdata/role/getAll').then(this.res);
- },
- /*********系统管理->获取组织机构*********/
- getBranchidList() {
- return $http.get('/htdata/branch/findAll').then(this.res);
- },
- /*********系统管理->用户查看*********/
- viewUser(data) {
- return $http.get('/htdata/user/findById', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********系统管理->添加用户*********/
- addUser(data) {
- return $http.post('/htdata/user/', data).then(this.res);
- },
- /*********系统管理->删除用户*********/
- delUser(data) {
- return $http.delete('/htdata/user/', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********系统管理->更新用户*********/
- updateUser(data) {
- return $http.put('/htdata/user/', data).then(this.res);
- },
- /*********系统管理->重置密码*********/
- resetDefaultPwd(data) {
- return $http.put('/htdata/user/resetPwd/', data).then(this.res);
- },
- /*********系统管理->角色添加*********/
- addRole(data) {
- return $http.post('/htdata/role/', data).then(this.res);
- },
- /*********系统管理->角色列表*********/
- getRoleList(data) {
- return $http.get('/htdata/role/getAll').then(this.res);
- },
- /*********系统管理->角色修改*********/
- updateRoleItem(data) {
- return $http.put('/htdata/role', data).then(this.res);
- },
- /*********系统管理->角色删除*********/
- delRole(data) {
- return $http.delete('/htdata/role/', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********系统管理->角色菜单获取*********/
- getRoleMenu(data) {
- return $http.get('/htdata/menu/getMenuByRole', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********系统管理->角色菜单获取*********/
- saveRoleMenu(data) {
- return $http.post('/htdata/menu/saveRoleMenu', data).then(this.res);
- },
- /*********系统管理->账号退出*********/
- loginOut(data) {
- return $http.delete('/htdata/user/pcLogout', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********园区管理->园区列表*********/
- getExpertList(data) {
- return $http.get('/htdata/orchard/findAll', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********园区管理->园区删除*********/
- delExpert(data) {
- return $http.delete('/htdata/orchard/', {
- data
- }).then(this.res);
- },
- /*********园区管理->新增**********/
- addOrchard(data){
- return $http.post('/htdata/orchard', data).then(this.res);
- },
- /*********园区管理->更新**********/
- updateOrchard(data){
- return $http.put('/htdata/orchard', data).then(this.res);
- },
- /*********园区管理->园区详情查询**********/
- getOrchard(data){
- return $http.get('/htdata/orchard/findById',{
- params:{
- ...data
- }
- }).then(this.res)
- },
- /*********园区管理->查询产出物*********/
- getProtypeList(data) {
- return $http.get('/htdata/orchard/findProdType', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********园区管理->涉及农业*********/
- getAgriTypeList(data) {
- return $http.get('/htdata/orchard/findAgriType', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专家团队管理->坝区信息查询*********/
- getDamList() {
- return $http.get('/htdata/dam/findAll').then(this.res);
- },
- /*********专家团队管理->坝区信息查询*********/
- addExpert(data) {
- return $http.post('/htdata/expert', data).then(this.res);
- },
- /*********专家团队管理->专家详情*********/
- getExpertDetail(data) {
- return $http.get('/htdata/expert/findById', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专家团队管理->更新专家详情*********/
- updateExpert(data) {
- return $http.put('/htdata/expert', data).then(this.res);
- },
- /*********系统全局->跳转至益农社*********/
- goYlAdmin(data) {
- return $http.post('/htdata/yinongshe/login').then(this.res);
- },
- /*********坝区信息管理->信息列表*********/
- getDamList(data) {
- return $http.get('/htdata/dam/findAll', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********坝区信息管理->新增*********/
- addDam(data) {
- return $http.post('/htdata/dam', data).then(this.res);
- },
- /*********坝区信息管理->删除*********/
- delDam(data) {
- return $http.delete('/htdata/dam', {
- data
- }).then(this.res);
- },
- /*********坝区信息管理->是否启用*********/
- damUpdateState(data) {
- return $http.post('/htdata/dam/updateState', data).then(this.res);
- },
- /*********坝区信息管理->获取详情*********/
- getDamInfo(params) {
- return $http.get('/htdata/dam/findById ', {
- params
- }).then(this.res);
- },
- /*********坝区信息管理->更新详情*********/
- updateDam(data) {
- return $http.put('/htdata/dam', data).then(this.res);
- },
- /*********区域数据管理->获取列表*********/
- getAreaListx(data) {
- return $http.get('/htdata/areaData/findAll', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********区域数据管理->查询详情*********/
- getAreaManageInfo(data) {
- return $http.get('/htdata/areaData/findById', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********区域数据管理->大屏应用状态修改*********/
- areaDataUpdate(data) {
- return $http.post('/htdata/areaData/updateState', data).then(this.res);
- },
- /*********区域数据管理->大屏删除*********/
- delareaData(data) {
- return $http.delete('/htdata/areaData', {
- data
- }).then(this.res);
- },
- /*********区域数据管理->数据类型*********/
- getAreaDataTypeList(data) {
- return $http.get('/htdata/dict/findValueByCode', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********获取系统菜单权限 new add**********/
- getUserMenuTree() {
- return $http.get('/htdata/menu/userMenuTree').then(this.res);
- },
- /*********大屏模板组件默认数据及数据字典接口**********/
- getDefaultModuleData(params) {
- return $http.get('/defdata/default/data', {
- params
- }).then(this.resD);
- },
- /*********查询口令列表**********/
- getPwdList(params) {
- return $http.get('/htdata/map/findPwd', {
- params
- }).then(this.res);
- },
- /*********更新口令信息**********/
- upPwdInfo(data) {
- return $http.post('/htdata/map/updatePwd', data).then(this.res);
- },
- /*********组件城市联动->获取省**********/
- getProvince() {
- return $http.get('/htdata/depart/findProvince').then(this.res);
- },
- /*********组件城市联动->获取市**********/
- getCity(data) {
- return $http.get('/htdata/depart/findCity',{
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********组件城市联动->获取区**********/
- getCounty(data){
- return $http.get('/htdata/depart/findCounty',{
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********组件城市联动->获取镇**********/
- getTown(data){
- return $http.get('/htdata/depart/findTown',{
- params: {
- ...data
- }
- }).then(this.res);
- },
- //地图检索
- serachAmap(data){
- return $http.get('/amapData/v3/place/text',{
- params:{
- ...data
- }
- }).then()
- },
- /*********专题列表->获取分布点数据源**********/
- getTopIcData(data) {
- return $http.get('/htdata/topic/findTopicDbField', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专题列表->专题新增**********/
- addTopic(data) {
- return $http.post('/htdata/topic', data).then(this.res);
- },
- /*********专题列表->获取专题列表**********/
- getTopIcList(data){
- return $http.get('/htdata/topic/findTopicInfo', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专题列表->删除专题**********/
- delTopic(data){
- return $http.delete('/htdata/topic', {
- data
- }).then(this.res);
- },
- /*********专题列表->修改专题**********/
- updateTopic(data){
- return $http.put('/htdata/topic', data).then(this.res);
- },
- /*********专题列表->产业扶贫列表**********/
- getNoticeList(data) {
- return $http.get('/htdata/notice/findAll', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专题列表->产业扶贫新增**********/
- addNotice(data) {
- return $http.post('/htdata/notice', data).then(this.res);
- },
- /*********专题列表->产业扶贫删除**********/
- delNotice(data) {
- return $http.delete('/htdata/notice', {
- data
- }).then(this.res);
- },
- /*********专题列表->获取产业扶贫详情**********/
- getNotice(data){
- return $http.get('/htdata/notice/findById', {
- params: {
- ...data
- }
- }).then(this.res);
- },
- /*********专题列表->产业扶贫更新**********/
- updateNotice(data) {
- return $http.put('/htdata/notice', data).then(this.res);
- },
-
-
- }
|