addgoods.html 81 KB

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