express_detail.blade.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('快递单模版编辑'))
  4. <script language='javascript' src="{{resource_get('plugins/exhelper/src/common/static/js/jquery.min.js', 1)}}"></script>
  5. <script language='javascript' src="{{resource_get('plugins/exhelper/src/common/static/js/designer.js', 1)}}"></script>
  6. <script language='javascript' src="{{resource_get('plugins/exhelper/src/common/static/js/jquery.contextMenu.js', 1)}}"></script>
  7. <script language='javascript' src="{{resource_get('plugins/exhelper/src/common/static/js/jquery.form.js', 1)}}"></script>
  8. <link href="{{resource_get('plugins/exhelper/src/common/static/js/jquery.contextMenu.css', 1)}}" rel="stylesheet">
  9. <style type='text/css'>
  10. #container {border: 1px solid #ccc;position: relative; background: #fff; overflow: hidden;}
  11. .items label {width: 120px; margin: 0; float: left;}
  12. #container .bg {position: absolute; width: 100%; z-index: 0;}
  13. #container .drag {position: absolute; min-width: 120px; min-height: 25px; border: 1px solid #aaa; z-index: 1; top: 10px; left: 100px; background: #fff; cursor: move;}
  14. #container .rRightDown, .rLeftDown, .rLeftUp, .rRightUp, .rRight, .rLeft, .rUp, .rDown { position: absolute; width: 7px; height: 7px; z-index: 1; font-size: 0;}
  15. .rRightDown, .rLeftDown, .rLeftUp, .rRightUp, .rRight, .rLeft, .rUp, .rDown {position: absolute; background: #428bca; width: 6px; height: 6px; z-index: 5; font-size: 0;}
  16. .rLeftDown, .rRightUp {cursor: ne-resize;}
  17. .rRightDown, .rLeftUp {cursor: nw-resize;}
  18. .rRight, .rLeft {cursor: e-resize;}
  19. .rUp, .rDown {cursor: n-resize;}
  20. .rRightDown {bottom: -3px; right: -3px; background: #2a6496;}
  21. .rLeftDown {bottom: -3px; left: -3px;}
  22. .rRightUp {top: -3px; right: -3px;}
  23. .rLeftUp {top: -3px; left: -3px;}
  24. .rRight {right: -3px; top: 50%; margin-top: -3px;}
  25. .rLeft {left: -3px; top: 50%; margin-top: -3px;}
  26. .rUp {top: -3px; left: 50%;}
  27. .rDown {bottom: -3px; left: 50%}
  28. .context-menu-layer {z-index: 9999;}
  29. .context-menu-list {z-index: 9999;}
  30. .items .checkbox-inline, .col-xs-12 .checkbox-inline {margin: 0; float: left; width: 100px;}
  31. </style>
  32. <div class="main rightlist">
  33. <form id='dataform' action="" method="post" class="form-horizontal form">
  34. <input type="hidden" name="id" value="{{$item->id}}" />
  35. <input type="hidden" name="cate" value="{{$cate}}" />
  36. <input type="hidden" id="datas" name="datas" value="" />
  37. <input type="hidden" id="expresscom" name="expresscom" value="" />
  38. <div class="panel panel-default">
  39. <div class="panel-heading">快递单模版编辑</div>
  40. <div class="panel-body">
  41. <div>
  42. <div class="input-group">
  43. <div class="input-group-addon" style="border-right:none">快递单名称</div>
  44. <input type="text" name="expressname" class="form-control" value="{{$item->expressname}}" />
  45. <div class="input-group-addon" style="border-right:none; border-left: none;"> 单据宽度</div>
  46. <input type="number" name="width" class="form-control" value="@if(!empty($item->width)){{$item->width}}@else{{250}}@endif" onchange="pagesize()" />
  47. <div class="input-group-addon" style="border-right:none; border-left: none;">mm(毫米) 单据高度</div>
  48. <input type="number" name="height" class="form-control" value="@if(!empty($item->height)){{$item->height}}@else{{150}}@endif" onchange="pagesize()" />
  49. <div class="input-group-addon" style="border-right:none; border-left: none;">mm(毫米)</div>
  50. <div class="input-group-addon" style="border-right:none;">快递单底图</div>
  51. <input id="bg" type="text" name="background" class="form-control" value="{{$item->bg}}" />
  52. <span style="background: #fff;" class="input-group-addon btn btn-default " onclick="changeBG()">选择图片</span>
  53. <span style="background: #fff;" class="input-group-addon btn btn-default " onclick="changeBG(1)">清除图片</span>
  54. </div>
  55. <div class="input-group" style="margin-top: 10px; width: 300px;">
  56. <div class="input-group-addon" style="border-right:none">快递类型</div>
  57. <select id="express" name="express" class="form-control">
  58. <option @if($item->express == '') selected="" @endif data-name="" value="" >其他快递</option>
  59. <option @if($item->express == 'shunfeng') selected="" @endif data-name="顺丰" value="shunfeng">顺丰</option>
  60. <option @if($item->express == 'shentong') selected="" @endif data-name="申通" value="shentong">申通</option>
  61. <option @if($item->express == 'yunda') selected="" @endif data-name="韵达快运" value="yunda">韵达快运</option>
  62. <option @if($item->express == 'tiantian') selected="" @endif data-name="天天快递" value="tiantian">天天快递</option>
  63. <option @if($item->express == 'yuantong') selected="" @endif data-name="圆通速递" value="yuantong">圆通速递</option>
  64. <option @if($item->express == 'zhongtong') selected="" @endif data-name="中通速递" value="zhongtong">中通速递</option>
  65. <option @if($item->express == 'ems') selected="" @endif data-name="ems快递" value="ems">ems快递</option>
  66. <option @if($item->express == 'huitongkuaidi') selected="" @endif data-name="汇通快运" value="huitongkuaidi">汇通快运</option>
  67. <option @if($item->express == 'quanfengkuaidi') selected="" @endif data-name="全峰快递" value="quanfengkuaidi">全峰快递</option>
  68. <option @if($item->express == 'jd') selected="" @endif data-name="京东物流" value="zhimakaimen">京东物流</option>
  69. <option @if($item->express == 'guosong') selected="" @endif data-name="国送快运" value="zhimakaimen">国送快运</option>
  70. <option @if($item->express == 'baishiwuliu') selected="" @endif data-name="百世快运" value="baishiwuliu">百世快运</option>
  71. <option @if($item->express == 'htky') selected="" @endif data-name="百世快递" value="htky">百世快递</option>
  72. <option @if($item->express == 'zhaijisong') selected="" @endif data-name="宅急送" value="zhaijisong">宅急送</option>
  73. <option @if($item->express == 'aae') selected="" @endif data-name="aae全球专递" value="aae">aae全球专递</option>
  74. <option @if($item->express == 'anjie') selected="" @endif data-name="安捷快递" value="anjie">安捷快递</option>
  75. <option @if($item->express == 'anxindakuaixi') selected="" @endif data-name="安信达快递" value="anxindakuaixi">安信达快递</option>
  76. <option @if($item->express == 'biaojikuaidi') selected="" @endif data-name="彪记快递" value="biaojikuaidi">彪记快递</option>
  77. <option @if($item->express == 'bht') selected="" @endif data-name="bht" value="bht">bht</option>
  78. <option @if($item->express == 'baifudongfang') selected="" @endif data-name="百福东方国际物流" value="baifudongfang">百福东方国际物流</option>
  79. <option @if($item->express == 'coe') selected="" @endif data-name="中国东方(COE)" value="coe">中国东方(COE)</option>
  80. <option @if($item->express == 'changyuwuliu') selected="" @endif data-name="长宇物流" value="changyuwuliu">长宇物流</option>
  81. <option @if($item->express == 'datianwuliu') selected="" @endif data-name="大田物流" value="datianwuliu">大田物流</option>
  82. <option @if($item->express == 'debangwuliu') selected="" @endif data-name="德邦物流" value="debangwuliu">德邦物流</option>
  83. <option @if($item->express == 'dhl') selected="" @endif data-name="dhl" value="dhl">dhl</option>
  84. <option @if($item->express == 'dpex') selected="" @endif data-name="dpex" value="dpex">dpex</option>
  85. <option @if($item->express == 'dsukuaidi') selected="" @endif data-name="d速快递" value="dsukuaidi">d速快递</option>
  86. <option @if($item->express == 'disifang') selected="" @endif data-name="递四方" value="disifang">递四方</option>
  87. <option @if($item->express == 'fedex') selected="" @endif data-name="fedex(国外)" value="fedex">fedex(国外)</option>
  88. <option @if($item->express == 'feikangda') selected="" @endif data-name="飞康达物流" value="feikangda">飞康达物流</option>
  89. <option @if($item->express == 'fenghuangkuaidi') selected="" @endif data-name="凤凰快递" value="fenghuangkuaidi">凤凰快递</option>
  90. <option @if($item->express == 'feikuaida') selected="" @endif data-name="飞快达" value="feikuaida">飞快达</option>
  91. <option @if($item->express == 'guotongkuaidi') selected="" @endif data-name="国通快递" value="guotongkuaidi">国通快递</option>
  92. <option @if($item->express == 'ganzhongnengda') selected="" @endif data-name="港中能达物流" value="ganzhongnengda">港中能达物流</option>
  93. <option @if($item->express == 'guangdongyouzhengwuliu') selected="" @endif data-name="广东邮政物流" value="guangdongyouzhengwuliu">广东邮政物流</option>
  94. <option @if($item->express == 'gongsuda') selected="" @endif data-name="共速达" value="gongsuda">共速达</option>
  95. <option @if($item->express == 'hengluwuliu') selected="" @endif data-name="恒路物流" value="hengluwuliu">恒路物流</option>
  96. <option @if($item->express == 'huaxialongwuliu') selected="" @endif data-name="华夏龙物流" value="huaxialongwuliu">华夏龙物流</option>
  97. <option @if($item->express == 'haihongwangsong') selected="" @endif data-name="海红" value="haihongwangsong">海红</option>
  98. <option @if($item->express == 'haiwaihuanqiu') selected="" @endif data-name="海外环球" value="haiwaihuanqiu">海外环球</option>
  99. <option @if($item->express == 'jiayiwuliu') selected="" @endif data-name="佳怡物流" value="jiayiwuliu">佳怡物流</option>
  100. <option @if($item->express == 'jinguangsudikuaijian') selected="" @endif data-name="京广速递" value="jinguangsudikuaijian">京广速递</option>
  101. <option @if($item->express == 'jixianda') selected="" @endif data-name="急先达" value="jixianda">急先达</option>
  102. <option @if($item->express == 'jjwl') selected="" @endif data-name="佳吉物流" value="jjwl">佳吉物流</option>
  103. <option @if($item->express == 'jymwl') selected="" @endif data-name="加运美物流" value="jymwl">加运美物流</option>
  104. <option @if($item->express == 'jindawuliu') selected="" @endif data-name="金大物流" value="jindawuliu">金大物流</option>
  105. <option @if($item->express == 'jialidatong') selected="" @endif data-name="嘉里大通" value="jialidatong">嘉里大通</option>
  106. <option @if($item->express == 'jykd') selected="" @endif data-name="晋越快递" value="jykd">晋越快递</option>
  107. <option @if($item->express == 'kuaijiesudi') selected="" @endif data-name="快捷速递" value="kuaijiesudi">快捷速递</option>
  108. <option @if($item->express == 'lianb') selected="" @endif data-name="联邦快递(国内)" value="lianb">联邦快递(国内)</option>
  109. <option @if($item->express == 'lianhaowuliu') selected="" @endif data-name="联昊通物流" value="lianhaowuliu">联昊通物流</option>
  110. <option @if($item->express == 'longbanwuliu') selected="" @endif data-name="龙邦物流" value="longbanwuliu">龙邦物流</option>
  111. <option @if($item->express == 'lijisong') selected="" @endif data-name="立即送" value="lijisong">立即送</option>
  112. <option @if($item->express == 'lejiedi') selected="" @endif data-name="乐捷递" value="lejiedi">乐捷递</option>
  113. <option @if($item->express == 'minghangkuaidi') selected="" @endif data-name="民航快递" value="minghangkuaidi">民航快递</option>
  114. <option @if($item->express == 'meiguokuaidi') selected="" @endif data-name="美国快递" value="meiguokuaidi">美国快递</option>
  115. <option @if($item->express == 'menduimen') selected="" @endif data-name="门对门" value="menduimen">门对门</option>
  116. <option @if($item->express == 'ocs') selected="" @endif data-name="OCS" value="ocs">OCS</option>
  117. <option @if($item->express == 'peisihuoyunkuaidi') selected="" @endif data-name="配思货运" value="peisihuoyunkuaidi">配思货运</option>
  118. <option @if($item->express == 'quanchenkuaidi') selected="" @endif data-name="全晨快递" value="quanchenkuaidi">全晨快递</option>
  119. <option @if($item->express == 'quanjitong') selected="" @endif data-name="全际通物流" value="quanjitong">全际通物流</option>
  120. <option @if($item->express == 'quanritongkuaidi') selected="" @endif data-name="全日通快递" value="quanritongkuaidi">全日通快递</option>
  121. <option @if($item->express == 'quanyikuaidi') selected="" @endif data-name="全一快递" value="quanyikuaidi">全一快递</option>
  122. <option @if($item->express == 'rufengda') selected="" @endif data-name="如风达" value="rufengda">如风达</option>
  123. <option @if($item->express == 'santaisudi') selected="" @endif data-name="三态速递" value="santaisudi">三态速递</option>
  124. <option @if($item->express == 'shenghuiwuliu') selected="" @endif data-name="盛辉物流" value="shenghuiwuliu">盛辉物流</option>
  125. <option @if($item->express == 'sue') selected="" @endif data-name="速尔物流" value="sue">速尔物流</option>
  126. <option @if($item->express == 'shengfeng') selected="" @endif data-name="盛丰物流" value="shengfeng">盛丰物流</option>
  127. <option @if($item->express == 'saiaodi') selected="" @endif data-name="赛澳递" value="saiaodi">赛澳递</option>
  128. <option @if($item->express == 'tiandihuayu') selected="" @endif data-name="天地华宇" value="tiandihuayu">天地华宇</option>
  129. <option @if($item->express == 'tnt') selected="" @endif data-name="tnt" value="tnt">tnt</option>
  130. <option @if($item->express == 'ups') selected="" @endif data-name="ups" value="ups">ups</option>
  131. <option @if($item->express == 'wanjiawuliu') selected="" @endif data-name="万家物流" value="wanjiawuliu">万家物流</option>
  132. <option @if($item->express == 'wenjiesudi') selected="" @endif data-name="文捷航空速递" value="wenjiesudi">文捷航空速递</option>
  133. <option @if($item->express == 'wuyuan') selected="" @endif data-name="伍圆" value="wuyuan">伍圆</option>
  134. <option @if($item->express == 'wxwl') selected="" @endif data-name="万象物流" value="wxwl">万象物流</option>
  135. <option @if($item->express == 'xinbangwuliu') selected="" @endif data-name="新邦物流" value="xinbangwuliu">新邦物流</option>
  136. <option @if($item->express == 'xinfengwuliu') selected="" @endif data-name="信丰物流" value="xinfengwuliu">信丰物流</option>
  137. <option @if($item->express == 'yafengsudi') selected="" @endif data-name="亚风速递" value="yafengsudi">亚风速递</option>
  138. <option @if($item->express == 'yibangwuliu') selected="" @endif data-name="一邦速递" value="yibangwuliu">一邦速递</option>
  139. <option @if($item->express == 'youshuwuliu') selected="" @endif data-name="优速物流" value="youshuwuliu">优速物流</option>
  140. <option @if($item->express == 'youzhengguonei') selected="" @endif data-name="邮政包裹挂号信" value="youzhengguonei">邮政包裹挂号信</option>
  141. <option @if($item->express == 'youzhengguoji') selected="" @endif data-name="邮政国际包裹挂号信" value="youzhengguoji">邮政国际包裹挂号信</option>
  142. <option @if($item->express == 'yuanchengwuliu') selected="" @endif data-name="远成物流" value="yuanchengwuliu">远成物流</option>
  143. <option @if($item->express == 'yuanweifeng') selected="" @endif data-name="源伟丰快递" value="yuanweifeng">源伟丰快递</option>
  144. <option @if($item->express == 'yuanzhijiecheng') selected="" @endif data-name="元智捷诚快递" value="yuanzhijiecheng">元智捷诚快递</option>
  145. <option @if($item->express == 'yuntongkuaidi') selected="" @endif data-name="运通快递" value="yuntongkuaidi">运通快递</option>
  146. <option @if($item->express == 'yuefengwuliu') selected="" @endif data-name="越丰物流" value="yuefengwuliu">越丰物流</option>
  147. <option @if($item->express == 'yad') selected="" @endif data-name="源安达" value="yad">源安达</option>
  148. <option @if($item->express == 'yinjiesudi') selected="" @endif data-name="银捷速递" value="yinjiesudi">银捷速递</option>
  149. <option @if($item->express == 'zhongtiekuaiyun') selected="" @endif data-name="中铁快运" value="zhongtiekuaiyun">中铁快运</option>
  150. <option @if($item->express == 'zhongyouwuliu') selected="" @endif data-name="中邮物流" value="zhongyouwuliu">中邮物流</option>
  151. <option @if($item->express == 'zhongxinda') selected="" @endif data-name="忠信达" value="zhongxinda">忠信达</option>
  152. <option @if($item->express == 'zhimakaimen') selected="" @endif data-name="芝麻开门" value="zhimakaimen">芝麻开门</option>
  153. </select>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="panel" style="height: auto; overflow: hidden; background: none;">
  159. @include('Yunshop\Exhelper::admin.print.print_tpl_items')
  160. <div class="edit-right">
  161. <div id="container" style=" height: @if($item->height && !empty(!$item->height)){{$item->height.'mm'}}@else{{'150mm'}}@endif;">
  162. <img id="bgimg" src="{{$item->bg}}" @if(empty($item->bg)) style="display: none;"@endif />
  163. @foreach($item->datas as $key => $value)
  164. <div class="drag" cate="{{$value['cate']}}" index="{{$key}}" items="{{$value['items']}}" item-string="{{$value['string']}}" item-font="{{$value['font']}}" item-size="{{$value['size']}}" item-color="{{$value['color']}}" item-bold="{{$value['bold']}}" item-pre="{{$value['pre']}}" item-last="{{$value['last']}}" item-align="{{$value['align']}}"
  165. style="font-size:{{$value['size']}}pt; z-index:{{$key}};left:{{$value['left']}};top:{{$value['top']}};width:{{$value['width']}};height:{{$value['height']}}; text-align:@if($value['align'] == '' || $value['align'] == 1) left @elseif($value['align'] == 2) center @elseif($value['align'] == 3) right @endif" item-virtual="{{$value['virtual']}}" cate="{{$value['cate']}}">
  166. <div class="text" style="@if(!empty($value['font']))font-family: {{$value['font']}};@endif font-size:@if(!empty($value['size'])){{$value['size']}}@else{{10}}@endif pt;@if(!empty($value['color']))color: {{$value['color']}};@endif @if(!empty($value['bold']))font-weight:bold;@endif">
  167. {{$value['pre']}}{{$value['string']}}{{$value['last']}}
  168. </div>
  169. <div class="rRightDown"> </div>
  170. <div class="rLeftDown"> </div>
  171. <div class="rRightUp"> </div>
  172. <div class="rLeftUp"> </div>
  173. <div class="rRight"> </div>
  174. <div class="rLeft"> </div>
  175. <div class="rUp"> </div>
  176. <div class="rDown"></div>
  177. </div>
  178. @endforeach
  179. </div>
  180. </div>
  181. </div>
  182. <div class='panel-body'>
  183. <div class="form-group">
  184. <div class="col-sm-9 col-xs-12">
  185. <a href="{{yzWebUrl(\Yunshop\Exhelper\common\models\Express::EXPRESS_INDEX_URL)}}"><span class="btn btn-default" style="float: left; margin-right: 10px;"><i class="fa fa-reply"></i> 返回列表</span></a>
  186. <input type="button" name="btnsave" value="保 存" class="btn btn-primary col-lg btnsave" onclick="save(false)" />
  187. <input type="button" name="btnpreview" value="保存并预览" class="btn btn-success col-lg btnsave" onclick="save(true)" style="margin-left:10px;" />
  188. <div style="float: left; margin-left: 10px;">
  189. <label class="radio-inline">
  190. <input type="radio" name='isdefault' value="1" @if($item->isdefault == 1) checked @endif /> 设为默认打印模版
  191. </label>
  192. <label class="radio-inline">
  193. <input type="radio" name='isdefault' value="0" @if($item->isdefault == 0) checked @endif /> 不设为默认打印模版
  194. </label>
  195. </div>
  196. @if($item->isdefault == 1)<span class="help-block">默认模版</span>@endif
  197. </div>
  198. </div>
  199. </div>
  200. </form>
  201. </div>
  202. <script language='javascript' src="{{resource_get('plugins/exhelper/src/common/static/js/LodopFuncs.js', 1)}}"></script>
  203. {{--<script src='http://@if(empty($print_set->id)){{8000}}@else{{$print_set->id}}@endif:@if(empty($print_set->port)){{8000}}@else{{$print_set->port}}@endif/CLodopfuncs.js'></script>--}}
  204. <script language='javascript'>
  205. function pagesize(){
  206. var _width = $("input[name=width]").val();
  207. var _height = $("input[name=height]").val();
  208. if(_width<10){
  209. alert("最低宽度不小于10");
  210. $("input[name=width]").val("10");
  211. return;
  212. }
  213. if(_width>400){
  214. alert("最大宽度不大于400");
  215. $("input[name=width]").val("400");
  216. return;
  217. }
  218. $("#container").height(_height+"mm").width(_width+"mm");
  219. }
  220. function delInput(){
  221. var _index = currentDrag.attr("index");
  222. $(".drag").each(function(){
  223. var index = $(this).attr("index");
  224. if(index==_index){
  225. $(this).remove();
  226. }
  227. });
  228. $(".deleteinput").hide();
  229. }
  230. function addInput(n) {
  231. var index = $('#container .drag').length + 1;
  232. if(n==1){
  233. var data = '<div class="drag" cate="2" style="width: auto; height: auto; padding: 10px;" index="' + index + '" style="z-index:' + index + '" fields="" item-size="12" item-font="微软雅黑" item-align="1">';
  234. data+='<div class="text-table">';
  235. data+='请在左侧先选择列';
  236. data+='</div>';
  237. data+='<div class="rRightDown"> </div><div class="rLeftDown"> </div><div class="rRightUp"> </div><div class="rLeftUp"> </div><div class="rRight"> </div><div class="rLeft"> </div><div class="rUp"> </div><div class="rDown"></div>';
  238. data+='</div>';
  239. var drag = $(data)
  240. }else{
  241. var drag = $('<div class="drag" cate="1" index="' + index + '" style="z-index:' + index + '" fields="" item-size="12" item-font="微软雅黑" item-align="1"><div class="text" style="font-size:12pt"></div><div class="rRightDown"> </div><div class="rLeftDown"> </div><div class="rRightUp"> </div><div class="rLeftUp"> </div><div class="rRight"> </div><div class="rLeft"> </div><div class="rUp"> </div><div class="rDown"></div></div>');
  242. }
  243. $('#container').append(drag);
  244. // todo 加上就报错
  245. bindEvents(drag);
  246. setCurrentDrag(drag);
  247. }
  248. function changeBG(n) {
  249. if(n){
  250. $("#bgimg").attr("src","").hide();
  251. $("#bg").val("");
  252. }else{
  253. util.image('', function(data) {
  254. $("#bgimg").attr("src",data.url).show();
  255. $("#bg").val(data.url);
  256. });
  257. }
  258. }
  259. var currentDrag = false;
  260. function bindEvents(obj) {
  261. var index = obj.attr('index');
  262. var rs = new Resize(obj, {
  263. Max: true,
  264. mxContainer: "#container"
  265. });
  266. rs.Set($(".rRightDown", obj), "right-down");
  267. rs.Set($(".rLeftDown", obj), "left-down");
  268. rs.Set($(".rRightUp", obj), "right-up");
  269. rs.Set($(".rLeftUp", obj), "left-up");
  270. rs.Set($(".rRight", obj), "right");
  271. rs.Set($(".rLeft", obj), "left");
  272. rs.Set($(".rUp", obj), "up");
  273. rs.Set($(".rDown", obj), "down");
  274. new Drag(obj, {
  275. Limit: true,
  276. mxContainer: "#container"
  277. });
  278. $('.drag .remove').unbind('click').click(function() {
  279. $(this).parent().remove();
  280. });
  281. $.contextMenu({
  282. selector: '.drag[index=' + index + ']',
  283. callback: function(key, options) {
  284. var index = $(this).attr('index');
  285. if (key == 'next') {
  286. var nextdiv = $(this).next('.drag');
  287. if (nextdiv.length > 0) {
  288. nextdiv.insertBefore($(this));
  289. }
  290. }
  291. else if (key == 'prev') {
  292. var prevdiv = $(this).prev('.drag');
  293. if (prevdiv.length > 0) {
  294. $(this).insertBefore(prevdiv);
  295. }
  296. }
  297. else if (key == 'last') {
  298. var len = $('.drag').length;
  299. if (index >= len - 1) {
  300. return;
  301. }
  302. var last = $('#container .drag:last');
  303. if (last.length > 0) {
  304. $(this).insertAfter(last);
  305. }
  306. }
  307. else if (key == 'first') {
  308. var index = $(this).index();
  309. if (index <= 1) {
  310. return;
  311. }
  312. var first = $('#container .drag:first');
  313. if (first.length > 0) {
  314. $(this).insertBefore(first);
  315. }
  316. }
  317. else if (key == 'delete') {
  318. $(this).remove();
  319. $('.items').hide();
  320. $(".item-tip").show();
  321. $(".deleteinput").hide();
  322. }
  323. var n = 1;
  324. $('.drag').each(function() {
  325. $(this).css("z-index", n);
  326. n++;
  327. })
  328. },
  329. items: {"next": {name: "调整到上层"},"prev": {name: "调整到下层"},"last": {name: "调整到最顶层"},"first": {name: "调整到最低层"},"delete": {name: "删除元素"}}
  330. });
  331. obj.unbind('mousedown').mousedown(function() {
  332. setCurrentDrag(obj);
  333. });
  334. }
  335. var timer = 0;
  336. function setCurrentDrag(obj) {
  337. currentDrag = obj;
  338. var cate = obj.attr('cate');
  339. bindItems();
  340. $(".item-tip").hide();
  341. $('.items').show();
  342. $(".deleteinput").show();
  343. $(".cate1").show();
  344. $(".cate2").hide();
  345. $('.drag').css('border', '1px solid #aaa');
  346. obj.css('border', '1px solid #428bca');
  347. }
  348. function bindItems() {
  349. var items = currentDrag.attr('items') || "";
  350. var values = items.split(',');
  351. $('.items').find(':checkbox').each(function() {
  352. $(this).get(0).checked = false;
  353. });
  354. $('#item-font').val('');
  355. $('#item-size').val('');
  356. $('#item-bold').val('');
  357. for (var i in values) {
  358. if (values[i] != '') {
  359. $('.items').find(":checkbox[value='" + values[i] + "']").get(0).checked = true;
  360. }
  361. }
  362. $('#item-font').val(currentDrag.attr('item-font') || '');
  363. $('#item-size').val(currentDrag.attr('item-size') || '');
  364. $('#item-bold').val(currentDrag.attr('item-bold') || '');
  365. $('#item-pre').val(currentDrag.attr('item-pre') || '');
  366. $('#item-last').val(currentDrag.attr('item-last') || '');
  367. $('#item-align').val(currentDrag.attr('item-align') || '');
  368. var itemcolor = $('#item-color');
  369. var input = itemcolor.find('input:first');
  370. var picker = itemcolor.find('.sp-preview-inner');
  371. var color = currentDrag.attr('item-color') || '#000';
  372. input.val(color);
  373. picker.css({
  374. 'background-color': color
  375. });
  376. timer = setInterval(function() {
  377. var cate = currentDrag.attr("cate");
  378. currentDrag.attr('item-color', input.val()).find('.text').css('color', input.val());
  379. currentDrag.attr('item-pre', $('#item-pre').val());
  380. currentDrag.attr('item-last', $('#item-last').val());
  381. var pre = currentDrag.attr('item-pre') || "";
  382. var last = currentDrag.attr('item-last') || "";
  383. var string = currentDrag.attr('item-string') || "";
  384. currentDrag.find('.text').html(pre + string + last);
  385. }, 10);
  386. }
  387. $(function() {
  388. $('#dataform').ajaxForm();
  389. $('.drag').each(function() {
  390. bindEvents($(this));
  391. })
  392. $('.items .checkbox-inline').click(function(e) {
  393. if( $(e.target).find('input').length>0){
  394. return;
  395. }
  396. if (currentDrag) {
  397. var cate = currentDrag.attr("cate");
  398. var values = [];
  399. var titles = [];
  400. var datas = [];
  401. var vd = [];
  402. $('.items').find(':checkbox:checked').each(function() {
  403. var _titles = $(this).attr('title');
  404. var _values = $(this).val();
  405. var _vd = $(this).data('vd');
  406. titles.push(_titles);
  407. values.push(_values);
  408. vd.push(_vd);
  409. datas.push({"value":_values,"title":_titles,"vd":_vd});
  410. });
  411. currentDrag.attr('items', values.join(',')).attr('item-string', titles.join(',')).find('.text').text(titles.join(','));
  412. }
  413. });
  414. $('#item-font').change(function() {
  415. if (currentDrag) {
  416. var cate = currentDrag.attr("cate");
  417. var data = $(this).val();
  418. currentDrag.attr('item-font', data);
  419. if (data == '') {
  420. data = "微软雅黑";
  421. }
  422. currentDrag.attr('item-font', data).find(".text").css('font-family', data);
  423. }
  424. });
  425. $('#item-align').change(function() {
  426. if (currentDrag) {
  427. var cate = currentDrag.attr("cate");
  428. var data = $(this).val();
  429. currentDrag.attr('item-align', data);
  430. if (data == '') {
  431. data = "1";
  432. }
  433. var str = '';
  434. if (data == 1) {
  435. str = "left";
  436. }
  437. if (data == 2) {
  438. str = "center";
  439. }
  440. if (data == 3) {
  441. str = "right";
  442. }
  443. currentDrag.attr('item-font', data).find(".text").css('text-align', str);
  444. }
  445. });
  446. $('#item-size').change(function() {
  447. if (currentDrag) {
  448. var cate = currentDrag.attr("cate");
  449. var data = $(this).val();
  450. currentDrag.attr('item-size', data);
  451. if (data == '') {
  452. data = 12;
  453. }
  454. currentDrag.find(".text").css('font-size', data + "pt");
  455. }
  456. });
  457. $('#item-bold').change(function() {
  458. if (currentDrag) {
  459. var cate = currentDrag.attr("cate");
  460. var data = $(this).val();
  461. currentDrag.attr('item-bold', data);
  462. if (data == 'bold') {
  463. currentDrag.css('font-weight', 'bold');
  464. } else {
  465. currentDrag.find(".text").css('font-weight', 'normal');
  466. }
  467. }
  468. });
  469. });
  470. function save(ispreview) {
  471. var data = [];
  472. $('.drag').each(function() {
  473. var obj = $(this);
  474. var d = {
  475. left: obj.css('left'),
  476. top: obj.css('top'),
  477. width: obj.css('width'),
  478. height: obj.css('height'),
  479. items: obj.attr('items'),
  480. font: obj.attr('item-font'),
  481. size: obj.attr('item-size'),
  482. color: obj.attr('item-color'),
  483. bold: obj.attr('item-bold'),
  484. string: obj.attr('item-string'),
  485. pre: obj.attr('item-pre'),
  486. last: obj.attr('item-last'),
  487. align: obj.attr('item-align'),
  488. cate: obj.attr('cate'),
  489. virtual: obj.attr('item-virtual')
  490. };
  491. data.push(d);
  492. });
  493. console.log(data);
  494. console.log(JSON.stringify(data));
  495. $("#expresscom").val($("#express").find("option:selected").data("name"));
  496. $('#datas').val(JSON.stringify(data));
  497. $('.btnsave').button('loading');
  498. $('#dataform').ajaxSubmit(function(res) {
  499. $('.btnsave').button('reset');
  500. console.log(res);
  501. //data = eval("(" + data + ")");
  502. //$(':hidden[name=id]').val(data.id);
  503. if (ispreview) {
  504. previews();
  505. } else {
  506. if (res == 'success'){
  507. console.log('ok...');
  508. location.href = "{!! yzWebUrl(\Yunshop\Exhelper\common\models\Express::EXPRESS_INDEX_URL) !!}";
  509. }
  510. }
  511. })
  512. return;
  513. }
  514. function previews() {
  515. var LODOP=getCLodop();
  516. alert("保存成功!正在生成预览。。。");
  517. var Width = $("input[name=width]").val()+"pt";
  518. var Height = $("input[name=height]").val()+"pt";
  519. LODOP.PRINT_INITA(0,0,Width,Height,"快递单预览"); //1188
  520. LODOP.ADD_PRINT_HTM(0, 0, 869, 480, $("#container").html());
  521. LODOP.PREVIEW();
  522. }
  523. </script>
  524. @endsection