edit.html 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. <extend name="Public:base" />
  2. <block name="content">
  3. <link rel="stylesheet" href="__CSS__/dialog.css" />
  4. <link rel="stylesheet" href="Common/css/chosen.css" />
  5. <link rel="stylesheet" href="Common/css/select2.css" />
  6. <style>
  7. .chosen-container-single .chosen-search:after{display:none;}
  8. .add-sku {
  9. display: inline-block;
  10. padding: 0 5px;
  11. margin: 9px 5px 0 5px;
  12. vertical-align: top;
  13. }
  14. </style>
  15. <div class="ks-ext-mask" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 999; display:none"></div>
  16. <div id="dialog" class="dialog" style="z-index: 9999; display:none">
  17. <div class="ks-contentbox">
  18. <div class="title"><span>新增菜单</span><a class="ks-ext-close" href="javascript:void(0)">X</a></div>
  19. <input type="hidden" name="action" value="" />
  20. <div class="row">
  21. <div class="col-xs-12" id="ks_shipping">
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="page-header" style="">
  27. <h1>
  28. {$breadcrumb2}
  29. <small>
  30. <i class="icon-double-angle-right"></i>
  31. {$crumbs}
  32. </small>
  33. <div style="right:10%;position: fixed;z-index: 999999;background-color: #fff;width: 100px;top:100px;">
  34. <button name="send" form="form-goods" id="submit" type="submit" style="width:100px;" class="btn btn-sm btn-primary">提交</button>
  35. </div>
  36. </h1>
  37. </div>
  38. <div style="height:58px;"></div>
  39. <div class="row">
  40. <div class="col-xs-12">
  41. <div class="panel-body">
  42. <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-goods" class="form-horizontal">
  43. <input type="hidden" value="{$goods_option_mult_str}" name="mult_option_zuhe" id="mult_option_zuhe" />
  44. <notempty name="Think.get.id">
  45. <input name="goods_id" type="hidden" value="{$Think.get.id}" />
  46. </notempty>
  47. <ul class="nav nav-tabs">
  48. <li class="active"><a href="#tab-general" data-toggle="tab">常规项</a></li>
  49. </ul>
  50. <div class="tab-content">
  51. <!-- 常规 START -->
  52. <div class="tab-pane active" id="tab-general">
  53. <div class="form-group required">
  54. <label class="col-sm-2 control-label" for="input-name2">商品名称:</label>
  55. <div class="col-sm-10">
  56. <input id="input-name2" class="form-control" type="text" placeholder="商品名称:" value="{$goods.name|default=''}" name="goods_description[name]">
  57. </div>
  58. </div>
  59. <div class="form-group">
  60. <label class="col-sm-2 control-label" for="input-description">商品简介:</label>
  61. <div class="col-sm-10">
  62. <textarea name="goods_description[summary]" class="form-control" rows="5">{$description.summary|default=''}</textarea>
  63. </div>
  64. </div>
  65. <div class="form-group required">
  66. <label class="col-sm-2 control-label" for="input-name2">分享标题:</label>
  67. <div class="col-sm-10">
  68. <input id="input-name2" class="form-control" type="text" placeholder="自定义分享标题" value="{$description.share_title|default=''}" name="goods_description[share_title]">
  69. <span class="help-inline ">
  70. <span class="middle red">不填写,默认使用商品标题分享</span>
  71. </span>
  72. </div>
  73. </div>
  74. <div class="form-group required">
  75. <label class="col-sm-2 control-label" for="input-name2">分享描述:</label>
  76. <div class="col-sm-10">
  77. <input id="input-name2" class="form-control" type="text" placeholder="自定义分享描述" value="{$description.share_descript|default=''}" name="goods_description[share_descript]">
  78. <span class="help-inline ">
  79. <span class="middle red">不填写,默认使用商品简介分享</span>
  80. </span>
  81. </div>
  82. </div>
  83. <div class="form-group required">
  84. <label class="col-sm-2 control-label" for="input-image">
  85. <span title="" data-toggle="tooltip" data-original-title="上传750x352的图片">首页横条展示图:</span>
  86. </label>
  87. <div class="col-sm-10" id="thumb">
  88. <a href="#" data-toggle="image" class="img-thumbnail">
  89. <img osctype="image" <if condition="$goods['image']">
  90. src="__ROOT__/{$goods.thumb_image}"
  91. <else />
  92. src="__ROOT__/Common/image/no_image_100x100.jpg"
  93. </if> />
  94. </a>
  95. <input osctype="image_input" type="hidden" name="image" value="{$goods.image|default=''}" id="input-image" />
  96. <span class="help-inline ">
  97. <span class="middle red">参考图片尺寸:750*352</span>
  98. </span>
  99. </div>
  100. </div>
  101. <div class="form-group required" id="goods-image-row9999">
  102. <label class="col-sm-2 control-label" for="input-image">
  103. <span title="" data-toggle="tooltip" data-original-title="上传400*400的图片">方形高清缩略图:</span>
  104. </label>
  105. <div class="col-sm-10" id="image-row9999">
  106. <a href="#" data-toggle="image" class="img-thumbnail" type="goods" id="thumb-image9999" num="9999">
  107. <img osctype="goods_image9999" <if condition="$goods['fan_image']">
  108. src="__ROOT__/{$goods.fan_image_thumb}"
  109. <else />
  110. src="__ROOT__/Common/image/no_image_100x100.jpg"
  111. </if> />
  112. </a>
  113. <input osctype="goods_image_input9999" type="hidden" name="fan_image" value="{$goods.fan_image|default=''}" id="input-image9999" />
  114. <span class="help-inline ">
  115. <span class="middle red">参考图片尺寸:400*400</span>
  116. </span>
  117. </div>
  118. </div>
  119. <div class="form-group required">
  120. <label class="col-sm-2 control-label" for="input-meta-title2">商品轮播图:</label>
  121. <div class="col-sm-10">
  122. <div class="table-responsive">
  123. <table id="images" class="table table-striped table-bordered table-hover">
  124. <thead>
  125. <tr>
  126. <td class="text-left">商品图片</td>
  127. <td class="text-right">选项排序</td>
  128. <td></td>
  129. </tr>
  130. </thead>
  131. <tbody>
  132. <?php $image_row = 0; ?>
  133. <?php if(isset($goods_images)){ ?>
  134. <?php foreach ($goods_images as $goods_image) { ?>
  135. <tr id="gallery-image-row<?php echo $image_row; ?>">
  136. <td class="text-left"><a href="" id="thumb-image<?php echo $image_row; ?>" num="<?php echo $image_row; ?>" type="gallery" data-toggle="image" class="img-thumbnail"><img osctype="gallery_image<?php echo $image_row; ?>" src="<?php echo $goods_image['thumb']; ?>" alt="" title="" /></a><input osctype="gallery_image_input<?php echo $image_row; ?>" type="hidden" name="goods_image[<?php echo $image_row; ?>][image]" value="<?php echo $goods_image['image']; ?>" id="input-image<?php echo $image_row; ?>" /></td>
  137. <td class="text-right"><input type="text" name="goods_image[<?php echo $image_row; ?>][sort_order]" value="<?php echo $goods_image['sort_order']; ?>" class="form-control" /></td>
  138. <td class="text-left"><button type="button" onclick="$('#gallery-image-row<?php echo $image_row; ?>').remove();" data-toggle="tooltip" class="btn btn-danger"><i class="icon-trash"></i></button></td>
  139. </tr>
  140. <?php $image_row++; ?>
  141. <?php } ?>
  142. <?php } ?>
  143. </tbody>
  144. </table>
  145. <div>
  146. <a onclick="addImage();" class="add_image btn btn-primary ">添加图片</a>
  147. <br/>
  148. <span class="help-inline ">
  149. <span class="middle red">参考图片尺寸:640宽度最佳,高度不限。参考尺寸:640*400,800*800 (支持任何大于等于640宽度的高宽比为8:5,或者1:1的图)</span>
  150. </span>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. <div class="form-group required" >
  156. <label class="col-sm-2 control-label" for="input-meta-title2">商家编号:</label>
  157. <div class="col-sm-10">
  158. <input id="input-meta-title2" class="form-control" type="text" placeholder="商家编号" value="{$goods.model|default=''}" name="model" >
  159. <span class="help-inline ">
  160. <span class="middle red">商品的一个编号</span>
  161. </span>
  162. </div>
  163. </div>
  164. <div class="form-group required">
  165. <label class="col-sm-2 control-label"><b class="red">选择分类:</b></label>
  166. <div class="col-sm-10" id="cateclass">
  167. <span class="help-inline">
  168. <volist name="goods_categories" id="cate_one" empty="$empty">
  169. {$cate_one.name}&nbsp;
  170. </volist>
  171. </span>
  172. <select id="class_1" class="checkbox-inline" name="class_1" rel="1">
  173. <option value="0">请选择类目</option>
  174. <volist name="cate_data" id="cate" empty="$empty">
  175. <option value="{$cate.id}">{$cate.name}</option>
  176. </volist>
  177. </select>
  178. </div>
  179. </div>
  180. <div class="form-group required">
  181. <label class="col-sm-2 control-label" for="input-meta-title2">市场价格:</label>
  182. <div class="col-sm-4">
  183. <input id="input-meta-title2" <?php if($goods['lock_price'] == 1){ ?> disabled <?php } ?> class="form-control" type="text" placeholder="市场价格" value="{$goods.price|default=''}" name="price">
  184. </div>
  185. <label class="col-sm-2 control-label" for="input-meta-title2">单独购买价格:</label>
  186. <div class="col-sm-4">
  187. <input id="input-meta-title2" class="form-control" type="text" placeholder="单独购买价格" value="{$goods.danprice|default=''}" name="danprice">
  188. </div>
  189. </div>
  190. <div class="form-group required">
  191. <label class="col-sm-2 control-label" for="input-meta-title2">商品库存:</label>
  192. <div class="col-sm-4">
  193. <input id="input-meta-title2" class="form-control" type="text" placeholder="商品库存" value="{$goods.quantity|default=''}" name="quantity">
  194. </div>
  195. <label class="col-sm-2 control-label" for="input-meta-title2">商品重量(kg):</label>
  196. <div class="col-sm-4">
  197. <input id="input-meta-title2" class="form-control" type="text" placeholder="商品重量" value="{$goods.weight|default=''}" name="weight">
  198. </div>
  199. </div>
  200. <div class="form-group required">
  201. <label class="col-sm-2 control-label" for="input-meta-title2">排序:</label>
  202. <div class="col-sm-4">
  203. <input id="input-meta-title2" class="form-control" type="text" placeholder="排序" value="{$goods.sort_order|default=''}" name="sort_order">
  204. </div>
  205. <label class="col-sm-2 control-label" for="input-tag2">
  206. <span title="" data-toggle="tooltip" data-original-title="使用逗号分开">商品标签:</span>
  207. </label>
  208. <div class="col-sm-4">
  209. <input id="input-tag2" class="form-control" type="text" placeholder="商品标签:" value="{$description.tag|default=''}" name="goods_description[tag]">
  210. </div>
  211. </div>
  212. <div class="form-group required">
  213. <label class="col-sm-2 control-label" for="input-tag2">
  214. 虚拟销量:
  215. </label>
  216. <div class="col-sm-4">
  217. <input id="input-tag2" class="form-control" type="text" placeholder="虚拟销量" value="{$goods.virtual_count|default='0'}" name="virtual_count">
  218. </div>
  219. <label class="col-sm-2 control-label">商品状态:</label>
  220. <div class="col-sm-4">
  221. <label class="radio-inline">
  222. <input type="radio" checked="checked" value="1" name="status">上架</label>
  223. <label class="radio-inline">
  224. <input type="radio" value="0" name="status">下架</label>
  225. </div>
  226. </div>
  227. <div class="form-group">
  228. <div class="row">
  229. <?php if(!empty($pick_up_list)){ ?>
  230. <label class="col-sm-2 control-label">仅自提:</label>
  231. <div class="col-sm-4" id="pick_just">
  232. <label class="radio-inline">
  233. <input type="radio" <?php if(empty($goods) || $goods['pick_just'] ==0){ ?> checked="checked" <?php } ?> value="0" name="pick_just">否</label>
  234. <label class="radio-inline" >
  235. <input type="radio" value="1" <?php if(!empty($goods) && $goods['pick_just'] ==1){ ?> checked="checked" <?php } ?> name="pick_just">是</label>
  236. </div>
  237. <?php } ?>
  238. </div>
  239. </div>
  240. <div class="form-group">
  241. <div class="row">
  242. <label class="col-sm-2 control-label">运费:</label>
  243. <div class="col-sm-10" id="shipping">
  244. <label class="radio-inline">
  245. <input type="radio" checked="checked" value="1" name="shipping">固定运费</label>
  246. <label class="radio-inline" >
  247. <input type="radio" value="2" name="shipping">使用运费模板</label>
  248. </div>
  249. </div>
  250. </div>
  251. <div class="form-group" id="shipping_tp">
  252. <label class="col-sm-2 control-label">&nbsp;</label>
  253. <div class="col-sm-10" id="shipping_temp">
  254. <div class="col-sm-12" <if condition="!empty($goods) && $goods.shipping eq 2">style="display:none;"</if>>
  255. <input id="input-goods_freight" class="col-sm-4" type="text" placeholder="" value="{$goods.goods_freight|default='0'}" name="goods_freight">
  256. <span class="help-inline col-sm-8">
  257. <span class="middle">(元)0表示免运费</span>
  258. </span>
  259. </div>
  260. <div class="col-sm-4" <?php if( empty($goods) || $goods['shipping'] == 1 ){ ?> style="display:none;" <?php }else{ ?> style="display:block;" <?php } ?> >
  261. <span id="transport_name" class="help-inline">
  262. <notempty name="transport">
  263. {$transport['title']}
  264. </notempty>
  265. </span>
  266. <span class="btn btn-info btn-sm popover-info" id="shipping_chose">
  267. <i class="icon-truck"></i>选择运费模板
  268. </span>
  269. <input type="hidden" name="transport_id" id="transport_id" value="{$goods.transport_id}" />
  270. </div>
  271. </div>
  272. </div>
  273. <div class="form-group required" id="guige_list">
  274. <label class="col-sm-2 control-label">商品规格:</label>
  275. <div class=" col-sm-2">
  276. <div style="form-group col-md-2">
  277. <select class="chosen-select form-control" data-placeholder="添加规格项目">
  278. <option value=""> </option>
  279. <?php foreach($options_list as $option){ ?>
  280. <option value="<?php echo $option['option_id']; ?>"><?php echo $option['name']; ?></option>
  281. <?php } ?>
  282. </select>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="row" style="margin-top:15px;">
  287. <label class="col-sm-2 control-label"></label>
  288. <div class="col-sm-10" id="mult_option_new">
  289. <?php if(!empty($goods_option_mult_value)){ ?>
  290. <table class="table table-striped table-bordered table-hover">
  291. <thead>
  292. <tr>
  293. <?php foreach ($goods_options as $goods_option) { ?>
  294. <td class="text-left"><?php echo $goods_option['name']; ?></td>
  295. <?php } ?>
  296. <td class="text-right">库存数量</td>
  297. <td class="text-right">单价</td>
  298. <td class="text-right">重量(kg)</td>
  299. <td class="text-left">图片</td>
  300. </tr>
  301. </thead>
  302. <tbody>
  303. <?php foreach($goods_option_mult_value as $goods_mul_op){ ?>
  304. <tr>
  305. <?php foreach($goods_mul_op['option_name_list'] as $mul_name){ ?>
  306. <td class="text-left"><?php echo $mul_name; ?></td>
  307. <?php } ?>
  308. <td class="text-left">
  309. <input type="text" name="<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" value="<?php echo $goods_mul_op['quantity']; ?>" class="form-control mult_option_zuhe">
  310. </td>
  311. <td class="text-left">
  312. <input type="text" id="<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>_price" value="<?php echo $goods_mul_op['dan_price']; ?>" class="form-control ">
  313. </td>
  314. <td class="text-left">
  315. <input type="text" id="<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>_weight" value="<?php echo $goods_mul_op['weight']; ?>" class="form-control ">
  316. </td>
  317. <td class="text-left">
  318. <a href="#" id="option-image-row<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" data-toggle="image" num="<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" type="option" class="img-thumbnail">
  319. <?php if(!empty($goods_mul_op['image'])){ ?>
  320. <img osctype="option_image<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" width="100" height="100" src="/Uploads/image/<?php echo $goods_mul_op['image'];?>" />
  321. <?php }else{ ?>
  322. <img osctype="option_image<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" src="/Common/image/no_image_100x100.jpg" />
  323. <?php } ?>
  324. <input osctype="option_image_input<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>" type="hidden" name="#" value="<?php echo $goods_mul_op['image']; ?>" id="input-image<?php echo $goods_mul_op['rela_goodsoption_valueid']; ?>"></a>
  325. </td>
  326. </tr>
  327. <?php } ?>
  328. </tbody>
  329. </table>
  330. <?php } ?>
  331. </div>
  332. </div>
  333. <input type="hidden" name="goods_option" id="goods_option" value="" />
  334. <div class="form-group">
  335. <label class="col-sm-2 control-label" for="input-description">商品详情:</label>
  336. <div class="col-sm-10">
  337. <textarea id="editor" name="goods_description[description]" id="description">{$description.description|default=''}</textarea>
  338. </div>
  339. </div>
  340. </div>
  341. <!-- 常规 END -->
  342. <!-- 基本信息 START -->
  343. <div class="tab-pane" id="tab-data">
  344. </div>
  345. <!-- 基本信息 END -->
  346. <!-- 图片 START -->
  347. <div class="tab-pane" id="tab-image">
  348. </div>
  349. <!-- 图片 END -->
  350. <!-- 选项 START -->
  351. <div class="tab-pane" id="tab-option">
  352. <div class="row">
  353. </div>
  354. </div>
  355. <!-- 选项 END -->
  356. </div>
  357. </form>
  358. </div>
  359. </div>
  360. </div>
  361. <style>
  362. .guige_name{background-color:#f8f8f8;padding:10px;}
  363. .select2-container-multi .select2-choices .select2-search-choice{border:none;}
  364. .select2-container-multi .select2-choices{background:none;}
  365. .tag-input-style{color:#07d;}
  366. .select2-default {
  367. color: #07d !important;
  368. }
  369. .select2-container-multi.tag-input-style .select2-choices .select2-search-choice {
  370. background-image: none;
  371. background-color: #91b8d0;
  372. color: #FFFFFF;
  373. display: inline-block;
  374. font-size: 13px;
  375. font-weight: normal;
  376. margin-bottom: 3px;
  377. margin-right: 0;
  378. padding: 6px 22px 7px 9px;
  379. position: relative;
  380. text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15);
  381. transition: all 0.2s ease 0s;
  382. vertical-align: baseline;
  383. white-space: nowrap;
  384. border: none;
  385. -webkit-box-shadow: none;
  386. box-shadow: none;
  387. border-radius: 0;
  388. }
  389. .select2-container-multi.tag-input-style .select2-choices .select2-search-choice{padding-left:18px;}
  390. .select2-container-multi .select2-choices .select2-search-choice {
  391. line-height: 16px;
  392. padding-bottom: 4px;
  393. }
  394. </style>
  395. </block>
  396. <block name="javascript">
  397. <script src="Common/js/chosen.jquery.js"></script>
  398. <script src="Common/js/select2.js"></script>
  399. <script language="JavaScript">
  400. var s= 2;
  401. $(document).ready(function(){
  402. $('.chosen-select').chosen({allow_single_deselect:true,allowClear:true });
  403. <?php if(!empty($goods)){ ?>
  404. $.ajax({
  405. url:"{:U('Option/get_goodsajax_option_value')}",
  406. type:'post',
  407. data:{goods_id:<?php echo $goods['goods_id']; ?>},
  408. dataType:'json',
  409. success:function(ret){
  410. if(ret.code ==1)
  411. {
  412. var option_data = ret.data;
  413. for(var i in option_data)
  414. {
  415. var s_template = '';
  416. s_template += '<div class="col-sm-10 col-sm-offset-2 guige_name"> ';
  417. s_template += ' <div class="tags" style="border:none;width:100%;">';
  418. s_template += ' <span class="tag option_new" rel_sku_name="'+option_data[i].option_name+'" rel_sku_id="'+option_data[i].option_id+'">'+option_data[i].option_name+'<button type="button" class="close">×</button></span>';
  419. s_template += ' </div>';
  420. s_template += '<select multiple="" name="goods_option_value[]" id="state" class="select_mult select_mult_'+option_data[i].option_id+' select'+s+'" data-placeholder="+添加属性">';
  421. s_template += '<option value="">&nbsp;</option>';
  422. var goods_option_value_list = option_data[i].goods_option_value_list;
  423. for(var j in goods_option_value_list)
  424. {
  425. s_template += '<option '+goods_option_value_list[j].selected+' value="'+goods_option_value_list[j].option_value_id+'">'+goods_option_value_list[j].value_name+'</option>';
  426. }
  427. s_template += '</select>';
  428. s_template +='</div>';
  429. $('#guige_list').append(s_template);
  430. $('.select'+s).select2({allowClear:true });
  431. s++;
  432. }
  433. //get_option_mult_info_new();
  434. }
  435. }
  436. })
  437. <?php } ?>
  438. $('.chosen-select').change(function(e){
  439. //console.log($(this).val());
  440. var option_arr = [];
  441. var option_ids_arr = [];
  442. $('.option_new').each(function(){
  443. if($(this).text() != '')
  444. {
  445. option_arr.push($(this).attr('rel_sku_name'));
  446. option_ids_arr.push($(this).attr('rel_sku_id'));
  447. }
  448. })
  449. var se_text = $(this).find("option:selected").text();
  450. var se_val = $(this).val();
  451. if(se_val == undefined || se_val =='')
  452. {
  453. return false;
  454. }else {
  455. if( $.inArray(se_val,option_ids_arr) > -1)
  456. {
  457. return false;
  458. }
  459. }
  460. //添加规格项目
  461. $.ajax({
  462. url:"{:U('Option/get_ajax_option_value')}",
  463. type:'post',
  464. data:{option_id:se_val},
  465. dataType:'json',
  466. success:function(ret){
  467. if(ret.code ==1)
  468. {
  469. var s_template = '';
  470. s_template += '<div class="col-sm-10 col-sm-offset-2 guige_name"> ';
  471. s_template += ' <div class="tags" style="border:none;width:100%;">';
  472. s_template += ' <span class="tag option_new" rel_sku_name="'+se_text+'" rel_sku_id="'+se_val+'">'+se_text+'<button type="button" class="close">×</button></span>';
  473. s_template += ' </div>';
  474. s_template += '<select multiple="" name="goods_option_value[]" id="state" class="select_mult select_mult_'+se_val+' select'+s+'" data-placeholder="+添加属性">';
  475. s_template += '<option value="">&nbsp;</option>';
  476. for(var i in ret.data)
  477. {
  478. s_template += '<option value="'+ret.data[i].option_value_id+'">'+ret.data[i].value_name+'</option>';
  479. }
  480. s_template += '</select>';
  481. s_template +='</div>';
  482. $('#guige_list').append(s_template);
  483. $('.select'+s).select2({allowClear:true });
  484. get_option_mult_info_new();
  485. s++;
  486. }
  487. }
  488. })
  489. })
  490. //chosen-select change option_new close
  491. //select2-search-choice option_new
  492. $(document).delegate('#guige_list .option_new .close', 'click', function(e) {
  493. $(this).parent().parent().parent().remove();
  494. get_option_mult_info_new();
  495. })
  496. $(document).delegate('#guige_list .select_mult', 'change', function(e) {
  497. get_option_mult_info_new();
  498. })
  499. //checkbox
  500. $(".prochk").click(function () {
  501. var chk = ($($(this).closest("tr").find("td")[2]).find("input"));
  502. var bl = true;
  503. if ($(this).attr("checked")!="checked") {
  504. $(this).removeAttr("checked");
  505. bl = false;
  506. }else{
  507. $(this).attr("checked", "checked");
  508. bl = true;
  509. }
  510. chk.each(function (i,e) {
  511. $(e).prop("checked", bl);
  512. if(bl){
  513. $(e).attr("checked",true);
  514. }else{
  515. $(e).removeAttr("checked");
  516. }
  517. })
  518. });
  519. $("#pktype_check").click(function(){
  520. var bl = true;
  521. if ($(this).attr("checked")!="checked") {
  522. $(this).removeAttr("checked");
  523. bl = false;
  524. }else{
  525. $(this).attr("checked", "checked");
  526. bl = true;
  527. }
  528. $(".scrollable-area input[type=checkbox]").each(function (i,e) {
  529. $(e).prop("checked", bl);
  530. if(bl){
  531. $(e).attr("checked",true);
  532. }else{
  533. $(e).removeAttr("checked");
  534. }
  535. })
  536. });
  537. $("input[name='citychk[]']").click(function () {
  538. var prochk = ($($(this).closest("tr").find("td")[0]).find("input"));
  539. if ($(this).attr("checked")!='checked') {
  540. $(this).removeAttr("checked");
  541. var citychk = ($($(this).closest("tr").find("td")[2]).find("input"));
  542. var bl = true;
  543. citychk.each(function (i, e) {
  544. if ($(e).attr("checked")=='checked') {
  545. bl = true;
  546. return false;
  547. }
  548. else {
  549. bl= false;
  550. }
  551. })
  552. if(bl){
  553. $(prochk).attr("checked", "checked");
  554. }else{
  555. $(prochk).removeAttr("checked");
  556. }
  557. prochk.prop("checked", bl);
  558. }
  559. else {
  560. $(this).attr("checked",true);
  561. $(prochk).attr("checked", "checked");
  562. prochk.prop("checked", true);
  563. }
  564. });
  565. });
  566. </script>
  567. <style>
  568. .table thead > tr > td, .table tbody > tr > td {
  569. vertical-align: middle;
  570. }
  571. .table thead td span[data-toggle="tooltip"]:after, label.control-label span:after {
  572. font-family: FontAwesome;
  573. color: #1E91CF;
  574. content: "\f059";
  575. margin-left: 4px;
  576. }
  577. .select2-container-multi .select2-choices{min-width:100px;}
  578. </style>
  579. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
  580. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
  581. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
  582. <script src="__PUBLIC__/fileupload/jquery.ui.widget.js"></script>
  583. <script src="__PUBLIC__/fileupload/jquery.fileupload.js"></script>
  584. <script>
  585. $(function(){
  586. var ue = UE.getEditor('editor',{
  587. initialFrameHeight:500,
  588. serverUrl: "__PUBLIC__/ueditor/php/controller.php",
  589. scaleEnabled:true
  590. });
  591. })
  592. var option_row = '<?php echo $option_row; ?>';
  593. var option_value_row = '<?php echo $option_value_row; ?>';
  594. function get_option_mult_info_new()
  595. {
  596. var option_arr = [];
  597. var option_ids_arr = [];
  598. $('.option_new').each(function(){
  599. if($(this).text() != '')
  600. {
  601. option_arr.push($(this).attr('rel_sku_name'));
  602. option_ids_arr.push($(this).attr('rel_sku_id'));
  603. }
  604. })
  605. var op_html = '<table class="table table-striped table-bordered table-hover">';
  606. op_html += '<thead><tr>';
  607. if(option_arr.length >0)
  608. {
  609. for(var i in option_arr)
  610. {
  611. }
  612. //价格(元) 库存数量 图片
  613. var option_count = option_arr.length;
  614. var option_value_arr = new Array();
  615. for(var i=0;i<option_count;i++)
  616. {
  617. var option_value0 =[];
  618. //$('select.select_mult').length select_mult_ option_ids_arr[i]
  619. $('select.select_mult_'+option_ids_arr[i]+' option:selected').each(function(){
  620. var tp_str = $(this).val()+'@@'+$(this).text();
  621. option_value0.push(tp_str);
  622. })
  623. if(option_value0.length > 0)
  624. {
  625. option_value_arr.push(option_value0.join(','));
  626. op_html += '<td class="text-left">'+option_arr[i]+'</td>';
  627. }
  628. }
  629. //<td class="text-right">价格(元)</td>
  630. op_html += '<td class="text-right">库存数量</td><td class="text-left">图片</td></tr></thead><tbody>';
  631. //叠加属性数组
  632. if(option_value_arr.length >=1)
  633. {
  634. var need_result = [];
  635. for(var j =0;j < option_value_arr.length; j++)
  636. {
  637. need_result = compare_arr_juz(need_result,option_value_arr[j]);
  638. }
  639. for(var k =0;k < need_result.length; k++)
  640. {
  641. var vl_arr = need_result[k].split('*_*');
  642. op_html += '<tr>';
  643. var op_ids_arr = [];
  644. for(var ki =0;ki<vl_arr.length;ki++)
  645. {
  646. var t_arr = vl_arr[ki].split('@@');
  647. op_ids_arr.push(t_arr[0]);
  648. op_html += '<td class="text-left">'+t_arr[1]+'</td>';
  649. }
  650. var op_ids_str = op_ids_arr.join('_');
  651. //op_html += '<td class="text-left"><input type="text" name="'+op_ids_str+'_price" value="0" class="form-control mult_option_zuhe"></td>';
  652. op_html += '<td class="text-left"><input type="text" name="'+op_ids_str+'" value="0" class="form-control mult_option_zuhe"></td>';
  653. op_html += '<td class="text-left"><a href="#" id="option-image-row'+op_ids_str+'" data-toggle="image" num="'+op_ids_str+'" type="option" class="img-thumbnail"><img osctype="option_image'+op_ids_str+'" src="/Common/image/no_image_100x100.jpg" alt="" title=""><input osctype="option_image_input'+op_ids_str+'" type="hidden" name="#" value="" id="input-image'+op_ids_str+'"></a></td>';
  654. op_html += '</tr>';
  655. }
  656. $('#mult_option_new').html(op_html);
  657. } else {
  658. $('#mult_option_new').html('');
  659. }
  660. }else {
  661. $('#mult_option_new').html('');
  662. }
  663. }
  664. $(document).delegate('#option-list select', 'change', function() {
  665. get_option_mult_info();
  666. })
  667. function compare_arr_juz(need_result,cha_str)
  668. {
  669. var new_need_result = [];
  670. var cha_arr = cha_str.split(',');
  671. if(need_result.length>0)
  672. {
  673. for(var i=0;i< need_result.length;i++)
  674. {
  675. for(var j=0; j< cha_arr.length;j++)
  676. {
  677. new_need_result.push(need_result[i]+'*_*'+cha_arr[j]);
  678. }
  679. }
  680. } else {
  681. for(var i=0;i< cha_arr.length;i++)
  682. {
  683. new_need_result.push(cha_arr[i]);
  684. }
  685. }
  686. return new_need_result;
  687. }
  688. $('input[name=\'category\']').autocomplete({
  689. 'source': function(request, response) {
  690. $.ajax({
  691. url: '{:U("GoodsCategory/autocomplete")}' +'/filter_name/'+ encodeURIComponent(request),
  692. dataType: 'json',
  693. success: function(json) {
  694. response($.map(json, function(item) {
  695. return {
  696. label: item['name'],
  697. value: item['category_id']
  698. }
  699. }));
  700. }
  701. });
  702. },
  703. 'select': function(item) {
  704. $('input[name=\'category\']').val('');
  705. $('#goods-category' + item['value']).remove();
  706. $('#goods-category').append('<div id="goods-category' + item['value'] + '"><i class="icon-ban-circle"></i> ' + item['label'] + '<input type="hidden" name="goods_category[]" value="' + item['value'] + '" /></div>');
  707. }
  708. });
  709. $('#goods-category').delegate('.icon-ban-circle', 'click', function() {
  710. $(this).parent().remove();
  711. });
  712. $(document).delegate('#submit', 'click', function() {
  713. if ( $("select[name=\'class_2\']").length > 0){
  714. var class_2 = $("select[name=\'class_2\']").val();
  715. if(parseInt(class_2) == 0){
  716. alert('请选择分类');
  717. return false;
  718. }
  719. }
  720. if ( $("select[name=\'class_3\']").length > 0){
  721. var class_3 = $("select[name=\'class_3\']").val();
  722. if(parseInt(class_3) == 0){
  723. alert('请选择分类');
  724. return false;
  725. }
  726. }
  727. var mult_option_zuhe = '';
  728. var mult_option_zuhe_arr = [];
  729. $('.mult_option_zuhe').each(function(){
  730. var mult_id = $(this).attr('name');
  731. var mult_qu = $(this).val();
  732. var mult_image = $('#input-image'+mult_id).val();
  733. mult_option_zuhe_arr.push( 'mult_id:'+mult_id+'@@'+'mult_qu:'+mult_qu+'@@mult_image:'+mult_image);
  734. })
  735. if(mult_option_zuhe_arr.length >0)
  736. {
  737. $('#mult_option_zuhe').val(mult_option_zuhe_arr.join(','));
  738. }
  739. var goods_option_arr = [];
  740. var goods_option_str = '';
  741. $('.option_new').each(function(){
  742. goods_option_arr.push( $(this).attr('rel_sku_id') );
  743. })
  744. if(goods_option_arr.length >0)
  745. {
  746. $('#goods_option').val(goods_option_arr.join(','));
  747. }
  748. //goods_option
  749. return true;
  750. });
  751. var image_row = '<?php echo $image_row; ?>';
  752. function addImage() {
  753. html = '<tr id="gallery-image-row' + image_row + '">';
  754. html += ' <td class="text-left"><a href="#" id="thumb-image' + image_row + '"data-toggle="image" type="gallery" num="'+image_row+'" class="img-thumbnail"><img osctype="gallery_image'+image_row+'" src="__ROOT__/Common/image/no_image_100x100.jpg" alt="" title="" /><input osctype="gallery_image_input'+image_row+'" type="hidden" name="goods_image[' + image_row + '][image]" value="" id="input-image' + image_row + '" /></td>';
  755. html += ' <td class="text-right"><input type="text" name="goods_image[' + image_row + '][sort_order]" value="'+image_row+'" class="form-control" /></td>';
  756. html += ' <td class="text-left"><button type="button" onclick="$(\'#gallery-image-row' + image_row + '\').remove();" data-toggle="tooltip" class="btn btn-danger"><i class="icon-trash"></i></button></td>';
  757. html += '</tr>';
  758. $('#images tbody').append(html);
  759. image_row++;
  760. }
  761. var discount_row ={$discount_row|default='0'};
  762. function addDiscount() {
  763. html = '<tr id="discount-row' + discount_row + '">';
  764. html += ' <td class="text-left"><input type="text" name="goods_discount[' + discount_row + '][quantity]" value="" class="form-control" /></td>';
  765. html += ' <td class="text-left"><input type="text" name="goods_discount[' + discount_row + '][price]" value="" class="form-control" /></td>';
  766. html += ' <td class="text-left"><button type="button" onclick="$(\'#discount-row' + discount_row + '\').remove();" data-toggle="tooltip" class="btn btn-danger"><i class="icon-trash"></i></button></td>';
  767. html += '</tr>';
  768. $('#discount tbody').append(html);
  769. discount_row++;
  770. }
  771. $(function(){
  772. <present name="Think.get.id">
  773. Oscshop.setValue("status", {$goods.status|default=1});
  774. Oscshop.setValue("subtract",{$goods.subtract|default=1});
  775. Oscshop.setValue("shipping",{$goods.shipping|default=1});
  776. </present>
  777. // tooltips on hover button-upload
  778. $('[data-toggle=\'tooltip\']').tooltip({container: 'body', html: true});
  779. // Makes tooltips work on ajax generated content
  780. $(document).ajaxStop(function() {
  781. $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
  782. });
  783. $(document).delegate('input[name=\'shipping\']', 'click', function(e) {
  784. var index = $(this).val()-1;
  785. $('#shipping_temp').children().hide();
  786. $('#shipping_temp').children().eq(index).show();
  787. })
  788. //关闭弹出层
  789. $('#dialog').on('click','.ks-ext-close',function(){
  790. $("#dialog").css('display','none');
  791. $('.ks-ext-mask').css('display','none');
  792. return false;
  793. });
  794. //关闭弹出层
  795. $('#dialog').on('click','.J_Cancel',function(){
  796. $("#dialog").css('display','none');
  797. $('.ks-ext-mask').css('display','none');
  798. return false;
  799. });
  800. //shipping_btn $('#dialog').on('click')
  801. $(document).delegate('.shipping_btn', 'click', function(e) {
  802. var transport_id = $(this).attr('rel');
  803. var relname = $(this).attr('relname');
  804. $('#transport_id').val(transport_id);
  805. $('#transport_name').html(relname);
  806. $("#dialog").css('display','none');
  807. $('.ks-ext-mask').css('display','none');
  808. return false;
  809. })
  810. $(document).delegate('#cateclass select', 'change', function(e) {
  811. e.preventDefault();
  812. var thisobj =$(this);
  813. var pid =thisobj.val();
  814. thisobj.nextAll().remove();
  815. var cur_rel =parseInt( thisobj.attr('rel'))+1;
  816. if(pid ==0)
  817. return ;
  818. $.ajax({
  819. url:"{:U(Goods/get_json_category_tree)}",
  820. type:'get',
  821. data:{pid:pid,is_ajax:1},
  822. dataType:'json',
  823. success:function(result){
  824. if(result.code == 1)
  825. {
  826. var after_html = '<select name="class_'+cur_rel+'" class="checkbox-inline" rel="'+cur_rel+'">';
  827. after_html += '<option value="0">请选择类目</option>';
  828. for(var i in result.list)
  829. {
  830. after_html += '<option value="'+result.list[i].id+'">'+result.list[i].name+'</option>'
  831. }
  832. after_html += '</select>';
  833. thisobj.after(after_html)
  834. }
  835. }
  836. })
  837. });
  838. $(document).delegate('#shipping_chose', 'click', function(e) {
  839. $.ajax({
  840. url: '{:U("Transport/getTransportList")}',
  841. dataType: 'json',
  842. type:'get',
  843. data:{store_id:"<?php echo $goods['store_id']; ?>"},
  844. success: function(result) {
  845. if(result.code == 1)
  846. {
  847. var shipping_html = '<table id="simple-table" class="table table-striped table-bordered table-hover"><thead><tr><th>运费模板ID</th><th>运费模板名称</th><th></th></tr></thead><tbody>';
  848. for(var i in result.list){
  849. shipping_html += '<tr><td>'+result.list[i].id+'</td>';
  850. shipping_html += '<td>'+result.list[i].title+'</td>';
  851. shipping_html += '<td><div class="btn-group shipping_btn" relname="'+result.list[i].title+'" rel="'+result.list[i].id+'"><button class="btn btn-xs btn-success"><i class="ace-icon fa icon-check bigger-120"></i></button></div></td></tr>';
  852. }
  853. shipping_html += '</tbody></table>';
  854. $('#ks_shipping').html(shipping_html);
  855. $("#dialog").css({'position' : 'fixed','display' : 'block', 'z-index' : '9999'});
  856. } else{
  857. alert('请先添加运费模板');
  858. }
  859. }
  860. });
  861. })
  862. $(document).delegate('a[data-toggle=\'image\']', 'click', function(e) {
  863. e.preventDefault();
  864. var index=$(this).attr('num');
  865. var type=$(this).attr('type');
  866. //alert(index);
  867. var element = this;
  868. if(index==undefined){
  869. $(element).popover({
  870. html: true,
  871. placement: 'right',
  872. trigger: 'manual',
  873. content: function() {
  874. return '<button type="button" id="thumb-image" class="btn btn-primary"><i class="icon-edit"></i></button> ';
  875. }
  876. });
  877. }else{
  878. $(element).popover({
  879. html: true,
  880. placement: 'right',
  881. trigger: 'manual',
  882. content: function() {
  883. return '<button type="button" n="'+index+'" t="'+type+'" class="btn btn-primary button-image"><i class="icon-edit"></i></button> ';
  884. }
  885. });
  886. }
  887. $(element).popover('toggle');
  888. //商品图片
  889. $('#thumb-image').on('click', function() {
  890. //alert('333');
  891. $('#modal-image').remove();
  892. $('#form-upload').remove();
  893. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  894. $('#form-upload input[name=\'file\']').trigger('click');
  895. $(element).popover('hide');
  896. $('[osctype="btn_upload_image"]').fileupload({
  897. dataType: 'json',
  898. url: "{:U('Image/upload_image',array('dir'=>'product'))}",
  899. add: function(e, data) {
  900. $parent = $('#thumb');
  901. $input = $parent.find('[osctype="image_input"]');
  902. $img = $parent.find('[osctype="image"]');
  903. data.formData = {old_goods_image:$input.val()};
  904. $img.attr('src', "__IMG__/loading.gif");
  905. data.submit();
  906. },
  907. done: function (e,data) {
  908. var image=data.result;
  909. $parent = $('#thumb');
  910. $input = $parent.find('[osctype="image_input"]');
  911. $img = $parent.find('[osctype="image"]');
  912. if(image) {
  913. // $img.prev('i').hide();
  914. $img.attr('src', '__ROOT__/'+image.image_thumb);
  915. $img.show();
  916. $input.val(image.image);
  917. } else {
  918. alert('上传失败');
  919. }
  920. }
  921. });
  922. });
  923. //商品相册
  924. $('.button-image').on('click', function() {
  925. $('#modal-image').remove();
  926. $('#form-upload').remove();
  927. var i=$(this).attr('n');
  928. var type=$(this).attr('t');
  929. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  930. $('#form-upload input[name=\'file\']').trigger('click');
  931. $(element).popover('hide');
  932. $('[osctype="btn_upload_image"]').fileupload({
  933. dataType: 'json',
  934. url: "{:U('Image/upload_image/dir')}"+'/'+type,
  935. add: function(e, data) {
  936. $parent = $('#image-row'+i);
  937. $input = $parent.find('[osctype="'+type+'_image_input'+i+'"]');
  938. $img = $parent.find('[osctype="'+type+'_image'+i+'"]');
  939. var old_name='old_'+type+'_image';
  940. data.formData = {old_name:$input.val()};
  941. $img.attr('src', "__IMG__/loading.gif");
  942. data.submit();
  943. },
  944. done: function (e,data) {
  945. var image=data.result;
  946. $parent = $('#'+type+'-image-row'+i);
  947. $input = $parent.find('[osctype="'+type+'_image_input'+i+'"]');
  948. $img = $parent.find('[osctype="'+type+'_image'+i+'"]');
  949. if(image) {
  950. // $img.prev('i').hide();
  951. $img.attr('src', '__ROOT__/'+image.image_thumb);
  952. $img.show();
  953. $input.val(image.image);
  954. } else {
  955. alert('上传失败');
  956. }
  957. }
  958. });
  959. });
  960. $('#button-clear').on('click', function() {
  961. $(element).find('img').attr('src', $(element).find('img').attr('data-placeholder'));
  962. $(element).parent().find('input').attr('value', '');
  963. $(element).popover('hide');
  964. });
  965. });
  966. });
  967. $('#option a:first').tab('show');
  968. </script>
  969. </block>