checkpoint.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <!--#include file="/inc/header.html"-->
  2. <style>
  3. @media screen
  4. {
  5. #canvas
  6. {
  7. display: block;
  8. }
  9. #image
  10. {
  11. display: none;
  12. }
  13. }
  14. @media print
  15. {
  16. #canvas
  17. {
  18. display: none;
  19. }
  20. #image
  21. {
  22. display: block;
  23. }
  24. }
  25. </style>
  26. <style>
  27. .author-nav-tree {
  28. display: inline-block;
  29. width: 200px;
  30. min-height: 400px;
  31. border: 1px solid lightgrey;
  32. float: left;
  33. overflow-x: hidden;
  34. overflow-y: auto;
  35. margin-top: 10px;
  36. }
  37. #con-map {
  38. min-height: 400px;
  39. display: inline-block;
  40. margin-top: 10px;
  41. }
  42. .bif-con {
  43. width: 1200px;
  44. height:500px;
  45. margin-top: 0px;
  46. margin-left: 0px;
  47. float: left;
  48. }
  49. .bif-nav-item {
  50. width: 150px;
  51. text-align: center;
  52. }
  53. </style>
  54. <script type="text/javascript">
  55. window.renderHeader=function(e)
  56. {
  57. var template="{{#childenList}}<li class=\"bif-nav-item\" title=\"{{moduleUrl}}\" data-fun=\"{{moduleUrl}}\" data-href=\"{{moduleUrl}}\">{{moduleName}}</li>{{/childenList}}";
  58. var views = Mustache.render(template, e);
  59. $("#bif-nav-ul").html(views);
  60. $("#bif-nav-ul li").each(function(){
  61. var txt=$(this).text();
  62. if(txt=='巡查点定义'){
  63. $(this).addClass("active");
  64. $(".tree-breadcrumb #nav-item-a").html("巡查点定义");
  65. }
  66. })
  67. };
  68. $(function(){
  69. var modules=JSON.parse(window.sessionStorage.getItem("modules"));
  70. if(window.treemap){
  71. renderHeader(window.treemap[13]);//参数管理 7
  72. }else if(modules){
  73. renderHeader(modules.treemap[13]);
  74. }
  75. })
  76. var getGrainData = {};
  77. $.ajax({
  78. type: "get",
  79. dataType: 'json',
  80. async: false,
  81. url: config.baseUrl + config.organization.getAllGrainList,
  82. success: function(e) {
  83. getGrainData = e.data.data;
  84. },
  85. error: function(e) {
  86. console.log(e);
  87. }
  88. });
  89. </script>
  90. <div class="con-wrap" style="min-height: 400px;">
  91. <div class="tree-breadcrumb">
  92. <span class="nav-prov">首页</span>&gt;
  93. <span class="nav-prov"><a id="cansgl" href="/pages/basedata/index.html">参数管理</a></span>&gt;
  94. <span class="nav-prov"><a href="javascript:;" id="nav-item-a"></a></span>
  95. </div>
  96. <div id="con-map" class="main3" style="margin-top: 0px;overflow:hidden">
  97. <div class="bif-nav">
  98. <ul id="bif-nav-ul" >
  99. </ul>
  100. </div>
  101. <div class="bif-container">
  102. <div class="bif-con panel-noscroll" style="width:1200px">
  103. <div id="bd-toolbar" style="margin-top: 0;padding: 10px 5px">&emsp;
  104. 库名:<input class="easyui-combobox libraryNameT" style="width:120px" name="inventoryDetail-libraryName" editable=true>
  105. 巡查点名称:<input class="easyui-textbox easyui-validatebox search-nameOther bd-w-name" name="checkpointName" data-options="validType:'length[0,20]'">&emsp;
  106. <a href="javascript:;" class="easyui-linkbutton bd-add-s bd-search"> 查找</a>
  107. <a href="#" class="easyui-linkbutton bd-add-s bd-add-bt3">新增</a>
  108. <a href="#" class="easyui-linkbutton bd-add-s clear-btn2" plain="true">清空</a>
  109. </div>
  110. <div id="base-table">
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="checkadd-w easyui-window " style="padding-left: 10px" data-options="closed:true"></div>
  117. <div class="bd-w easyui-window" style="padding-left: 10px" data-options="closed:true">
  118. <form class="bd-w-form" style="margin-top: 12px;">
  119. <input type="hidden" name="id" >
  120. <span class="pf-pitem-li">
  121. <span class="pf-pitem-lit">巡查点名称:</span>
  122. <span class="pf-pitem-lic"><input class="easyui-textbox checkpointName" data-options="validType:'length[0,20]',width:'160px',height:'20px',required:true" name="checkpointName"></span>
  123. </span>
  124. <span class="pf-pitem-li">
  125. <span class="pf-pitem-lit">库名:</span>
  126. <span class="pf-pitem-lic"><input class="easyui-combobox updateGrainId " data-options="required:true,width:'160px'" name="checkpointGrainId" editable=false></span>
  127. </span>
  128. <span class="pf-pitem-li">
  129. <span class="pf-pitem-lit">位置描述:</span>
  130. <span class="pf-pitem-lic">
  131. <input class="easyui-textbox easyui-validatebox" data-options="validType:'length[0,50]',width:'160px',height:'70px',multiline:true" name="checkpointDesc">
  132. </span>
  133. </span>
  134. <br/>
  135. <a href="#" class="easyui-linkbutton bd-add-s btn-add-new" plain="true" style="margin-top: 20px;">确定</a>
  136. <a href="javascript:;" class="easyui-linkbutton bd-add-s " onclick="$('.bd-w').window('close');" plain="true" style="margin-top: 20px;">取消</a>
  137. </form>
  138. </div>
  139. <!--#include file="/inc/footer.html"-->
  140. <!--二维码页面-->
  141. <div class="erweimap easyui-window" style="padding-left: 10px" data-options="closed:true">
  142. <!--startprint-->
  143. <div id="codeHtml">
  144. <div id="code"></div>
  145. </div>
  146. <a id="download" download="qrcode.jpg"></a>
  147. <a href="#" class="easyui-linkbutton dayin" plain="true" style="margin-top: 20px;">打印</a>
  148. <a id="saveQrCode" class="easyui-linkbutton" plain="true" style="margin-top: 20px;cursor: pointer;">下载二维码</a>
  149. <!--endprint onclick="$('.erweimap').window('close');"-->
  150. </div>
  151. <img id="image" src=""/>
  152. </body>
  153. </html>
  154. <script type="text/javascript">
  155. $(function() {
  156. // var value=["虫害","结露","温度","验收"];
  157. group.dropdownWhole(".libraryNameT");
  158. baseData.initNav();
  159. loadData();
  160. search();
  161. addNewLine();
  162. $('.clear-btn2').on('click',function(e){
  163. e.preventDefault();
  164. $('.search-nameOther').textbox('clear');
  165. $('.libraryNameT').combobox('clear');
  166. });
  167. });
  168. function loadData(name,grainId){
  169. var url=config.baseUrl + config.checkpoint.listPage+"?1=1";
  170. if(name){
  171. url=url+"&checkpointName="+name;
  172. }
  173. if(grainId){
  174. url=url+"&grainId="+grainId;
  175. }
  176. $('#base-table').datagrid({
  177. url: url,
  178. method: 'post',
  179. rownumbers: true,
  180. pagination: true,
  181. fitColumns: true,
  182. singleSelect: true,
  183. selectOnCheck: false,
  184. checkOnSelect: false,
  185. toolbar: '#bd-toolbar',
  186. fit: true,
  187. columns: [[
  188. {field:'checkpointGrainName', title:'库名', width:'15%',
  189. formatter: function(value,row,index){
  190. if(value=='' || value=='undefined' || value==null || value=='null'){
  191. }else{
  192. return '<span title='+value+'>'+value+'</span>';
  193. }
  194. }},
  195. {field:'checkpointName', title:'巡查点名称', width:'20%',
  196. formatter: function(value,row,index){
  197. if(value=='' || value=='undefined' || value==null || value=='null'){
  198. }else{
  199. return '<span title='+value+'>'+value+'</span>';
  200. }
  201. }},
  202. {field:'checkpointDesc', title:'巡查点位置描述', width:'20%',
  203. formatter: function(value,row,index){
  204. if(value=='' || value=='undefined' || value==null || value=='null'){
  205. }else{
  206. return '<span title='+value+'>'+value+'</span>';
  207. }
  208. }},
  209. {
  210. field:'id',
  211. title:'操作',
  212. width:'25%',
  213. align: 'center',
  214. formatter: function(value, row, index) {
  215. //return '<a class="record_record_update t-update" data-id=' + row.id + '>更新</a>';
  216. return '<a class="record_record_update t-update" data-id=' + row.id + '>修改</a>&nbsp;|&nbsp;<a class="t-del bm-del" data-id=' + row.id + '>删除</a>&nbsp;|&nbsp;<a class=" t-update erweima" data-id=' + row.id + ' >二维码</a>';
  217. }
  218. }
  219. ]],
  220. loadFilter: function(e) {
  221. return {
  222. total: e.data.count,
  223. rows: e.data.list
  224. };
  225. },
  226. onLoadSuccess: function() {
  227. // base.delInfo('.iso-noticeMag-del', config.noticeMag.toDelete, '#noticeMag-info');
  228. update();
  229. $('.t-del').on('click', function() {
  230. var id = $(this).data('id');
  231. $.messager.confirm('提示', '确认删除', function(e) {
  232. if (e) {
  233. base.ajaxFunc('get', config.checkpoint.toDelete, {
  234. id: id
  235. }, function(e) {
  236. if (e.code === 0) {
  237. $.messager.alert('提示', e.msg, 'info');
  238. $('#tree-tt').tree('reload');
  239. $('#base-table').datagrid('reload');
  240. } else {
  241. $.messager.alert('警告', e.msg, 'error');
  242. }
  243. });
  244. }
  245. });
  246. });
  247. $(".erweima").off("click").on("click",function(){
  248. $("#code").empty();
  249. base.renderwindow('.erweimap',
  250. {
  251. title: '二维码',
  252. width: 440,
  253. height: 500,
  254. });
  255. var id=$(this).data('id');
  256. var erwei="checkpoint_"+id;
  257. erwei=toUtf8(erwei);
  258. $("#code").qrcode({
  259. render: "canvas", //table方式
  260. width: 400, //宽度
  261. height:400, //高度
  262. text: erwei //任意内容
  263. });
  264. $('.erweimap').window('open').window('center');
  265. dayinerweima();
  266. xiazai();
  267. });
  268. }
  269. });
  270. }
  271. function xiazai() {
  272. $('#saveQrCode').click(function () {
  273. var canvas = $('#code').find("canvas").get(0);
  274. try {//解决IE转base64时缓存不足,canvas转blob下载
  275. var blob = canvas.msToBlob();
  276. navigator.msSaveBlob(blob, 'qrcode.jpg');
  277. } catch (e) {//如果为其他浏览器,使用base64转码下载
  278. var url = canvas.toDataURL('image/jpeg');
  279. $("#download").attr('href', url).get(0).click();
  280. }
  281. return false;
  282. });
  283. }
  284. function dayinerweima(){
  285. $(".dayin").off().on("click",function(){
  286. var img = document.getElementById("image"); /// get image element
  287. var canvas = document.getElementsByTagName("canvas")[0]; /// get canvas element
  288. img.src = canvas.toDataURL(); /// update image
  289. $("#image").jqprint({
  290. debug:false,
  291. importCSS:true,
  292. printContainer:true,
  293. operaSupport:false
  294. });
  295. });
  296. }
  297. function update(){
  298. $(".record_record_update").off("click").on("click",function(){
  299. base.renderwindow('.bd-w',
  300. {
  301. title: '修改巡查点信息',
  302. width: 450,
  303. height: 270,
  304. });
  305. var id=$(this).data('id');
  306. $('.bd-w').window('open').window('center');
  307. //将id的值绑定到确认按钮上
  308. base.ajaxFunc('get', config.checkpoint.getById, {id: id}, function(e) {
  309. var row = e.obj;
  310. $('.bd-w-form').form("clear").form('load',row);
  311. group.initGrainHouseCombox(".bd-w-form .updateGrainId",true);
  312. group.editGrainHouseCombox(".bd-w-form .updateGrainId",".houseId",e.obj.checkpointGrainId,e.obj.houseId,false);
  313. //当鼠标移动到文本框时显示该文本框的信息内容
  314. $(".bd-w-form input,textarea").each(function(i) {
  315. var str=$(this).val();
  316. $(this).attr("title", $(this).val());
  317. });
  318. doupdate();
  319. });
  320. });
  321. }
  322. function doupdate(){
  323. $(".btn-add-new").off().on("click",function(){
  324. var data = $('.bd-w-form').serializeArray();
  325. var valresult=$(".bd-w-form").form('validate');
  326. if(!valresult){
  327. $.messager.alert('提示', base.tooltip, 'info');
  328. return;
  329. }
  330. base.ajaxFunc('post', config.checkpoint.toUpdate, data, function(e) {
  331. base.requestTip(e, '.bd-w', '#base-table', 0);
  332. });
  333. });
  334. }
  335. function search(){
  336. $(".bd-search").off("click").on("click",function(){
  337. if(!$('.search-nameOther').textbox('isValid')) return;
  338. var checkpointName = $('.search-nameOther').textbox('getValue');
  339. var grainId = $('.libraryNameT').combobox('getValue');
  340. loadData(checkpointName,grainId);
  341. });
  342. }
  343. function addNewLine() {
  344. //添加按钮bd-add-bt3点击事件
  345. $('.bd-add-bt3').off('click').on('click', function(e) {
  346. e.preventDefault();
  347. $(".checkpointGrainId").combobox('clear');
  348. group.initGrainHouseCombox(".storeman-manage-form .checkpointGrainId",true);
  349. var href = '/pages/basedata/checkpointAdd.html';
  350. $('.checkadd-w').load(href,function(){
  351. $.parser.parse($('.checkadd-w'));
  352. $('#bm-add-form').form('clear');
  353. //确定按钮事件
  354. $('.bd-win-y').on('click', function(e){
  355. e.preventDefault();
  356. var $form = $("#bm-add-form");//表单信息
  357. var postData = $form.serialize();
  358. if($("#bm-add-form .bd-w-checkpointName").val() == ""){
  359. $.messager.alert('操作提示', '有重要参数未填写');
  360. return false;
  361. }
  362. //postData.typeName = $('#typeName').combobox('getValue');
  363. base.ajaxFunc('post', config.checkpoint.toInsert, postData, function(e){
  364. //$.messager.alert('操作提示', '添加成功');
  365. base.requestTip(e, '.checkadd-w', '#base-table', 0);
  366. $('.checkadd-w').window('close');
  367. });
  368. });
  369. });
  370. base.renderwindow('.checkadd-w', {
  371. title: '新增基础参数',
  372. width: 450,
  373. height: 300,
  374. top: 100
  375. });
  376. $('.checkadd-w').window('open');
  377. $('#bm-add-form').form('clear');
  378. });
  379. }
  380. function toUtf8(str) {
  381. var out, i, len, c;
  382. out = "";
  383. len = str.length;
  384. for(i = 0; i < len; i++) {
  385. c = str.charCodeAt(i);
  386. if ((c >= 0x0001) && (c <= 0x007F)) {
  387. out += str.charAt(i);
  388. } else if (c > 0x07FF) {
  389. out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
  390. out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
  391. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  392. } else {
  393. out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
  394. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  395. }
  396. }
  397. return out;
  398. }
  399. </script>