0
0

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. 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. sessionStorage.setItem("QRcodeDetaileID",obj.data.id);
  194. layer.open({
  195. type: 2,
  196. id: 'updateQRcode',
  197. title:'修改二维码',
  198. shadeClose: true,
  199. scrollbar:true,
  200. shade: 0.3,
  201. maxmin: true,
  202. skin: 'oaBtn',
  203. area: ['100%', '100%'],
  204. content: updateHtml,
  205. success: function (layero, index) {
  206. var indexk = layer.load(2);
  207. var body = layer.getChildFrame('body', index);
  208. body.find('#pageFlag').val('true');
  209. var iframeWindow = window['layui-layer-iframe'+ index];
  210. $.ajax({
  211. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/getPageEdit/'+obj.data.id,
  212. type: 'get',
  213. dataType: 'json',
  214. success: function (res) {
  215. var indexk = layer.load(2);
  216. var b = new Base64();
  217. body.find('.edit_head_title').html(res.data.page.title);
  218. var newArray =[];
  219. console.log(res.data,'res.data')
  220. for (var j = 0; j < res.data.pageItemList.length; j++) {
  221. if (res.data.pageItemList[j].pageRelation.zIndex == j+1){
  222. newArray.push(res.data.pageItemList[j])
  223. }
  224. }
  225. console.log(newArray,'newArray')
  226. for (var i = 0; i < newArray.length; i++) {
  227. // 文本
  228. if (newArray[i].textVo != null) {
  229. var str = b.decode(newArray[i].textVo.dataContent);
  230. var _modeltemp = '';
  231. var data_id =creatuuid(12,36);
  232. _modeltemp = body.find('#temp-1').html();
  233. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  234. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  235. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  236. body.find("#module_box .sortable-dragging").each(function(i,p){
  237. $(this).attr("sort",i+1);
  238. $(this).attr("module",i+1);
  239. });
  240. iframeWindow.editPureTextTitleName(data_id,newArray[i].textVo.title,newArray[i].textVo.id,newArray[i].pageRelation.id,str);
  241. }
  242. // 图文
  243. if (newArray[i].imageText != null) {
  244. var str = b.decode(newArray[i].imageText.dataContent);
  245. var _modeltemp = '';
  246. var data_id =creatuuid(12,36);
  247. _modeltemp = body.find('#temp-2').html();
  248. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  249. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  250. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  251. body.find("#module_box .sortable-dragging").each(function(i,p){
  252. $(this).attr("sort",i+1);
  253. $(this).attr("module",i+1)
  254. });
  255. iframeWindow.edituploadImage(data_id,newArray[i].imageText.title,newArray[i].imageText.imageUrl,newArray[i].imageText.id,newArray[i].pageRelation.id,str);
  256. }
  257. // 图集
  258. if (newArray[i].pictureList != null) {
  259. var _modeltemp = '';
  260. var data_id =creatuuid(12,36);
  261. _modeltemp = body.find('#temp-3').html();
  262. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  263. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  264. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  265. body.find("#module_box .sortable-dragging").each(function(i,p){
  266. $(this).attr("sort",i+1);
  267. $(this).attr("module",i+1)
  268. });
  269. iframeWindow.edituploadImageAtlas(data_id,newArray[i].pictureList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id);
  270. }
  271. // 文件
  272. if (newArray[i].fileList != null) {
  273. var _modeltemp = '';
  274. var data_id =creatuuid(12,36);
  275. _modeltemp = body.find('#temp-4').html();
  276. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  277. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  278. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  279. body.find("#module_box .sortable-dragging").each(function(i,p){
  280. $(this).attr("sort",i+1);
  281. $(this).attr("module",i+1)
  282. });
  283. iframeWindow.edituploadFile(data_id,newArray[i].fileList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  284. }
  285. // 链接
  286. if (newArray[i].linksList !=null) {
  287. var _modeltemp = '';
  288. var data_id =creatuuid(12,36);
  289. _modeltemp = body.find('#temp-5').html();
  290. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  291. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  292. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  293. body.find("#module_box .sortable-dragging").each(function(i,p){
  294. $(this).attr("sort",i+1);
  295. $(this).attr("module",i+1)
  296. });
  297. iframeWindow.editlinkFun(data_id,newArray[i].linksList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  298. }
  299. // 视频
  300. if (newArray[i].videoList !=null) {
  301. var _modeltemp = '';
  302. var data_id =creatuuid(12,36);
  303. _modeltemp = body.find('#temp-6').html();
  304. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  305. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  306. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  307. body.find("#module_box .sortable-dragging").each(function(i,p){
  308. $(this).attr("sort",i+1);
  309. $(this).attr("module",i+1)
  310. });
  311. iframeWindow.editaddVideo(data_id,newArray[i].videoList[0].videoUrl,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  312. }
  313. // 设备铭牌editDevice
  314. if (newArray[i].equipmentList !=null) {
  315. var _modeltemp = '';
  316. var data_id =creatuuid(12,36);
  317. _modeltemp = body.find('#temp-7').html();
  318. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  319. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  320. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  321. body.find("#module_box .sortable-dragging").each(function(i,p){
  322. $(this).attr("sort",i+1);
  323. $(this).attr("module",i+1)
  324. });
  325. iframeWindow.editDevice(data_id,newArray[i].equipmentList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  326. }
  327. // 记录模版
  328. if (newArray[i].pageRecordList !=null) {
  329. var _modeltemp = '';
  330. var data_id =creatuuid(12,36);
  331. _modeltemp = body.find('#temp-8').html();
  332. body.find('.module_box').children('div.b-g').last().before(_modeltemp);
  333. body.find(".reisze-now").css("height",$(".reisze-now").height()+250+'px');
  334. body.find('.module_box').children('.sortable-dragging').last().attr("dataid",data_id);
  335. body.find("#module_box .sortable-dragging").each(function(i,p){
  336. $(this).attr("sort",i+1);
  337. $(this).attr("module",i+1)
  338. });
  339. iframeWindow.editRecord(data_id,newArray[i].pageRecordList,newArray[i].pageRelation.businessId,newArray[i].pageRelation.id)
  340. }
  341. }
  342. layer.close(indexk);
  343. },
  344. error:function () {
  345. layer.msg('请检查网络', {icon: 2});
  346. }
  347. });
  348. },
  349. cancel: function(index, layero){
  350. table.reload('idQRcode');
  351. }
  352. })
  353. } else if (obj.event === "delete"){
  354. var content ={
  355. _method:'DELETE'
  356. };
  357. layer.alert('确认要删除吗?',{icon: 8}, function(index){
  358. $.ajax({
  359. url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/removePage/'+obj.data.id,
  360. method: 'post',
  361. dataType: 'json',
  362. data: content,
  363. success: function (res) {
  364. if (res.code === '200'){
  365. layer.msg('删除成功', {icon: 1});
  366. table.reload('idQRcode');
  367. } else{
  368. layer.msg('删除失败', {icon: 2});
  369. table.reload('idQRcode');
  370. }
  371. layer.close(index);
  372. },
  373. error:function () {
  374. layer.msg('请检查网络', {icon: 2});
  375. layer.close(index);
  376. }
  377. });
  378. });
  379. }
  380. });
  381. // 添加状态
  382. // 打开添加弹窗
  383. $(".addState").click(function () {
  384. layer.open({
  385. type: 2,
  386. id: 'addQRcodeID',
  387. title:'添加二维码',
  388. shadeClose: true,
  389. scrollbar:true,
  390. shade: 0.3,
  391. maxmin: true,
  392. skin: 'oaBtn',
  393. area: ['100%', '100%'],
  394. content: addQRcode,
  395. success: function (layero, index) {
  396. var body = layer.getChildFrame('body', index);
  397. },
  398. cancel: function(index, layero){
  399. table.reload('idQRcode');
  400. }
  401. })
  402. })
  403. });