QRcode.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. layui.config({
  2. base: '../../lib/layui/lay/mymodules/'
  3. ,version: '101100'
  4. }).use('eleTree');
  5. layui.extend({
  6. admin: '{/}../../static/js/admin'
  7. });
  8. layui.use(['jquery','eleTree','table','laypage','admin'], function(){
  9. var $= layui.jquery,
  10. eleTree = layui.eleTree,
  11. laypage = layui.laypage,
  12. table = layui.table;
  13. var addQRcode = '../../pages/QRcode/addQRcode.html';
  14. var updateHtml = '../../pages/editQRcode/editQRcode.html';
  15. // 部门
  16. var belpID = 'root';
  17. delpFun();
  18. function delpFun(){
  19. sessionStorage.setItem("depID",'root');
  20. $.ajax({
  21. url:'http://apptest.jieweizhineng.com/api/section/getlist',
  22. method:'get',
  23. dataType: 'json',
  24. data: {
  25. },
  26. success:function (res) {
  27. if(res.code === 0){
  28. var data = [res.data];
  29. eleTree.render({
  30. elem: '.ele1',
  31. data:data ,
  32. defaultExpandAll:true,
  33. // showCheckbox: true,
  34. });
  35. eleTree.on("nodeClick(data)",function(d) {
  36. belpID = d.data.currentData.id;
  37. sessionStorage.setItem("depID",belpID);
  38. $('.stetaName').val("");
  39. var info={
  40. statusContent: '',
  41. departmentId: d.data.currentData.id,
  42. deleteStatus: 'false',
  43. pageNumber: '1',
  44. pageSize: '1',
  45. };
  46. getStateList(info);
  47. })
  48. }else{
  49. layer.msg('请检查网路', {icon: 2});
  50. }
  51. },
  52. error:function (err) {
  53. layer.msg('请检查网路', {icon: 2});
  54. }
  55. })
  56. }
  57. var info={
  58. title: $('.stetaName').val(),
  59. departmentId: belpID,
  60. deleteStatus: 'false',
  61. pageNumber: '1',
  62. pageSize: '1',
  63. };
  64. getStateList(info);
  65. function getStateList(res) {
  66. $.ajax({
  67. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageList',
  68. method: 'get',
  69. dataType: 'json',
  70. data: res,
  71. success: function (data) {
  72. laypage.render({
  73. elem: 'pageItem',
  74. count: data.count,
  75. limit: 10,
  76. layout: ['count', 'prev', 'page', 'next', 'skip'],
  77. jump: function(obj, first) {
  78. var index = layer.load(2);
  79. table.render({
  80. elem: '#stateRemind',
  81. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageList',
  82. id: 'idQRcode',
  83. method: 'get',
  84. loading: true,
  85. cols: [[
  86. {field: 'title', title: '二维码名称', align: 'center'}
  87. , {field: 'createDate', title: '创建日期', align: 'center'}
  88. , {title: ' 操作', align: 'center', toolbar: '#barDemo'}
  89. ]],
  90. where: {
  91. title: res.title,
  92. departmentId: res.departmentId,
  93. deleteStatus: res.deleteStatus,
  94. pageNumber: obj.curr,
  95. pageSize: obj.limit,
  96. },
  97. response: {
  98. statusName: 'code'
  99. , statusCode: 200,
  100. countName: 'count',
  101. dataName: 'data'
  102. },
  103. done: function (res, curr, count) {
  104. layer.close(index);
  105. if (res.code === '200') {
  106. $('.fr').html('共有数据:'+res.count+' 条')
  107. }
  108. }
  109. });
  110. }
  111. })
  112. }
  113. });
  114. }
  115. // 查询
  116. $(".seachSteta").click(function () {
  117. var checkbox = $("#checkboxT").prop('checked'),
  118. root='',
  119. info;
  120. if(checkbox == true){
  121. root = '';
  122. info={
  123. statusContent: $('.stetaName').val(),
  124. departmentId: root,
  125. deleteStatus: 'false',
  126. pageNumber: '1',
  127. pageSize: '1',
  128. };
  129. }else {
  130. info={
  131. statusContent: $('.stetaName').val(),
  132. departmentId: belpID,
  133. deleteStatus: 'false',
  134. pageNumber: '1',
  135. pageSize: '1',
  136. };
  137. }
  138. getStateList(info)
  139. });
  140. // 生成uid
  141. function creatuuid(len, radix) { // len位数,radix基数
  142. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
  143. var uuid = [], i;
  144. radix = radix || chars.length;
  145. if (len) {
  146. for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
  147. } else {
  148. var r;
  149. uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
  150. uuid[14] = '4';
  151. for (i = 0; i < 36; i++) {
  152. if (!uuid[i]) {
  153. r = 0 | Math.random()*16;
  154. uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
  155. }
  156. }
  157. }
  158. return uuid.join('');
  159. }
  160. // 监听状态table
  161. table.on('tool(stateItme)', function(obj) {
  162. if( obj.event === "move"){
  163. } else if (obj.event === "copy"){
  164. var content ={
  165. _method:'put'
  166. };
  167. layer.alert('确认要复制记录模板吗?',{icon: 8}, function(index){
  168. $.ajax({
  169. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/copyPage/'+obj.data.id,
  170. method: 'post',
  171. dataType: 'json',
  172. data: content,
  173. success: function (res) {
  174. if (res.code === '200'){
  175. layer.msg('复制成功', {icon: 1});
  176. table.reload('idQRcode');
  177. } else{
  178. layer.msg('复制失败', {icon: 2});
  179. table.reload('idQRcode');
  180. }
  181. layer.close(index);
  182. },
  183. error:function () {
  184. layer.msg('请检查网络', {icon: 2});
  185. layer.close(index);
  186. }
  187. });
  188. });
  189. } else if (obj.event === "edit"){
  190. var objID =obj.data;
  191. var delobj=[];
  192. sessionStorage.setItem("QRcodeDetaileID",obj.data.id);
  193. layer.open({
  194. type: 2,
  195. id: 'updateQRcode',
  196. title:'修改二维码',
  197. shadeClose: true,
  198. scrollbar:true,
  199. shade: 0.3,
  200. maxmin: true,
  201. skin: 'oaBtn',
  202. area: ['100%', '100%'],
  203. content: updateHtml,
  204. success: function (layero, index) {
  205. var indexk = layer.load(2);
  206. var body = layer.getChildFrame('body', index);
  207. body.find('#pageFlag').val('true');
  208. var iframeWindow = window['layui-layer-iframe'+ index];
  209. $.ajax({
  210. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageEdit/'+obj.data.id,
  211. type: 'get',
  212. dataType: 'json',
  213. success: function (res) {
  214. var indexk = layer.load(2);
  215. var b = new Base64();
  216. body.find('.edit_head_title').html(res.data.page.title);
  217. var newArray =[];
  218. for (var j = 0; j < res.data.pageItemList.length; j++) {
  219. if (res.data.pageItemList[j].pageRelation.zIndex == j+1){
  220. newArray.push(res.data.pageItemList[j])
  221. }
  222. }
  223. for (var i = 0; i < newArray.length; i++) {
  224. // 文本
  225. if (newArray[i].textVo != null) {
  226. var str = b.decode(newArray[i].textVo.dataContent);
  227. var _modeltemp = '';
  228. var data_id =creatuuid(12,36);
  229. _modeltemp = body.find('#temp-1').html();
  230. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  231. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  232. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  233. body.find("#module_box .sortable-dragging").each(function(i,p){
  234. $(this).attr("sort",i+1);
  235. $(this).attr("module",i+1);
  236. });
  237. iframeWindow.editPureTextTitleName(data_id,newArray[i].textVo.title,newArray[i].textVo.id,newArray[i].pageRelation.id,str);
  238. }
  239. // 图文
  240. if (newArray[i].imageText != null) {
  241. var str = b.decode(newArray[i].imageText.dataContent);
  242. var _modeltemp = '';
  243. var data_id =creatuuid(12,36);
  244. _modeltemp = body.find('#temp-2').html();
  245. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  246. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  247. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  248. body.find("#module_box .sortable-dragging").each(function(i,p){
  249. $(this).attr("sort",i+1);
  250. $(this).attr("module",i+1)
  251. });
  252. iframeWindow.edituploadImage(data_id,newArray[i].imageText.title,newArray[i].imageText.imageUrl,newArray[i].imageText.id,newArray[i].pageRelation.id,str);
  253. }
  254. // 图集
  255. if (newArray[i].pictureList != null) {
  256. var _modeltemp = '';
  257. var data_id =creatuuid(12,36);
  258. _modeltemp = body.find('#temp-3').html();
  259. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  260. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  261. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  262. body.find("#module_box .sortable-dragging").each(function(i,p){
  263. $(this).attr("sort",i+1);
  264. $(this).attr("module",i+1)
  265. });
  266. iframeWindow.edituploadImageAtlas(data_id,newArray[i].pictureList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id);
  267. }
  268. // 文件
  269. if (newArray[i].fileList != null) {
  270. var _modeltemp = '';
  271. var data_id =creatuuid(12,36);
  272. _modeltemp = body.find('#temp-4').html();
  273. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  274. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  275. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  276. body.find("#module_box .sortable-dragging").each(function(i,p){
  277. $(this).attr("sort",i+1);
  278. $(this).attr("module",i+1)
  279. });
  280. iframeWindow.edituploadFile(data_id,newArray[i].fileList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  281. }
  282. // 链接
  283. if (newArray[i].linksList !=null) {
  284. var _modeltemp = '';
  285. var data_id =creatuuid(12,36);
  286. _modeltemp = body.find('#temp-5').html();
  287. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  288. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  289. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  290. body.find("#module_box .sortable-dragging").each(function(i,p){
  291. $(this).attr("sort",i+1);
  292. $(this).attr("module",i+1)
  293. });
  294. iframeWindow.editlinkFun(data_id,newArray[i].linksList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  295. }
  296. // 视频
  297. if (newArray[i].videoList !=null) {
  298. var _modeltemp = '';
  299. var data_id =creatuuid(12,36);
  300. _modeltemp = body.find('#temp-6').html();
  301. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  302. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  303. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  304. body.find("#module_box .sortable-dragging").each(function(i,p){
  305. $(this).attr("sort",i+1);
  306. $(this).attr("module",i+1)
  307. });
  308. iframeWindow.editaddVideo(data_id,newArray[i].videoList[0].videoUrl,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  309. }
  310. // 设备铭牌editDevice
  311. if (newArray[i].equipmentList !=null) {
  312. var _modeltemp = '';
  313. var data_id =creatuuid(12,36);
  314. _modeltemp = body.find('#temp-7').html();
  315. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  316. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  317. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  318. body.find("#module_box .sortable-dragging").each(function(i,p){
  319. $(this).attr("sort",i+1);
  320. $(this).attr("module",i+1)
  321. });
  322. iframeWindow.editDevice(data_id,newArray[i].equipmentList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  323. }
  324. // 记录模版
  325. if (newArray[i].pageRecordList !=null) {
  326. var _modeltemp = '';
  327. var data_id =creatuuid(12,36);
  328. _modeltemp = body.find('#temp-8').html();
  329. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  330. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  331. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  332. body.find("#module_box .sortable-dragging").each(function(i,p){
  333. $(this).attr("sort",i+1);
  334. $(this).attr("module",i+1)
  335. });
  336. iframeWindow.editRecord(data_id,newArray[i].pageRecordList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  337. }
  338. }
  339. layer.close(indexk);
  340. },
  341. error:function () {
  342. layer.msg('请检查网络', {icon: 2});
  343. }
  344. });
  345. },
  346. cancel: function(index, layero){
  347. table.reload('idQRcode');
  348. }
  349. })
  350. } else if (obj.event === "delete"){
  351. var content ={
  352. _method:'DELETE'
  353. };
  354. layer.alert('确认要删除吗?',{icon: 8}, function(index){
  355. $.ajax({
  356. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/removePage/'+obj.data.id,
  357. method: 'post',
  358. dataType: 'json',
  359. data: content,
  360. success: function (res) {
  361. if (res.code === '200'){
  362. layer.msg('删除成功', {icon: 1});
  363. table.reload('idQRcode');
  364. } else{
  365. layer.msg('删除失败', {icon: 2});
  366. table.reload('idQRcode');
  367. }
  368. layer.close(index);
  369. },
  370. error:function () {
  371. layer.msg('请检查网络', {icon: 2});
  372. layer.close(index);
  373. }
  374. });
  375. });
  376. }
  377. });
  378. // 添加状态
  379. // 打开添加弹窗
  380. $(".addState").click(function () {
  381. layer.open({
  382. type: 2,
  383. id: 'addQRcodeID',
  384. title:'添加二维码',
  385. shadeClose: true,
  386. scrollbar:true,
  387. shade: 0.3,
  388. maxmin: true,
  389. skin: 'oaBtn',
  390. area: ['100%', '100%'],
  391. content: addQRcode,
  392. success: function (layero, index) {
  393. var body = layer.getChildFrame('body', index);
  394. },
  395. cancel: function(index, layero){
  396. table.reload('idQRcode');
  397. }
  398. })
  399. })
  400. });