0
0

QRcode.js 19 KB

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