wangui1.0.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497
  1. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  2. window.location.href="./m";
  3. }
  4. var WorkSpaceName="";
  5. var WorkSpacePath="workpage";
  6. class WorkSpace{
  7. Init(PageTitle="WinntoUI 原生态 java script 管理平台框架 ",AreaStyle={TopBGColor:"#233",TopColor:"#fff",LeftBGColor:"#257",RightBGColor:"#fff"}){
  8. WorkSpaceName=GetVarName(this);
  9. this.none=document.createElement('div');
  10. this.none.style.display="none";
  11. //document.body.appendChild(this.none);
  12. var ele=document.createElement('div');
  13. document.body.appendChild(ele);
  14. this.AlertMsg= new AlertMsg;
  15. this.AlertMsg.Init(ele);
  16. ele=document.createElement('div');
  17. document.body.appendChild(ele);
  18. this.Dialog= new DialogBox;
  19. this.Dialog.Init(ele);
  20. // top 顶部信息栏
  21. var eleStyle={position:"absolute",width:"100%",height:"50px",background:AreaStyle.TopBGColor,color:"#fff"};
  22. this.Top=document.createElement('div');
  23. this.Top=AcceptStyle(this.Top,eleStyle);
  24. var MenuBnt=ICON.MenuButton("24px","#fff","#f60");// 菜单隐藏按钮
  25. MenuBnt.style.marginTop="18px";
  26. MenuBnt.style.marginLeft="15px",
  27. (function(OBJ){
  28. MenuBnt.addEventListener('click', function (event) {OBJ.Menu()});
  29. })(this);
  30. this.Top.appendChild(MenuBnt);
  31. this.Title=document.createElement('span');// top 标题
  32. this.Title.style.marginTop="15px";
  33. this.Title.style.marginLeft="30px";
  34. this.Title.innerHTML=PageTitle;
  35. this.Top.appendChild(this.Title);
  36. this.UserInfo=document.createElement('span'); //top 右侧用户信息
  37. this.UserInfo.style.marginTop="14px";
  38. this.UserInfo.style.marginRight="10px";
  39. this.UserInfo.style.float="right";
  40. this.Top.appendChild(this.UserInfo);
  41. document.body.appendChild(this.Top);
  42. this.CommInfo=document.createElement('span'); //top 通信状态
  43. this.CommInfo.id="CommInfo";
  44. this.CommInfo.style.marginTop="16px";
  45. this.CommInfo.style.marginRight="20px";
  46. this.CommInfo.style.float="right";
  47. this.CommInfo.innerHTML="正在连接...";
  48. this.Top.appendChild(this.CommInfo);
  49. //左侧菜单
  50. eleStyle={position:"absolute",top:"50px",width:"160px",overflow:"auto",bottom:"0",background:AreaStyle.LeftBGColor,padding_left:"20px",padding_top:"40px",color:"#fff"};
  51. this.LeftArea=document.createElement('div');
  52. this.LeftArea=AcceptStyle(this.LeftArea,eleStyle);
  53. document.body.appendChild(this.LeftArea);
  54. //右侧数据区
  55. eleStyle={position:"absolute",top:"50px",left:"180px",right:"0",bottom:"0",overflow:"auto",background:AreaStyle.RightBGColor,transition_property:"opacity left",transition_duration: "0.5s"};
  56. this.RightArea=document.createElement('div');
  57. this.RightArea.id="BodyData";
  58. this.RightArea=AcceptStyle(this.RightArea,eleStyle);
  59. document.body.appendChild(this.RightArea);
  60. // 菜单中的选中提示点
  61. this.FocusDot=document.createElement('div');
  62. eleStyle={display:"none",margin_left:"10px",width:"8px",height:"8px",z_index:"9",background:"#5ce",border_radius:"50%"};
  63. this.FocusDot=AcceptStyle(this.FocusDot,eleStyle);
  64. document.body.appendChild(this.FocusDot);
  65. //加载时动画
  66. this.Loading=document.createElement('div');
  67. this.Loading.className="Loading";
  68. document.body.appendChild(this.Loading);
  69. this.AsynLoad("menu",this.LeftArea); //加载左侧菜单
  70. (function(OBJ){window.addEventListener('hashchange', function (event) {OBJ.LoadPage(window.location.hash);});})(this);
  71. }
  72. setTitle(html){this.Title.innerHTML=html;}
  73. setUserInfo(html){this.UserInfo.innerHTML=html;}
  74. setTopBGColor(Color){this.Top.style.backgroundColor=Color;}
  75. setTopColor(Color){this.Top.style.color=Color;}
  76. setLeftBGColor(Color){this.LeftArea.style.backgroundColor=Color;}
  77. setRightBGColor(Color){this.RightArea.style.backgroundColor=Color;}
  78. Menu(){
  79. if(this.RightArea.style.left!="0px"){
  80. this.RightArea.style.left="0px";
  81. }else{
  82. this.RightArea.style.left="180px";
  83. }
  84. }
  85. AsynLoad(Url,Dom,Send="",Mode="GET"){
  86. var WX=this;
  87. WX.LoadingShow();
  88. var xmlhttp;
  89. xmlhttp=new XMLHttpRequest();
  90. xmlhttp.onreadystatechange=function(D){
  91. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  92. if (xmlhttp.responseText!=""){
  93. Dom.innerHTML=xmlhttp.responseText;
  94. for(let i=0;i<Dom.getElementsByTagName("script").length;i++){
  95. if(window.execScript) {
  96. window.execScript(Dom.getElementsByTagName("script").item(i).innerHTML);
  97. }else{
  98. window.eval(Dom.getElementsByTagName("script").item(i).innerHTML)
  99. }
  100. }
  101. WX.LoadingClose();
  102. }
  103. }
  104. if (xmlhttp.status==500){
  105. Dom.innerHTML="<div class='PageError'><span>500</span><br>页面内部错误</div>";
  106. WX.LoadingClose()
  107. }
  108. if (xmlhttp.status==404){
  109. Dom.innerHTML="<div class='PageError'><span>come soon</span><br>敬请期待...</div>";
  110. WX.LoadingClose()
  111. }
  112. };
  113. xmlhttp.open(Mode,Url);
  114. xmlhttp.send(Send);
  115. }
  116. LoadPage(Url){
  117. if(Url!=""){
  118. Url=Url.replace(/#/g,"");
  119. this.AsynLoad(WorkSpacePath+"/"+Url,this.RightArea);
  120. if(document.getElementById(Url.split("?")[0].replace(/\//g,""))){
  121. var Act=document.getElementById(Url.split("?")[0].replace(/\//g,""));
  122. this.FocusDot.style.display="inline-block";
  123. Act.appendChild(this.FocusDot);
  124. if(Act.parentNode.offsetHeight=="0"){
  125. Act.parentNode.style.height=(Act.parentNode.children.length*36).toString()+"px";
  126. document.getElementById("MenuItem0Arrow"+Act.parentNode.id.replace(/MenuItem1BK/g,"")).style.transform='rotate(-90deg)';
  127. }
  128. }
  129. }else{
  130. window.location.hash="home";
  131. }
  132. }
  133. LoadingClose(){this.RightArea.style.opacity=1; this.Loading.style.display="none";}
  134. LoadingShow(){ this.RightArea.style.opacity=0.5;this.Loading.style.display="block";}
  135. }
  136. function MainMenu(Dom,Item){
  137. var Html="";
  138. for(let i=0;i<Item.length;i++){
  139. if(Item[i].depth==0){
  140. Html+="<div class='MenuItem0' style='height:20px;margin-bottom:30px' onclick='window.location.hash=\""+Item[i].url+"\";document.getElementById(\"TipsDot\").style.display=\"none\"'><img src='"+Item[i].icon+"' >"+Item[i].title+"</div>";
  141. }else{
  142. Html+="<div class='MenuItem0' onclick='MenuItems1("+i.toString()+")'><img src='"+Item[i].icon+"'>"+Item[i].title+"<span class='MenuItem0Arrow' id='MenuItem0Arrow"+i.toString()+"'></span></div>";
  143. Html+="<div class='MenuItem1BK' id='MenuItem1BK"+i.toString()+"' >";
  144. for(let j=0;j<Item[i].items.length;j++){
  145. Html+="<div class='MenuItem1' onclick='window.location.hash=\""+Item[i].items[j].url+"\"' id='"+Item[i].items[j].url.replace(/\//g,"")+"'>"+Item[i].items[j].title+"</div>";
  146. }
  147. Html+="</div>";
  148. }
  149. }
  150. Dom.innerHTML=Html;
  151. }
  152. function MenuItems1(Id){
  153. var Dom=document.getElementById("MenuItem1BK"+Id.toString());
  154. var Arrow=document.getElementById("MenuItem0Arrow"+Id.toString());
  155. if(Dom.offsetHeight!="0"){
  156. Dom.style.height="0";
  157. Arrow.style.transform='rotate(0deg)';
  158. }else{
  159. Dom.style.height=(Dom.children.length*36).toString()+"px";
  160. Arrow.style.transform='rotate(-90deg)';
  161. }
  162. }
  163. class InputTips{
  164. Init(){
  165. var Dom=document.createElement('div');
  166. var iStyle={z_index:"9999",display:"block",left:"250px",top:"0",font_weight:"500",font_size:"13px",color:"#f00",min_width:"100px",height:"20px",position:"fixed"};
  167. Dom=AcceptStyle(Dom,iStyle);
  168. var Arrow=document.createElement('div');
  169. var Title=document.createElement('div');
  170. Dom.appendChild(Title);
  171. this.Dom=Dom;
  172. this.Title=Title;
  173. document.body.appendChild( this.Dom );
  174. }
  175. Show(Dom,Title){
  176. this.Dom.style.display="block";
  177. this.Title.innerHTML=Title;
  178. this.Dom.style.left=Dom.getBoundingClientRect().left.toString()+"px";
  179. this.Dom.style.top=(parseInt(Dom.getBoundingClientRect().top)+parseInt(Dom.style.height)+8).toString()+"px" ;
  180. }
  181. Close(){
  182. this.Dom.style.display="none";
  183. //alert();
  184. }
  185. }
  186. class FormEditor{
  187. Init(Dom,FormJson,Src="save"){
  188. Dom.name="FormDom";
  189. this.Tips=new InputTips;
  190. this.Tips.Init();
  191. this.Json=FormJson;
  192. var IFRAME=document.createElement('iframe');
  193. IFRAME.name="FormEditorSave";
  194. IFRAME.style.display="none";
  195. this.IFRAME=IFRAME;
  196. document.body.appendChild(IFRAME);
  197. this.Src=Src;
  198. this.Form=document.createElement('form');
  199. this.Form.method="POST";
  200. var div0,div1,ele;
  201. var div0Style={float:"left",width:"100%",marginBottom:"18px"};
  202. var TitleStyle={float:"left",width:"17%",text_align:"right",margin_top:"5px"};
  203. var ValueStyle={float:"left",width:"55%",height:"100%",padding_left:"5%"};
  204. var TipsStyle={float:"left",width:"23%",margin_top:"7px",font_size:"13px"};
  205. for (let key in FormJson){
  206. switch(FormJson[key].type){
  207. case "hidden":
  208. ele=document.createElement('input');
  209. ele.type="hidden";
  210. ele.value=FormJson[key].value;
  211. ele.name=key;
  212. this.Form.appendChild(ele);
  213. break;
  214. case "CheckMultiple":
  215. div0=document.createElement('div');
  216. div0=AcceptStyle(div0,div0Style);
  217. div1=document.createElement('div');
  218. div1=AcceptStyle(div1,TitleStyle);
  219. div1.innerHTML=FormJson[key].title;
  220. div0.appendChild(div1);
  221. div1=document.createElement('div');
  222. div1=AcceptStyle(div1,ValueStyle);
  223. div1.style.position="relative";
  224. ele=document.createElement('input');
  225. ele.type="text";
  226. ele.name=key;
  227. ele.value=FormJson[key].value;
  228. ele.readOnly=true;
  229. ele.style.height="26px";
  230. div1.appendChild(ele);
  231. var div2=document.createElement('div');
  232. var div2Style={width:"80%",padding:"2%",padding_top:"0",position:"absolute",background:"#fff",z_index:"8",box_shadow:"2px 2px 5px rgba(0, 0, 0, 0.5)",display:"none"};
  233. div2=AcceptStyle(div2,div2Style);
  234. div2.id=key+"CheckMultiple";
  235. div2.name=key+"CheckMultiple";
  236. (function(Row,Dom){Row.addEventListener('click',function (event){Dom.Tips.Close();if(div2.style.display=="block" ){div2.style.display="none"}else{div2.style.display="block"}});})(ele,this);
  237. Dom.addEventListener('click',function (event){if(event.target.name!=key && event.target.id!=(key+"CheckMultiple") && event.target.name!=(key+"CheckMultipleValue")){div2.style.display="none"}});
  238. var Checked="";
  239. for(let Option in FormJson[key].options){
  240. Checked="";
  241. if( FormJson[key].value.indexOf(Option)>=0){ Checked="checked";}
  242. div2.innerHTML+="<div style='float:left;margin-top:15px;width:"+FormJson[key].ItemWidth+"' id='"+key+"CheckMultiple' ><input type='checkbox' "+Checked+" name='"+key+"CheckMultipleValue' value='"+Option+"' onclick='var CkMV=document.getElementsByName(\""+key+"CheckMultipleValue\");var InputV=document.getElementsByName(\""+key+"\");InputV[0].value=\"\";for(let i=0;i<CkMV.length;i++){if(CkMV[i].checked){InputV[0].value+=CkMV[i].value+\",\"};}InputV[0].value=InputV[0].value.substring(0, InputV[0].value.length-1);'>"+Option+"("+FormJson[key].options[Option]+")</div>";
  243. }
  244. div1.appendChild(div2);
  245. div0.appendChild(div1);
  246. div1=document.createElement('div');
  247. div1=AcceptStyle(div1,TipsStyle);
  248. div1.innerHTML=FormJson[key].tips;
  249. div0.appendChild(div1);
  250. this.Form.appendChild(div0);
  251. break;
  252. case "readonly":
  253. div0=document.createElement('div');
  254. div0=AcceptStyle(div0,div0Style);
  255. div1=document.createElement('div');
  256. div1=AcceptStyle(div1,TitleStyle);
  257. div1.innerHTML=FormJson[key].title;
  258. div0.appendChild(div1);
  259. div1=document.createElement('div');
  260. div1=AcceptStyle(div1,ValueStyle);
  261. ele=document.createElement('input');
  262. ele.type="hidden";
  263. ele.value=FormJson[key].value;
  264. ele.name=key;
  265. div1.appendChild(ele);
  266. ele=document.createElement('input');
  267. ele.type="text";
  268. ele.value=FormJson[key].value;
  269. ele.disabled=true;
  270. ele.style.backgroundColor="#eee";
  271. div1.appendChild(ele);
  272. div0.appendChild(div1);
  273. div1=document.createElement('div');
  274. div1=AcceptStyle(div1,TipsStyle);
  275. div1.innerHTML=FormJson[key].tips;
  276. div0.appendChild(div1);
  277. this.Form.appendChild(div0);
  278. break;
  279. case "date":
  280. case "text":
  281. case "password":
  282. div0=document.createElement('div');
  283. div0=AcceptStyle(div0,div0Style);
  284. div1=document.createElement('div');
  285. div1=AcceptStyle(div1,TitleStyle);
  286. div1.innerHTML=FormJson[key].title;
  287. div0.appendChild(div1);
  288. div1=document.createElement('div');
  289. div1=AcceptStyle(div1,ValueStyle);
  290. div1.style.position="relative";
  291. ele=document.createElement('input');
  292. ele.type=FormJson[key].type;
  293. ele.autocomplete="new-password";
  294. ele.value=FormJson[key].value;
  295. ele.style.height="26px";
  296. ele.name=key;
  297. if( FormJson[key].rules){ele.addEventListener('input',function (event){ eval( FormJson[key].rules )})};
  298. div1.appendChild(ele);
  299. div0.appendChild(div1);
  300. div1=document.createElement('div');
  301. div1=AcceptStyle(div1,TipsStyle);
  302. div1.innerHTML=FormJson[key].tips;
  303. div0.appendChild(div1);
  304. this.Form.appendChild(div0);
  305. break;
  306. case "DateRange":
  307. div0=document.createElement('div');
  308. div0=AcceptStyle(div0,div0Style);
  309. div1=document.createElement('div');
  310. div1=AcceptStyle(div1,TitleStyle);
  311. div1.innerHTML=FormJson[key].title;
  312. div0.appendChild(div1);
  313. div1=document.createElement('div');
  314. div1=AcceptStyle(div1,ValueStyle);
  315. div1.style.position="relative";
  316. ele=document.createElement('input');
  317. ele.type="date";
  318. ele.autocomplete="new-password";
  319. ele.value=FormJson[key].begin;
  320. ele.style.height="26px";
  321. ele.name=key+"begin";
  322. div1.appendChild(ele);
  323. ele=document.createElement('span');
  324. ele.style.marginLeft=ele.style.marginRight="20px";
  325. ele.innerHTML=" 至 "
  326. div1.appendChild(ele);
  327. ele=document.createElement('input');
  328. ele.type="date";
  329. ele.autocomplete="new-password";
  330. ele.value=FormJson[key].end;
  331. ele.style.height="26px";
  332. ele.name=key+"end";
  333. div1.appendChild(ele);
  334. div0.appendChild(div1);
  335. div1=document.createElement('div');
  336. div1=AcceptStyle(div1,TipsStyle);
  337. div1.innerHTML=FormJson[key].tips;
  338. div0.appendChild(div1);
  339. this.Form.appendChild(div0);
  340. break;
  341. case "price":
  342. div0=document.createElement('div');
  343. div0=AcceptStyle(div0,div0Style);
  344. div1=document.createElement('div');
  345. div1=AcceptStyle(div1,TitleStyle);
  346. div1.innerHTML=FormJson[key].title;
  347. div0.appendChild(div1);
  348. div1=document.createElement('div');
  349. div1=AcceptStyle(div1,ValueStyle);
  350. div1.style.position="relative";
  351. ele=document.createElement('input');
  352. ele.type=FormJson[key].type;
  353. ele.autocomplete="new-password";
  354. ele.value=parseFloat(FormJson[key].value).toFixed(2);
  355. ele.style.height="26px";
  356. ele.name=key;
  357. ele.addEventListener('input',function (event){ $_OnlyNum(this,"Y") });
  358. div1.appendChild(ele);
  359. div0.appendChild(div1);
  360. div1=document.createElement('div');
  361. div1=AcceptStyle(div1,TipsStyle);
  362. div1.innerHTML=FormJson[key].tips;
  363. div0.appendChild(div1);
  364. this.Form.appendChild(div0);
  365. break;
  366. case "textarea":
  367. div0=document.createElement('div');
  368. div0=AcceptStyle(div0,div0Style);
  369. div0.style.height="140px"
  370. div1=document.createElement('div');
  371. div1=AcceptStyle(div1,TitleStyle);
  372. div1.innerHTML=FormJson[key].title;
  373. div0.appendChild(div1);
  374. div1=document.createElement('div');
  375. div1=AcceptStyle(div1,ValueStyle);
  376. div1.style.height="150px"
  377. div1.style.position="relative";
  378. ele=document.createElement('textarea');
  379. ele.value=FormJson[key].value;
  380. ele.name=key;
  381. ele.style.width="90%";
  382. ele.style.height="120px";
  383. if( FormJson[key].rules){ele.addEventListener('input',function (event){ eval( FormJson[key].rules )})};
  384. div1.appendChild(ele);
  385. div0.appendChild(div1);
  386. div1=document.createElement('div');
  387. div1=AcceptStyle(div1,TipsStyle);
  388. div1.innerHTML=FormJson[key].tips;
  389. div0.appendChild(div1);
  390. this.Form.appendChild(div0);
  391. break;
  392. case "radio":
  393. div0=document.createElement('div');
  394. div0=AcceptStyle(div0,div0Style);
  395. div1=document.createElement('div');
  396. div1=AcceptStyle(div1,TitleStyle);
  397. div1.innerHTML=FormJson[key].title;
  398. div0.appendChild(div1);
  399. div1=document.createElement('div');
  400. div1=AcceptStyle(div1,ValueStyle);
  401. var Checked=[""," checked"];
  402. for (let op in FormJson[key].option){
  403. ele=document.createElement('input');
  404. ele.type="radio";
  405. ele.value=op;
  406. ele.name=key;
  407. if(op==FormJson[key].value){ele.checked=true;}
  408. div1.appendChild(ele);
  409. var span= document.createElement('span');
  410. span.innerHTML+=FormJson[key].option[op];
  411. span.style.marginTop="3px";
  412. span.style.marginRight="30px";
  413. div1.appendChild(span);
  414. }
  415. div0.appendChild(div1);
  416. this.Form.appendChild(div0);
  417. break;
  418. case "checkbox":
  419. div0=document.createElement('div');
  420. div0=AcceptStyle(div0,div0Style);
  421. div1=document.createElement('div');
  422. div1=AcceptStyle(div1,TitleStyle);
  423. div1.innerHTML=FormJson[key].title;
  424. div0.appendChild(div1);
  425. div1=document.createElement('div');
  426. div1=AcceptStyle(div1,ValueStyle);
  427. div1.style.width="10%";
  428. div1.style.marginTop="4px";
  429. ele=document.createElement('input');
  430. ele.type="checkbox";
  431. ele.style.cursor="pointer";
  432. ele.style.width="18px";
  433. ele.style.height="18px";
  434. ele.checked=FormJson[key].checked;
  435. ele.value=FormJson[key].value;
  436. ele.name=key;
  437. if(FormJson[key].value==FormJson[key].field_value){ele.checked=true}
  438. div1.appendChild(ele);
  439. div0.appendChild(div1);
  440. div1=document.createElement('div');
  441. div1=AcceptStyle(div1,TipsStyle);
  442. div1.style.width="65%";
  443. div1.innerHTML=FormJson[key].tips;
  444. div0.appendChild(div1);
  445. this.Form.appendChild(div0);
  446. break;
  447. case "img":
  448. div0=document.createElement('div');
  449. div0=AcceptStyle(div0,div0Style);
  450. div1=document.createElement('div');
  451. div1=AcceptStyle(div1,TitleStyle);
  452. div1.style.marginTop="10px";
  453. div1.innerHTML=FormJson[key].title;
  454. div0.appendChild(div1);
  455. div1=document.createElement('div');
  456. div1=AcceptStyle(div1,ValueStyle);
  457. div1.style.width="auto";
  458. for(let i=0;i<FormJson[key].img.length;i++){
  459. let Span=document.createElement('span');
  460. Span.style.marginRight="30px";
  461. Span.style.textAlign="center";
  462. Span.style.fontSize="11px";
  463. let Img=document.createElement('img');
  464. Img.src=FormJson[key].img[i].src;
  465. Img.id=key+i.toString();
  466. Img.style.width=FormJson[key].size.split(",")[0]+"px";
  467. Img.style.height=FormJson[key].size.split(",")[1]+"px";
  468. let ImgSrc=document.createElement('input');
  469. ImgSrc.type='hidden';
  470. ImgSrc.value=FormJson[key].img[i].src;
  471. ImgSrc.id=key+"Src"+i.toString();
  472. ImgSrc.name=key+"Src"+i.toString();
  473. Span.appendChild(Img);
  474. Span.appendChild(ImgSrc);
  475. let Title=document.createElement('span');
  476. Title.style.width="100%";
  477. Title.innerHTML+="<br>"+FormJson[key].img[i].title;
  478. Span.appendChild(Title);
  479. div1.appendChild(Span);
  480. }
  481. div0.appendChild(div1);
  482. div1=document.createElement('div');
  483. div1=AcceptStyle(div1,TipsStyle);
  484. div1.innerHTML=FormJson[key].tips;
  485. div0.appendChild(div1);
  486. this.Form.appendChild(div0);
  487. break;
  488. case "select":
  489. div0=document.createElement('div');
  490. div0=AcceptStyle(div0,div0Style);
  491. div1=document.createElement('div');
  492. div1=AcceptStyle(div1,TitleStyle);
  493. div1.innerHTML=FormJson[key].title;
  494. div0.appendChild(div1);
  495. div1=document.createElement('div');
  496. div1=AcceptStyle(div1,ValueStyle);
  497. var ele=document.createElement("select");
  498. ele.name=key;
  499. for(let okey in FormJson[key].option){
  500. let opt = new Option( FormJson[key].option[okey],okey);
  501. if(FormJson[key].value==okey){opt.selected=true;}
  502. ele.add(opt);
  503. }
  504. //ele.type="checkbox";
  505. div1.appendChild(ele);
  506. div0.appendChild(div1);
  507. this.Form.appendChild(div0);
  508. break;
  509. case "SelectCity":
  510. div0=document.createElement('div');
  511. div0=AcceptStyle(div0,div0Style);
  512. div1=document.createElement('div');
  513. div1=AcceptStyle(div1,TitleStyle);
  514. div1.innerHTML=FormJson[key].title;
  515. div0.appendChild(div1);
  516. div1=document.createElement('div');
  517. div1=AcceptStyle(div1,ValueStyle);
  518. var City=new SelectCity;
  519. City.Init(div1,FormJson[key].value.prov,FormJson[key].value.city,FormJson[key].value.dist);
  520. div0.appendChild(div1);
  521. this.Form.appendChild(div0);
  522. break;
  523. case "SelectIndustry":
  524. div0=document.createElement('div');
  525. div0=AcceptStyle(div0,div0Style);
  526. div1=document.createElement('div');
  527. div1=AcceptStyle(div1,TitleStyle);
  528. div1.innerHTML=FormJson[key].title;
  529. div0.appendChild(div1);
  530. div1=document.createElement('div');
  531. div1=AcceptStyle(div1,ValueStyle);
  532. var Industry=new SelectIndustry;
  533. Industry.Init(div1,FormJson[key].value.class0,FormJson[key].value.class1);
  534. div0.appendChild(div1);
  535. this.Form.appendChild(div0);
  536. break;
  537. case "SelectIntegrationType":
  538. div0=document.createElement('div');
  539. div0=AcceptStyle(div0,div0Style);
  540. div1=document.createElement('div');
  541. div1=AcceptStyle(div1,TitleStyle);
  542. div1.innerHTML=FormJson[key].title;
  543. div0.appendChild(div1);
  544. div1=document.createElement('div');
  545. div1=AcceptStyle(div1,ValueStyle);
  546. var IntegrationType=new SelectIntegrationType;
  547. IntegrationType.Init(div1,FormJson[key].value.industry,FormJson[key].value.type);
  548. div0.appendChild(div1);
  549. this.Form.appendChild(div0);
  550. break;
  551. case "SelectLinkage2":
  552. div0=document.createElement('div');
  553. div0=AcceptStyle(div0,div0Style);
  554. div1=document.createElement('div');
  555. div1=AcceptStyle(div1,TitleStyle);
  556. div1.innerHTML=FormJson[key].title;
  557. div0.appendChild(div1);
  558. div1=document.createElement('div');
  559. div1=AcceptStyle(div1,ValueStyle);
  560. var SelectLinkage =new SelectLinkage2;
  561. SelectLinkage.Init( div1,FormJson[key].value[2],FormJson[key].value[3],FormJson[key].value[0],FormJson[key].value[1]);
  562. div0.appendChild(div1);
  563. this.Form.appendChild(div0);
  564. break;
  565. case "SelectMultiple":
  566. div0=document.createElement('div');
  567. div0=AcceptStyle(div0,div0Style);
  568. div1=document.createElement('div');
  569. div1=AcceptStyle(div1,TitleStyle);
  570. div1.innerHTML=FormJson[key].title;
  571. div0.appendChild(div1);
  572. div1=document.createElement('div');
  573. div1=AcceptStyle(div1,ValueStyle);
  574. var Value=JSON.parse(FormJson[key].value);
  575. var InputValue="",DivHTML="";
  576. var i=0;
  577. for (let key1 in Value) {
  578. i++
  579. InputValue+=key1;
  580. DivHTML+="<span style='width:90%;margin-top:3%;margin-left:2%'>"+Value[key1]+"</span>";
  581. if(i<Object.keys(Value).length){InputValue+=",";}
  582. }
  583. ele=document.createElement('input');
  584. ele.type="hidden";
  585. ele.value=InputValue;
  586. ele.name=key;
  587. div1.appendChild(ele);
  588. div0.appendChild(div1);
  589. var div2=document.createElement('div');
  590. div2.id="SelectMultiple";
  591. div2.style.border='1px solid #aaa';
  592. div2.style.overflow="auto";
  593. div2.style.height='140px';
  594. div2.style.width='92%'
  595. div2.style.borderRadius='3px';
  596. div2.innerHTML=DivHTML;
  597. div1.appendChild(div2);
  598. div1=document.createElement('div');
  599. div1=AcceptStyle(div1,TipsStyle);
  600. div1.innerHTML=FormJson[key].tips;
  601. div0.appendChild(div1);
  602. this.Form.appendChild(div0);
  603. break;
  604. case "SelectSingle":
  605. div0=document.createElement('div');
  606. div0=AcceptStyle(div0,div0Style);
  607. div1=document.createElement('div');
  608. div1=AcceptStyle(div1,TitleStyle);
  609. div1.innerHTML=FormJson[key].title;
  610. div0.appendChild(div1);
  611. div1=document.createElement('div');
  612. div1=AcceptStyle(div1,ValueStyle);
  613. ele=document.createElement('input');
  614. ele.type="hidden";
  615. ele.value=FormJson[key].value.value;
  616. ele.name=key;
  617. div1.appendChild(ele);
  618. ele=document.createElement('input');
  619. ele.type="text";
  620. ele.value=FormJson[key].value.face;
  621. ele.name=key+"face";
  622. ele.disabled=true;
  623. div1.appendChild(ele);
  624. div0.appendChild(div1);
  625. div1=document.createElement('div');
  626. div1=AcceptStyle(div1,TipsStyle);
  627. div1.innerHTML=FormJson[key].tips;
  628. div0.appendChild(div1);
  629. this.Form.appendChild(div0);
  630. break;
  631. case "MultipleItems":
  632. div0=document.createElement('div');
  633. div0=AcceptStyle(div0,div0Style);
  634. div1=document.createElement('div');
  635. div1=AcceptStyle(div1,TitleStyle);
  636. div1.innerHTML=FormJson[key].title;
  637. div0.appendChild(div1);
  638. this.Form.appendChild(div0);
  639. div1=document.createElement('div');
  640. div1=AcceptStyle(div1,ValueStyle);
  641. var ItemStyle={float:"left",width:"130%",height:"320px",overflow:"hidden",overflow:"auto",scrollbarColor:"#999",border:"1px solid #999",border_radius:"3px"};
  642. var Item=document.createElement('div');
  643. Item=AcceptStyle(Item,ItemStyle);
  644. div1.appendChild(Item);
  645. var ItemTable=document.createElement('table');
  646. ItemTable.id="MultipleItems";
  647. ItemTable.style.height="50px"
  648. ItemTable.style.boxShadow='none';
  649. var Tr=document.createElement('tr');
  650. Tr.style.height="50px";
  651. Tr.style.backgroundColor="#eee";
  652. var NewTr="<tr style=''>";
  653. for (let field in FormJson[key].item){ // 输入项 表头
  654. var Td=document.createElement('td');
  655. Td.innerHTML=FormJson[key].item[field].title;
  656. Tr.appendChild(Td);
  657. NewTr+="<td style='border:0;height:40px'>";
  658. switch(FormJson[key].item[field].type){
  659. case "text":
  660. NewTr+="<input style='width:70%;height:20px;margin-top:-5px' type='text' name='"+field+"[]' value='' >";
  661. break;
  662. case "number":
  663. NewTr+="<input style='width:70%;height:20px;margin-top:-5px' type='text' name='"+field+"[]' value='0' oninput='$_OnlyNum(this)'>";
  664. break;
  665. case "select":
  666. let selectHTML="<div style='width:100px;'><select name='"+field+"[]' style='width:80px;'>";
  667. for (let option in FormJson[key].item[field].option){
  668. selectHTML+="<option value='"+option+"'>"+FormJson[key].item[field].option[option]+"</option>";
  669. }
  670. selectHTML+="</select>";
  671. NewTr+=""+ selectHTML;
  672. break;
  673. }
  674. }
  675. NewTr+="</div></td'>";
  676. NewTr+="<td style='border:0;text-align:center'><span class='TextButton' style='font-size:26px;margin-top:-3px;color:#f70' onclick='this.Tips.Close();this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);'>×</span></td>";
  677. NewTr+="</tr>";
  678. Td=document.createElement('td');
  679. Td.innerHTML="移除";
  680. Tr.appendChild(Td);
  681. ItemTable.appendChild(Tr);
  682. for(let i=0;i<FormJson[key].value.length;i++){
  683. var Tr=document.createElement('tr');
  684. Tr.style.height="50px";
  685. for (let field in FormJson[key].item){
  686. var Td=document.createElement('td');
  687. Td.innerHTML="<td style='border:0'>";
  688. switch(FormJson[key].item[field].type){
  689. case "text":
  690. Td.innerHTML+="<input style='width:70%;height:20px;margin-top:-5px' type='text' name='"+field+"[]' value='"+FormJson[key].value[i][field]+"' >";
  691. break;
  692. case "number":
  693. Td.innerHTML+="<input style='width:70%;height:20px;margin-top:-5px' type='text' name='"+field+"[]' value='"+FormJson[key].value[i][field]+"' oninput='$_OnlyNum(this)'>";
  694. break;
  695. case "select":
  696. let selectHTML="<div style='width:100px;'><select name='"+field+"[]' style='width:80px;'>";
  697. for (let option in FormJson[key].item[field].option){
  698. selectHTML+="<option value='"+option+"' ";
  699. if(option==FormJson[key].value[i][field]){ selectHTML+=" selected " }
  700. selectHTML+=">"+FormJson[key].item[field].option[option]+"</option>";
  701. }
  702. selectHTML+="</select>";
  703. Td.innerHTML+= selectHTML
  704. break;
  705. }
  706. Td.innerHTML+="</div></td>";
  707. Td.id="MultipleItemsTD";
  708. Td.style.position="relative";
  709. Td.style.borderTop=0;
  710. Tr.appendChild(Td);
  711. }
  712. Td=document.createElement('td');
  713. Td.style.borderTop=0;
  714. Td.style.textAlign="center";
  715. Td.innerHTML="<span class='TextButton' style='font-size:26px;margin-top:-3px;color:#f70' onclick='iTips.Close();this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);' >×</span>";
  716. //(function(Obj,Class){Obj.addEventListener('click',function (event) {Class.MultipleItemsAddNew(NewTr)});})(SpanAdd,this);
  717. Tr.appendChild(Td);
  718. ItemTable.appendChild(Tr);
  719. }
  720. var Tr=document.createElement('tr');
  721. Tr.style.textAlign="center";
  722. Item.appendChild(ItemTable);
  723. var DivAdd=document.createElement('div');
  724. DivAdd.style.float="left";
  725. DivAdd.style.width=Item.style.width;
  726. DivAdd.style.textAlign="center";
  727. var SpanAdd=document.createElement('span');
  728. SpanAdd.className="TextButton";
  729. SpanAdd.style.fontSize="32px";
  730. SpanAdd.style.fontWeight="400";
  731. SpanAdd.style.marginTop="-3px"
  732. SpanAdd.innerHTML="+";
  733. DivAdd.appendChild(SpanAdd);
  734. div1.appendChild(DivAdd);
  735. (function(Obj,Class){Obj.addEventListener('click',function (event) {Class.MultipleItemsAddNew(NewTr)});})(SpanAdd,this);
  736. div0.appendChild(div1);
  737. break;
  738. case "UploadImg":
  739. div0=document.createElement('div');
  740. div0=AcceptStyle(div0,div0Style);
  741. div1=document.createElement('div');
  742. div1=AcceptStyle(div1,TitleStyle);
  743. div1.innerHTML=FormJson[key].title;
  744. div0.appendChild(div1);
  745. div1=document.createElement('div');
  746. div1=AcceptStyle(div1,ValueStyle);
  747. div1.style.position="relative";
  748. ele=document.createElement('input');
  749. ele.type="hidden";
  750. ele.autocomplete="new-password";
  751. ele.value=FormJson[key].value;
  752. ele.name=key;
  753. div1.appendChild(ele);
  754. div0.appendChild(div1);
  755. var Imgs=FormJson[key].value;
  756. SpanAdd=document.createElement('div');
  757. SpanAdd.id="ImgItems";
  758. SpanAdd.long=key;
  759. SpanAdd.style.float="left";
  760. div0.appendChild(SpanAdd);
  761. var UpImgStyle={position:"relative",cursor:"pointer",width:"80px",height:"60px",border_radius:"3px",text_align:"center",border:"1px solid #ccc",margin_right:"10px",margin_bottom:"10px"};
  762. var ImgItem,ImgSpan,ImgId;
  763. for(let i=0;i<Imgs.length;i++){
  764. ImgSpan=document.createElement('span');
  765. ImgSpan=AcceptStyle(ImgSpan,UpImgStyle);
  766. ImgId=Imgs[i].split("/")[Imgs[i].split("/").length-1];
  767. ImgId=ImgId.split(".")[0];
  768. ImgSpan.id=ImgId;
  769. ImgItem=document.createElement('img');
  770. ImgItem.style.maxWidth="80px";
  771. ImgItem.style.height="100%";
  772. ImgItem.style.maxHeight="60px";
  773. ImgItem.src=Imgs[i];
  774. ImgItem.id="Img"+ImgId;
  775. ImgSpan.appendChild(ImgItem);
  776. ImgDelIcon(ImgSpan);
  777. SpanAdd.appendChild(ImgSpan);
  778. ImgSpan.addEventListener('mouseover', function() {document.getElementById("Del"+this.id).style.display="block";});
  779. ImgSpan.addEventListener('mouseout', function() {document.getElementById("Del"+this.id).style.display="none";});
  780. }
  781. div1.appendChild(SpanAdd);
  782. var SpanAddStyle={float:"left",text_align:"center",padding_top:"13px",height:"47px",font_size:"22px",font_weight:"600",width:"80px",border_radius:"3px",border:"1px solid #ccc",margin_bottom:"10px"};
  783. SpanAdd=document.createElement('span');
  784. SpanAdd.className="TextButton";
  785. SpanAdd.innerHTML="+";
  786. SpanAdd=AcceptStyle(SpanAdd,SpanAddStyle);
  787. ele=document.createElement('input');
  788. ele.type="file";
  789. ele.accept=".jpg,.png,.jpeg,.gif";
  790. ele.style.display="none";
  791. ele.onchange=(function(){UploadImg(ele,FormJson[key].UploadPath,UpImgStyle,FormJson[key].SubmitBnt)});
  792. SpanAdd.appendChild(ele);
  793. div1.appendChild(SpanAdd);
  794. SpanAdd.onclick=(function(){ele.click();});
  795. div1=document.createElement('div');
  796. div1=AcceptStyle(div1,TipsStyle);
  797. div1.innerHTML=FormJson[key].tips;
  798. div0.appendChild(div1);
  799. this.Form.appendChild(div0);
  800. break;
  801. }
  802. }
  803. (function(Obj,Tips){Obj.addEventListener('keydown',function (event){Tips.Close()});})(Dom,this.Tips);
  804. Dom.appendChild(this.Form);
  805. }
  806. MultipleItemsAddNew(HTML){
  807. var NewTr= document.getElementById("MultipleItems").insertRow();
  808. NewTr.innerHTML=HTML;
  809. this.Tips.Close();
  810. }
  811. Submit(){
  812. var Check={MobTel:{RegExp:/^1[3456789]\d{9}$/,Tips:"手机号码格式不正确"},Email:{RegExp:/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,Tips:"电子邮箱格式不正确"},IdCard:{RegExp:/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,Tips:"身份证号码格式不正确"},Required:{RegExp:/\S/,Tips:"内容不能为空"},LetterFirst:{RegExp:/^[a-zA-Z][-_a-zA-Z0-9]{5,15}/,Tips:"必须以英文字母开头,长度至少6位"},NoPunct:{RegExp:/^[\u4E00-\u9FA5A-Za-z0-9]+$/,Tips:"不能包括标点、空格等特殊符号"}};
  813. for (let key in this.Json){
  814. if(this.Json[key].type=="CheckMultiple"){document.getElementById(key+"CheckMultiple").style.display="none"; }
  815. if(this.Json[key].type=="text" || this.Json[key].type=="CheckMultiple" || this.Json[key].type=="password" || this.Json[key].type=="textarea" || this.Json[key].type=="price"){
  816. var ele=document.getElementsByName(key)[0];
  817. for (let Reg in Check){
  818. if(this.Json[key].template.indexOf(Reg)>=0){
  819. if(!Check[Reg].RegExp.test(ele.value.trim())){
  820. this.Tips.Show(ele,"<span class='Sigh'>!</span> <span>"+Check[Reg].Tips+"</span>");
  821. ele.focus()
  822. return false;
  823. }
  824. }
  825. }
  826. }
  827. }
  828. if(document.getElementById("MultipleItems")){
  829. var MultipleItems=document.getElementById("MultipleItems");
  830. var ItemInputs= MultipleItems.getElementsByTagName("INPUT");//得到input数组
  831. if(ItemInputs.length<=0){
  832. this.Tips.Show(MultipleItems,"<span class='Sigh'>!</span> <span>至少添加一个返回值</span>","20px","-4px");
  833. return false;
  834. }
  835. for(let i=0;i<ItemInputs.length;i++){
  836. //ItemInputs[i].value="";
  837. if(ItemInputs[i].value.trim()==""){
  838. this.Tips.Show(ItemInputs[i],"<span class='Sigh'>!</span> <span>字段不能为空</span>","20px","-4px");
  839. ItemInputs[i].focus();
  840. return false;
  841. }
  842. }
  843. }
  844. this.Form.target="FormEditorSave";
  845. this.Form.action=this.Src;
  846. this.Form.submit();
  847. return true;
  848. }
  849. ReEdit(){
  850. }
  851. Debug(flag=false){
  852. if(flag){
  853. this.IFRAME.style.position="fixed";
  854. this.IFRAME.style.bottom="0";
  855. this.IFRAME.style.width="50%";
  856. this.IFRAME.style.height="100px";
  857. this.IFRAME.style.display="block";
  858. }
  859. }
  860. }
  861. function SetImgValue(ImgDom){
  862. var Imgs=ImgDom.getElementsByTagName('img');
  863. var ImgValue="";
  864. for(let i=0;i<Imgs.length;i++){
  865. ImgValue+=Imgs[i].src;
  866. if(i<Imgs.length-1){
  867. ImgValue+=",";
  868. }
  869. }
  870. document.getElementsByName(ImgDom.long)[0].value=ImgValue;
  871. }
  872. function ImgDel(ImgSpan){
  873. var FormImg = new FormData();
  874. FormImg.append("Token",$_COOKIE("UserToken"));
  875. FormImg.append("Img",document.getElementById("Img"+ImgSpan.id).src);
  876. var Url="https://api.winnto.com/application/user/image/delete";
  877. var xmlhttp;
  878. xmlhttp=new XMLHttpRequest();
  879. xmlhttp.onreadystatechange=function(D){
  880. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  881. if (xmlhttp.responseText!=""){
  882. var Re=JSON.parse(xmlhttp.responseText);
  883. if(Re.code=="0"){
  884. window.top.WX.AlertMsg.Show(Re.msg,1);
  885. } else{
  886. window.top.WX.AlertMsg.Show(Re.msg,0);
  887. }
  888. var ImgDom=ImgSpan.parentNode;
  889. document.getElementById("ImgItems").removeChild(ImgSpan);
  890. SetImgValue(ImgDom);
  891. }
  892. }
  893. };
  894. xmlhttp.open("POST",Url);
  895. xmlhttp.send(FormImg);
  896. }
  897. function ImgDelIcon(ImgSpan){
  898. var ImgDelStyle={display:"none",position:"absolute",cursor:"pointer",color:"#f00",font_size:"26px",left:"0",top:"-10px",font_weight:"500",text_shadow:"0 1px #fff, 1px 0 #fff, -1px 0 #fff, 0 -1px #fff"};
  899. var ImgDelSpan=document.createElement('span');
  900. ImgDelSpan.innerHTML="×";
  901. ImgDelspan=AcceptStyle(ImgDelSpan,ImgDelStyle);
  902. ImgDelspan.id="Del"+ImgSpan.id;
  903. ImgDelspan.addEventListener('click', function(){ImgDel(ImgSpan);});
  904. ImgSpan.appendChild(ImgDelspan)
  905. }
  906. function UploadImg(File,Path,InsertStyle,SubmitBnt){
  907. var Accept=".jpg,.png,.jpeg,.gif";
  908. var FileSize=1024*1024
  909. var Ext=File.files[0].name.split(".")[File.files[0].name.split(".").length-1];
  910. if(Accept.indexOf(Ext)<0){
  911. alert("只允许上传图片文件,请选择正确文件类型!");
  912. return;
  913. }
  914. if(File.files[0].size>1024*1024){
  915. alert("文件大小不能超过1M,请进行优化处理");
  916. return;
  917. }
  918. document.getElementById(SubmitBnt).style.background="#999";
  919. document.getElementById(SubmitBnt).disabled=true;
  920. var Uping = document.createElement("img");
  921. Uping.src="//open.winnto.com/image/loading/1.gif";
  922. Uping.id="Uping";
  923. Uping.style.width="40px";
  924. Uping.style.position="absolute";
  925. Uping.style.left="20px";
  926. Uping.style.top="10px";
  927. var ImgSpan = document.createElement("span");
  928. ImgSpan=AcceptStyle(ImgSpan,InsertStyle);
  929. var ImgFile = document.createElement("img");
  930. ImgFile.style.maxWidth="80px";
  931. ImgFile.style.height="100%";
  932. ImgFile.style.maxHeight="60px";
  933. ImgFile.style.filter="brightness(50%)";
  934. ImgFile.src=window.URL.createObjectURL(File.files[0]) ;
  935. ImgSpan.appendChild(ImgFile);
  936. ImgSpan.appendChild(Uping);
  937. document.getElementById("ImgItems").appendChild(ImgSpan);
  938. var FormImg = new FormData();
  939. FormImg.append("UploadFile",File.files[0]);
  940. FormImg.append("Token",$_COOKIE("UserToken"));
  941. FormImg.append("Path",Path);
  942. var Url="https://api.winnto.com/application/user/image/upload";
  943. var xmlhttp;
  944. xmlhttp=new XMLHttpRequest();
  945. xmlhttp.onreadystatechange=function(D){
  946. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  947. if (xmlhttp.responseText!=""){
  948. document.getElementById(SubmitBnt).style.background="#294";
  949. document.getElementById(SubmitBnt).disabled=false;
  950. var Re=JSON.parse(xmlhttp.responseText);
  951. if(Re.code=="0"){
  952. window.top.WX.AlertMsg.Show(Re.msg,1);
  953. ImgSpan.removeChild(document.getElementById("Uping"));
  954. ImgFile.style.filter="brightness(100%)";
  955. ImgFile.src=Re.imgurl;
  956. var ImgId=Re.imgurl.split("/")[Re.imgurl.split("/").length-1];
  957. ImgId=ImgId.split(".")[0];
  958. ImgSpan.id=ImgId;
  959. ImgFile.id="Img"+ImgId;
  960. ImgDelIcon(ImgSpan);
  961. ImgSpan.addEventListener('mouseover', function() {document.getElementById("Del"+this.id).style.display="block";});
  962. ImgSpan.addEventListener('mouseout', function() {document.getElementById("Del"+this.id).style.display="none";});
  963. SetImgValue(ImgSpan.parentNode);
  964. } else{
  965. window.top.WX.AlertMsg.Show(Re.msg,0);
  966. ImgSpan.removeChild(document.getElementById("Uping"));
  967. var UpError = document.createElement("img");
  968. UpError.src="//open.winnto.com/image/icon/error.png";
  969. UpError.style.width="40px";
  970. UpError.style.position="absolute";
  971. UpError.style.left="20px";
  972. UpError.style.top="10px";
  973. ImgSpan.appendChild(UpError);
  974. }
  975. }
  976. }
  977. };
  978. xmlhttp.open("POST",Url);
  979. xmlhttp.send(FormImg);
  980. }
  981. class PageNavigat{
  982. Init(Dom,Conf,Color="#257",UrlType="hash"){
  983. var html="";
  984. var PageCount=Math.ceil(Conf.record_count / Conf.page_size);
  985. var IconSize="16px"
  986. var Left=document.createElement("span");
  987. Left.style.float="left";
  988. Left.innerHTML="<span>本页 "+Conf.current_page_record_count+" 条,共 "+Conf.record_count+" 条,分 "+PageCount+" 页,每页</span>";
  989. Left.innerHTML+=" <span><select id='SelectPageSize' style='width:auto;height:25px;' ><option value='10'>10</option><option value='20'>20</option><option value='50'>50</option><option value='100'>100</option></select> </span> <span>条</span>";
  990. Dom.appendChild(Left);
  991. var e=document.getElementById("SelectPageSize");
  992. for(let j=0;j<e.options.length;j++){if(e.options[j].value==Conf.page_size){e.options[j].selected = true;}}
  993. e.onchange=function (event){
  994. var param="page=1&size="+e.value+CreatUrlParam(document.getElementById("SearchBar"));
  995. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  996. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,"1",e.value) ; }
  997. };
  998. this.SelectPageSize= e;
  999. var Right=document.createElement("span");
  1000. Right.style.float="right";
  1001. var F=ICON.First(IconSize,Color); // 首页
  1002. F.style.marginRight="20px";
  1003. if(Conf.page_index<=1){
  1004. F.style.cursor="not-allowed";
  1005. }else{
  1006. F.onclick=function (event){
  1007. var param="page=1&size="+Conf.page_size.toString()+CreatUrlParam(document.getElementById("SearchBar"));
  1008. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  1009. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,"1",Conf.page_size.toString()) ; }
  1010. };
  1011. }
  1012. this.FirstP=F;
  1013. Right.appendChild(this.FirstP);
  1014. F=ICON.Prev(IconSize,Color); //上一页
  1015. F.style.marginRight="20px";
  1016. if(Conf.page_index<=1){
  1017. F.style.cursor="not-allowed";
  1018. }else{
  1019. F.onclick=function (event){
  1020. var Page=parseInt(Conf.page_index)-1;
  1021. var param="page="+Page.toString()+"&size="+Conf.page_size.toString()+CreatUrlParam(document.getElementById("SearchBar"));
  1022. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  1023. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,Page.toString(),Conf.page_size.toString()) ; }
  1024. }
  1025. }
  1026. this.PrevP=F;
  1027. Right.appendChild(this.PrevP);
  1028. var PageInput=document.createElement("input");//输入跳转 页码
  1029. PageInput.type="text";
  1030. PageInput.style.width="40px";
  1031. PageInput.style.border="1px solid "+Color;
  1032. PageInput.style.height="20px";
  1033. PageInput.style.textAlign="center";
  1034. PageInput.placeholder=Conf.page_index.toString()+"/"+PageCount.toString();
  1035. PageInput.oninput=function (event){
  1036. $_OnlyNum(PageInput);
  1037. if(PageInput.value>PageCount)PageInput.value=PageCount;
  1038. }
  1039. Right.appendChild( PageInput);
  1040. F=ICON.Next(IconSize,Color); //下一页
  1041. F.style.marginLeft=F.style.marginRight="20px";
  1042. if(Conf.page_index>=PageCount){
  1043. F.style.cursor="not-allowed";
  1044. }else{
  1045. F.onclick=function (event){
  1046. var Page=parseInt(Conf.page_index)+1;
  1047. var param="page="+Page.toString()+"&size="+Conf.page_size.toString()+CreatUrlParam(document.getElementById("SearchBar"));
  1048. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  1049. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,Page.toString(),Conf.page_size.toString()) ; }
  1050. }
  1051. }
  1052. this.NextP=F;
  1053. Right.appendChild( this.NextP);
  1054. F=ICON.Last(IconSize,Color); //末页
  1055. F.style.marginRight="20px";
  1056. if(Conf.page_index>=PageCount){
  1057. F.style.cursor="not-allowed";
  1058. }else{
  1059. F.onclick=function (event){
  1060. var param="page="+PageCount.toString()+"&size="+Conf.page_size.toString()+CreatUrlParam(document.getElementById("SearchBar"));
  1061. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  1062. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,PageCount.toString(),Conf.page_size.toString()) ; }
  1063. };
  1064. }
  1065. this.LastP=F;
  1066. Right.appendChild(this.LastP);
  1067. var PageGO=document.createElement("input");
  1068. PageGO.style.border="0";
  1069. PageGO.style.backgroundColor=Color;
  1070. PageGO.style.height="30px";
  1071. PageGO.style.cursor="pointer";
  1072. PageGO.style.borderRadius="5px";
  1073. PageGO.style.color="#fff";
  1074. PageGO.type="button";
  1075. PageGO.value="GO";
  1076. this.PageInput=PageInput;
  1077. PageGO.onclick=function (event){
  1078. if(PageInput.value.trim()!=""){
  1079. var param="page="+PageInput.value.trim()+"&size="+Conf.page_size.toString()+CreatUrlParam(document.getElementById("SearchBar"));
  1080. if(UrlType=="hash"){window.location.hash=window.location.hash.split("?")[0]+"?"+param;}
  1081. if(UrlType=="href"){ window.location.href= SetPageUrl(window.location.href,PageInput.value.trim(),Conf.page_size.toString()) ; }
  1082. }else{
  1083. PageInput.focus();
  1084. }
  1085. };
  1086. this.PageGO=PageGO;
  1087. Right.appendChild(this.PageGO);
  1088. Dom.appendChild(Right);
  1089. this.Dom=Dom;
  1090. }
  1091. }
  1092. var SearchStyle={};
  1093. function SetPageUrl(URL,PageIndex,PageSize){
  1094. var Href=URL.split("?");
  1095. var PR="";
  1096. var j=0;
  1097. if(Href.length>1){
  1098. var P=Href[1].split("&");
  1099. for(let i=0;i<P.length;i++){
  1100. if(P[i].indexOf("page")<0 && P[i].indexOf("size")<0 ){
  1101. var D="";
  1102. if(j>0){D="&"}
  1103. PR+=D+P[i];
  1104. j++;
  1105. }
  1106. }
  1107. PR+="&page="+PageIndex;
  1108. }else{
  1109. PR+="page="+PageIndex;
  1110. }
  1111. PR+="&size="+PageSize;
  1112. return Href[0]+"?"+PR;
  1113. }
  1114. class SearchBar{
  1115. Init(Dom,Set,PageSize=20,color="#f60"){
  1116. this.PageSize=PageSize;
  1117. var Style={white_space:"nowrap",overflow:"hidden",border_radius:"5px",border:"1px solid "+color};
  1118. var SearchBar=document.createElement('span');
  1119. SearchBar=AcceptStyle(SearchBar,Style);
  1120. var InputDateStyle={width:"auto",display:"inline-block",vertical_align:"middle",height:"28px",border:"1px solid "+color,background:"#fff",color:"#257",margin_right:"10px"};
  1121. var SpanStyle={display:"inline-block",vertical_align:"middle","margin_right":"10px"};
  1122. var SelectStyle={width:"auto",display:"inline-block",vertical_align:"middle",height:"40px",border:"1px solid "+color,background:"#fff",color:"#257",margin_right:"10px"};
  1123. SearchStyle=SelectStyle;
  1124. var InputStyle={font_size:"16px",display:"inline-block",vertical_align:"middle",border:"0",width:"300px",height:"30px",padding:"2px",border_radius:"3px"};
  1125. var Select,opt,Input;
  1126. for(let i=0;i<Set.length;i++){
  1127. switch(Set[i].type){
  1128. case "SelectCity":
  1129. var SLC=document.createElement('span')
  1130. SLC.id="SelectCityDom";
  1131. var City=new SelectCity;
  1132. City.Init(SLC,"选择省份","选择地市","选择县区",SelectStyle,"Y");
  1133. Dom.appendChild(SLC);
  1134. break;
  1135. case "select":
  1136. Select=document.createElement('select');
  1137. Select=AcceptStyle(Select,SelectStyle);
  1138. for(let j=0;j<Set[i].option.length;j++){
  1139. opt=new Option(Set[i].option[j].text,Set[i].option[j].value);
  1140. Select.options.add(opt);
  1141. }
  1142. Select.id=Set[i].id;
  1143. Dom.appendChild(Select);
  1144. break;
  1145. case "SelectIntegrationType":
  1146. var SLC=document.createElement('span')
  1147. SLC.id="SelectIntegrationTypeDom";
  1148. var IntegrationType=new SelectIntegrationType;
  1149. IntegrationType.Init(SLC,"选择省份","选择地市",SelectStyle,"Y");
  1150. Dom.appendChild(SLC);
  1151. break;
  1152. case "input":
  1153. var Input=document.createElement('input');
  1154. Input.placeholder=Set[i].placeholder;
  1155. Input.id=Set[i].id;
  1156. Input=AcceptStyle(Input,InputStyle);
  1157. SearchBar.appendChild(Input);
  1158. break;
  1159. case "date":
  1160. var Input=document.createElement('input');
  1161. Input.type='date';
  1162. Input.id=Set[i].id;
  1163. Input.value=Set[i].value;
  1164. Input=AcceptStyle(Input,InputDateStyle);
  1165. Dom.appendChild(Input);
  1166. break;
  1167. case "text":
  1168. var Text=document.createElement('span');
  1169. Text=AcceptStyle(Text,SpanStyle);
  1170. Text.innerHTML=Set[i].value;
  1171. Dom.appendChild(Text);
  1172. break;
  1173. }
  1174. }
  1175. var Bnt=ICON.Search("#fff",color);
  1176. Bnt.onclick=this.Search;
  1177. this.bnt=Bnt;
  1178. SearchBar.appendChild(this.bnt);
  1179. Dom.appendChild(SearchBar);
  1180. }
  1181. Search(e){
  1182. if(document.getElementById("SelectPageSize")){
  1183. this.PageSize=document.getElementById("SelectPageSize").value;
  1184. }
  1185. window.location.hash=window.location.hash.split("?")[0]+"?page=1&size="+this.PageSize+CreatUrlParam(document.getElementById("SearchBar"))
  1186. }
  1187. }
  1188. class DataTable{
  1189. Init(Dom,DataJson,TableHeader,TableRows,Style={HeaderBGColor:"#f60",HeaderColor:"#fff",BorderColor:"#f60",RowHeight:"50px",RowBGColor:"#999",RowHover:"#f7f7f7",RowColor:"#fff"}){
  1190. this.Table=document.createElement('table');
  1191. this.Table.style.borderTop="5px solid "+Style.BorderColor;
  1192. this.Table.id="Table";
  1193. this.BorderColor=Style.BorderColor;
  1194. if(Style.RowColor){this.RowColor=Style.RowColor}else{this.RowColor="#fff"};
  1195. this.RowBGColor=Style.RowBGColor
  1196. this.Header=document.createElement('tr');
  1197. this.Header.style.color=Style.HeaderColor;
  1198. this.Header.style.height=Style.RowHeight;
  1199. this.Header.style.fontWeight="500";
  1200. this.Header.style.backgroundColor=Style.HeaderBGColor;
  1201. this.Style=Style;
  1202. this.Empty=document.createElement('div');
  1203. this.Empty.style.position="absolute";
  1204. this.Empty.style.width="90%";
  1205. this.Empty.style.marginTop="120px";
  1206. this.Empty.style.display="none";
  1207. this.Empty.style.textAlign="center";
  1208. this.Empty.innerHTML="<div style='font-size:22px;color:#f60'>没有符合条件的数据</div>";
  1209. Dom.appendChild(this.Empty);
  1210. var html="";
  1211. for (let key in TableHeader){
  1212. switch (TableHeader[key]["type"]){
  1213. case "text":
  1214. html+="<td nowrap='nowrap'>"+TableHeader[key]["text"]+"</td>";
  1215. break;
  1216. case "checkbox":
  1217. html+="<td><input type='checkbox' "+TableHeader[key]["event"]+" id='"+TableHeader[key]["id"]+"'>"+TableHeader[key]["text"]+"</td>";
  1218. break;
  1219. }
  1220. }
  1221. var Rows=[];
  1222. for (let i=0;i<TableRows.operation.length;i++){html+="<td></td>";}
  1223. this.Header.innerHTML=html;
  1224. this.Table.appendChild(this.Header);
  1225. var CheckStatus=[""," checked "];
  1226. var Row;
  1227. if(DataJson.length==0){
  1228. this.Empty.style.display="block";
  1229. }
  1230. var OnLine=["<span style='color:#f00;font-size:22px'>☒</span>","<span style='color:#297;font-size:22px'>⇄</span>","<span style='color:#297;font-size:22px'>?</span>"];
  1231. for (let i=0;i<DataJson.length;i++){
  1232. Row=document.createElement('tr');
  1233. Row.style.height=Style.RowHeight;
  1234. Row.style.backgroundColor=Style.RowBGColor;
  1235. html="";
  1236. for (let key in TableHeader){
  1237. if(TableRows[key]){
  1238. switch (TableRows[key].type){
  1239. case "text":html+="<td><div class='OHI' >"+DataJson[i][key]+"</div></td>";break;
  1240. case "online":html+="<td><div class='OHI' >"+OnLine[DataJson[i][key]]+"</div></td>";break;
  1241. case "enum":html+="<td><div class='OHI' >"+TableRows[key].enum[DataJson[i][key]]+"</div></td>";break;
  1242. case "price":html+="<td><div class='OHI' style='font-weight:600'>"+ parseFloat(DataJson[i][key]).toFixed(2) +"</div></td>";break;
  1243. case "SetField":
  1244. var event=TableRows[key].target;
  1245. var Title=TableRows[key].title;
  1246. for(let x=0;x<TableRows[key].param.length;x++){
  1247. var reg=new RegExp( "\\["+x.toString()+"\\]" ,"g");
  1248. event=event.replace(reg, DataJson[i][ TableRows[key].param[x] ] );
  1249. Title=Title.replace(reg, DataJson[i][ TableRows[key].param[x] ] );
  1250. }
  1251. var reg=new RegExp( "\\[0\\]" ,"g");
  1252. html+="<td >"+DataJson[i][key]+"<span class='TextButton' style='margin-left:20px;' onclick='WX.Dialog.Show(\""+event+"\",\""+Title+"\")' > 🖊</span></td>";
  1253. break;
  1254. case "StatusList":
  1255. html+="<td style='color:"+ColorArray[DataJson[i][key]]+"'>"+TableRows[key].item[DataJson[i][key]].text+"</td>";
  1256. break;
  1257. case "checkbox":html+="<td><input type='checkbox' onclick='this.checked=!this.checked' " +CheckStatus[DataJson[i][key]]+ " value='"+DataJson[i][TableRows[key].value]+"' "+TableRows[key].event+" name='"+TableRows[key].element_name+"'></td>";
  1258. break;
  1259. case "img":
  1260. html+="<td ><img src='"+DataJson[i][key]+"' style='width:"+TableRows[key].size[0]+";height:"+TableRows[key].size[1]+"'></td>";
  1261. break;
  1262. }
  1263. }
  1264. }
  1265. for (let j=0;j<TableRows.operation.length;j++){
  1266. var event=TableRows.operation[j]["event"];
  1267. for(let x=0;x<TableRows.operation[j]["param"].length;x++){
  1268. var reg=new RegExp( "\\["+x.toString()+"\\]" ,"g");
  1269. event=event.replace(reg, DataJson[i][ TableRows.operation[j]["param"][x]] );
  1270. //if(TableRows.operation[j].type=="link")alert(TableRows.operation[j]["param"][x]);
  1271. }
  1272. switch (TableRows.operation[j].type){
  1273. case "textbnt":html+="<td style='text-align:center'><span class='TextButton' "+event+">"+TableRows.operation[j]["text"]+"</span></td>";break;
  1274. case "link":html+="<td style='text-align:center'><a href='"+event+"'>"+TableRows.operation[j]["text"]+"</a></td>";break;
  1275. }
  1276. }
  1277. Row.innerHTML=html;
  1278. Row.id=DataJson[i]["id"];
  1279. Row.addEventListener('mouseover',function (event) {document.getElementById(DataJson[i]["id"]).style.backgroundColor=Style.RowHover;});
  1280. Row.addEventListener('mouseout',function (event) {document.getElementById(DataJson[i]["id"]).style.backgroundColor=Style.RowBGColor;});
  1281. this.Table.appendChild(Row);
  1282. Rows[i]={id:DataJson[i].id};
  1283. }
  1284. this.Rows=Rows;
  1285. Dom.appendChild(this.Table);
  1286. }
  1287. Delete(Id){
  1288. var Row=document.getElementById(Id);
  1289. Row.parentNode.removeChild(Row);
  1290. }
  1291. Insert(Json){
  1292. var NewTr= this.Table.insertRow(1);
  1293. NewTr.id=Json.id;
  1294. NewTr.style.height=this.Style.RowHeight;
  1295. (function(Row,Dom){
  1296. Row.addEventListener('mouseover',function (event) {document.getElementById(Json["id"]).style.backgroundColor=Dom.Style.RowHover;});
  1297. Row.addEventListener('mouseout',function (event) {document.getElementById(Json["id"]).style.backgroundColor=Dom.Style.RowBGColor;});
  1298. })(NewTr,this);
  1299. NewTr.innerHTML="";
  1300. for (let key in Json){
  1301. if(key!="id"){
  1302. NewTr.innerHTML+="<td>"+Json[key]+"</td>";
  1303. }
  1304. }
  1305. this.Empty.style.display="none";
  1306. }
  1307. Update(Json){
  1308. var Row=document.getElementById(Json.id);
  1309. Row.innerHTML="";
  1310. for (let key in Json){
  1311. if(key!="id"){
  1312. Row.innerHTML+="<td>"+Json[key]+"</td>";
  1313. }
  1314. }
  1315. }
  1316. setHeaderBGColor(Color="#f60"){this.Header.style.backgroundColor=Color;}
  1317. setHeaderColor(Color="#fff"){this.Header.style.color=Color;}
  1318. setRowColor(Color="#fff"){this.RowColor=Color;for(let i=0;i<this.Rows.length;i++){document.getElementById(this.Rows[i].id).style.color=Color;}
  1319. }
  1320. setRowBGColor(BGColor="#fff",Hover="auto"){
  1321. this.RowBGColor=BGColor;
  1322. for(var i=0;i<this.Rows.length;i++){
  1323. var Row=document.getElementById(this.Rows[i].id);
  1324. Row.style.backgroundColor=BGColor;
  1325. (function(Row){
  1326. Row.addEventListener('mouseover',function (event) {Row.style.backgroundColor=Hover;});
  1327. Row.addEventListener('mouseout',function (event) {Row.style.backgroundColor=BGColor;});
  1328. })(Row);
  1329. }
  1330. }
  1331. setTableBorder(Color="#f60",Width="1px"){this.Table.style.border=Width+" solid "+Color;}
  1332. setTable3D(Flag="Y"){
  1333. if(Flag=="Y"){
  1334. this.Table.style.boxShadow="0px 1px 18px rgba(0, 0, 0, 0.5)";
  1335. this.Table.style.borderLeft="0";
  1336. this.Table.style.borderRight="0";
  1337. this.Table.style.borderBottom="5px solid " +this.RowBGColor;
  1338. }else{
  1339. this.Table.style.boxShadow="none";
  1340. this.Table.style.borderLeft="1px solid " +this.BorderColor;
  1341. this.Table.style.borderRight="1px solid "+this.BorderColor;
  1342. this.Table.style.paddingBottom="5px";
  1343. this.Table.style.borderBottom="1px solid " +this.BorderColor;
  1344. this.Table.style.backgroundColor=this.RowBGColor;
  1345. }
  1346. }
  1347. }
  1348. class RowTable{
  1349. Init(Dom,DataJson,DataRows,Operation,Style={HeaderBGColor:"#f60",HeaderColor:"#fff",BorderColor:"#f60",RowHeight:"50px",RowBGColor:"#999",RowHover:"#f7f7f7",RowColor:"#fff"}){
  1350. this.Table=document.createElement('table');
  1351. this.Table.style.borderTop="5px solid "+Style.BorderColor;
  1352. this.Table.id="Table";
  1353. this.BorderColor=Style.BorderColor;
  1354. if(Style.RowColor){this.RowColor=Style.RowColor}else{this.RowColor="#fff"};
  1355. this.RowBGColor=Style.RowBGColor
  1356. this.Header=document.createElement('tr');
  1357. this.Header.style.color=Style.HeaderColor;
  1358. this.Header.style.height=Style.RowHeight;
  1359. this.Header.style.fontWeight="500";
  1360. this.Header.style.backgroundColor=Style.HeaderBGColor;
  1361. this.Style=Style;
  1362. this.Empty=document.createElement('div');
  1363. this.Empty.style.position="absolute";
  1364. this.Empty.style.width="90%";
  1365. this.Empty.style.marginTop="120px";
  1366. this.Empty.style.display="none";
  1367. this.Empty.style.textAlign="center";
  1368. this.Empty.innerHTML="<div style='font-size:22px;color:#f60'>没有符合条件的数据</div>";
  1369. Dom.appendChild(this.Empty);
  1370. var html="";
  1371. if(DataJson.length>0 && DataJson[0].subset!=undefined){ html="<td nowrap='nowrap'></td>";}
  1372. for (let key in DataRows){
  1373. switch (DataRows[key].header.type){
  1374. case "text":
  1375. html+="<td nowrap='nowrap' >"+DataRows[key].header.text+"</td>";
  1376. break;
  1377. case "checkbox":
  1378. html+="<td><input type='checkbox' "+DataRows[key].header.event+" id='"+DataRows[key].header.id+"'>"+DataRows[key].text+"</td>";
  1379. break;
  1380. }
  1381. }
  1382. for (let i=0;i<Operation.length;i++){
  1383. html+="<td style='text-align:center'>"+Operation[i].text+"</td>";
  1384. }
  1385. this.Header.innerHTML=html;
  1386. this.Table.appendChild(this.Header);
  1387. if(DataJson.length==0){ this.Empty.style.display="block";}
  1388. var Row,RowSub;
  1389. var x=0;
  1390. for (let i=0;i<DataJson.length;i++){
  1391. Row=document.createElement('tr');
  1392. Row.id=DataJson[i]["id"];
  1393. Row.style.height=Style.RowHeight;
  1394. Row.style.backgroundColor=Style.RowBGColor;
  1395. html="";
  1396. if(DataJson[i].subset!=undefined){
  1397. html="<td nowrap='nowrap' style='width:1%'><span class='TextButton' style='font-size:12px' onclick='ShowSub("+i.toString()+","+DataJson[i].subset.length+")' >〉</span> </td>";
  1398. }
  1399. Row.innerHTML=html+this.InsetRow(DataJson[i],DataRows,Operation)
  1400. Row.addEventListener('mouseover',function (event) {document.getElementById(DataJson[i]["id"]).style.backgroundColor=Style.RowHover;});
  1401. Row.addEventListener('mouseout',function (event) {document.getElementById(DataJson[i]["id"]).style.backgroundColor=Style.RowBGColor;});
  1402. this.Table.appendChild(Row);
  1403. if(DataJson[i].subset!=undefined){
  1404. for(let j=0;j<DataJson[i].subset.length;j++){
  1405. RowSub=document.createElement('tr');
  1406. RowSub.id="Subset"+i.toString()+j.toString();
  1407. RowSub.style.height="50px";
  1408. RowSub.style.fontSize="15px";
  1409. RowSub.style.color="#f60";
  1410. RowSub.style.visibility="collapse";
  1411. RowSub.style.backgroundColor="#ececec";
  1412. RowSub.style.border=0;
  1413. RowSub.innerHTML="<td></td>"+this.InsetRow(DataJson[i].subset[j],DataRows,Operation);
  1414. this.Table.appendChild(RowSub);
  1415. }
  1416. }
  1417. }
  1418. Dom.appendChild(this.Table);
  1419. }
  1420. InsetRow(DataRecord,DataRows,Operation){
  1421. var OnLine=["<span style='color:#f00;font-size:22px'>☒</span>","<span style='color:#297;font-size:22px'>⇄</span>","<span style='color:#297;font-size:20px;font-weight:500'>?</span>"];
  1422. var RecordHtml="";
  1423. for (let key in DataRows){
  1424. switch (DataRows[key].value.type){
  1425. case "img": RecordHtml+="<td ><img src='"+DataRecord[key]+"' style='width:"+DataRows[key].value.size[0]+";height:"+DataRows[key].value.size[1]+"'></td>";break;
  1426. case "online":RecordHtml+="<td><div class='OHI' >"+OnLine[DataRecord[key]]+"</div></td>";break;
  1427. case "text":
  1428. var Highlight="";
  1429. if( !isNaN(DataRecord[key]) && DataRecord[key]!="0" && DataRecord[key].length<9){Highlight=" style='font-weight:500'"; }
  1430. if( DataRecord[key]=="0"){Highlight=" style='color:#777'";}
  1431. RecordHtml+="<td><div class='OHI' "+Highlight+">"+DataRecord[key]+"</div></td>";
  1432. break;
  1433. case "segment":RecordHtml+="<td><div class='OHI' "+Highlight+">"+DataRecord[DataRows[key].value.fields[0]]+" 至 "+DataRecord[DataRows[key].value.fields[1]]+"</div></td>";break;
  1434. case "json":RecordHtml+="<td><div class='OHI' "+Highlight+">"+DataRows[key].value.source[DataRecord[key]]+"</div></td>";break;
  1435. case "checkbox":let Checked="";if(DataRecord[key]!="0"){Checked="checked";}RecordHtml+="<td><input type='checkbox' style='pointer-events:none' "+Checked+"></td>"; break;
  1436. case "selectcheckbox":RecordHtml+="<td><input type='checkbox' "+DataRows[key].event+" value='"+DataRecord[key]+"'></td>";break;
  1437. case "SetField":
  1438. var event=DataRows[key].value.target;
  1439. var Title=DataRows[key].value.title;
  1440. for(let x=0;x<DataRows[key].value.param.length;x++){
  1441. var reg=new RegExp( "\\["+x.toString()+"\\]" ,"g");
  1442. event=event.replace(reg, DataRecord[ DataRows[key].value.param[x] ] );
  1443. Title=Title.replace(reg, DataRecord[ DataRows[key].value.param[x] ] );
  1444. }
  1445. var reg=new RegExp( "\\[0\\]" ,"g");
  1446. RecordHtml+="<td >"+DataRecord[key]+"<span class='TextButton' style='margin-left:20px;' onclick='WX.Dialog.Show(\""+event+"\",\""+Title+"\")' > 🖊</span></td>";
  1447. break;
  1448. case "AtGet":
  1449. var event=DataRows[key].value.target;
  1450. var Title=DataRows[key].value.title;
  1451. for(let x=0;x<DataRows[key].value.param.length;x++){
  1452. var reg=new RegExp( "\\["+x.toString()+"\\]" ,"g");
  1453. event=event.replace(reg, DataRecord[ DataRows[key].value.param[x] ] );
  1454. Title=Title.replace(reg, DataRecord[ DataRows[key].value.param[x] ] );
  1455. }
  1456. var reg=new RegExp( "\\[0\\]" ,"g");
  1457. RecordHtml+="<td >"+DataRecord[key]+"<span class='TextButton' style='margin-left:20px;' onclick='WX.Dialog.Show(\""+event+"\",\""+Title+"\")' > 🖊</span></td>";
  1458. break;
  1459. }
  1460. }
  1461. for (let j=0;j<Operation.length;j++){
  1462. var event=Operation[j]["event"];
  1463. for(let x=0;x<Operation[j]["param"].length;x++){
  1464. var reg=new RegExp( "\\["+x.toString()+"\\]" ,"g");
  1465. event=event.replace(reg, DataRecord[ Operation[j]["param"][x] ] );
  1466. }
  1467. switch (Operation[j].type){
  1468. case "disabled":RecordHtml+="<td style='text-align:center'><span style='color:#999'>"+Operation[j]["text"]+"</span></td>";break;
  1469. case "textbnt":RecordHtml+="<td style='text-align:center'><span class='TextButton' "+event+">"+Operation[j]["text"]+"</span></td>";break;
  1470. case "link":RecordHtml+="<td style='text-align:center'><a href='"+event+"' target='"+Operation[j]["target"]+"'>"+Operation[j]["text"]+"</a></td>";break;
  1471. }
  1472. }
  1473. return RecordHtml;
  1474. }
  1475. setTable3D(Flag="Y"){
  1476. if(Flag=="Y"){
  1477. this.Table.style.boxShadow="0px 1px 18px rgba(0, 0, 0, 0.5)";
  1478. this.Table.style.borderLeft="0";
  1479. this.Table.style.borderRight="0";
  1480. this.Table.style.borderBottom="5px solid " +this.RowBGColor;
  1481. }else{
  1482. this.Table.style.boxShadow="none";
  1483. this.Table.style.borderLeft="1px solid " +this.BorderColor;
  1484. this.Table.style.borderRight="1px solid "+this.BorderColor;
  1485. this.Table.style.paddingBottom="5px";
  1486. this.Table.style.borderBottom="1px solid " +this.BorderColor;
  1487. this.Table.style.backgroundColor=this.RowBGColor;
  1488. }
  1489. }
  1490. }
  1491. class PanelPage{
  1492. Init(Dom,Conf){
  1493. var BackColor="#fff";
  1494. var FaceColor="#000";
  1495. if(Conf.skin=="dark"){
  1496. BackColor="#000";
  1497. FaceColor="#fff";
  1498. }
  1499. this.Dom=Dom;
  1500. this.Head=document.createElement('div');
  1501. this.Head.style.float="left";
  1502. this.Dom.style.position="relative";
  1503. this.Head.style.width="100%";
  1504. this.Head.style.height="35px";
  1505. this.Head.style.paddingTop="15px";
  1506. this.Head.style.textAlign="center";
  1507. this.Head.style.backgroundColor=BackColor;
  1508. this.Dom.appendChild(this.Head);
  1509. var ActBar=document.createElement('div');
  1510. ActBar.style.position="absolute";
  1511. ActBar.style.height="4px";
  1512. ActBar.style.width=(100 / Conf.items.length).toString()+ "%";
  1513. ActBar.style.maxWidth="120px";
  1514. ActBar.style.backgroundColor="#f60";
  1515. ActBar.style.top="43px";
  1516. ActBar.style.transition="left 0.3s";
  1517. this.ActBar=ActBar;
  1518. this.Dom.appendChild(this.ActBar);
  1519. this.Page=document.createElement('div');
  1520. this.Page.style.float="left";
  1521. this.Page.style.position="relative";
  1522. this.Page.style.overflow="hidden";
  1523. this.Page.style.width="100%";
  1524. this.Page.style.height="calc(100% - 50px)";
  1525. this.Page.style.backgroundColor=BackColor;
  1526. this.Page.style.color=FaceColor;
  1527. this.Dom.appendChild(this.Page);
  1528. var VarName=GetVarName(this);
  1529. for(let i=0;i<Conf.items.length;i++){
  1530. var Item=document.createElement('div');
  1531. Item.style.float="left";
  1532. Item.style.width=(100 / Conf.items.length).toString()+ "%";
  1533. Item.style.maxWidth="120px";
  1534. Item.innerHTML="<span class='TextButton' onclick='"+VarName+".ItemClick("+i.toString()+")'>"+Conf.items[i]+"<span>";
  1535. this.Head.appendChild(Item);
  1536. var PageItem=document.createElement('div');
  1537. PageItem.style.position="absolute";
  1538. PageItem.style.width="100%";
  1539. PageItem.style.height="100%";
  1540. PageItem.style.transitionDuration="0.5s";
  1541. PageItem.style.transitionProperty="opacity,left";
  1542. PageItem.style.left="-100%";
  1543. PageItem.style.backgroundColor=BackColor;
  1544. PageItem.style.color=FaceColor;
  1545. PageItem.innerHTML="<div style='margin-top:20%;text-align:center;font-size:48px;color:#ccc;'>第 "+(i+1).toString()+" 页</div>";
  1546. this.Page.appendChild(PageItem);
  1547. }
  1548. this.Pages=this.Page.childNodes;
  1549. this.HeadItems=this.Head.childNodes;
  1550. this.ItemClick(0);
  1551. }
  1552. ItemClick(Index){
  1553. for(let i=0;i<this.Pages.length;i++){
  1554. if(i==Index){
  1555. this.Pages[i].style.left=0;
  1556. this.Pages[i].style.opacity=1;
  1557. var left=((this.Head.offsetWidth/ this.Pages.length));
  1558. if(left>120){left=120;}
  1559. this.ActBar.style.left=(left*i).toString()+ "px";
  1560. this.HeadItems[i].getElementsByTagName("span")[0].style.color="#f60";
  1561. }else{
  1562. this.HeadItems[i].getElementsByTagName("span")[0].style.color="";
  1563. this.Pages[i].style.left="-100%";this.Pages[i].style.opacity=0
  1564. }
  1565. }
  1566. }
  1567. }
  1568. class AlertMsg{
  1569. Init(Dom){
  1570. var AlertMsgStyle={transition:"top 0.5s",position:"absolute",border_radius:"5px",padding_top:"20px",padding_bottom:"10px",padding_right:"25px",padding_left:"25px",top:"-100px",height:"35px",background_color:"#fff",z_index:"999",font_weight:"500"};
  1571. this.Text=document.createElement('span');
  1572. this.Text.style.display="inline-block";
  1573. this.Text.style.verticalAlign="middle";
  1574. Dom.appendChild(this.Text);
  1575. this.CloseIcon=ICON.Close("16px","#25c","#f50");
  1576. this.CloseIcon.style.float="right";
  1577. this.CloseIcon.style.right="-18px";
  1578. this.CloseIcon.style.top="-16px";
  1579. this.CloseIcon.addEventListener('click', function (event) { Dom.style.top="-100px";});
  1580. Dom.appendChild(this.CloseIcon);
  1581. this.Dom=AcceptStyle(Dom,AlertMsgStyle);
  1582. }
  1583. Close(){ this.Dom.style.top="-100px";}
  1584. Show(Msg="",Flag=1){
  1585. var SuccClass=[{box_shadow:"0 0 5px rgba(255, 60, 100, 0.5)",color:"#f60"},{box_shadow:"0 0 5px rgba(20, 90, 70, 0.5)",color:"#297"}]
  1586. var SuccIcon=[ICON.Failed("16px","#f50"),ICON.Succeed("26px","#297")];
  1587. this.Text.innerHTML="";
  1588. this.Text.appendChild(SuccIcon[Flag]);
  1589. this.Text.innerHTML=this.Text.innerHTML+"<span style='margin-left:10px;'>"+Msg+"</span>";
  1590. this.Dom.style.left="calc( 50% - "+(this.Dom.offsetWidth/2-90).toString() +"px)"
  1591. this.Dom=AcceptStyle(this.Dom,SuccClass[Flag]);
  1592. this.Dom.style.top="30px";
  1593. (function(Obj){setTimeout(function(){Obj.style.top="-100px";},2000);})(this.Dom);
  1594. }
  1595. }
  1596. class CreatIcon{
  1597. First(Size="24px",Color="#257",Hover="#F60"){
  1598. var Icon=document.createElement("span");
  1599. var Inner=document.createElement("span");
  1600. var Style={cursor:"pointer",overflow:"hidden",width:Size,height:Size,border_left:"1px solid "+Color,position:"relative"};
  1601. Icon=AcceptStyle(Icon,Style);
  1602. Style={width:"calc(100% - 1px)",height:"calc(100% - 1px)",border_left:"1px solid "+Color,left:"30%",border_bottom:"1px solid "+Color,transform:"rotate(45deg)",position:"absolute"};
  1603. Inner=AcceptStyle(Inner,Style);
  1604. Icon.appendChild(Inner);
  1605. (function(Obj){Obj.addEventListener('mouseover',function (event){
  1606. Obj.style.borderColor=Hover;
  1607. Obj.children[0].style.borderColor=Hover;
  1608. });})(Icon);
  1609. (function(Obj){Obj.addEventListener('mouseout',function (event){
  1610. Obj.style.borderColor=Color;
  1611. Obj.children[0].style.borderColor=Color;
  1612. });})(Icon);
  1613. return Icon;
  1614. }
  1615. Last(Size="24px",Color="#257",Hover="#F60"){
  1616. var Icon=this.First(Size,Color,Hover);
  1617. Icon.style.transform="rotate(180deg)";
  1618. return Icon
  1619. }
  1620. Prev(Size="24px",Color="#257",Hover="#F60"){
  1621. var Icon=this.First(Size,Color,Hover);
  1622. Icon.style.borderLeft="0";
  1623. return Icon
  1624. }
  1625. Next(Size="24px",Color="#257",Hover="#F60"){
  1626. var Icon=this.First(Size,Color,Hover);
  1627. Icon.style.borderLeft="0";
  1628. Icon.style.transform="rotate(180deg)";
  1629. return Icon
  1630. }
  1631. Search(Color="#fff",BGColor="#257"){
  1632. var Style={width:"40px",height:"35px",padding_top:"3px",background:BGColor,cursor:"pointer"};
  1633. var Bnt=document.createElement('span');
  1634. Bnt=AcceptStyle(Bnt,Style);
  1635. Style={display:"inline-block",vertical_align:"middle",position:"relative",padding_right:"2px",padding_bottom:"0px"};
  1636. var Bnt0=document.createElement('span');
  1637. Bnt0=AcceptStyle(Bnt0,Style);
  1638. Style={width:"12px",height:"12px",border:" 2px solid " +Color,border_radius:"50%"};
  1639. var Bnt1=document.createElement('span');
  1640. Bnt1=AcceptStyle(Bnt1,Style);
  1641. Style={position:"absolute",right:"-1px",bottom:"-1px",width:"8px",height:"2px",background:Color,_webkit_transform:"rotate225deg)",_moz_transform:"rotate(225deg)",_ms_transform:"rotate(225deg)",_o_transform:"rotate(225deg)",transform:"rotate(45deg)"};
  1642. var Bnt2=document.createElement('span');
  1643. Bnt2=AcceptStyle(Bnt2,Style);
  1644. Bnt0.appendChild(Bnt1);
  1645. Bnt0.appendChild(Bnt2);
  1646. Bnt.appendChild(Bnt0);
  1647. return Bnt;
  1648. }
  1649. Close(Size="20px",BorderColor="#000",MouseOver=""){
  1650. var CloseStyle={width:Size,height:Size,position:"relative",overflow:"hidden",border_radius:"50%",transform:"rotate(-45deg)"};
  1651. var CloseChildStyle=[{position:"absolute",border_top:"2px solid "+BorderColor,width:"100%",height:"100%",margin_top:"calc(50% - 2px)"},{position:"absolute",border_left:"2px solid "+BorderColor,width:"100%",height:"100%",margin_left:"calc(50% - 1px)"}];
  1652. var Icon=document.createElement('div');
  1653. Icon=AcceptStyle(Icon,CloseStyle);
  1654. for(let i=0;i<CloseChildStyle.length;i++){
  1655. let Div=document.createElement('div');
  1656. Div=AcceptStyle(Div,CloseChildStyle[i]);
  1657. Icon.appendChild(Div);
  1658. }
  1659. if(MouseOver!=""){
  1660. Icon.style.cursor="pointer";
  1661. var Line=Icon.childNodes;
  1662. Icon.addEventListener('mouseover', function (event) {
  1663. Line[0].style.borderTop="2px solid "+MouseOver;
  1664. Line[1].style.borderLeft="2px solid "+MouseOver;
  1665. });
  1666. Icon.addEventListener('mouseout', function (event) {
  1667. Line[0].style.borderTop="2px solid "+BorderColor;
  1668. Line[1].style.borderLeft="2px solid "+BorderColor;
  1669. });
  1670. }
  1671. return Icon;
  1672. }
  1673. Succeed(Size="26px",Color="#f50"){
  1674. var Icon=document.createElement('span');
  1675. var SuccStyle={position:"relative",z_index:"999",border_radius:"10px",width:Size,height:Size,border:"1px solid "+Color,border_radius:"50%"};
  1676. var SuccContStyle={position:"absolute",left:"40%",top:"22%",width:"20%",height:"40%",border_color:Color,border_style: "solid",border_width:"0 3px 3px 0",transform:"rotate(45deg)"};
  1677. Icon=AcceptStyle(Icon,SuccStyle);
  1678. var SuccCont=document.createElement('span');
  1679. SuccCont=AcceptStyle(SuccCont,SuccContStyle);
  1680. Icon.appendChild(SuccCont);
  1681. return Icon;
  1682. }
  1683. Failed(Size="26px",Color="#f50"){
  1684. var Icon=document.createElement('span');
  1685. var FailStyle={display:"inline-block",padding:"5px",border:"2px solid "+Color,border_radius:"50%",width:Size,height:Size};
  1686. var FailContStyle={display:"block",width:"100%",height:"100%",position:"relative",overflow:"hidden",transform:"rotate(-45deg)"};
  1687. var FailIDrawStyle=[{position:"absolute",width:"100%",height:"100%",border_top:"2px solid "+Color,margin_top:"calc(50% - 1px)"},{position:"absolute",width:"100%",height:"100%",border_left:"2px solid "+Color,margin_left:"calc(50% - 1px)"}];
  1688. Icon=AcceptStyle(Icon,FailStyle);
  1689. var FailCont=document.createElement('span');
  1690. FailCont=AcceptStyle(FailCont,FailContStyle);
  1691. for(let i=0;i<FailIDrawStyle.length;i++){
  1692. var FailIDraw=document.createElement("span");
  1693. FailIDraw=AcceptStyle(FailIDraw,FailIDrawStyle[i]);
  1694. FailCont.appendChild(FailIDraw);
  1695. }
  1696. Icon.appendChild(FailCont);
  1697. return Icon;
  1698. }
  1699. MenuButton(Size,Color,Hover){
  1700. var Height=parseInt( Size.replace(/px/g,""));
  1701. var Border=Math.round(Height / 12);
  1702. var Padding=Border*3;
  1703. var Style={width:Size,height:"2px",border_top: Border.toString()+"px solid "+Color,border_bottom:Border.toString()+"px solid "+Color,background_color:Color,background_clip:"content-box",padding_top:Padding.toString()+"px",padding_bottom:Padding.toString()+"px",cursor:"pointer"};
  1704. var Icon=document.createElement('span');
  1705. Icon.addEventListener('mouseover',function (event) {Icon.style.borderColor=Hover; Icon.style.backgroundColor=Hover; });
  1706. Icon.addEventListener('mouseout',function (event) {Icon.style.borderColor=Color; Icon.style.backgroundColor=Color; });
  1707. return AcceptStyle(Icon,Style);
  1708. }
  1709. }
  1710. var ICON= new CreatIcon;
  1711. class DialogBox{
  1712. Init(Dom){
  1713. var eleStyle={overflow:"hidden",opacity:"0.5",box_shadow:"0px 1px 8px rgba(0, 0, 0, 0.8)",border_radius:"5px",transition_property:"opacity,top,width,height,left",transition_duration:".5s",top:"-0px",position:"fixed",width:"1000px",height:"0",left:"calc( 50% - 410px)",background:"#fff",z_index:"99"};
  1714. this.Dom=AcceptStyle(Dom,eleStyle);
  1715. eleStyle={top:"0",left:"0",bottom:"0",right:"0",position:"fixed",background_color:"#000",z_Index:"2",opacity:"0.5",filter:"alpha(opacity=50)"};
  1716. this.CoverLayer=document.createElement("div");
  1717. this.CoverLayer=AcceptStyle(this.CoverLayer,eleStyle);
  1718. eleStyle={position:"absolute",width:"100%",height:"50px",background:"#eee",border_radius:"5px 5px 0 0",z_index:"999"};
  1719. this.Head=document.createElement("div");
  1720. this.Head=AcceptStyle(this.Head,eleStyle);
  1721. this.Dom.appendChild(this.Head);
  1722. this.Title=document.createElement("div");
  1723. eleStyle={float:"left",margin_left:"20px",margin_top:"16px",font_weight:"500"};
  1724. this.Title=AcceptStyle(this.Title,eleStyle);
  1725. this.Title.innerHTML="正在加载...";
  1726. this.Head.appendChild(this.Title);
  1727. this.CloseIcon=ICON.Close("24px","#27c","#f50");
  1728. this.CloseIcon.style.float="right";
  1729. this.CloseIcon.style.right="12px";
  1730. this.CloseIcon.style.top="12px";
  1731. (function(Obj){Obj.CloseIcon.addEventListener('click',function (event) {Obj.Close();});})(this);
  1732. this.Head.appendChild(this.CloseIcon);
  1733. eleStyle={position:"absolute",top:"50px",left:"0",bottom:"0",right:"0",background:"#fff",border_radius:"0 0 5px 5px"};
  1734. this.Content=document.createElement("div");
  1735. this.Content=AcceptStyle(this.Content,eleStyle);
  1736. this.Dom.appendChild(this.Content);
  1737. this.Loading=document.createElement('div');
  1738. this.Loading.className="Loading";
  1739. this.Loading.style.width=this.Loading.style.height="40px";
  1740. this.Loading.style.left="calc( 50% - 20px )";
  1741. this.Loading.style.top="40%";
  1742. this.Loading.style.display="none";
  1743. this.Dom.appendChild(this.Loading);
  1744. }
  1745. Show(Url="",title="",width=800,height=600,dark=0){
  1746. var skin={HeadBack:"#eee",HeadColor:"#000",BodyBack:"#fff",BodyColor:"#000"};
  1747. if(dark==1){
  1748. skin={HeadBack:"#012",HeadColor:"#fff",BodyBack:"#012",BodyColor:"#fff"};
  1749. }
  1750. this.Loading.style.display="block";
  1751. document.body.appendChild(this.CoverLayer);
  1752. this.Title.innerHTML=title;
  1753. this.Dom.style.width=width+"px";
  1754. this.Dom.style.height=height+"px";
  1755. this.Content.style.backgroundColor=skin.BodyBack;
  1756. this.Content.style.color=skin.BodyColor;
  1757. this.Head.style.backgroundColor=skin.HeadBack;
  1758. this.Head.style.color=skin.HeadColor;
  1759. var iframe=document.createElement("iframe");
  1760. iframe.id="DialogFrame";
  1761. iframe.style.border=0;
  1762. iframe.style.width=iframe.style.height="100%";
  1763. iframe.scroll="no";
  1764. iframe.style.overflow="hidden";
  1765. iframe.style.transition="opacity .3s";
  1766. iframe.style.opacity=0;
  1767. iframe.setAttribute('allowFullScreen','');
  1768. (function (Obj,Dom){
  1769. Obj.addEventListener('load', function (event) {
  1770. setTimeout(function(){Dom.LoadingClose();Obj.style.opacity=1;},400);
  1771. })})(iframe,this);
  1772. iframe.src=Url;
  1773. this.iframe=iframe;
  1774. this.Content.appendChild(iframe);
  1775. this.ReSize(width,height);
  1776. this.Dom.style.opacity=1;
  1777. }
  1778. ReSize(width,height){
  1779. //alert(document.body.scrollHeight);
  1780. this.Dom.style.width=width+"px";
  1781. this.Dom.style.height=height+"px";
  1782. var top=(document.body.scrollHeight/2)-(height/2+100);
  1783. if(top<60){top=60;}
  1784. if(top>400){top=400;}
  1785. this.Dom.style.left="calc( 50% - "+(width/2-90).toString() +"px)";
  1786. this.Dom.style.top=top.toString() +"px";
  1787. }
  1788. Close(){
  1789. this.Dom.style.width="1000px";
  1790. this.Dom.style.height="0px";
  1791. this.Dom.style.left="calc( 50% - "+(500-90).toString() +"px)";
  1792. this.Dom.style.top="0";
  1793. this.Dom.style.opacity=0;
  1794. this.Title.innerHTML="";
  1795. this.Content.innerHTML="";
  1796. document.body.removeChild(this.CoverLayer);
  1797. }
  1798. LoadingClose(){this.Loading.style.display="none";}
  1799. LoadingShow(){this.Loading.style.display="block";}
  1800. setSkin(Skin={HeadBack:"#eee",HeadColor:"#000",BodyBack:"#fff",BodyColor:"#000"}){
  1801. this.Head.style.color=Skin.HeadColor;
  1802. this.Head.style.backgroundColor=Skin.HeadBack;
  1803. this.Content.style.backgroundColor=Skin.BodyBack;
  1804. this.Content.style.color=Skin.BodyColor;
  1805. }
  1806. setUrl(url){this.iframe.src=url;}
  1807. setHearderColor(Color="#123"){this.Head.style.color=Color}
  1808. setHearderBGColor(Color="#eee"){this.Head.style.backgroundColor=Color}
  1809. setBodyBGColor(Color="#fff"){this.Content.style.backgroundColor=Color;}
  1810. setBodyColor(Color="#000"){this.Content.style.color=Color;}
  1811. setTitle(title){this.Title.innerHTML=title;}
  1812. }
  1813. class NavigationMenu{
  1814. Init(Dom,Item){
  1815. var Html="<div class='MenuItem0' style='height:20px;margin-bottom:30px' onclick='window.location.hash=\"home/index\";document.getElementById(\"TipsDot\").style.display=\"none\"'><img src='//ctrl.ccniot.com/image/icon/menu/home.png' >主页</div>";
  1816. for(let i=0;i<Item.length;i++){
  1817. Html+="<div class='MenuItem0' onclick='MenuItems1("+i.toString()+")'><img src='"+Item[i].icon+"'>"+Item[i].title+"<span class='MenuItem0Arrow' id='MenuItem0Arrow"+i.toString()+"'></span></div>";
  1818. Html+="<div class='MenuItem1BK' id='MenuItem1BK"+i.toString()+"' >";
  1819. for(let j=0;j<Item[i].items.length;j++){
  1820. Html+="<div class='MenuItem1' onclick='window.location.hash=\""+Item[i].items[j].url+"\"' id='"+Item[i].items[j].url.replace(/\//g,"")+"'>"+Item[i].items[j].title+"</div>";
  1821. }
  1822. Html+="</div>";
  1823. }
  1824. Html+="<div class='MenuItem0' onclick='window.location.hash=\"help/index\";document.getElementById(\"TipsDot\").style.display=\"none\"'><img src='//ctrl.ccniot.com/image/icon/menu/help.png'>帮助</div>";
  1825. Dom.innerHTML=Html;
  1826. }
  1827. }
  1828. class PicBox{
  1829. Init(Dom){
  1830. var Style={background_color:"#000",opacity:0,box_shadow:"0px 1px 8px rgba(0, 0, 0, 0.8)",border_radius:"5px",transition_property:"opacity,top,width,height,left",transition_duration:".5s",top:"10%",position:"fixed",width:"0",height:"0",left:"50%",z_index:"99"};
  1831. this.PicBox=document.createElement("div");
  1832. this.PicBox=AcceptStyle(this.PicBox,Style);
  1833. this.CloseButton=ICON.Close();
  1834. this.CloseIcon=ICON.Close("36px","#FFF","#fff");
  1835. //this.CloseIcon.style.float="right";
  1836. this.CloseIcon.style.position="absolute";
  1837. this.CloseIcon.style.right="-35px";
  1838. this.CloseIcon.style.top="-35px";
  1839. this.PicBox.appendChild(this.CloseIcon);
  1840. (function(Obj){Obj.CloseIcon.addEventListener('click',function (event) {Obj.Close();});})(this);
  1841. this.ImgDiv=document.createElement("div");
  1842. this.ImgDiv.style.height="100%";
  1843. this.ImgDiv.style.width="100%";
  1844. this.ImgDiv.style.backgroundColor="#000";
  1845. this.PicBox.appendChild(this.ImgDiv);
  1846. this.Img=document.createElement("img");
  1847. this.Img.style.height="100%";
  1848. this.Img.style.width="100%";
  1849. this.Img.style.borderRadius="5px";
  1850. this.ImgDiv.appendChild(this.Img);
  1851. this.ImgTitle=document.createElement("div");
  1852. this.ImgTitle.style.position="absolute";
  1853. this.ImgTitle.style.width="100%";
  1854. this.ImgTitle.style.fontSize="26px";
  1855. this.ImgTitle.style.bottom="10px";
  1856. this.ImgTitle.style.textAlign="center";
  1857. this.ImgTitle.style.color="#5ce";
  1858. this.ImgTitle.style.textShadow="0px 0px 5px #000";
  1859. this.PicBox.appendChild(this.ImgTitle);
  1860. this.ImgText=document.createElement("div");
  1861. this.ImgText.style.position="absolute";
  1862. this.ImgText.style.width="200px";
  1863. this.ImgText.style.fontSize="18px";
  1864. this.ImgText.style.top="20px";
  1865. this.ImgText.style.right="20px";
  1866. this.ImgText.style.padding="20px";
  1867. this.ImgText.style.color="#5ce";
  1868. this.ImgText.style.textShadow="0px 0px 5px #000";
  1869. this.ImgText.style.backgroundColor="rgba(0,0,0,0.8)";
  1870. this.ImgText.style.borderRadius="5px";
  1871. this.ImgText.style.border="1px solid #297";
  1872. this.ImgText.style.display='none';
  1873. this.ImgText.style.lineHeight='2';
  1874. this.PicBox.appendChild(this.ImgText);
  1875. Dom.appendChild(this.PicBox);
  1876. }
  1877. Show(PicInfo){
  1878. this.PicBox.style.height="80%";
  1879. this.PicBox.style.width="80%";
  1880. this.PicBox.style.left="10%"; //"calc( 50%- "+(500-90).toString() +"px)";
  1881. this.PicBox.style.top="10%";
  1882. this.PicBox.style.opacity=1;
  1883. this.Img.src=PicInfo[0].src;
  1884. var ImgTitle="";
  1885. for(let i=0;i<PicInfo.length;i++){
  1886. var ShowT="window.top.PBox.CloseText()";
  1887. if(i==1){
  1888. ShowT="window.top.PBox.ShowText()";
  1889. }
  1890. ImgTitle+="<span class='TextButton' style='margin-right:20px;margin-left:20px' onclick='window.top.PBox.Img.src=\""+PicInfo[i].src+"\"'> "+PicInfo[i].title+"</span>"
  1891. }
  1892. this.ImgTitle.innerHTML=ImgTitle;
  1893. if(PicInfo[1]){
  1894. this.ImgText.innerHTML=PicInfo[1]["text"];
  1895. window.top.PBox.ShowText();
  1896. }
  1897. }
  1898. ShowText(){
  1899. this.ImgText.style.display='block';
  1900. }
  1901. CloseText(){
  1902. this.ImgText.style.display='none';
  1903. }
  1904. Close(){
  1905. this.PicBox.style.width="0";
  1906. this.PicBox.style.height="0";
  1907. this.PicBox.style.left="50%";
  1908. this.PicBox.style.top="50%";
  1909. this.PicBox.style.opacity=0;
  1910. this.ImgText.style.display='none';
  1911. this.Img.src="";
  1912. //this.PicBox.innerHTML="";
  1913. }
  1914. }
  1915. class SelectLinkage2{
  1916. Init(Dom,Selected0="张海涛",Selected1="农业",Option0,Option1,Style={width:"auto",margin_right:"20px"},BlankItem="N"){
  1917. Dom.style.whiteSpace="nowrap";
  1918. this.Option0=Option0;
  1919. this.Option1=Option1;
  1920. this.Select0=document.createElement('select');
  1921. this.Select0.name="Select0";
  1922. for(let key in this.Option0){
  1923. let Opt = new Option(this.Option0[key],key);
  1924. if(Selected0==key){Opt.selected=true;}
  1925. this.Select0.add(Opt);
  1926. }
  1927. (function(Obj){
  1928. Obj.Select0.addEventListener('change',function (event){
  1929. var Select1Opt=Obj.Option1[Obj.Select0.options[Obj.Select0.selectedIndex].value];
  1930. Obj.Select1.options.length=0;
  1931. for(let key in Select1Opt){
  1932. let Opt = new Option(Select1Opt[key],key);
  1933. if(Selected1==key){Opt.selected=true;}
  1934. Obj.Select1.add(Opt);
  1935. }
  1936. });
  1937. })(this);
  1938. var Select1Opt=this.Option1[this.Select0.options[this.Select0.selectedIndex].value];
  1939. this.Select1=document.createElement('select');
  1940. this.Select1.name="Select1";
  1941. for(let key in Select1Opt){
  1942. let Opt = new Option(Select1Opt[key],key);
  1943. if(Selected1==key){Opt.selected=true;}
  1944. this.Select1.add(Opt);
  1945. }
  1946. this.Select0=AcceptStyle(this.Select0,Style);
  1947. this.Select1=AcceptStyle(this.Select1,Style);
  1948. Dom.appendChild(this.Select0);
  1949. Dom.appendChild(this.Select1);
  1950. }
  1951. }
  1952. function GetVarName(Dom){var VarName=null;for(let a in window){if(window[a]==Dom){VarName=a;break;}}return VarName;}
  1953. function UpdateJson(S,T){for(let i=0;i<S.length;i++){if(S[i].id==T.id){ for(let key in S[i]){ if(T[key]!=undefined ){ S[i][key]=T[key]; }} return true;} }if(i>=S.length){return false;}}
  1954. function UpdateJsonField(S,Id,F,V){for(let i=0;i<S.length;i++){if(S[i].id==Id){S[i][F]=V;return true;} }if(i>=S.length){return false;}}
  1955. function InsertJson(S,T){S.unshift (T);}
  1956. function CreatUrlParam(Dom){
  1957. if(Dom){
  1958. var key=Dom.getElementsByTagName("select");
  1959. var param="";
  1960. for(let i=0;i<key.length;i++){
  1961. if(key[i].id){param+=key[i].id+"="+key[i].value;}
  1962. if(i<key.length-1){param+="&";}
  1963. }
  1964. if(key.length>0){param+="&";}
  1965. key=Dom.getElementsByTagName("input");
  1966. for(let i=0;i<key.length;i++){
  1967. if(key[i].id){param+=key[i].id+"="+key[i].value;}
  1968. if(i<key.length-1){param+="&";}
  1969. }
  1970. return "&"+param;
  1971. }else{
  1972. return "";
  1973. }
  1974. }
  1975. function ParamBackFill(Dom){
  1976. var key=Dom.getElementsByTagName("input");
  1977. var param=window.location.hash;
  1978. param=param.split("?")[1];
  1979. if(param){
  1980. var v=param.split("&");
  1981. var SearchCity=0,IntegrationType=0;
  1982. var ValurCity=["","",""];
  1983. for(let i=0;i<v.length;i++){
  1984. let k=v[i].split("=");
  1985. let e=document.getElementById(k[0]);
  1986. if( e){
  1987. if(e.nodeName=="INPUT"){e.value=decodeURIComponent(k[1]);}
  1988. if(e.nodeName=="SELECT"){
  1989. switch(e.id){
  1990. case "FormProv":
  1991. case "FormCity":
  1992. case "FormDist":
  1993. SearchCity=1;
  1994. break;
  1995. case "IntegrationIndustry":
  1996. case "IntegrationType":
  1997. IntegrationType=1;
  1998. break;
  1999. default:
  2000. for(let j=0;j<e.options.length;j++){
  2001. if( e.options[j].value==decodeURI(k[1]) ){e.options[j].selected = true;}
  2002. }
  2003. }
  2004. }
  2005. }
  2006. }
  2007. if(SearchCity==1){
  2008. var City=new SelectCity;
  2009. var SLC=document.getElementById("SelectCityDom");
  2010. SLC.innerHTML="";
  2011. City.Init(SLC,$_GET_hash("FormProv"),$_GET_hash("FormCity"),$_GET_hash("FormDist"),SearchStyle,"Y");
  2012. }
  2013. if(IntegrationType==1){
  2014. var SLC=document.getElementById("SelectIntegrationTypeDom");
  2015. SLC.innerHTML="";
  2016. var IntegrationType=new SelectIntegrationType;
  2017. IntegrationType.Init(SLC,$_GET_hash("IntegrationIndustry"),$_GET_hash("IntegrationType"),SearchStyle,"Y");
  2018. }
  2019. }
  2020. }
  2021. function AryJsonToJson(AryJson){ // 把 [{text:"aaa",value:"bbb"},{text:"xxx",value:"yyy"}] 转换成 {"aaa":"bbb","xxx":"yyy"}
  2022. var Json={};
  2023. for(let i=0;i<AryJson.length;i++){
  2024. Json[AryJson[i].text]=AryJson[i].value;
  2025. }
  2026. return Json;
  2027. }
  2028. function $_GET_hash(F){
  2029. var param=window.location.hash;
  2030. param=param.split("?")[1];
  2031. if(param){
  2032. var v=param.split("&");
  2033. for(let i=0;i<v.length;i++){
  2034. let k=v[i].split("=");
  2035. if(k[0]==F){
  2036. return decodeURIComponent(k[1]);
  2037. }
  2038. }
  2039. }
  2040. }
  2041. function AcceptStyle(Dom,Style){for(let Key in Style){let iKey=Key.replace(/_/g,"-");Dom.style[iKey]=Style[Key];}return Dom;}
  2042. function $_OnlyNum(Dom,Decimal="N"){if(Decimal=="N"){Dom.value=Dom.value.replace(/[^\d]/g,'');}else{Dom.value=Dom.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'');Dom.value=Dom.value.replace(/\.{2,}/g, '');Dom.value=Dom.value.replace(/^\./g, ''); Dom.value=Dom.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');}}
  2043. function $_NOW(flag="full"){var time = new Date();if(flag=="date"){return time.getFullYear() +"-" +NumAdd0((time.getMonth()+1),2) +"-" + NumAdd0(time.getDate(),2);}else{return time.getFullYear() +"-" +NumAdd0((time.getMonth()+1),2) +"-" + NumAdd0(time.getDate(),2)+" " +NumAdd0(time.getHours(),2) +":" +NumAdd0(time.getMinutes(),2) +":"+NumAdd0(time.getSeconds(),2);}}function NumAdd0(n,l){return (Array(l).join(0) + n).slice(-l);}
  2044. function $_SELECT(Field,Value,Source){for(var i=0;i<Source.length;i++){if(Source[i][Field]){if(Source[i][Field]==Value){return Source[i];}}else{return false;} }if(i>=Source.length){return false;} }
  2045. function $_COOKIE(name){var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)){return decodeURI(arr[2]); }else{return false;}}
  2046. function $_GET(variable){var query = window.location.search.substring(1);var vars = query.split("&");for (var i=0;i<vars.length;i++){var pair = vars[i].split("=");if(pair[0] == variable){return decodeURI(pair[1]);}}return(false);}
  2047. function zoom(){
  2048. if(document.getElementById("zoombnt").src.indexOf("zoom1")>=0){
  2049. exitFullscreen();
  2050. WX.Top.style.display="block";
  2051. WX.LeftArea.style.display="block";
  2052. WX.RightArea.style.left="180px";
  2053. WX.RightArea.style.top="50px";
  2054. document.getElementById("zoombnt").src="//open.winnto.com/image/icon/zoom0.png";
  2055. }else{
  2056. WX.Top.style.display="none";
  2057. WX.LeftArea.style.display="none";
  2058. WX.RightArea.style.left="0";
  2059. WX.RightArea.style.top="0";
  2060. toFullscreen()
  2061. document.getElementById("zoombnt").src="//open.winnto.com/image/icon/zoom1.png";
  2062. }
  2063. }
  2064. function toFullscreen() {
  2065. var de = document.documentElement;
  2066. if (de.requestFullscreen) {
  2067. de.requestFullscreen();
  2068. } else if (de.mozRequestFullScreen) {
  2069. de.mozRequestFullScreen();
  2070. } else if (de.webkitRequestFullScreen) {
  2071. de.webkitRequestFullScreen();
  2072. }
  2073. }
  2074. function exitFullscreen() {
  2075. if(document.exitFullScreen) {
  2076. document.exitFullScreen();
  2077. } else if(document.mozCancelFullScreen) {
  2078. document.mozCancelFullScreen();
  2079. } else if(document.webkitExitFullscreen) {
  2080. document.webkitExitFullscreen();
  2081. } else if(element.msExitFullscreen) {
  2082. element.msExitFullscreen();
  2083. }
  2084. }