addgoods.html 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie' : {'pre': ''},
  33. 'account' : {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css" rel="stylesheet">
  44. <script type="text/javascript" src="/static/js/dist/area/cascade.js"></script>
  45. <script type="text/javascript" src="/static/js/dist/select2/select2.min.js"></script>
  46. <link rel="stylesheet" href="/static/js/dist/select2/select2-bootstrap.css">
  47. <link rel="stylesheet" href="/static/js/dist/select2/select2.css">
  48. <script type="text/javascript" src="/web/resource/js/lib/moment.js"></script>
  49. <link rel="stylesheet" href="/web/resource/components/datetimepicker/jquery.datetimepicker.css">
  50. <link rel="stylesheet" href="/web/resource/components/daterangepicker/daterangepicker.css">
  51. <style type='text/css'>
  52. .tabs-container .layui-form-item {overflow: hidden;}
  53. .tabs-container .tabs-left > .nav-tabs {}
  54. .tab-goods .nav li {float:left;}
  55. .spec_item_thumb {position: relative; width: 30px; height: 20px; padding: 0; border-left: none;}
  56. .spec_item_thumb i {position: absolute; top: -5px; right: -5px;}
  57. .input-group .spec_item_thumb{padding:0px;}
  58. .multi-img-details, .multi-audio-details {margin-top:.5em;max-width: 700px; padding:0; }
  59. .multi-audio-details .multi-audio-item {width:155px; height: 40px; position:relative; float: left; margin-right: 5px;}
  60. .region-goods-details {
  61. background: #f8f8f8;
  62. margin-bottom: 10px;
  63. padding: 0 10px;
  64. }
  65. .region-goods-left{
  66. text-align: center;
  67. font-weight: bold;
  68. color: #333;
  69. font-size: 14px;
  70. padding: 20px 0;
  71. }
  72. .region-goods-right{
  73. border-left: 3px solid #fff;
  74. padding: 10px 10px;
  75. }
  76. .input-group .input-group-btn .btn:hover{background-color:#5bc0de}
  77. .layui-form-select{display:none;}
  78. .daterangepicker select.ampmselect, .daterangepicker select.hourselect, .daterangepicker select.minuteselect {
  79. width: auto!important;
  80. }
  81. .input-group .input-group-addon{}
  82. </style>
  83. </head>
  84. <body layadmin-themealias="default">
  85. <div class="layui-fluid">
  86. <div class="layui-card">
  87. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>商品 <small><?php if( !empty($item['id'])){ ?>修改【<span class="text-info">{$item['goodsname']}</span>】<?php } ?></small></span></div>
  88. <div class="layui-card-body" style="padding:15px;">
  89. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  90. <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  91. <ul class="layui-tab-title">
  92. <li <?php if( empty($_GPC['tab']) || $_GPC['tab']=='basic'){ ?>class="layui-this"<?php } ?>>基本信息</li>
  93. <li <?php if( $_GPC['tab']=='option'){ ?>class="layui-this"<?php } ?> >规格库存</li>
  94. <li <?php if( $_GPC['tab']=='des'){ ?>class="layui-this"<?php } ?> >商品详情</li>
  95. </ul>
  96. <div class="layui-tab-content" >
  97. <div class="layui-tab-item <?php if( empty($_GPC['tab']) || $_GPC['tab']=='basic'){ ?>layui-show<?php } ?>" >
  98. <!---- 基本信息begin --->
  99. <div class="region-goods-details layui-row">
  100. <div class="layui-form-item">
  101. <div class="layui-form-item" style="padding-top:10px;">
  102. <label class="layui-form-label must">商品名称</label>
  103. <div class="layui-input-block" style="padding-right:0;" >
  104. <input type="text" name="goodsname" id="goodsname" class="form-control" value="{$item['goodsname']}" data-rule-required="true" />
  105. </div>
  106. </div>
  107. <div class="layui-form-item" style="display:none;">
  108. <label class="layui-form-label">商品分类</label>
  109. <div class="layui-input-block">
  110. <select id="cates" multiple="multiple" name='cates[]' class="form-control select2" >
  111. <?php foreach( $category as $c ){ ?>
  112. <option value="{$c['id']}" <?php if( is_array($item['cates']) && in_array($c['id'],$item['cates'])){ ?>selected<?php } ?> >{$c['name']}</option>
  113. <?php } ?>
  114. </select>
  115. </div>
  116. </div>
  117. <div class="layui-form-item">
  118. <label class="layui-form-label">商品简介</label>
  119. <div class="layui-input-block">
  120. <textarea name="subtitle" id="subtitle" rows="5" class="form-control" data-parent=".subtitle" maxlength="100" data-rule-maxlength="100">{$item['subtitle']}</textarea>
  121. <div class="layui-form-mid layui-word-aux">副标题的长度请控制在100字以内</div>
  122. </div>
  123. </div>
  124. <div class="layui-form-item">
  125. <label class="layui-form-label must">商品视频</label>
  126. <div class="layui-input-block gimgs">
  127. {:tpl_form_field_video('video',$item['video'] );}
  128. <span class="layui-form-mid layui-word-aux image-block">
  129. 请输入视频源地址或者选择上传视频
  130. </span>
  131. </div>
  132. </div>
  133. <div class="layui-form-item">
  134. <label class="layui-form-label must">首页商品(大图)</label>
  135. <div class="layui-input-block gimgs">
  136. {:tpl_form_field_image2('big_img',$item['big_img'])}
  137. <span class="layui-form-mid layui-word-aux image-block">此图为首页商品大图模式封面图,最佳尺寸:710*400</span>
  138. </div>
  139. </div>
  140. <div class="layui-form-item">
  141. <label class="layui-form-label must">商品图片<label style="color:red;font-size:16px;font-weight:900">*</label></label>
  142. <div class="layui-input-block gimgs" id="gimgs_mult">
  143. {:tpl_form_field_multi_image3('thumbs',$item['piclist'])}
  144. <span class="layui-form-mid layui-word-aux image-block">第一张为缩略图,建议为正方型图片,其他为详情页面图片,尺寸建议宽度为640,并保持图片大小一致,可拖拽改变图片顺序</span>
  145. </div>
  146. </div>
  147. <div class="layui-form-item">
  148. <label class="layui-form-label">分享标题</label>
  149. <div class="layui-input-block">
  150. <input type="text" name="share_title" class="form-control" value="{$item['share_title']}" />
  151. <div class="layui-form-mid layui-word-aux"></div>
  152. </div>
  153. </div>
  154. <div class="layui-form-item">
  155. <label class="layui-form-label ">分享图片</label>
  156. <div class="layui-input-block gimgs">
  157. {:tpl_form_field_image2('goods_share_image',$item['goods_share_image'])}
  158. <span class="layui-form-mid layui-word-aux image-block">此图为商品详情页分享图片(比例为长宽比5:4)</span>
  159. </div>
  160. </div>
  161. <div class="layui-form-item">
  162. <label class="layui-form-label">商品状态</label>
  163. <div class="layui-input-block">
  164. <label class="radio-inline"><input type="radio" name="grounding" value="1" <?php if( !isset($item['grounding']) || $item['grounding'] == 1){ ?>checked="true"<?php } ?> title="上架" /> </label>
  165. <label class="radio-inline"><input type="radio" name="grounding" value="0" <?php if( isset($item['grounding']) && $item['grounding'] == 0){ ?>checked="true"<?php } ?> title="下架" /> </label>
  166. </div>
  167. </div>
  168. <div class="layui-form-item" style="display:none;">
  169. <label class="layui-form-label">首页推荐</label>
  170. <div class="layui-input-block">
  171. <label class="radio-inline"><input type="radio" name="is_index_show" value="1" <?php if( !isset($item['is_index_show']) || $item['is_index_show'] == 1){ ?>checked="true"<?php } ?> title="是" /> </label>
  172. <label class="radio-inline"><input type="radio" name="is_index_show" value="0" <?php if( isset($item['is_index_show']) && $item['is_index_show'] == 0){ ?>checked="true"<?php } ?> title="否" /> </label>
  173. </div>
  174. </div>
  175. <div class="layui-form-item price" >
  176. <label class="layui-form-label">兑换积分<label style="color:red;font-size:16px;font-weight:900">*</label></label>
  177. <div class="layui-input-block">
  178. <div class="input-group">
  179. <input type="text" name="price" id="price" class="form-control" value="{$item['price']}" <?php if( $item['hasoption']!=1 ){ ?>lay-verify="required"<?php } ?> placeholder="请填写兑换积分"/>
  180. <span class="input-group-addon">分 市场价</span>
  181. <input type="text" name="productprice" id="productprice" class="form-control" value="{$item['productprice']}" <?php if( $item['hasoption']!=1 ){ ?>lay-verify="required"<?php } ?> placeholder="请填写商品原价"/>
  182. <span class="input-group-addon">元 (市场价、划线价) 成本价</span>
  183. <input type="text" name="costprice" id="costpriceprice" class="form-control" value="{$item['costprice']}" placeholder="请填写商品成本价"/>
  184. </div>
  185. <span class='layui-form-mid layui-word-aux'>如未启用商品规格,请填写商品价格</span>
  186. </div>
  187. </div>
  188. <?php if($is_vir_count){ ?>
  189. <div class="layui-form-item" >
  190. <label class="layui-form-label">已兑换数</label>
  191. <div class="layui-input-block">
  192. <div class="input-group">
  193. <input type="text" name="sales" id="sales" class="form-control" value="{$item['sales']}" />
  194. <span class="input-group-addon">备注:前台销量=虚拟销量+实际销量</span>
  195. </div>
  196. </div>
  197. </div>
  198. <?php } ?>
  199. <input type="hidden" name="is_only_express" value="1" />
  200. <div class="layui-form-item dispatch_info">
  201. <label class="layui-form-label">运费设置</label>
  202. <div class="layui-input-block" style='padding-left:0'>
  203. <div class="input-group">
  204. <span class='input-group-addon' style='border:none;padding:0px;'><label class="radio-inline" style='margin-top:-7px;' ><input type="radio" name="dispatchtype" value="0" <?php if( empty($item['dispatchtype'])){ ?>checked="true"<?php } ?> title="运费模板" /> </label></span>
  205. <select class="form-control tpl-category-parent select2" id="dispatchid" name="dispatchid">
  206. <?php foreach( $dispatch_data as $dispatch_item ){ ?>
  207. <option value="{$dispatch_item['id']}" <?php if( $item['dispatchid'] == $dispatch_item['id']){ ?>selected="true"<?php } ?>>{$dispatch_item['name']}</option>
  208. <?php } ?>
  209. </select>
  210. </div>
  211. </div>
  212. </div>
  213. <div class="layui-form-item dispatch_info">
  214. <label class="layui-form-label"></label>
  215. <div class="layui-input-block" style='padding-left:0'>
  216. <div class="input-group">
  217. <span class='input-group-addon' style='border:none;padding:0px;'><label class="radio-inline" style='margin-top:-7px;' >
  218. <input type="radio"name="dispatchtype" value="1" <?php if( $item['dispatchtype'] == 1){ ?>checked="true"<?php } ?> title="统一邮费" /> </label></span>
  219. <input type="text" name="dispatchprice" id="dispatchprice" class="form-control" value="{$item['dispatchprice']}" />
  220. <span class="input-group-addon">元</span>
  221. </div>
  222. </div>
  223. </div>
  224. <div class="layui-form-item" style="display:none;">
  225. <label class="layui-form-label">下单送积分</label>
  226. <div class="col-sm-10 col-xs-12" id="send_score_div">
  227. <input type="checkbox" lay-filter="is_modify_sendscore" lay-skin="primary" name="is_modify_sendscore" <?php if(isset($item['is_modify_sendscore']) && $item['is_modify_sendscore'] ==1){ ?> checked <?php } ?> value="1" />
  228. <input class="form-control " id="send_score_divTip" name="send_socre" style="vertical-align: sub; <?php if(isset($item['is_modify_sendscore']) && $item['is_modify_sendscore'] ==1){ ?>display:inline;<?php }else{ ?>display: none;<?php } ?>width: 120px;" type="text" value="{$item['send_socre']}">
  229. <div style="clear:both;"></div>
  230. <span class="layui-form-mid layui-word-aux">赠送数量 = 商品数量 * 下单送积分数量(未开启,则使用系统全局设置)</span>
  231. </div>
  232. </div>
  233. <?php if($index_sort_method == 1){ ?>
  234. <div class="layui-form-item" >
  235. <label class="layui-form-label">首页排序</label>
  236. <div class="layui-input-block">
  237. <div class="input-group">
  238. <input type="text" name="index_sort" id="index_sort" class="form-control" value="{$item['index_sort']}" />
  239. <span class="input-group-addon">备注:排序越大显示越靠前</span>
  240. </div>
  241. </div>
  242. </div>
  243. <?php } ?>
  244. </div>
  245. </div>
  246. <div class="region-goods-details ">
  247. <div class="layui-form-item">
  248. <div class="layui-form-item">
  249. <label class="layui-form-label">兑换时间</label>
  250. <div class="layui-input-block">
  251. {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $item['begin_time']),'endtime'=>date('Y-m-d H:i', $item['end_time'])),true);}
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. <div class="region-goods-details ">
  257. <div class="layui-form-item">
  258. <div class="layui-form-item">
  259. <label class="layui-form-label">单次兑换</label>
  260. <div class="layui-input-block">
  261. <input type="text" name="one_limit_count" class="form-control " value="{$item['one_limit_count']}" />
  262. <div class="layui-form-mid layui-word-aux">用户单次提交订单最多可兑换数,默认为0表示不限制</div>
  263. </div>
  264. </div>
  265. <div class="layui-form-item">
  266. <label class="layui-form-label">历史兑换</label>
  267. <div class="layui-input-block">
  268. <input type="text" name="total_limit_count" class="form-control" value="{$item['total_limit_count']}" />
  269. <div class="layui-form-mid layui-word-aux">用户历史累积最多可兑换数,默认为0表示不限制</div>
  270. </div>
  271. </div>
  272. </div>
  273. </div>
  274. <script language="javascript">
  275. $(function () {
  276. $('#price').blur(function(){
  277. var price = parseFloat( $("#price").val() );
  278. var community_head_commission = parseFloat( $("#community_head_commission").val() );
  279. if(price > 0 && community_head_commission >0)
  280. {
  281. $('#precommiss_head_money_tip').html( ( (price * community_head_commission) /100 ).toFixed(2) );
  282. }else{
  283. $('#precommiss_head_money_tip').html('0.00');
  284. }
  285. })
  286. $("#community_head_commission").blur(function(){
  287. var price = parseFloat( $("#price").val() );
  288. var community_head_commission = parseFloat( $(this).val() );
  289. if(price > 0 && community_head_commission >0)
  290. {
  291. $('#precommiss_head_money_tip').html( ( (price * community_head_commission) /100 ).toFixed(2) );
  292. }else{
  293. $('#precommiss_head_money_tip').html('0.00');
  294. }
  295. });
  296. $('#radPickupDateTip input[type=radio]').click(function(){
  297. var s_val = $(this).val();
  298. if(s_val == 3)
  299. {
  300. $('#txtPickupDateTip').css('display','inline-block');
  301. }else{
  302. $('#txtPickupDateTip').css('display', 'none');
  303. }
  304. })
  305. $("input[name=isstatustime]").off('click').on('click',function () {
  306. if($(this).val()==1){
  307. $("#shelves").show()
  308. }else{
  309. $("#shelves").hide();
  310. }
  311. })
  312. })
  313. </script>
  314. <!--- 基本信息 end -->
  315. </div>
  316. <div class="layui-tab-item <?php if( $_GPC['tab']=='option'){ ?>layui-show<?php } ?>" >
  317. <!--规格begin-->
  318. <div class="region-goods-details ">
  319. <div class="region-goods-left col-sm-2">规格库存</div>
  320. <div class="region-goods-right col-sm-10">
  321. <div class="layui-form-item">
  322. <label class="layui-form-label">商品编码</label>
  323. <div class="layui-input-block">
  324. <input type="text" name="codes" class="form-control" value="{$item['codes']}" />
  325. <div class="help-block">商品编码 用部分商家用于统计</div>
  326. </div>
  327. </div>
  328. <div class="layui-form-item">
  329. <label class="layui-form-label">重量</label>
  330. <div class="layui-input-block">
  331. <div class="input-group fixsingle-input-group">
  332. <input type="text" name="weight" id="weight" <?php if( $item['hasoption']){ ?>readonly<?php } ?> class="form-control hasoption" value="{$item['weight']}"/>
  333. <span class="input-group-addon">克</span>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="layui-form-item">
  338. <label class="layui-form-label">库存</label>
  339. <div class="layui-input-block">
  340. <input type="text" name="total" id="total" class="form-control hasoption" value="{$item['total']}" style="width:150px;display: inline;margin-right: 20px;" <?php if( $item['hasoption']){ ?>readonly<?php } ?>/>
  341. <span class="help-block">商品的剩余数量, 如启用多规格,则此处设置无效.</span>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. <div class="region-goods-details ">
  347. <div class="region-goods-left col-sm-2">
  348. 规格
  349. </div>
  350. <div class="region-goods-right col-sm-10">
  351. <div class="layui-form-item">
  352. <div class="layui-row" style=''>
  353. <input type="checkbox" lay-skin="primary" title="启用商品规格" lay-filter="hasoption" value="1" name="hasoption" <?php if( $item['hasoption']==1){ ?>checked<?php } ?> />
  354. <span class="help-block">启用商品规格后,商品的价格及库存以商品规格为准,库存设置为0则会到”已售罄“中,手机也不会显示, -1为不限制</span>
  355. </div>
  356. </div>
  357. <div id='tboption' style="padding-left:15px;<?php if( $item['hasoption']!=1){ ?>display:none<?php } ?>" >
  358. <div class="alert alert-info" style="display:none;">
  359. 1. 拖动规格可调整规格显示顺序, 更改规格及规格项后请点击下方的【刷新规格项目表】来更新数据。<br/>
  360. 2. 每一种规格代表不同型号,例如颜色为一种规格,尺寸为一种规格,如果设置多规格,手机用户必须每一种规格都选择一个规格项,才能添加购物车或购买。
  361. </div>
  362. <div id='specs'>
  363. <?php foreach( $item['allspecs'] as $spec ){ ?>
  364. <!--spec-->
  365. <div class='spec_item spec_class_{$cur_cate_id}' id="spec_{$spec['id']}" >
  366. <div style='border:1px solid #e7eaec;padding:10px;margin-bottom: 10px;' >
  367. <input name="spec_id[]" type="hidden" class="form-control spec_id" value="{$spec['id']}"/>
  368. <div class="form-group">
  369. <div class="col-sm-12">
  370. <div class='input-group'>
  371. <input name="spec_title[{$spec['id']}]" type="text" class="form-control spec_title" value="{$spec['title']}" placeholder="规格名称 (比如: 颜色)"/>
  372. <div class='input-group-btn'>
  373. <a href="javascript:;" id="add-specitem-{$spec['id']}" specid='{$spec['id']}' class='btn btn-info add-specitem' onclick="addSpecItem('{$spec['id']}')"><i class="fa fa-plus"></i> 添加规格项</a>
  374. <a href="javascript:void(0);" class='btn btn-danger' onclick="removeSpec('{$spec['id']}')"><i class="fa fa-remove"></i></a>
  375. </div>
  376. </div>
  377. </div>
  378. </div>
  379. <div class="form-group">
  380. <div class="col-md-12">
  381. <div id='spec_item_{$spec['id']}' class='spec_item_items'>
  382. <?php foreach( $spec['items'] as $specitem ){ ?>
  383. <!--spec_item begin-->
  384. <div class="spec_item_item" style="float:left;margin:5px;width:250px; position: relative">
  385. <input type="hidden" class="form-control spec_item_show" name="spec_item_show_{$spec['id']}[]" value="{$specitem['show']}" />
  386. <input type="hidden" class="form-control spec_item_id" name="spec_item_id_{$spec['id']}[]" value="{$specitem['id']}" />
  387. <div class="input-group">
  388. <span class="input-group-addon">
  389. <input type="checkbox" lay-skin="primary" <?php if( $specitem['id']>0){ ?>checked<?php } ?> value="1" onclick='showItem(this)'>
  390. </span>
  391. <input type="text" class="form-control spec_item_title" onblur="refreshOptions()" name="spec_item_title_{$spec['id']}[]" VALUE="{$specitem['title']}" />
  392. <span class="input-group-addon spec_item_thumb <?php if( !empty($specitem['thumb'])){ ?>has_thumb<?php } ?>">
  393. <input type='hidden' name="spec_item_thumb_{$spec['id']}[]" value="{$specitem['thumb']}"
  394. />
  395. <img onclick="selectSpecItemImage(this)"
  396. src="<?php if( empty($specitem['thumb'])){ ?><?php }else{ ?>{:resize($specitem['thumb'],100)}<?php } ?>" style='width:100%;'
  397. <?php if( !empty($specitem['thumb'])){ ?>
  398. data-toggle='popover'
  399. data-html ='true'
  400. data-placement='top'
  401. data-trigger ='hover'
  402. data-content="<img src='{:tomedia($specitem['thumb'])}' style='width:100px;height:100px;' />"
  403. <?php } ?>
  404. >
  405. <i class="fa fa-times-circle" <?php if( empty($specitem['thumb'])){ ?>style="display:none"<?php } ?>></i>
  406. </span>
  407. <span class="input-group-addon">
  408. <a href="javascript:;" onclick="removeSpecItem(this)" title='删除'><i class="fa fa-times"></i></a>
  409. <a href="javascript:;" class="fa fa-arrows" title="拖动调整显示顺序" ></a>
  410. </span>
  411. </div>
  412. </div>
  413. <!--spec_item end-->
  414. <?php } ?>
  415. </div>
  416. </div>
  417. </div>
  418. </div>
  419. </div>
  420. <!--end spec-->
  421. <?php } ?>
  422. </div>
  423. <table class="table">
  424. <tr>
  425. <td>
  426. <div class="layui-form-item">
  427. <label class="col-sm-2 control-label">选择规格</label>
  428. <div class="col-sm-8 col-xs-12">
  429. <select id="cates2" name='options[]' class="form-control select2" style='width:605px;' multiple='' >
  430. <?php foreach( $spec_list as $c ){ ?>
  431. <option value="{$c['id']}" data-names="{$c['value_str']}">{$c['name']}</option>
  432. <?php } ?>
  433. </select>
  434. </div>
  435. </div>
  436. <td>
  437. </tr>
  438. <tr>
  439. <td>
  440. <h4>
  441. <a href="javascript:;" class='btn btn-primary' id='add-spec' onclick="addSpec()" style="margin-top:10px;margin-bottom:10px;" title="添加规格"><i class='fa fa-plus'></i> 添加规格</a>
  442. <a style="display:none;" href="javascript:;" onclick="refreshOptions();" title="刷新规格项目表" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新规格项目表</a>
  443. </h4>
  444. </td>
  445. </tr>
  446. <tr style="display: none;" >
  447. <td>
  448. <div class="alert alert-danger">警告:规格数据有变动,请重新点击上方 [刷新规格项目表] 按钮!</div>
  449. </td>
  450. </tr>
  451. </table>
  452. <div class="alert alert-info wholesalewarning" style="display:none;">
  453. </div>
  454. <div id="options" style="padding:0;">{$item['html']}</div>
  455. </div>
  456. </div>
  457. </div>
  458. <input type="hidden" name="optionArray" value=''>
  459. <input type="hidden" name="isdiscountDiscountsArray" value=''>
  460. <input type="hidden" name="discountArray" value=''>
  461. <input type="hidden" name="commissionArray" value=''>
  462. <!--规格end-->
  463. </div>
  464. <div class="layui-tab-item <?php if( $_GPC['tab']=='des'){ ?>layui-show<?php } ?>" >
  465. <div class="region-goods-details row">
  466. <div class="region-goods-left col-sm-2">商品详情</div>
  467. <div class=" region-goods-right col-sm-10">
  468. <div class="" >
  469. {:tpl_ueditor('content',htmlspecialchars_decode($item['content']),array('height'=>'300'))}
  470. </div>
  471. </div>
  472. </div>
  473. </div>
  474. <script>
  475. $(function(){
  476. $(".select2").select2({
  477. placeholder:'请选择',
  478. allowClear:true
  479. })
  480. })
  481. </script>
  482. <div class="layui-form-item">
  483. <label class="layui-form-label"> </label>
  484. <div class="layui-input-block">
  485. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  486. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  487. <a class="btn btn-default" style='margin-left:10px;' href="{:U('goods/index' , array( 'ok' => 1))}">返回列表</a>
  488. </div>
  489. </div>
  490. </form>
  491. </div>
  492. </div>
  493. </div>
  494. <script src="/layuiadmin/layui/layui.js"></script>
  495. <script type="text/javascript" src="/static/js/jquery-migrate-1.1.1.js"></script>
  496. <script src="/static/js/jquery-ui.min.js"></script>
  497. <style>
  498. .multi-img-details{width:100%;}
  499. </style>
  500. <script>
  501. layui.config({
  502. base: '/layuiadmin/' //静态资源所在路径
  503. }).extend({
  504. index: 'lib/index' //主入口模块
  505. }).use('index');
  506. </script>
  507. <script>
  508. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  509. var layer = layui.layer;
  510. var $;
  511. var cur_open_div;
  512. var form;
  513. layui.use(['jquery', 'layer','form'], function(){
  514. $ = layui.$;
  515. form = layui.form;
  516. console.log(22);
  517. form.on('radio(linktype)', function(data){
  518. if (data.value == 2) {
  519. $('#typeGroup').show();
  520. } else {
  521. $('#typeGroup').hide();
  522. }
  523. });
  524. form.on('checkbox(commissTuan)', function(data){
  525. if (data.elem.checked) {
  526. $("#zero_opentuan_div").css('display','inline');
  527. $("#newman_div").css('display','inline');
  528. $("#commiss_money_div").css('display','inline');
  529. } else {
  530. $("#zero_opentuan_div").hide();
  531. $("#newman_div").hide();
  532. $("#commiss_money_div").hide();
  533. }
  534. form.render('checkbox');
  535. });
  536. form.on('checkbox(is_modify_sendscore)', function(data){
  537. console.log(data.elem.checked)
  538. if (data.elem.checked) {
  539. console.log(12);
  540. $("#send_score_divTip").css('display','inline');
  541. } else {
  542. console.log(33);
  543. $("#send_score_divTip").hide();
  544. }
  545. form.render('checkbox');
  546. });
  547. form.on('checkbox(xinrenckbox)', function(data){
  548. if (data.elem.checked) {
  549. $("#xianshickbox").removeAttr("checked");
  550. } else {
  551. }
  552. form.render('checkbox');
  553. });
  554. form.on('checkbox(xianshickbox)', function(data){
  555. if (data.elem.checked) {
  556. $("#xinrenckbox").removeAttr("checked");
  557. } else {
  558. }
  559. form.render('checkbox');
  560. });
  561. form.on('checkbox(hascommission)', function(data){
  562. if (data.elem.checked) {
  563. $('#commission_div').show();
  564. } else {
  565. $('#commission_div').hide();
  566. }
  567. })
  568. //hascommission
  569. $('#chose_label_id').click(function(){
  570. cur_open_div = $(this).attr('data-input');
  571. $.post("{:U('goods/labelquery', array('ok' => 1))}", {}, function(shtml){
  572. layer.open({
  573. type: 1,
  574. area: '930px',
  575. content: shtml //注意,如果str是object,那么需要字符拼接。
  576. });
  577. });
  578. })
  579. $('#chose_member_id').click(function(){
  580. cur_open_div = $(this).attr('data-input');
  581. $.post("{:U('supply/zhenquery', array('ok' => 1))}", {}, function(shtml){
  582. layer.open({
  583. type: 1,
  584. area: '930px',
  585. content: shtml //注意,如果str是object,那么需要字符拼接。
  586. });
  587. });
  588. })
  589. $('#chose_agent_id').click(function(){
  590. cur_open_div = $(this).attr('data-input');
  591. $.post("{:U('communityhead/query_head_user', array('ok' => 1))}", {}, function(shtml){
  592. layer.open({
  593. type: 1,
  594. area: '930px',
  595. content: shtml //注意,如果str是object,那么需要字符拼接。
  596. });
  597. });
  598. })
  599. $('#chose_link').click(function(){
  600. cur_open_div = $(this).attr('data-input');
  601. $.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
  602. layer.open({
  603. type: 1,
  604. area: '930px',
  605. content: shtml //注意,如果str是object,那么需要字符拼接。
  606. });
  607. });
  608. })
  609. $('.layui-tab-title li').click(function(){
  610. form.render('radio');
  611. form.render('checkbox');
  612. })
  613. //监听提交
  614. form.on('submit(formDemo)', function(data){
  615. var s_cates = $('#cates').val();
  616. var cate_mult = [];
  617. for(var i in s_cates)
  618. {
  619. cate_mult.push(s_cates[i]);
  620. }
  621. data.field.cate_mult = cate_mult;
  622. <?php if( !empty($is_open_goods_relative_goods) && $is_open_goods_relative_goods == 1 ){ ?>
  623. var gd_ar = [];
  624. var gd_str = '';
  625. $('.mult_choose_goodsid').each(function(){
  626. gd_ar.push( $(this).attr('data-gid') );
  627. })
  628. gd_str = gd_ar.join(',');
  629. data.field.limit_goods_list = gd_str;
  630. <?php } ?>
  631. $.ajax({
  632. url: data.form.action,
  633. type: data.form.method,
  634. data: data.field,
  635. dataType:'json',
  636. success: function (info) {
  637. if(info.status == 0)
  638. {
  639. layer.msg(info.result.message,{icon: 1,time: 2000});
  640. }else if(info.status == 1){
  641. var go_url = location.href;
  642. if( info.result.hasOwnProperty("url") )
  643. {
  644. go_url = info.result.url;
  645. }
  646. layer.msg('操作成功',{time: 1000,
  647. end:function(){
  648. location.href = info.result.url;
  649. }
  650. });
  651. }
  652. }
  653. });
  654. return false;
  655. });
  656. form.on('checkbox(hasoption)', function(data){
  657. if(data.elem.checked)
  658. {
  659. $('#goodssn').attr('readonly',true);
  660. $('#productsn').attr('readonly',true);
  661. $('#weight').attr('readonly',true);
  662. $('#total').attr('readonly',true);
  663. $("#tboption").show();
  664. $("#tbdiscount").show();
  665. $("#isdiscount_discounts").show();
  666. $("#isdiscount_discounts_default").hide();
  667. $("#commission").show();
  668. $("#commission_default").hide();
  669. $("#discounts_type1").show().parent().show();
  670. refreshOptions();
  671. }else{
  672. $('#weight').removeAttr('readonly');
  673. $('#total').removeAttr('readonly');
  674. $("#tboption").hide();
  675. refreshOptions();
  676. $("#isdiscount_discounts").hide();
  677. var isdiscount_discounts = $("#isdiscount_discounts").html();
  678. $("#isdiscount_discounts").html('');
  679. $("#isdiscount_discounts").html(isdiscount_discounts);
  680. $("#tbdiscount").hide();
  681. $("#isdiscount_discounts_default").show();
  682. $("#commission_default").show();
  683. $('#goodssn').removeAttr('readonly');
  684. $('#productsn').removeAttr('readonly');
  685. $("#discounts_type1").hide().parent().hide();
  686. $("#discounts_type0").click();
  687. $(this).prop("checked", false);
  688. }
  689. form.render('checkbox');
  690. });
  691. $('#chose_agent_id2').click(function(){
  692. cur_open_div = $(this).attr('data-input');
  693. $.post("{:U('goods/query_normal', array('template' => 'mult', 'unselect_goodsid' => $id))}", {}, function(shtml){
  694. layer.open({
  695. type: 1,
  696. area: '930px',
  697. content: shtml //注意,如果str是object,那么需要字符拼接。
  698. });
  699. });
  700. })
  701. form.on('checkbox(is_modify_head_commission)', function(data){
  702. if(data.elem.checked)
  703. {
  704. $("#head_commission_div").show();
  705. }else{
  706. $("#head_commission_div").hide();
  707. }
  708. form.render('checkbox');
  709. });
  710. })
  711. function cancle_bind(obj,sdiv)
  712. {
  713. $('#'+sdiv).val('');
  714. $(obj).parent().parent().remove();
  715. }
  716. </script>
  717. <script>
  718. $(function () {
  719. // 拖拽时开始滚动的间距
  720. var scrollingSensitivity = 20
  721. // 拖拽时滚动速度
  722. let scrollingSpeed = 20
  723. // 拖拽前的父级节点
  724. let dragBeforeParentNode = null
  725. // 初始化拖拽函数
  726. $('.multi-img-details').sortable({
  727. // 自适应placeholder的大小
  728. forceHelperSize: true,
  729. // 拖拽时的鼠标形状
  730. cursor: '-webkit-grabbing',
  731. // 拖拽的父级节点(该节点一定要注意,配置错误会导致当前屏幕外的元素没法自动滚动拖拽,两列之间拖拽的滚动也会出问题)
  732. appendTo: '.layui-form-item',
  733. // 拖拽时的倾斜度
  734. rotate: '5deg',
  735. // 延迟时间(毫秒),避免和click同时操作时出现的冲突
  736. delay: 0,
  737. // 以clone方式拖拽
  738. helper: 'clone',
  739. // 拖拽到边框出现滚动的间距,
  740. scrollSensitivity: scrollingSensitivity,
  741. // 应用于拖拽空白区域的样式
  742. placeholder: 'portlet-placeholder ui-state-highlight',
  743. // 允许拖拽预留空白区域
  744. forcePlaceholderSize: false,
  745. // 多个列表之间的拖拽的dom元素
  746. connectWith: '.multi-img-details',
  747. // 鼠标到区域则填充
  748. tolerance: "pointer",
  749. // 可以拖拽的项
  750. items: '.multi-item',
  751. // 填充动画
  752. revert: 0,
  753. // 拖拽结束函数
  754. stop: (e, ui) => {
  755. // 当前拽入的元素
  756. let item = $(ui.item)
  757. // 当前拽入元素的下标
  758. let index = item.index()
  759. let kid = ''
  760. // xxxx 这里面可以操作数据更新
  761. },
  762. // 开始拖拽时的函数
  763. start: (e, ui) => {
  764. // 拖拽前的父级节点
  765. dragBeforeParentNode = ui.item[0].parentNode
  766. // 让placeholder和源高度一致
  767. ui.helper.addClass('item').width(110)
  768. // xxxx 这里可以记录一些拖拽前的元素属性
  769. },
  770. // 处理两列滚动条问题
  771. sort: function (event, ui) {
  772. var scrollContainer = ui.placeholder[0].parentNode
  773. // 设置拽入的列表的滚动位置
  774. var overflowOffset = $(scrollContainer).offset()
  775. if ((overflowOffset.top + scrollContainer.offsetHeight) - event.pageY <
  776. scrollingSensitivity) {
  777. scrollContainer.scrollTop = scrollContainer.scrollTop + scrollingSpeed
  778. } else if (event.pageY - overflowOffset.top < scrollingSensitivity) {
  779. scrollContainer.scrollTop = scrollContainer.scrollTop - scrollingSpeed
  780. }
  781. }
  782. }).disableSelection()
  783. })
  784. </script>
  785. <script language="javascript">
  786. var chose_cate = -1;
  787. var chose_cate_id_arr = [];
  788. $(function(){
  789. $('#cates2').on('change',function(){
  790. var s_length = $("#cates2 option:selected").length -1;
  791. var options_name = $("#cates2 option:selected:eq("+s_length+")").text();
  792. var options_str = $("#cates2 option:selected:eq("+s_length+")").attr('data-names');
  793. if(s_length > chose_cate)
  794. {
  795. chose_cate++;
  796. var cur_cate_id = '';
  797. $("#cates2 option:selected").each(function(){
  798. var tmp_cate_id = parseInt($(this).val());
  799. if( $.inArray( tmp_cate_id, chose_cate_id_arr ) == -1)
  800. {
  801. chose_cate_id_arr.push( parseInt(tmp_cate_id) );
  802. cur_cate_id = tmp_cate_id;
  803. }
  804. })
  805. addSpecList(options_name,options_str,cur_cate_id);
  806. }else{
  807. chose_cate--;
  808. var new_chose_cate_id_arr = [];
  809. if(chose_cate_id_arr.length == 1)
  810. {
  811. $('.spec_class_'+chose_cate_id_arr[0]).remove();
  812. }
  813. $("#cates2 option:selected").each(function(){
  814. var tmp_cate_id = parseInt( $(this).val() );
  815. if( $.inArray( tmp_cate_id, chose_cate_id_arr ) != -1)
  816. {
  817. new_chose_cate_id_arr.push( parseInt(tmp_cate_id) );
  818. chose_cate_id_arr.splice($.inArray( tmp_cate_id, chose_cate_id_arr ), 1);
  819. }
  820. })
  821. if(chose_cate_id_arr.length == 1)
  822. {
  823. $('.spec_class_'+chose_cate_id_arr[0]).remove();
  824. }
  825. chose_cate_id_arr = new_chose_cate_id_arr;
  826. refreshOptions();
  827. }
  828. })
  829. $(document).on('input propertychange change', '#specs input', function () {
  830. window.optionchanged = true;
  831. $('#optiontip').show();
  832. });
  833. $(document).on('input propertychange change', '#specs input', function () {
  834. window.optionchanged = true;
  835. $('#optiontip').show();
  836. });
  837. $(".spec_item_thumb").find('i').click(function(){
  838. var group =$(this).parent();
  839. group.find('img').attr('src',"{SNAILFISH_LOCAL}static/images/nopic100.jpg");
  840. group.find(':hidden').val('');
  841. $(this).hide();
  842. group.find('img').popover('destroy');
  843. });
  844. });
  845. function selectSpecItemImage(obj){
  846. util.image('',function(val){
  847. $(obj).attr('src',val.url).popover({
  848. trigger: 'hover',
  849. html: true,
  850. container: $(document.body),
  851. content: "<img src='" + val.url + "' style='width:100px;height:100px;' />",
  852. placement: 'top'
  853. });
  854. var group =$(obj).parent();
  855. group.find(':hidden').val(val.attachment), group.find('i').show().unbind('click').click(function(){
  856. $(obj).attr('src',"{SNAILFISH_LOCAL}static/images/nopic100.jpg");
  857. group.find(':hidden').val('');
  858. group.find('i').hide();
  859. $(obj).popover('destroy');
  860. });
  861. });
  862. }
  863. function addSpecList(options_name,spec_str, cur_cate_id)
  864. {
  865. var len = $(".spec_item").length;
  866. $("#add-spec").html("正在处理...").attr("disabled", "true").toggleClass("btn-primary");
  867. var url = "{:U('goods/mult_tpl',array('tpl'=>'spec'))}";
  868. $.ajax({
  869. "url": url,
  870. type:'post',
  871. data:{options_name:options_name,spec_str:spec_str,cur_cate_id:cur_cate_id},
  872. success:function(data){
  873. $("#add-spec").html('<i class="fa fa-plus"></i> 添加规格').removeAttr("disabled").toggleClass("btn-primary"); ;
  874. $('#specs').append(data);
  875. var len = $(".add-specitem").length -1;
  876. $(".add-specitem:eq(" +len+ ")").focus();
  877. refreshOptions();
  878. }
  879. });
  880. }
  881. function addSpec(){
  882. var len = $(".spec_item").length;
  883. $("#add-spec").html("正在处理...").attr("disabled", "true").toggleClass("btn-primary");
  884. var url = "{:U('goods/tpl',array('tpl'=>'spec'))}";
  885. $.ajax({
  886. "url": url,
  887. success:function(data){
  888. $("#add-spec").html('<i class="fa fa-plus"></i> 添加规格').removeAttr("disabled").toggleClass("btn-primary"); ;
  889. $('#specs').append(data);
  890. var len = $(".add-specitem").length -1;
  891. $(".add-specitem:eq(" +len+ ")").focus();
  892. refreshOptions();
  893. }
  894. });
  895. }
  896. function removeSpec(specid){
  897. if (confirm('确认要删除此规格?')){
  898. $("#spec_" + specid).remove();
  899. refreshOptions();
  900. }
  901. }
  902. function addSpecItem(specid){
  903. $("#add-specitem-" + specid).html("正在处理...").attr("disabled", "true");
  904. var url = "{:U('goods/tpl',array('tpl'=>'specitem'))}" + "&specid=" + specid;
  905. $.ajax({
  906. "url": url,
  907. success:function(data){
  908. $("#add-specitem-" + specid).html('<i class="fa fa-plus"></i> 添加规格项').removeAttr("disabled");
  909. $('#spec_item_' + specid).append(data);
  910. var len = $("#spec_" + specid + " .spec_item_title").length -1;
  911. $("#spec_" + specid + " .spec_item_title:eq(" +len+ ")").focus();
  912. refreshOptions
  913. if(type==3 && virtual==0){
  914. $(".choosetemp").show();
  915. }
  916. }
  917. });
  918. }
  919. function removeSpecItem(obj){
  920. $(obj).closest('.spec_item_item').remove();
  921. refreshOptions();
  922. }
  923. function refreshOptions(){
  924. // 刷新后重置
  925. window.optionchanged = false;
  926. $('#optiontip').hide();
  927. var html = '<table class="table table-bordered table-condensed"><thead><tr class="active">';
  928. var specs = [];
  929. if($('.spec_item').length<=0){
  930. $("#options").html('');
  931. $("#discount").html('');
  932. $("#isdiscount_discounts").html('');
  933. $("#commission").html('');
  934. return;
  935. }
  936. $(".spec_item").each(function(i){
  937. var _this = $(this);
  938. var spec = {
  939. id: _this.find(".spec_id").val(),
  940. title: _this.find(".spec_title").val()
  941. };
  942. var items = [];
  943. _this.find(".spec_item_item").each(function(){
  944. var __this = $(this);
  945. var item = {
  946. id: __this.find(".spec_item_id").val(),
  947. title: __this.find(".spec_item_title").val(),
  948. virtual: __this.find(".spec_item_virtual").val(),
  949. show:__this.find(".spec_item_show").get(0).checked?"1":"0"
  950. }
  951. items.push(item);
  952. });
  953. spec.items = items;
  954. specs.push(spec);
  955. });
  956. specs.sort(function(x,y){
  957. if (x.items.length > y.items.length){
  958. return 1;
  959. }
  960. if (x.items.length < y.items.length) {
  961. return -1;
  962. }
  963. });
  964. var len = specs.length;
  965. var newlen = 1;
  966. var h = new Array(len);
  967. var rowspans = new Array(len);
  968. for(var i=0;i<len;i++){
  969. html+="<th>" + specs[i].title + "</th>";
  970. var itemlen = specs[i].items.length;
  971. if(itemlen<=0) { itemlen = 1 };
  972. newlen*=itemlen;
  973. h[i] = new Array(newlen);
  974. for(var j=0;j<newlen;j++){
  975. h[i][j] = new Array();
  976. }
  977. var l = specs[i].items.length;
  978. rowspans[i] = 1;
  979. for(j=i+1;j<len;j++){
  980. rowspans[i]*= specs[j].items.length;
  981. }
  982. }
  983. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">库存</div><div class="input-group"><input type="text" class="form-control input-sm option_stock_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_stock\');"></a></span></div></div></th>';
  984. html += '<th class="type-4"><div class=""><div style="padding-bottom:10px;text-align:center;">兑换积分</div><div class="input-group"><input type="text" class="form-control input-sm option_marketprice_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_marketprice\');"></a></span></div></div></th>';
  985. html+='<th class="type-4"><div class=""><div style="padding-bottom:10px;text-align:center;">原价</div><div class="input-group"><input type="text" class="form-control input-sm option_productprice_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_productprice\');"></a></span></div></div></th>';
  986. html+='<th class="type-4"><div class=""><div style="padding-bottom:10px;text-align:center;">成本价</div><div class="input-group"><input type="text" class="form-control input-sm option_costprice_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_costprice\');"></a></span></div></div></th>';
  987. html+='<th><div class=""><div style="padding-bottom:10px;text-align:center;">编码</div><div class="input-group"><input type="text" class="form-control input-sm option_goodssn_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_goodssn\');"></a></span></div></div></th>';
  988. html+='<th><div class=""><div style="padding-bottom:10px;text-align:center;">重量(克)</div><div class="input-group"><input type="text" class="form-control input-sm option_weight_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_weight\');"></a></span></div></div></th>';
  989. html+='</tr></thead>';
  990. for(var m=0;m<len;m++){
  991. var k = 0,kid = 0,n=0;
  992. for(var j=0;j<newlen;j++){
  993. var rowspan = rowspans[m];
  994. if( j % rowspan==0){
  995. h[m][j]={title: specs[m].items[kid].title, virtual: specs[m].items[kid].virtual,html: "<td class='full' rowspan='" +rowspan + "'>"+ specs[m].items[kid].title+"</td>\r\n",id: specs[m].items[kid].id};
  996. }
  997. else{
  998. h[m][j]={title:specs[m].items[kid].title,virtual: specs[m].items[kid].virtual, html: "",id: specs[m].items[kid].id};
  999. }
  1000. n++;
  1001. if(n==rowspan){
  1002. kid++; if(kid>specs[m].items.length-1) { kid=0; }
  1003. n=0;
  1004. }
  1005. }
  1006. }
  1007. var hh = "";
  1008. for(var i=0;i<newlen;i++){
  1009. hh+="<tr>";
  1010. var ids = [];
  1011. var titles = [];
  1012. var virtuals = [];
  1013. for(var j=0;j<len;j++){
  1014. hh+=h[j][i].html;
  1015. ids.push( h[j][i].id);
  1016. titles.push( h[j][i].title);
  1017. virtuals.push( h[j][i].virtual);
  1018. }
  1019. ids =ids.join('_');
  1020. titles= titles.join('+');
  1021. var val ={ id : "",title:titles, stock : "",presell : "",costprice : "",productprice : "",marketprice : "",weight:"",productsn:"",goodssn:"",virtual:virtuals };
  1022. if( $(".option_id_" + ids).length>0){
  1023. val ={
  1024. id : $(".option_id_" + ids+":eq(0)").val(),
  1025. title: titles,
  1026. stock : $(".option_stock_" + ids+":eq(0)").val(),
  1027. presell : $(".option_presell_" + ids+":eq(0)").val(),
  1028. costprice : $(".option_costprice_" + ids+":eq(0)").val(),
  1029. productprice : $(".option_productprice_" + ids+":eq(0)").val(),
  1030. marketprice : $(".option_marketprice_" + ids +":eq(0)").val(),
  1031. goodssn : $(".option_goodssn_" + ids +":eq(0)").val(),
  1032. productsn : $(".option_productsn_" + ids +":eq(0)").val(),
  1033. weight : $(".option_weight_" + ids+":eq(0)").val(),
  1034. virtual : virtuals
  1035. }
  1036. }
  1037. hh += '<td>'
  1038. hh += '<input name="option_stock_' + ids +'" type="text" class="form-control option_stock option_stock_' + ids +'" value="' +(val.stock=='undefined'?'':val.stock )+'"/></td>';
  1039. hh += '<input name="option_id_' + ids+'" type="hidden" class="form-control option_id option_id_' + ids +'" value="' +(val.id=='undefined'?'':val.id )+'"/>';
  1040. hh += '<input name="option_ids[]" type="hidden" class="form-control option_ids option_ids_' + ids +'" value="' + ids +'"/>';
  1041. hh += '<input name="option_title_' + ids +'" type="hidden" class="form-control option_title option_title_' + ids +'" value="' +(val.title=='undefined'?'':val.title )+'"/></td>';
  1042. hh += '<input name="option_virtual_' + ids +'" type="hidden" class="form-control option_virtual option_virtual_' + ids +'" value="' +(val.virtual=='undefined'?'':val.virtual )+'"/></td>';
  1043. hh += '</td>';
  1044. hh += '<td class="type-4"><input name="option_marketprice_' + ids+'" type="text" class="form-control option_marketprice option_marketprice_' + ids +'" value="' +(val.marketprice=='undefined'?'':val.marketprice )+'"/></td>';
  1045. hh += '<td class="type-4"><input name="option_productprice_' + ids+'" type="text" class="form-control option_productprice option_productprice_' + ids +'" " value="' +(val.productprice=='undefined'?'':val.productprice )+'"/></td>';
  1046. hh += '<td class="type-4"><input name="option_costprice_' +ids+'" type="text" class="form-control option_costprice option_costprice_' + ids +'" " value="' +(val.costprice=='undefined'?'':val.costprice )+'"/></td>';
  1047. hh += '<td><input name="option_goodssn_' +ids+'" type="text" class="form-control option_goodssn option_goodssn_' + ids +'" " value="' +(val.goodssn=='undefined'?'':val.goodssn )+'"/></td>';
  1048. //hh += '<td><input data-name="option_productsn_' +ids+'" type="text" class="form-control option_productsn option_productsn_' + ids +'" " value="' +(val.productsn=='undefined'?'':val.productsn )+'"/></td>';
  1049. hh += '<td><input name="option_weight_' + ids +'" type="text" class="form-control option_weight option_weight_' + ids +'" " value="' +(val.weight=='undefined'?'':val.weight )+'"/></td>';
  1050. hh += "</tr>";
  1051. }
  1052. html+=hh;
  1053. html+="</table>";
  1054. $("#options").html(html);
  1055. refreshDiscount();
  1056. refreshIsDiscount();
  1057. if(window.type=='4'){
  1058. $('.type-4').hide();
  1059. }else{
  1060. $('.type-4').show();
  1061. }
  1062. }
  1063. function refreshDiscount() {
  1064. var html = '<table class="table table-bordered table-condensed"><thead><tr class="active">';
  1065. var specs = [];
  1066. $(".spec_item").each(function (i) {
  1067. var _this = $(this);
  1068. var spec = {
  1069. id: _this.find(".spec_id").val(),
  1070. title: _this.find(".spec_title").val()
  1071. };
  1072. var items = [];
  1073. _this.find(".spec_item_item").each(function () {
  1074. var __this = $(this);
  1075. var item = {
  1076. id: __this.find(".spec_item_id").val(),
  1077. title: __this.find(".spec_item_title").val(),
  1078. virtual: __this.find(".spec_item_virtual").val(),
  1079. show: __this.find(".spec_item_show").get(0).checked ? "1" : "0"
  1080. }
  1081. items.push(item);
  1082. });
  1083. spec.items = items;
  1084. specs.push(spec);
  1085. });
  1086. specs.sort(function (x, y) {
  1087. if (x.items.length > y.items.length) {
  1088. return 1;
  1089. }
  1090. if (x.items.length < y.items.length) {
  1091. return -1;
  1092. }
  1093. });
  1094. var len = specs.length;
  1095. var newlen = 1;
  1096. var h = new Array(len);
  1097. var rowspans = new Array(len);
  1098. for (var i = 0; i < len; i++) {
  1099. html += "<th>" + specs[i].title + "</th>";
  1100. var itemlen = specs[i].items.length;
  1101. if (itemlen <= 0) {
  1102. itemlen = 1
  1103. }
  1104. ;
  1105. newlen *= itemlen;
  1106. h[i] = new Array(newlen);
  1107. for (var j = 0; j < newlen; j++) {
  1108. h[i][j] = new Array();
  1109. }
  1110. var l = specs[i].items.length;
  1111. rowspans[i] = 1;
  1112. for (j = i + 1; j < len; j++) {
  1113. rowspans[i] *= specs[j].items.length;
  1114. }
  1115. }
  1116. <?php foreach( $levels as $level ){ ?>
  1117. <?php if( $level['key']=='default'){ ?>
  1118. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">{$level['levelname']}</div><div class="input-group"><input type="text" class="form-control input-sm discount_{$level["key"]}_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'discount_{$level["key"]}\');"></a></span></div></div></th>';
  1119. <?php }else{ ?>
  1120. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">{$level['levelname']}</div><div class="input-group"><input type="text" class="form-control input-sm discount_level{$level['id']}_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'discount_level{$level['id']}\');"></a></span></div></div></th>';
  1121. <?php } ?>
  1122. <?php } ?>
  1123. html += '</tr></thead>';
  1124. for (var m = 0; m < len; m++) {
  1125. var k = 0, kid = 0, n = 0;
  1126. for (var j = 0; j < newlen; j++) {
  1127. var rowspan = rowspans[m];
  1128. if (j % rowspan == 0) {
  1129. h[m][j] = {
  1130. title: specs[m].items[kid].title,
  1131. virtual: specs[m].items[kid].virtual,
  1132. html: "<td class='full' rowspan='" + rowspan + "'>" + specs[m].items[kid].title + "</td>\r\n",
  1133. id: specs[m].items[kid].id
  1134. };
  1135. }
  1136. else {
  1137. h[m][j] = {
  1138. title: specs[m].items[kid].title,
  1139. virtual: specs[m].items[kid].virtual,
  1140. html: "",
  1141. id: specs[m].items[kid].id
  1142. };
  1143. }
  1144. n++;
  1145. if (n == rowspan) {
  1146. kid++;
  1147. if (kid > specs[m].items.length - 1) {
  1148. kid = 0;
  1149. }
  1150. n = 0;
  1151. }
  1152. }
  1153. }
  1154. var hh = "";
  1155. for (var i = 0; i < newlen; i++) {
  1156. hh += "<tr>";
  1157. var ids = [];
  1158. var titles = [];
  1159. var virtuals = [];
  1160. for (var j = 0; j < len; j++) {
  1161. hh += h[j][i].html;
  1162. ids.push(h[j][i].id);
  1163. titles.push(h[j][i].title);
  1164. virtuals.push(h[j][i].virtual);
  1165. }
  1166. ids = ids.join('_');
  1167. titles = titles.join('+');
  1168. var val = {
  1169. id: "",
  1170. title: titles,
  1171. <?php foreach( $levels as $level ){ ?>
  1172. <?php if( $level['key']=='default'){ ?>
  1173. level{$level['key']}: '',
  1174. <?php }else{ ?>
  1175. level{$level['id']}: '',
  1176. <?php } ?>
  1177. <?php } ?>
  1178. costprice: "",
  1179. presell: "",
  1180. productprice: "",
  1181. marketprice: "",
  1182. weight: "",
  1183. productsn: "",
  1184. goodssn: "",
  1185. virtual: virtuals
  1186. };
  1187. var val ={ id : "",title:titles,<?php foreach( $levels as $level ){ ?><?php if( $level['key']=='default'){ ?> level{$level['key']}: '',<?php }else{ ?> level{$level['id']}: '',<?php } ?><?php } ?>costprice : "",productprice : "",marketprice : "",weight:"",productsn:"",goodssn:"",virtual:virtuals };
  1188. if ($(".discount_id_" + ids).length > 0) {
  1189. val = {
  1190. id: $(".discount_id_" + ids + ":eq(0)").val(),
  1191. title: titles,
  1192. <?php foreach( $levels as $level ){ ?>
  1193. <?php if( $level['key']=='default'){ ?>
  1194. level{$level['key']}: $(".discount_{$level['key']}_" + ids + ":eq(0)").val(),
  1195. <?php }else{ ?>
  1196. level{$level['id']}: $(".discount_level{$level['id']}_" + ids + ":eq(0)").val(),
  1197. <?php } ?>
  1198. <?php } ?>
  1199. costprice: $(".discount_costprice_" + ids + ":eq(0)").val(),
  1200. presell: $(".discount_presell_" + ids + ":eq(0)").val(),
  1201. productprice: $(".discount_productprice_" + ids + ":eq(0)").val(),
  1202. marketprice: $(".discount_marketprice_" + ids + ":eq(0)").val(),
  1203. presell: $(".discount_presell_" + ids + ":eq(0)").val(),
  1204. goodssn: $(".discount_goodssn_" + ids + ":eq(0)").val(),
  1205. productsn: $(".discount_productsn_" + ids + ":eq(0)").val(),
  1206. weight: $(".discount_weight_" + ids + ":eq(0)").val(),
  1207. virtual: virtuals
  1208. }
  1209. }
  1210. <?php foreach( $levels as $level ){ ?>
  1211. hh += '<td>'
  1212. <?php if( $level['key']=='default'){ ?>
  1213. hh += '<input data-name="discount_level_{$level['key']}_' + ids +'"type="text" class="form-control discount_{$level['key']} discount_{$level['key']}_' + ids +'" value="' +(val.level{$level['key']}=='undefined'?'':val.level{$level['key']} )+'"/>';
  1214. <?php }else{ ?>
  1215. hh += '<input data-name="discount_level_{$level['id']}_' + ids +'"type="text" class="form-control discount_level{$level['id']} discount_level{$level['id']}_' + ids +'" value="' +(val.level{$level['id']}=='undefined'?'':val.level{$level['id']} )+'"/>';
  1216. <?php } ?>
  1217. hh += '</td>';
  1218. <?php } ?>
  1219. hh += '<input data-name="discount_id_' + ids+'"type="hidden" class="form-control discount_id discount_id_' + ids +'" value="' +(val.id=='undefined'?'':val.id )+'"/>';
  1220. hh += '<input data-name="discount_ids"type="hidden" class="form-control discount_ids discount_ids_' + ids +'" value="' + ids +'"/>';
  1221. hh += '<input data-name="discount_title_' + ids +'"type="hidden" class="form-control discount_title discount_title_' + ids +'" value="' +(val.title=='undefined'?'':val.title )+'"/></td>';
  1222. hh += '<input data-name="discount_virtual_' + ids +'"type="hidden" class="form-control discount_virtual discount_virtual_' + ids +'" value="' +(val.virtual=='undefined'?'':val.virtual )+'"/></td>';
  1223. hh += "</tr>";
  1224. }
  1225. html += hh;
  1226. html += "</table>";
  1227. $("#discount").html(html);
  1228. }
  1229. function refreshIsDiscount() {
  1230. var html = '<table class="table table-bordered table-condensed"><thead><tr class="active">';
  1231. var specs = [];
  1232. $(".spec_item").each(function (i) {
  1233. var _this = $(this);
  1234. var spec = {
  1235. id: _this.find(".spec_id").val(),
  1236. title: _this.find(".spec_title").val()
  1237. };
  1238. var items = [];
  1239. _this.find(".spec_item_item").each(function () {
  1240. var __this = $(this);
  1241. var item = {
  1242. id: __this.find(".spec_item_id").val(),
  1243. title: __this.find(".spec_item_title").val(),
  1244. virtual: __this.find(".spec_item_virtual").val(),
  1245. show: __this.find(".spec_item_show").get(0).checked ? "1" : "0"
  1246. }
  1247. items.push(item);
  1248. });
  1249. spec.items = items;
  1250. specs.push(spec);
  1251. });
  1252. specs.sort(function (x, y) {
  1253. if (x.items.length > y.items.length) {
  1254. return 1;
  1255. }
  1256. if (x.items.length < y.items.length) {
  1257. return -1;
  1258. }
  1259. });
  1260. var len = specs.length;
  1261. var newlen = 1;
  1262. var h = new Array(len);
  1263. var rowspans = new Array(len);
  1264. for (var i = 0; i < len; i++) {
  1265. html += "<th>" + specs[i].title + "</th>";
  1266. var itemlen = specs[i].items.length;
  1267. if (itemlen <= 0) {
  1268. itemlen = 1
  1269. }
  1270. ;
  1271. newlen *= itemlen;
  1272. h[i] = new Array(newlen);
  1273. for (var j = 0; j < newlen; j++) {
  1274. h[i][j] = new Array();
  1275. }
  1276. var l = specs[i].items.length;
  1277. rowspans[i] = 1;
  1278. for (j = i + 1; j < len; j++) {
  1279. rowspans[i] *= specs[j].items.length;
  1280. }
  1281. }
  1282. <?php foreach( $levels as $level ){ ?>
  1283. <?php if( $level['key']=='default'){ ?>
  1284. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">{$level['levelname']}</div><div class="input-group"><input type="text" class="form-control input-sm isdiscount_discounts_{$level['key']}_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'isdiscount_discounts_{$level['key']}\');"></a></span></div></div></th>';
  1285. <?php }else{ ?>
  1286. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">{$level['levelname']}</div><div class="input-group"><input type="text" class="form-control input-sm isdiscount_discounts_level{$level['id']}_all"VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'isdiscount_discounts_level{$level['id']}\');"></a></span></div></div></th>';
  1287. <?php } ?>
  1288. <?php } ?>
  1289. html += '</tr></thead>';
  1290. for (var m = 0; m < len; m++) {
  1291. var k = 0, kid = 0, n = 0;
  1292. for (var j = 0; j < newlen; j++) {
  1293. var rowspan = rowspans[m];
  1294. if (j % rowspan == 0) {
  1295. h[m][j] = {
  1296. title: specs[m].items[kid].title,
  1297. virtual: specs[m].items[kid].virtual,
  1298. html: "<td class='full' rowspan='" + rowspan + "'>" + specs[m].items[kid].title + "</td>\r\n",
  1299. id: specs[m].items[kid].id
  1300. };
  1301. }
  1302. else {
  1303. h[m][j] = {
  1304. title: specs[m].items[kid].title,
  1305. virtual: specs[m].items[kid].virtual,
  1306. html: "",
  1307. id: specs[m].items[kid].id
  1308. };
  1309. }
  1310. n++;
  1311. if (n == rowspan) {
  1312. kid++;
  1313. if (kid > specs[m].items.length - 1) {
  1314. kid = 0;
  1315. }
  1316. n = 0;
  1317. }
  1318. }
  1319. }
  1320. var hh = "";
  1321. for (var i = 0; i < newlen; i++) {
  1322. hh += "<tr>";
  1323. var ids = [];
  1324. var titles = [];
  1325. var virtuals = [];
  1326. for (var j = 0; j < len; j++) {
  1327. hh += h[j][i].html;
  1328. ids.push(h[j][i].id);
  1329. titles.push(h[j][i].title);
  1330. virtuals.push(h[j][i].virtual);
  1331. }
  1332. ids = ids.join('_');
  1333. titles = titles.join('+');
  1334. var val = {
  1335. id: "",
  1336. title: titles,
  1337. <?php foreach( $levels as $level ){ ?>
  1338. <?php if( $level['key']=='default'){ ?>
  1339. level{$level['key']}: '',
  1340. <?php }else{ ?>
  1341. level{$level['if']}: '',
  1342. <?php } ?>
  1343. <?php } ?>
  1344. costprice: "",
  1345. presell: "",
  1346. productprice: "",
  1347. marketprice: "",
  1348. weight: "",
  1349. productsn: "",
  1350. goodssn: "",
  1351. virtual: virtuals
  1352. };
  1353. var val ={ id : "",title:titles,<?php foreach( $levels as $level ){ ?><?php if( $level['key']=='default'){ ?> level{$level['key']}: '',<?php }else{ ?> level{$level['id']}: '',<?php } ?><?php } ?>costprice : "",productprice : "",marketprice : "",weight:"",productsn:"",goodssn:"",virtual:virtuals };
  1354. if ($(".isdiscount_discounts_id_" + ids).length > 0) {
  1355. val = {
  1356. id: $(".isdiscount_discounts_id_" + ids + ":eq(0)").val(),
  1357. title: titles,
  1358. <?php foreach( $levels as $level ){ ?>
  1359. <?php if( $level['key']=='default'){ ?>
  1360. level{$level['key']}: $(".isdiscount_discounts_{$level['key']}_" + ids + ":eq(0)").val(),
  1361. <?php }else{ ?>
  1362. level{$level['id']}: $(".isdiscount_discounts_level{$level['id']}_" + ids + ":eq(0)").val(),
  1363. <?php } ?>
  1364. <?php } ?>
  1365. costprice: $(".isdiscount_discounts_costprice_" + ids + ":eq(0)").val(),
  1366. productprice: $(".isdiscount_discounts_productprice_" + ids + ":eq(0)").val(),
  1367. marketprice: $(".isdiscount_discounts_marketprice_" + ids + ":eq(0)").val(),
  1368. presell: $(".isdiscount_discounts_presell_" + ids + ":eq(0)").val(),
  1369. goodssn: $(".isdiscount_discounts_goodssn_" + ids + ":eq(0)").val(),
  1370. productsn: $(".isdiscount_discounts_productsn_" + ids + ":eq(0)").val(),
  1371. weight: $(".isdiscount_discounts_weight_" + ids + ":eq(0)").val(),
  1372. virtual: virtuals
  1373. }
  1374. }
  1375. <?php foreach( $levels as $level ){ ?>
  1376. hh += '<td>'
  1377. <?php if( $level['key']=='default'){ ?>
  1378. hh += '<input data-name="isdiscount_discounts_level_{$level['key']}_' + ids +'"type="text" class="form-control isdiscount_discounts_{$level['key']} isdiscount_discounts_{$level['key']}_' + ids +'" value="' +(val.level{$level['key']}=='undefined'?'':val.level{$level['key']} )+'"/>';
  1379. <?php }else{ ?>
  1380. hh += '<input data-name="isdiscount_discounts_level_{$level['id']}_' + ids +'"type="text" class="form-control isdiscount_discounts_level{$level['id']} isdiscount_discounts_level{$level['id']}_' + ids +'" value="' +(val.level{$level['id']}=='undefined'?'':val.level{$level['id']} )+'"/>';
  1381. <?php } ?>
  1382. hh += '</td>';
  1383. <?php } ?>
  1384. hh += '<input data-name="isdiscount_discounts_id_' + ids+'"type="hidden" class="form-control isdiscount_discounts_id isdiscount_discounts_id_' + ids +'" value="' +(val.id=='undefined'?'':val.id )+'"/>';
  1385. hh += '<input data-name="isdiscount_discounts_ids"type="hidden" class="form-control isdiscount_discounts_ids isdiscount_discounts_ids_' + ids +'" value="' + ids +'"/>';
  1386. hh += '<input data-name="isdiscount_discounts_title_' + ids +'"type="hidden" class="form-control isdiscount_discounts_title isdiscount_discounts_title_' + ids +'" value="' +(val.title=='undefined'?'':val.title )+'"/></td>';
  1387. hh += '<input data-name="isdiscount_discounts_virtual_' + ids +'"type="hidden" class="form-control isdiscount_discounts_virtual isdiscount_discounts_virtual_' + ids +'" value="' +(val.virtual=='undefined'?'':val.virtual )+'"/></td>';
  1388. hh += "</tr>";
  1389. }
  1390. html += hh;
  1391. html += "</table>";
  1392. $("#isdiscount_discounts").html(html);
  1393. }
  1394. function refreshCommission() {
  1395. var commission_level = {:json_encode($commission_level)};
  1396. var html = '<table class="table table-bordered table-condensed"><thead><tr class="active">';
  1397. var specs = [];
  1398. $(".spec_item").each(function (i) {
  1399. var _this = $(this);
  1400. var spec = {
  1401. id: _this.find(".spec_id").val(),
  1402. title: _this.find(".spec_title").val()
  1403. };
  1404. var items = [];
  1405. _this.find(".spec_item_item").each(function () {
  1406. var __this = $(this);
  1407. var item = {
  1408. id: __this.find(".spec_item_id").val(),
  1409. title: __this.find(".spec_item_title").val(),
  1410. virtual: __this.find(".spec_item_virtual").val(),
  1411. show: __this.find(".spec_item_show").get(0).checked ? "1" : "0"
  1412. }
  1413. items.push(item);
  1414. });
  1415. spec.items = items;
  1416. specs.push(spec);
  1417. });
  1418. specs.sort(function (x, y) {
  1419. if (x.items.length > y.items.length) {
  1420. return 1;
  1421. }
  1422. if (x.items.length < y.items.length) {
  1423. return -1;
  1424. }
  1425. });
  1426. var len = specs.length;
  1427. var newlen = 1;
  1428. var h = new Array(len);
  1429. var rowspans = new Array(len);
  1430. for (var i = 0; i < len; i++) {
  1431. html += "<th>" + specs[i].title + "</th>";
  1432. var itemlen = specs[i].items.length;
  1433. if (itemlen <= 0) {
  1434. itemlen = 1
  1435. }
  1436. ;
  1437. newlen *= itemlen;
  1438. h[i] = new Array(newlen);
  1439. for (var j = 0; j < newlen; j++) {
  1440. h[i][j] = new Array();
  1441. }
  1442. var l = specs[i].items.length;
  1443. rowspans[i] = 1;
  1444. for (j = i + 1; j < len; j++) {
  1445. rowspans[i] *= specs[j].items.length;
  1446. }
  1447. }
  1448. $.each(commission_level,function (key,level) {
  1449. html += '<th><div class=""><div style="padding-bottom:10px;text-align:center;">'+level.levelname+'</div></div></th>';
  1450. })
  1451. html += '</tr></thead>';
  1452. for (var m = 0; m < len; m++) {
  1453. var k = 0, kid = 0, n = 0;
  1454. for (var j = 0; j < newlen; j++) {
  1455. var rowspan = rowspans[m];
  1456. if (j % rowspan == 0) {
  1457. h[m][j] = {
  1458. title: specs[m].items[kid].title,
  1459. virtual: specs[m].items[kid].virtual,
  1460. html: "<td class='full' rowspan='" + rowspan + "'>" + specs[m].items[kid].title + "</td>\r\n",
  1461. id: specs[m].items[kid].id
  1462. };
  1463. }
  1464. else {
  1465. h[m][j] = {
  1466. title: specs[m].items[kid].title,
  1467. virtual: specs[m].items[kid].virtual,
  1468. html: "",
  1469. id: specs[m].items[kid].id
  1470. };
  1471. }
  1472. n++;
  1473. if (n == rowspan) {
  1474. kid++;
  1475. if (kid > specs[m].items.length - 1) {
  1476. kid = 0;
  1477. }
  1478. n = 0;
  1479. }
  1480. }
  1481. }
  1482. var hh = "";
  1483. for (var i = 0; i < newlen; i++) {
  1484. hh += "<tr>";
  1485. var ids = [];
  1486. var titles = [];
  1487. var virtuals = [];
  1488. for (var j = 0; j < len; j++) {
  1489. hh += h[j][i].html;
  1490. ids.push(h[j][i].id);
  1491. titles.push(h[j][i].title);
  1492. virtuals.push(h[j][i].virtual);
  1493. }
  1494. ids = ids.join('_');
  1495. titles = titles.join('+');
  1496. var val = {
  1497. id: "",
  1498. title: titles,
  1499. <?php foreach( $commission_level as $level ){ ?>
  1500. <?php if( $level["key"] == "default"){ ?>
  1501. level{$level['key']}: '',
  1502. <?php }else{ ?>
  1503. level{$level['id']}: '',
  1504. <?php } ?>
  1505. <?php } ?>
  1506. costprice: "",
  1507. presell: "",
  1508. productprice: "",
  1509. marketprice: "",
  1510. weight: "",
  1511. productsn: "",
  1512. goodssn: "",
  1513. virtual: virtuals
  1514. };
  1515. var val ={ id : "",title:titles,<?php foreach( $commission_level as $level ){ ?> <?php if( $level["key"] == "default"){ ?>level{$level['key']}: '',<?php }else{ ?>level{$level['id']}: '',<?php } ?><?php } ?>costprice : "",productprice : "",marketprice : "",weight:"",productsn:"",goodssn:"",virtual:virtuals };
  1516. <?php foreach( $commission_level as $level ){ ?>
  1517. <?php if( $level["key"] == "default"){ ?>
  1518. var level{$level['key']} = new Array(3);
  1519. $(".commission_{$level['key']}_"+ ids).each(function(index,val){
  1520. level{$level['key']}[index] = val;
  1521. })
  1522. <?php }else{ ?>
  1523. var level{$level['id']} = new Array(3);
  1524. $(".commission_level{$level['id']}_"+ ids).each(function(index,val){
  1525. level{$level['id']}[index] = val;
  1526. })
  1527. <?php } ?>
  1528. <?php } ?>
  1529. if ($(".commission_id_" + ids).length > 0) {
  1530. val = {
  1531. id: $(".commission_id_" + ids + ":eq(0)").val(),
  1532. title: titles,
  1533. costprice: $(".commission_costprice_" + ids + ":eq(0)").val(),
  1534. presell: $(".commission_presell_" + ids + ":eq(0)").val(),
  1535. productprice: $(".commission_productprice_" + ids + ":eq(0)").val(),
  1536. marketprice: $(".commission_marketprice_" + ids + ":eq(0)").val(),
  1537. goodssn: $(".commission_goodssn_" + ids + ":eq(0)").val(),
  1538. productsn: $(".commission_productsn_" + ids + ":eq(0)").val(),
  1539. weight: $(".commission_weight_" + ids + ":eq(0)").val(),
  1540. virtual: virtuals
  1541. }
  1542. }
  1543. <?php foreach( $commission_level as $level ){ ?>
  1544. hh += '<td>';
  1545. var level_temp = <?php if( $level['key'] == 'default'){ ?>level{$level['key']}<?php }else{ ?>level{$level['id']}<?php } ?>;
  1546. if (len >= i && typeof (level_temp) != 'undefined')
  1547. {
  1548. if('{$level['key']}' == 'default')
  1549. {
  1550. for (var li = 0; li<{$shopset_level};li++)
  1551. {
  1552. if (typeof (level_temp[li])!= "undefined")
  1553. {
  1554. hh += '<input data-name="commission_level_{$level['key']}_' +ids+ '" type="text" class="form-control commission_{$level['key']} commission_{$level['key']}_' +ids+ '" value="' +$(level_temp[li]).val()+ '" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1555. }
  1556. else
  1557. {
  1558. hh += '<input data-name="commission_level_{$level['key']}_' +ids+ '" type="text" class="form-control commission_{$level['key']} commission_{$level['key']}_' +ids+ '" value="" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1559. }
  1560. }
  1561. }
  1562. else
  1563. {
  1564. for (var li = 0; li<{$shopset_level};li++)
  1565. {
  1566. if (typeof (level_temp[li])!= "undefined")
  1567. {
  1568. hh += '<input data-name="commission_level_{$level['id']}_' +ids+ '" type="text" class="form-control commission_level{$level['id']} commission_level{$level['id']}_' +ids+ '" value="' +$(level_temp[li]).val()+ '" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1569. }
  1570. else
  1571. {
  1572. hh += '<input data-name="commission_level_{$level['id']}_' +ids+ '" type="text" class="form-control commission_level{$level['id']} commission_level{$level['id']}_' +ids+ '" value="" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1573. }
  1574. }
  1575. }
  1576. }
  1577. else
  1578. {
  1579. if('{$level['key']}' == 'default')
  1580. {
  1581. for (var li = 0; li<{$shopset_level};li++)
  1582. {
  1583. if (typeof (level_temp[li])!= "undefined")
  1584. {
  1585. hh += '<input data-name="commission_level_{$level['key']}_' +ids+ '" type="text" class="form-control commission_{$level['key']} commission_{$level['key']}_' +ids+ '" value="' +$(level_temp[li]).val()+ '" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1586. }
  1587. else
  1588. {
  1589. hh += '<input data-name="commission_level_{$level['key']}_' +ids+ '" type="text" class="form-control commission_{$level['key']} commission_{$level['key']}_' +ids+ '" value="" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1590. }
  1591. }
  1592. }
  1593. else
  1594. {
  1595. for (var li = 0; li<{$shopset_level};li++)
  1596. {
  1597. if (typeof (level_temp[li])!= "undefined")
  1598. {
  1599. hh += '<input data-name="commission_level_{$level['id']}_' +ids+ '" type="text" class="form-control commission_level{$level['id']} commission_level{$level['id']}_' +ids+ '" value="' +$(level_temp[li]).val()+ '" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1600. }
  1601. else
  1602. {
  1603. hh += '<input data-name="commission_level_{$level['id']}_' +ids+ '" type="text" class="form-control commission_level{$level['id']} commission_level{$level['id']}_' +ids+ '" value="" style="display:inline;width: '+96/parseInt({$shopset_level})+'%;"/> ';
  1604. }
  1605. }
  1606. }
  1607. }
  1608. hh += '</td>';
  1609. <?php } ?>
  1610. hh += '<input data-name="commission_id_' + ids+'"type="hidden" class="form-control commission_id commission_id_' + ids +'" value="' +(val.id=='undefined'?'':val.id )+'"/>';
  1611. hh += '<input data-name="commission_ids"type="hidden" class="form-control commission_ids commission_ids_' + ids +'" value="' + ids +'"/>';
  1612. hh += '<input data-name="commission_title_' + ids +'"type="hidden" class="form-control commission_title commission_title_' + ids +'" value="' +(val.title=='undefined'?'':val.title )+'"/></td>';
  1613. hh += '<input data-name="commission_virtual_' + ids +'"type="hidden" class="form-control commission_virtual commission_virtual_' + ids +'" value="' +(val.virtual=='undefined'?'':val.virtual )+'"/></td>';
  1614. hh += "</tr>";
  1615. }
  1616. html += hh;
  1617. html += "</table>";
  1618. $("#commission").html(html);
  1619. }
  1620. function setCol(cls){
  1621. $("."+cls).val( $("."+cls+"_all").val());
  1622. }
  1623. function showItem(obj){
  1624. var show = $(obj).get(0).checked?"1":"0";
  1625. $(obj).parents('.spec_item_item').find('.spec_item_show:eq(0)').val(show);
  1626. }
  1627. function nofind(){
  1628. var img=event.srcElement;
  1629. img.src="./resource/image/module-nopic-small.jpg";
  1630. img.onerror=null;
  1631. }
  1632. function choosetemp(id){
  1633. $('#modal-module-chooestemp').modal();
  1634. $('#modal-module-chooestemp').data("temp",id);
  1635. }
  1636. function addtemp(){
  1637. var id = $('#modal-module-chooestemp').data("temp");
  1638. var temp_id = $('#modal-module-chooestemp').find("select").val();
  1639. var temp_name = $('#modal-module-chooestemp option[value='+temp_id+']').text();
  1640. //alert(temp_id+":"+temp_name);
  1641. $("#temp_name_"+id).val(temp_name);
  1642. $("#temp_id_"+id).val(temp_id);
  1643. $('#modal-module-chooestemp .close').click();
  1644. refreshOptions()
  1645. }
  1646. function setinterval(type)
  1647. {
  1648. var intervalfloor =$('#intervalfloor').val();
  1649. if(intervalfloor=="")
  1650. {
  1651. intervalfloor=0;
  1652. }
  1653. intervalfloor = parseInt(intervalfloor);
  1654. if(type=='plus')
  1655. {
  1656. if(intervalfloor==3)
  1657. {
  1658. tip.msgbox.err("最多添加三个区间价格");
  1659. return;
  1660. }
  1661. intervalfloor=intervalfloor+1;
  1662. }
  1663. else if(type=='minus')
  1664. {
  1665. if(intervalfloor==0)
  1666. {
  1667. tip.msgbox.err("请最少添加一个区间价格");
  1668. return;
  1669. }
  1670. intervalfloor=intervalfloor-1;
  1671. }else
  1672. {
  1673. return;
  1674. }
  1675. if(intervalfloor<1)
  1676. {
  1677. $('#interval1').hide();
  1678. $('#intervalnum1').val("");
  1679. $('#intervalprice1').val("");
  1680. }else
  1681. {
  1682. $('#interval1').show();
  1683. }
  1684. if(intervalfloor<2)
  1685. {
  1686. $('#interval2').hide();
  1687. $('#intervalnum2').val("");
  1688. $('#intervalprice2').val("");
  1689. }else
  1690. {
  1691. $('#interval2').show();
  1692. }
  1693. if(intervalfloor<3)
  1694. {
  1695. $('#interval3').hide();
  1696. $('#intervalnum3').val("");
  1697. $('#intervalprice3').val("");
  1698. }else
  1699. {
  1700. $('#interval3').show();
  1701. }
  1702. $('#intervalfloor').val(intervalfloor);
  1703. }
  1704. </script>
  1705. <script language="javascript">
  1706. $(function() {
  1707. })
  1708. </script>
  1709. </body>