interface.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. import $http from '../script/http';
  2. import code from './code';
  3. import {
  4. Message
  5. } from "element-ui";
  6. import cookieStorage from 'js-cookie';
  7. //统一处理
  8. const res = (res) => {
  9. const {
  10. retBody = {}, retHead = {}
  11. } = res.data,
  12. codeFun = code[retHead.errCode];
  13. typeof codeFun == "function" ? codeFun(retHead.errMsg) : Message.error(retHead.errMsg || '未知错误');
  14. if (!(retHead.errCode == 0 ? 0 : 1)) {
  15. return retBody || {};
  16. } else {
  17. return {
  18. code: 1
  19. };
  20. }
  21. };
  22. //统一处理默认数据
  23. const resD = (res) => {
  24. const {
  25. msg,
  26. errCode,
  27. data
  28. } = res.data,
  29. codeFun = code[errCode];
  30. typeof codeFun == "function" ? codeFun(msg) : Message.error(msg || '未知错误');
  31. if (!(errCode == 0 ? 0 : 1)) {
  32. return data || {};
  33. } else {
  34. return {
  35. code: 1
  36. };
  37. }
  38. };
  39. export default {
  40. res,
  41. resD,
  42. //登录
  43. login(data) {
  44. return $http.post('/htdata/user/pcLogin', data).then(this.res);
  45. },
  46. //大屏框架
  47. findMapTemplate(data) {
  48. return $http.get('/htdata/map/findMapTemplate').then(this.res);
  49. },
  50. //新增大屏
  51. addMap(data) {
  52. return $http.post('/htdata/map', data).then(this.res);
  53. },
  54. //删除大屏
  55. delMap(data) {
  56. return $http.delete('/htdata/map', {
  57. data
  58. }).then(this.res);
  59. },
  60. //发布大屏
  61. releaseMap(data) {
  62. return $http.post('/htdata/map/updateState', {
  63. id: data.id,
  64. state: 1
  65. }).then(this.res);
  66. },
  67. //获取大屏列表
  68. getMap(data) {
  69. return $http.get('/htdata/map/findMapAll', {
  70. params: {
  71. pageNum: 1,
  72. pageSize: 10,
  73. ...data
  74. }
  75. }).then(this.res);
  76. },
  77. //保存组件数据 参数( 大屏ID、组件ID )
  78. //删除大屏时通过ID清空组件数据
  79. //通过大屏ID 查询 发布状态 控制大屏展示数据是否返回
  80. addModuleData(data) {
  81. /**
  82. * data 对象
  83. * id 大屏ID
  84. * moduleCode 组件ID
  85. * dataType 数据类型 1-API 2-数据库 3-CSV数据表 4-静态数据
  86. * sourceName 数据源名称,当静态数据时,此字段为空
  87. * content 组件数据
  88. */
  89. return $http.post('/htdata/map/addModuleData', data).then(this.res);
  90. },
  91. //统一上传接口
  92. upIuccess(data) {
  93. return new Promise(r => {
  94. r(this.res({
  95. data
  96. }));
  97. });
  98. },
  99. //获取token
  100. getMonitorToken() {
  101. //过期验证
  102. const atName = "accessToken",
  103. at = cookieStorage.get(atName);
  104. if (!at) {
  105. let body = new FormData();
  106. body.append("appKey", "519cce9165e94f56a6f30c927a1699f7");
  107. body.append("appSecret", "bbfaacaf9ffebb0210f866c035fe81fb");
  108. //取得监控token
  109. return fetch('https://open.ys7.com/api/lapp/token/get', {
  110. method: 'post',
  111. body
  112. }).then(res => res.json()).then(res => {
  113. if (res.code == 200) {
  114. const accessToken = (res.data || {}).accessToken || '';
  115. cookieStorage.set(atName, accessToken, {
  116. expires: 6
  117. })
  118. return {
  119. accessToken
  120. }
  121. } else {
  122. return {
  123. code: 200
  124. }
  125. }
  126. });
  127. }
  128. return new Promise(r => {
  129. r({
  130. accessToken: at
  131. });
  132. });
  133. },
  134. //海康监控列表
  135. getMonitorList() {
  136. return this.getMonitorToken().then(res => {
  137. //获取列表
  138. let body = new FormData(), accessToken = res.accessToken || "";
  139. body.append("accessToken", res.accessToken);
  140. body.append("pageStart", 0);
  141. body.append("pageSize", 50);
  142. //获取摄像头监控列表
  143. return fetch("https://open.ys7.com/api/lapp/camera/list", {
  144. method: 'post',
  145. body
  146. }).then(res => res.json()).then(res => {
  147. //组装监控地址
  148. return Array.isArray(res.data) ? res.data.map(x => {
  149. return {
  150. ...x,
  151. //wss播放模式
  152. //“ezopen://open.ys7.com/440912260/1.hd.live”,可以播放序列号为“440912260”设备“1通道”“高清”的“实时视频”
  153. url: `ezopen://open.ys7.com/${x.deviceSerial}/${x.channelNo}.hd.live`,
  154. accessToken
  155. }
  156. }) : [];
  157. })
  158. /*.then(res => {
  159. //筛选掉不能用的摄像头
  160. return res.filter(x => {
  161. return !!x.status;
  162. });
  163. });*/
  164. });
  165. },
  166. /*********系统管理->用户列表接口**********/
  167. getUserList(data) {
  168. return $http.get('/htdata/user/findAll', {
  169. params: {
  170. ...data
  171. }
  172. }).then(this.res);
  173. },
  174. /*********系统管理->获取用户角色**********/
  175. getRolesList() {
  176. return $http.get('/htdata/role/getAll').then(this.res);
  177. },
  178. /*********系统管理->获取组织机构*********/
  179. getBranchidList() {
  180. return $http.get('/htdata/branch/findAll').then(this.res);
  181. },
  182. /*********系统管理->用户查看*********/
  183. viewUser(data) {
  184. return $http.get('/htdata/user/findById', {
  185. params: {
  186. ...data
  187. }
  188. }).then(this.res);
  189. },
  190. /*********系统管理->添加用户*********/
  191. addUser(data) {
  192. return $http.post('/htdata/user/', data).then(this.res);
  193. },
  194. /*********系统管理->删除用户*********/
  195. delUser(data) {
  196. return $http.delete('/htdata/user/', {
  197. params: {
  198. ...data
  199. }
  200. }).then(this.res);
  201. },
  202. /*********系统管理->更新用户*********/
  203. updateUser(data) {
  204. return $http.put('/htdata/user/', data).then(this.res);
  205. },
  206. /*********系统管理->重置密码*********/
  207. resetDefaultPwd(data) {
  208. return $http.put('/htdata/user/resetPwd/', data).then(this.res);
  209. },
  210. /*********系统管理->角色添加*********/
  211. addRole(data) {
  212. return $http.post('/htdata/role/', data).then(this.res);
  213. },
  214. /*********系统管理->角色列表*********/
  215. getRoleList(data) {
  216. return $http.get('/htdata/role/getAll').then(this.res);
  217. },
  218. /*********系统管理->角色修改*********/
  219. updateRoleItem(data) {
  220. return $http.put('/htdata/role', data).then(this.res);
  221. },
  222. /*********系统管理->角色删除*********/
  223. delRole(data) {
  224. return $http.delete('/htdata/role/', {
  225. params: {
  226. ...data
  227. }
  228. }).then(this.res);
  229. },
  230. /*********系统管理->角色菜单获取*********/
  231. getRoleMenu(data) {
  232. return $http.get('/htdata/menu/getMenuByRole', {
  233. params: {
  234. ...data
  235. }
  236. }).then(this.res);
  237. },
  238. /*********系统管理->角色菜单获取*********/
  239. saveRoleMenu(data) {
  240. return $http.post('/htdata/menu/saveRoleMenu', data).then(this.res);
  241. },
  242. /*********系统管理->账号退出*********/
  243. loginOut(data) {
  244. return $http.delete('/htdata/user/pcLogout', {
  245. params: {
  246. ...data
  247. }
  248. }).then(this.res);
  249. },
  250. /*********园区管理->园区列表*********/
  251. getExpertList(data) {
  252. return $http.get('/htdata/orchard/findAll', {
  253. params: {
  254. ...data
  255. }
  256. }).then(this.res);
  257. },
  258. /*********园区管理->园区删除*********/
  259. delExpert(data) {
  260. return $http.delete('/htdata/orchard/', {
  261. data
  262. }).then(this.res);
  263. },
  264. /*********园区管理->新增**********/
  265. addOrchard(data){
  266. return $http.post('/htdata/orchard', data).then(this.res);
  267. },
  268. /*********园区管理->更新**********/
  269. updateOrchard(data){
  270. return $http.put('/htdata/orchard', data).then(this.res);
  271. },
  272. /*********园区管理->园区详情查询**********/
  273. getOrchard(data){
  274. return $http.get('/htdata/orchard/findById',{
  275. params:{
  276. ...data
  277. }
  278. }).then(this.res)
  279. },
  280. /*********园区管理->查询产出物*********/
  281. getProtypeList(data) {
  282. return $http.get('/htdata/orchard/findProdType', {
  283. params: {
  284. ...data
  285. }
  286. }).then(this.res);
  287. },
  288. /*********园区管理->涉及农业*********/
  289. getAgriTypeList(data) {
  290. return $http.get('/htdata/orchard/findAgriType', {
  291. params: {
  292. ...data
  293. }
  294. }).then(this.res);
  295. },
  296. /*********专家团队管理->坝区信息查询*********/
  297. getDamList() {
  298. return $http.get('/htdata/dam/findAll').then(this.res);
  299. },
  300. /*********专家团队管理->坝区信息查询*********/
  301. addExpert(data) {
  302. return $http.post('/htdata/expert', data).then(this.res);
  303. },
  304. /*********专家团队管理->专家详情*********/
  305. getExpertDetail(data) {
  306. return $http.get('/htdata/expert/findById', {
  307. params: {
  308. ...data
  309. }
  310. }).then(this.res);
  311. },
  312. /*********专家团队管理->更新专家详情*********/
  313. updateExpert(data) {
  314. return $http.put('/htdata/expert', data).then(this.res);
  315. },
  316. /*********系统全局->跳转至益农社*********/
  317. goYlAdmin(data) {
  318. return $http.post('/htdata/yinongshe/login').then(this.res);
  319. },
  320. /*********坝区信息管理->信息列表*********/
  321. getDamList(data) {
  322. return $http.get('/htdata/dam/findAll', {
  323. params: {
  324. ...data
  325. }
  326. }).then(this.res);
  327. },
  328. /*********坝区信息管理->新增*********/
  329. addDam(data) {
  330. return $http.post('/htdata/dam', data).then(this.res);
  331. },
  332. /*********坝区信息管理->删除*********/
  333. delDam(data) {
  334. return $http.delete('/htdata/dam', {
  335. data
  336. }).then(this.res);
  337. },
  338. /*********坝区信息管理->是否启用*********/
  339. damUpdateState(data) {
  340. return $http.post('/htdata/dam/updateState', data).then(this.res);
  341. },
  342. /*********坝区信息管理->获取详情*********/
  343. getDamInfo(params) {
  344. return $http.get('/htdata/dam/findById ', {
  345. params
  346. }).then(this.res);
  347. },
  348. /*********坝区信息管理->更新详情*********/
  349. updateDam(data) {
  350. return $http.put('/htdata/dam', data).then(this.res);
  351. },
  352. /*********区域数据管理->获取列表*********/
  353. getAreaListx(data) {
  354. return $http.get('/htdata/areaData/findAll', {
  355. params: {
  356. ...data
  357. }
  358. }).then(this.res);
  359. },
  360. /*********区域数据管理->查询详情*********/
  361. getAreaManageInfo(data) {
  362. return $http.get('/htdata/areaData/findById', {
  363. params: {
  364. ...data
  365. }
  366. }).then(this.res);
  367. },
  368. /*********区域数据管理->大屏应用状态修改*********/
  369. areaDataUpdate(data) {
  370. return $http.post('/htdata/areaData/updateState', data).then(this.res);
  371. },
  372. /*********区域数据管理->大屏删除*********/
  373. delareaData(data) {
  374. return $http.delete('/htdata/areaData', {
  375. data
  376. }).then(this.res);
  377. },
  378. /*********区域数据管理->数据类型*********/
  379. getAreaDataTypeList(data) {
  380. return $http.get('/htdata/dict/findValueByCode', {
  381. params: {
  382. ...data
  383. }
  384. }).then(this.res);
  385. },
  386. /*********获取系统菜单权限 new add**********/
  387. getUserMenuTree() {
  388. return $http.get('/htdata/menu/userMenuTree').then(this.res);
  389. },
  390. /*********大屏模板组件默认数据及数据字典接口**********/
  391. getDefaultModuleData(params) {
  392. return $http.get('/defdata/default/data', {
  393. params
  394. }).then(this.resD);
  395. },
  396. /*********查询口令列表**********/
  397. getPwdList(params) {
  398. return $http.get('/htdata/map/findPwd', {
  399. params
  400. }).then(this.res);
  401. },
  402. /*********更新口令信息**********/
  403. upPwdInfo(data) {
  404. return $http.post('/htdata/map/updatePwd', data).then(this.res);
  405. },
  406. /*********组件城市联动->获取省**********/
  407. getProvince() {
  408. return $http.get('/htdata/depart/findProvince').then(this.res);
  409. },
  410. /*********组件城市联动->获取市**********/
  411. getCity(data) {
  412. return $http.get('/htdata/depart/findCity',{
  413. params: {
  414. ...data
  415. }
  416. }).then(this.res);
  417. },
  418. /*********组件城市联动->获取区**********/
  419. getCounty(data){
  420. return $http.get('/htdata/depart/findCounty',{
  421. params: {
  422. ...data
  423. }
  424. }).then(this.res);
  425. },
  426. /*********组件城市联动->获取镇**********/
  427. getTown(data){
  428. return $http.get('/htdata/depart/findTown',{
  429. params: {
  430. ...data
  431. }
  432. }).then(this.res);
  433. },
  434. //地图检索
  435. serachAmap(data){
  436. return $http.get('/amapData/v3/place/text',{
  437. params:{
  438. ...data
  439. }
  440. }).then()
  441. },
  442. /*********专题列表->获取分布点数据源**********/
  443. getTopIcData(data) {
  444. return $http.get('/htdata/topic/findTopicDbField', {
  445. params: {
  446. ...data
  447. }
  448. }).then(this.res);
  449. },
  450. /*********专题列表->专题新增**********/
  451. addTopic(data) {
  452. return $http.post('/htdata/topic', data).then(this.res);
  453. },
  454. /*********专题列表->获取专题列表**********/
  455. getTopIcList(data){
  456. return $http.get('/htdata/topic/findTopicInfo', {
  457. params: {
  458. ...data
  459. }
  460. }).then(this.res);
  461. },
  462. /*********专题列表->删除专题**********/
  463. delTopic(data){
  464. return $http.delete('/htdata/topic', {
  465. data
  466. }).then(this.res);
  467. },
  468. /*********专题列表->修改专题**********/
  469. updateTopic(data){
  470. return $http.put('/htdata/topic', data).then(this.res);
  471. },
  472. /*********专题列表->产业扶贫列表**********/
  473. getNoticeList(data) {
  474. return $http.get('/htdata/notice/findAll', {
  475. params: {
  476. ...data
  477. }
  478. }).then(this.res);
  479. },
  480. /*********专题列表->产业扶贫新增**********/
  481. addNotice(data) {
  482. return $http.post('/htdata/notice', data).then(this.res);
  483. },
  484. /*********专题列表->产业扶贫删除**********/
  485. delNotice(data) {
  486. return $http.delete('/htdata/notice', {
  487. data
  488. }).then(this.res);
  489. },
  490. /*********专题列表->获取产业扶贫详情**********/
  491. getNotice(data){
  492. return $http.get('/htdata/notice/findById', {
  493. params: {
  494. ...data
  495. }
  496. }).then(this.res);
  497. },
  498. /*********专题列表->产业扶贫更新**********/
  499. updateNotice(data) {
  500. return $http.put('/htdata/notice', data).then(this.res);
  501. },
  502. }