QRcode.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. sessionStorage.setItem("ztreeDepid",'root');
  18. delpFun();
  19. function delpFun(){
  20. sessionStorage.setItem("depID",'root');
  21. $.ajax({
  22. url:'http://apptest.jieweizhineng.com/api/section/getlist',
  23. method:'get',
  24. dataType: 'json',
  25. data: {
  26. },
  27. success:function (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. sessionStorage.setItem("ztreeDepid",d.data.currentData.id);
  40. $('.stetaName').val("");
  41. var info={
  42. statusContent: '',
  43. departmentId: d.data.currentData.id,
  44. deleteStatus: 'false',
  45. pageNumber: '1',
  46. pageSize: '1',
  47. };
  48. getStateList(info);
  49. })
  50. }else{
  51. layer.msg('请检查网路', {icon: 2});
  52. }
  53. },
  54. error:function (err) {
  55. layer.msg('请检查网路', {icon: 2});
  56. }
  57. })
  58. }
  59. var info={
  60. title: $('.stetaName').val(),
  61. departmentId: belpID,
  62. deleteStatus: 'false',
  63. pageNumber: '1',
  64. pageSize: '1',
  65. };
  66. getStateList(info);
  67. function getStateList(res) {
  68. $.ajax({
  69. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageList',
  70. method: 'get',
  71. dataType: 'json',
  72. data: res,
  73. success: function (data) {
  74. laypage.render({
  75. elem: 'pageItem',
  76. count: data.count,
  77. limit: 10,
  78. layout: ['count', 'prev', 'page', 'next', 'skip'],
  79. jump: function(obj, first) {
  80. var index = layer.load(2);
  81. table.render({
  82. elem: '#stateRemind',
  83. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageList',
  84. id: 'idQRcode',
  85. method: 'get',
  86. loading: true,
  87. cols: [[
  88. {field: 'title', title: '二维码名称', align: 'center'}
  89. , {field: 'createDate', title: '创建日期', align: 'center'}
  90. , {title: ' 操作', align: 'center', toolbar: '#barDemo'}
  91. ]],
  92. where: {
  93. title: res.title,
  94. departmentId: res.departmentId,
  95. deleteStatus: res.deleteStatus,
  96. pageNumber: obj.curr,
  97. pageSize: obj.limit,
  98. },
  99. response: {
  100. statusName: 'code'
  101. , statusCode: 200,
  102. countName: 'count',
  103. dataName: 'data'
  104. },
  105. done: function (res, curr, count) {
  106. layer.close(index);
  107. if (res.code === '200') {
  108. $('.fr').html('共有数据:'+res.count+' 条')
  109. }
  110. }
  111. });
  112. }
  113. })
  114. }
  115. });
  116. }
  117. // 查询
  118. $(".seachSteta").click(function () {
  119. var checkbox = $("#checkboxT").prop('checked'),
  120. root='',
  121. info;
  122. if(checkbox == true){
  123. root = '';
  124. info={
  125. statusContent: $('.stetaName').val(),
  126. departmentId: root,
  127. deleteStatus: 'false',
  128. pageNumber: '1',
  129. pageSize: '1',
  130. };
  131. }else {
  132. info={
  133. statusContent: $('.stetaName').val(),
  134. departmentId: belpID,
  135. deleteStatus: 'false',
  136. pageNumber: '1',
  137. pageSize: '1',
  138. };
  139. }
  140. getStateList(info)
  141. });
  142. // 生成uid
  143. function creatuuid(len, radix) { // len位数,radix基数
  144. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
  145. var uuid = [], i;
  146. radix = radix || chars.length;
  147. if (len) {
  148. for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
  149. } else {
  150. var r;
  151. uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
  152. uuid[14] = '4';
  153. for (i = 0; i < 36; i++) {
  154. if (!uuid[i]) {
  155. r = 0 | Math.random()*16;
  156. uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
  157. }
  158. }
  159. }
  160. return uuid.join('');
  161. }
  162. // 监听状态table
  163. table.on('tool(stateItme)', function(obj) {
  164. if( obj.event === "move"){
  165. sessionStorage.setItem("statusId",obj.data.id);
  166. moveDep('选择部门信息','http://apptest.jieweizhineng.com/api/swagger/api/page/v1/movePage/','400','500',table,'idQRcode');
  167. } else if (obj.event === "copy"){
  168. var content ={
  169. _method:'put'
  170. };
  171. layer.alert('确认要复制记录模板吗?',{icon: 8}, function(index){
  172. $.ajax({
  173. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/copyPage/'+obj.data.id,
  174. method: 'post',
  175. dataType: 'json',
  176. data: content,
  177. success: function (res) {
  178. if (res.code === '200'){
  179. layer.msg('复制成功', {icon: 1});
  180. table.reload('idQRcode');
  181. } else{
  182. layer.msg('复制失败', {icon: 2});
  183. table.reload('idQRcode');
  184. }
  185. layer.close(index);
  186. },
  187. error:function () {
  188. layer.msg('请检查网络', {icon: 2});
  189. layer.close(index);
  190. }
  191. });
  192. });
  193. } else if (obj.event === "edit"){
  194. var objID =obj.data;
  195. var delobj=[];
  196. sessionStorage.setItem("QRcodeDetaileID",obj.data.id);
  197. layer.open({
  198. type: 2,
  199. id: 'updateQRcode',
  200. title:'修改二维码',
  201. shadeClose: true,
  202. scrollbar:true,
  203. shade: 0.3,
  204. maxmin: true,
  205. skin: 'oaBtn',
  206. area: ['100%', '100%'],
  207. content: updateHtml,
  208. success: function (layero, index) {
  209. var indexk = layer.load(2);
  210. var body = layer.getChildFrame('body', index);
  211. body.find('#pageFlag').val('true');
  212. var iframeWindow = window['layui-layer-iframe'+ index];
  213. $.ajax({
  214. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageEdit/'+obj.data.id,
  215. type: 'get',
  216. dataType: 'json',
  217. success: function (res) {
  218. var indexk = layer.load(2);
  219. var b = new Base64();
  220. body.find('.edit_head_title').html(res.data.page.title);
  221. var newArray =[];
  222. for (var j = 0; j < res.data.pageItemList.length; j++) {
  223. if (res.data.pageItemList[j].pageRelation.zIndex == j+1){
  224. newArray.push(res.data.pageItemList[j])
  225. }
  226. }
  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. });