0
0

QRcode.js 20 KB

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