addgoods.html 77 KB

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