util.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. function setConfig(params) {
  2. return Object.assign(
  3. {},
  4. {
  5. skin: 'terrace',
  6. multiselect: true,
  7. // imagePath: "../../prologui/dist/vendors/dhtmlx/grid/skins/web/imgs",
  8. type: 'get', //数据提交方式,默认为get
  9. params: (function() {
  10. return {
  11. // "warehouseId": getLocalStrongSelectedWarehouseIds().toString(),
  12. // // "company_id": Prolog.getLocalStorage('userinfo').p_organizationid, // 默认值是0
  13. // "deleteFlag": 0
  14. }
  15. })(), //查询提交参数,分页参数默认为pageNum,pageSize
  16. page: true, //是否启用分页
  17. totalCount: 'totalCount', //总记录数字段,默认totalCount
  18. toolbar: []
  19. },
  20. params
  21. )
  22. }
  23. Prolog.download = function(url, fileName, hasAuth) {
  24. var xhr = new XMLHttpRequest()
  25. xhr.open('GET', url, true) //get请求,请求地址,是否异步
  26. if (hasAuth) {
  27. xhr.setRequestHeader('Authorization', localStorage.getItem('authorization'))
  28. }
  29. xhr.responseType = 'blob' // 返回类型blo
  30. xhr.onload = function() {
  31. // 请求完成处理函数
  32. if (this.status === 200) {
  33. var blob = this.response // 获取返回值
  34. const a = document.getElementById('down')
  35. a.href = URL.createObjectURL(blob)
  36. a.download = fileName
  37. a.click()
  38. // URL.revokeObjectUrl(blob)
  39. }
  40. }
  41. // 发送ajax请求
  42. xhr.send()
  43. }
  44. /*
  45. elem 指向容器选择器,如:elem: '#id'。也可以是DOM对象 string/object -
  46. url 服务端上传接口,返回的数据规范请详见下文 string -
  47. data 请求上传接口的额外参数。如:data: {id: 'xxx'}
  48. headers 接口的请求头。如:headers: {token: 'sasasas'}。注:该参数为 layui 2.2.6 开始新增
  49. accept 指定允许上传时校验的文件类型,可选值有:images(图片)、file(所有文件)、video(视频)、audio(音频) string images
  50. acceptMime 规定打开文件选择框时,筛选出的文件类型,值为用逗号隔开的 MIME 类型列表。如:
  51. acceptMime: 'image/*'(只显示图片文件)
  52. acceptMime: 'image/jpg, image/png'(只显示 jpg 和 png 文件)
  53. 注:该参数为 layui 2.2.6 开始新增 string images
  54. exts 允许上传的文件后缀。一般结合 accept 参数类设定。假设 accept 为 file 类型时,那么你设置 exts: 'zip|rar|7z' 即代表只允许上传压缩格式的文件。如果 accept 未设定,那么限制的就是图片的文件格式 string jpg|png|gif|bmp|jpeg
  55. auto 是否选完文件后自动上传。如果设定 false,那么需要设置 bindAction 参数来指向一个其它按钮提交上传 boolean true
  56. bindAction 指向一个按钮触发上传,一般配合 auto: false 来使用。值为选择器或DOM对象,如:bindAction: '#btn' string/object -
  57. field 设定文件域的字段名 string file
  58. size 设置文件最大可允许上传的大小,单位 KB。不支持ie8/9 number 0(即不限制)
  59. multiple 是否允许多文件上传。设置 true即可开启。不支持ie8/9 boolean false
  60. number 设置同时可上传的文件数量,一般配合 multiple 参数出现。注意:该参数为 layui 2.2.3 开始新增 number 0(即不限制)
  61. drag 是否接受拖拽的文件上传,设置 false 可禁用。不支持ie8/9 boolean true
  62. 回调
  63. choose 选择文件后的回调函数。返回一个object参数,详见下文 function -
  64. before 文件提交上传前的回调。返回一个object参数(同上),详见下文 function -
  65. done 执行上传请求后的回调。返回三个参数,分别为:res(服务端响应信息)、index(当前文件的索引)、upload(重新上传的方法,一般在文件上传失败后使用)。详见下文 function -
  66. error 执行上传请求出现异常的回调(一般为网络异常、URL 404等)。返回两个参数,分别为:index(当前文件的索引)、upload(重新上传的方法)。详见下文 function -
  67. */
  68. Prolog.upload = function(opts, hasAuth) {
  69. var upload = layui.upload //得到 upload 对象
  70. if (hasAuth) {
  71. if (opts.headers) opts.headers['Authorization'] = 'Bearer ' + localStorage.getItem('authorization')
  72. else opts.headers = { Authorization: 'Bearer ' + localStorage.getItem('authorization') }
  73. }
  74. //创建一个上传组件
  75. upload.render(opts)
  76. }
  77. /**
  78. *
  79. * @param {function} GridPlant hdw个人使用工厂函数
  80. */
  81. function GridPlant(obj) {
  82. ;(this.isI18n = window.isI18n || false), //多语言默认false
  83. // enableSideBar: true,
  84. (this.idS = '') //
  85. this.rowId = ''
  86. this.PlgGridInstance = obj.instance
  87. this.addBtnUrl = obj.addBtnUrl
  88. this.delBtnUrl = obj.delBtnUrl
  89. this.downBtnUrl = obj.downBtnUrl
  90. this.exportBtnUrl = obj.exportBtnUrl
  91. this.importBtnUrl = obj.importBtnUrl
  92. this.fileText = obj.fileText || 'fileText' //中文模块名称
  93. this.moduleName = obj.moduleName //查日志使用的英文模块名称
  94. this.formDataArea = [750, 350]
  95. if (obj.instance.opts.formDataArea && obj.instance.opts.formDataArea.length > 0) {
  96. this.formDataArea[0] = obj.instance.opts.formDataArea[0] //弹框width
  97. this.formDataArea[1] = obj.instance.opts.formDataArea[1] //弹框height
  98. }
  99. this.t = (function(is) {
  100. if (is) {
  101. return (this.t = function(text) {
  102. return i18next.t(text)
  103. })
  104. } else {
  105. return (this.t = function(text) {
  106. return text
  107. })
  108. }
  109. })(this.isI18n)
  110. this.logBtn = function() {
  111. var _this = this
  112. if (!this.moduleName) {
  113. throw new Error('this.moduleName模块名称没定义')
  114. }
  115. var popUps = function(id, modulesName, contentContainer) {
  116. if (!id || !modulesName || !contentContainer) {
  117. throw new Error('当前传递的参数缺少值')
  118. }
  119. layer.open({
  120. type: 1, //此处以iframe举例
  121. title: `<div class="k-log-title">【${_this.t(modulesName)}】${_this.t('修改记录')}</div>`,
  122. area: ['470px', '430px'],
  123. shade: 0.3,
  124. shadeClose: true,
  125. offset: 'auto',
  126. content: contentContainer
  127. })
  128. }
  129. var paramsObj = {
  130. systemId: SYSTEMID, // 系统id
  131. bussinessKey1: this.moduleName, // 当前模块名
  132. bussinessKey2: this.rowId // 当前记录的id
  133. }
  134. var clearloading = Prolog.loading2()
  135. Prolog.syncAjax({
  136. url: APIS.ServiceLog.list + '?' + $.param(paramsObj),
  137. type: 'get',
  138. before: function() {},
  139. success: function(res) {
  140. if (res.success) {
  141. var obj = res.data
  142. var contentContainer = ''
  143. if (obj.length > 0) {
  144. obj.forEach(function(val) {
  145. contentContainer += `<li class="layui-timeline-item">
  146. <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
  147. <div class="layui-timeline-content layui-text">
  148. <h4 class="layui-timeline-title" id="updateTime">时间:<span class="k-log-createTime">${val.createTime}</span>----操作人: <span class="k-log-UserName">${val.userName}</span></h4>
  149. <p class="k-log-des">
  150. ${val.description}
  151. </p>
  152. </div>
  153. </li>`
  154. })
  155. } else {
  156. contentContainer = `<li class="layui-timeline-item">
  157. <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
  158. <div class="layui-timeline-content layui-text">
  159. <h4 class="layui-timeline-title">
  160. 暂无日志
  161. </h4>
  162. </div>
  163. </li>
  164. `
  165. }
  166. popUps(_this.rowId, _this.fileText, contentContainer)
  167. } else {
  168. console.error(res)
  169. }
  170. clearloading()
  171. },
  172. error: function(res) {
  173. console.error(res)
  174. clearloading()
  175. }
  176. })
  177. }
  178. this.addBtn = function() {
  179. this.formatForm(0, 'POST', this.t('新增'), this.addBtnUrl)
  180. }
  181. this.editBtn = function(type = 'PUT') {
  182. this.formatForm(1, type, this.t('编辑'), this.addBtnUrl)
  183. }
  184. this.delBtn = function(type = 'POST', param) {
  185. this.formatForm(3, type, this.t('是否删除数据'), this.delBtnUrl, param)
  186. }
  187. this.selectAllBtn = function() {
  188. this.formatForm(4, 'GET', '', this.addBtnUrl)
  189. }
  190. this.resetBtn = function() {
  191. this.formatForm(5, 'GET', '', this.addBtnUrl)
  192. }
  193. ;(this.exportBtn = function() {
  194. Prolog.download(
  195. this.exportBtnUrl + '?' + $.param(this.PlgGridInstance.getParams()),
  196. this.fileText + new Date().format('yyyy_MM_dd') + '.xls',
  197. true
  198. )
  199. }),
  200. (this.downBtn = function() {
  201. Prolog.download(this.downBtnUrl, `${this.fileText}.xls`, true)
  202. })
  203. this.deleteFlag = function(name, vlaue) {
  204. this.selectAllBtn()
  205. }
  206. }
  207. GridPlant.prototype.init = function() {
  208. var _this = this
  209. //分页点击d
  210. _this.PlgGridInstance.PageBarJump(function(obj, first) {
  211. _this.chekIds()
  212. _this.getRowId()
  213. })
  214. //注册layuiDate日期挂件
  215. var closeLoad
  216. Prolog.upload(
  217. {
  218. elem: $('#' + _this.PlgGridInstance.getPanelId() + ' .upload'),
  219. url: _this.importBtnUrl,
  220. accept: 'file', //普通文件
  221. exts: 'xls|xlsx',
  222. multiple: true,
  223. acceptMime: '.xls,.xlsx',
  224. before: function() {
  225. closeLoad = Prolog.loading2()
  226. },
  227. done: function(res, index, upload) {
  228. if (res.success) {
  229. layer.msg(res.message)
  230. } else {
  231. layer.open({
  232. type: 1,
  233. shade: false,
  234. title: false, //不显示标题
  235. content: res.message
  236. })
  237. }
  238. _this.PlgGridInstance.reload()
  239. closeLoad()
  240. },
  241. error: function(index, upload) {
  242. closeLoad()
  243. upload()
  244. }
  245. },
  246. true
  247. )
  248. setLayuiDate && setLayuiDate(_this.PlgGridInstance.getToolBarForm(), _this.PlgGridInstance.opts.toolbar, 'time')
  249. //注册事件
  250. //头部工具条按扭事件
  251. _this.PlgGridInstance.attachToolBarEvent('onchange', function(name, value) {
  252. if (name && _this.hasOwnProperty(name)) {
  253. _this[name](name, value)
  254. }
  255. return _this
  256. })
  257. //如果有右边栏
  258. if (_this.PlgGridInstance.opts.enableSideBar) {
  259. _this.PlgGridInstance.attachSideBarEvent('onButtonClick', function(name) {
  260. if (name && _this.hasOwnProperty(name)) {
  261. _this[name]()
  262. }
  263. })
  264. }
  265. _this.PlgGridInstance.attachToolBarEvent('onButtonClick', function(name) {
  266. if (name && _this.hasOwnProperty(name)) {
  267. _this[name]()
  268. } else if (name == 'plg-more-001') {
  269. _this.PlgGridInstance.resetSize()
  270. }
  271. return _this
  272. })
  273. _this.PlgGridInstance.attachEvent('onRowSelect', function(id, ind) {
  274. _this.getRowId()
  275. })
  276. _this.PlgGridInstance.attachEvent('onCheck', function(rId, cInd) {
  277. _this.chekIds()
  278. })
  279. _this.PlgGridInstance.attachEvent('onRowDblClicked', function(rId) {
  280. if (_this.PlgGridInstance.getSelectedRowData().deleteFlag === 1) {
  281. _this.logBtn()
  282. } else {
  283. _this.editBtn()
  284. }
  285. })
  286. _this.PlgGridInstance.attachEvent('onHeaderClick', function(ind, obj) {
  287. if (ind === 1) {
  288. _this.chekIds()
  289. }
  290. return _this
  291. })
  292. return _this
  293. }
  294. GridPlant.prototype.beforeRender = function(callback) {
  295. if (typeof callback == 'function') {
  296. this.beforeRender = callback
  297. this.beforeRender()
  298. return this
  299. }
  300. }
  301. //使用layui的data
  302. function setLayuiDate(GridForm, arr, portName, typeValue) {
  303. if (!typeValue) typeValue = 'input'
  304. arr.forEach(function(item, index) {
  305. if (item.type == typeValue && item.name == portName) {
  306. var f = item.dateFormat || 'yyyy/MM/dd',
  307. t = item.dateType || 'date'
  308. GridForm.getInput(portName).setAttribute('readonly', true)
  309. layui.laydate.render({
  310. elem: GridForm.getInput(portName),
  311. type: t,
  312. lang: i18next.language,
  313. format: f,
  314. value: item.value,
  315. // theme: '#0959a7',
  316. //showBottom: false,
  317. change: function(value, date, endDate) {
  318. $('.layui-laydate-content')
  319. .off()
  320. .on('click', 'li', function() {
  321. value.substring(0, 19)
  322. value.replace(/-/g, '/')
  323. GridForm.setItemValue(portName, value ? value : '')
  324. $('.layui-laydate').remove() //删除
  325. })
  326. },
  327. done: function(value, date, endDate) {
  328. value.substring(0, 19)
  329. value.replace(/-/g, '/')
  330. GridForm.setItemValue(portName, value ? value : '')
  331. }
  332. })
  333. return false
  334. } else {
  335. if (item.list && item.list.length > 0) {
  336. setLayuiDate(GridForm, item.list, portName)
  337. }
  338. return false
  339. }
  340. })
  341. }
  342. GridPlant.prototype.formatForm = function(
  343. num,
  344. type,
  345. title,
  346. protUrl,
  347. param = {
  348. id: this.idS
  349. }
  350. ) {
  351. var _this = this
  352. //num=0 add num=1 edit num=3 del num=4 搜索 reset=5重制
  353. if (num === 3) {
  354. //del
  355. layer.confirm(
  356. title,
  357. {
  358. title: _this.t('提示'),
  359. btn: [_this.t('确定'), _this.t('取消')] //按钮
  360. },
  361. function(index) {
  362. var close = PlgDialog.loading2()
  363. Prolog.ajax({
  364. url: protUrl,
  365. type: type,
  366. data: param,
  367. dataType: 'json',
  368. success: function(data) {
  369. if (data.success) {
  370. _this.PlgGridInstance.reload()
  371. _this.chekIds()
  372. }
  373. layer.msg(_this.t(data.message))
  374. close()
  375. layer.close(index)
  376. _this.delBtnAfter()
  377. },
  378. error: function() {
  379. close()
  380. }
  381. })
  382. },
  383. function() {
  384. close()
  385. }
  386. )
  387. return
  388. } else if (num === 4) {
  389. //搜索
  390. // var WarehouseIds=getLocalStrongSelectedWarehouseIds();
  391. // getLocalStrongSelectedWarehouseIds()&& this.PlgGridInstance.getToolBarForm().setItemValue("warehouseId", WarehouseIds.toString())
  392. var fdata = this.PlgGridInstance.getToolBarForm().getFormData()
  393. if (fdata.startTime && fdata.endTime) {
  394. if (fdata.endTime.valueOf() - fdata.startTime.valueOf() < 0) {
  395. PlgDialog.msg('结束时间不得早于开始时间,请重新选择')
  396. this.PlgGridInstance.getToolBarForm()
  397. .getInput('startTime')
  398. .select()
  399. return false
  400. }
  401. }
  402. if (fdata['time']) {
  403. fdata['time'] = new Date(fdata['time'])
  404. }
  405. var obj = {}
  406. for (key in fdata) {
  407. if (fdata[key]) {
  408. obj[key] = fdata[key]
  409. }
  410. }
  411. this.selectAllBtnAfter(obj)
  412. var getToolBarForm = this.PlgGridInstance.getToolBarForm().getDForm()
  413. // //如果是无效数据就把chark隐藏
  414. // if (obj.deleteFlag && obj.deleteFlag === 1) {
  415. // this.PlgGridInstance.setColumnHidden(1, true);
  416. // getToolBarForm.hideItem("downBtn")
  417. // getToolBarForm.hideItem("exportBtn")
  418. // getToolBarForm.hideItem("exportBtn")
  419. // getToolBarForm.hideItem("addBtn")
  420. // getToolBarForm.hideItem("importBtn");
  421. // getToolBarForm.hideItem("editBtn");
  422. // getToolBarForm.hideItem("delBtn");
  423. // } else {
  424. // obj.deleteFlag = 0;
  425. // this.PlgGridInstance.setColumnHidden(1, false);
  426. // getToolBarForm.showItem("downBtn")
  427. // getToolBarForm.showItem("exportBtn")
  428. // getToolBarForm.showItem("exportBtn")
  429. // getToolBarForm.showItem("addBtn")
  430. // getToolBarForm.showItem("importBtn");
  431. // getToolBarForm.showItem("editBtn");
  432. // getToolBarForm.showItem("delBtn");
  433. // }
  434. this.PlgGridInstance.setParams(obj)
  435. this.PlgGridInstance.reload()
  436. this.getRowId()
  437. this.chekIds()
  438. return
  439. } else if (num === 5) {
  440. var dform = this.PlgGridInstance.getToolBarForm()
  441. if (_this.PlgGridInstance.opts.enableSideBar) dform = this.PlgGridInstance.getSideBarForm()
  442. dform.clear()
  443. dform.getDForm().checkItem('deleteFlag', 0)
  444. dform.setItemValue('warehouseId', getLocalStrongSelectedWarehouseIds())
  445. return
  446. }
  447. _this.PlgGridInstance.showDialog(num, title, _this.formDataArea[0], _this.formDataArea[1], {
  448. url: protUrl,
  449. type: type,
  450. saveAfter: function(gridForm, data) {
  451. if (data.time && typeof data.time === 'string') {
  452. data.time = new Date(data.time)
  453. }
  454. if (data.id == '') {
  455. data.id = 0
  456. }
  457. if (data.warehouseName == '') {
  458. data.warehouseName = WAREHOUSE_CATEGORY.length > 0 && WAREHOUSE_CATEGORY[0].text
  459. }
  460. if(num==0){
  461. if(data.authorizedGrantTypes && data.authorizedGrantTypes.length>0){
  462. data.authorizedGrantTypes = data.authorizedGrantTypes.join(",");
  463. }else{
  464. data.authorizedGrantTypes = 'client_credentials';
  465. }
  466. }
  467. _this.showDialogSaveBtn(gridForm, data)
  468. return data
  469. },
  470. resetAfter: _this.showDialogResetBtn
  471. })
  472. //新增或修改弹出时的From表单
  473. var GridForm = _this.PlgGridInstance.getGridForm()
  474. setLayuiDate && setLayuiDate(GridForm, _this.PlgGridInstance.opts.formData, 'time')
  475. _this.showDialogAfter && _this.showDialogAfter(GridForm)
  476. if (num === 1 && type == 'PUT') {
  477. _this.editBtnAfter && _this.editBtnAfter(GridForm)
  478. }
  479. GridForm.attachEvent('onchange', function(name, value, state) {
  480. if (name == 'warehouseId') {
  481. var opt = Array.prototype.slice.call(GridForm.getSelect('warehouseId').children).filter(function(item) {
  482. return value == item.value
  483. })
  484. GridForm.setItemValue('warehouseName', opt[0].text)
  485. } else if (name == 'typeId') {
  486. var opt = Array.prototype.slice.call(GridForm.getSelect('typeId').children).filter(function(item) {
  487. return value == item.value
  488. })
  489. GridForm.setItemValue('type', opt[0].text)
  490. }
  491. _this.formOnChange && _this.formOnChange(name, value, GridForm)
  492. return
  493. })
  494. return
  495. }
  496. GridPlant.prototype.showDialogAfter = function(callback) {
  497. if (typeof callback === 'function') {
  498. return (this.showDialogAfter = callback)
  499. }
  500. }
  501. ;(GridPlant.prototype.showDialogSaveBtn = function(callback) {
  502. if (typeof callback === 'function') {
  503. return (this.showDialogSaveBtn = callback)
  504. } else {
  505. return null
  506. }
  507. }),
  508. (GridPlant.prototype.selectAllBtnAfter = function(callback) {
  509. if (typeof callback === 'function') {
  510. return (this.selectAllBtnAfter = callback)
  511. } else {
  512. return null
  513. }
  514. }),
  515. (GridPlant.prototype.editBtnAfter = function(callback) {
  516. if (typeof callback === 'function') {
  517. return (this.editBtnAfter = callback)
  518. }
  519. })
  520. GridPlant.prototype.delBtnAfter = function(callback) {
  521. if (typeof callback === 'function') {
  522. return (this.delBtnAfter = callback)
  523. } else {
  524. return null
  525. }
  526. }
  527. GridPlant.prototype.showDialogResetBtn = function(callback) {
  528. if (typeof callback === 'function') {
  529. this.showDialogResetBtn = callback
  530. return this
  531. }
  532. }
  533. GridPlant.prototype.formOnChange = function(callback) {
  534. if (typeof callback === 'function') {
  535. return (this.formOnChange = callback)
  536. }
  537. }
  538. GridPlant.prototype.getRowId = function() {
  539. this.rowId = this.PlgGridInstance.getSelectedRowId()
  540. if (this.rowId && this.rowId.indexOf(',') == -1) {
  541. this.PlgGridInstance.getToolBarForm().enableItem('logBtn')
  542. //如果是无效数据就禁用编辑按钮
  543. if (this.PlgGridInstance.getSelectedRowData().deleteFlag !== 1) {
  544. this.PlgGridInstance.getToolBarForm().enableItem('editBtn')
  545. }
  546. } else {
  547. this.PlgGridInstance.getToolBarForm().disableItem('logBtn')
  548. this.PlgGridInstance.getToolBarForm().disableItem('editBtn')
  549. }
  550. return this
  551. }
  552. GridPlant.prototype.chekIds = function() {
  553. this.idS = this.PlgGridInstance.getCheckedIds()
  554. if (this.idS) {
  555. this.PlgGridInstance.getToolBarForm().enableItem('delBtn')
  556. } else {
  557. this.PlgGridInstance.getToolBarForm().disableItem('delBtn')
  558. }
  559. return this
  560. }
  561. // 获取版本号
  562. function getVersion() {
  563. var version
  564. if (!version) {
  565. $.ajaxSettings.async = false
  566. $.get('/ops/getVersion', function(res) {
  567. version = res.version
  568. })
  569. $.ajaxSettings.async = true
  570. }
  571. return version
  572. }
  573. //表格圖片配置
  574. ;(Prolog.GridImageBasePath = './prologui/dist/images/PlgGrid/'),
  575. (Prolog.reloadToken = function() {
  576. Prolog.token = 'Bearer ' + localStorage.getItem('authorization')
  577. }),
  578. /**
  579. * 判断是否已登录(支持携带access_token和expir登录)
  580. */
  581. (Prolog.isLogined = function() {
  582. var tk = null
  583. var exp = null
  584. var P_GET = Prolog.getRequestParams()
  585. if (P_GET['access_token'] && P_GET['expir']) {
  586. tk = P_GET['access_token']
  587. exp = P_GET['expir']
  588. localStorage.setItem('authorization', tk)
  589. localStorage.setItem('token_expir', exp)
  590. } else {
  591. tk = 'Bearer ' + localStorage.getItem('authorization')
  592. exp = localStorage.getItem('token_expir')
  593. }
  594. if (tk != null && tk != '' && exp != null && exp != '') {
  595. var expir = parseInt(exp)
  596. var b = new Date().getTime() > expir ? false : true
  597. return b
  598. } else {
  599. return false
  600. }
  601. })