CultureDecorate.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. $(function()
  2. {
  3. /* 搜索切换 */
  4. var $more_where = $('.more-where');
  5. $more_submit = $('.more-submit');
  6. $more_submit.find('input[name="is_more"]').change(function()
  7. {
  8. if($more_submit.find('i').hasClass('am-icon-angle-down'))
  9. {
  10. $more_submit.find('i').removeClass('am-icon-angle-down');
  11. $more_submit.find('i').addClass('am-icon-angle-up');
  12. } else {
  13. $more_submit.find('i').addClass('am-icon-angle-down');
  14. $more_submit.find('i').removeClass('am-icon-angle-up');
  15. }
  16. if($more_submit.find('input[name="is_more"]:checked').val() == undefined)
  17. {
  18. $more_where.addClass('none');
  19. } else {
  20. $more_where.removeClass('none');
  21. }
  22. });
  23. // 日期选择
  24. var $time_start = $('#time_start');
  25. var $time_end = $('#time_end');
  26. var nowTemp = new Date();
  27. var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
  28. var checkin = $time_start.datepicker({}).on('changeDate.datepicker.amui', function(ev) {
  29. var newDate = new Date(ev.date)
  30. newDate = (ev.date.valueOf() > checkout.date.valueOf() || ev.date.valueOf() == checkout.date.valueOf()) ? newDate.setDate(newDate.getDate() + 1) : checkout.date.valueOf();
  31. checkout.setValue(newDate);
  32. checkin.close();
  33. $time_end[0].blur();
  34. }).data('amui.datepicker');
  35. var checkout = $time_end.datepicker({
  36. onRender:function(date) {
  37. return date.valueOf() <= checkin.date.valueOf() ? 'am-disabled' : '';
  38. }
  39. }).on('changeDate.datepicker.amui', function(ev) {
  40. checkout.close();
  41. }).data('amui.datepicker');
  42. //文件上传
  43. var uploader = WebUploader.create({
  44. // 选完文件后,是否自动上传。
  45. auto: true,
  46. // 表单文件名称
  47. fileVal: 'upfile',
  48. // 文件接收服务端。
  49. server: '/admin.php?m=Admin&c=Ueditor&a=Index&action=uploadimage',
  50. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  51. pick: '#uploader',
  52. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  53. resize: false,
  54. });
  55. //上传成功
  56. uploader.on( 'uploadSuccess', function( file , response) {
  57. if(response.state != 'SUCCESS'){
  58. Prompt(response.state);
  59. return false;
  60. }
  61. var $li = $(
  62. '<img src="' + response.url + '" alt="" class="am-img-thumbnail">'
  63. ),
  64. $img = $li.find('img');
  65. var $list = $("#fileList");
  66. // $list为容器jQuery实例
  67. $list.html( $li );
  68. $("#thumb").val(response.url);
  69. });
  70. // 文件上传失败,显示上传出错。
  71. uploader.on('uploadError', function( file, response ) {
  72. Prompt(response.state);
  73. });
  74. $('#decorate_type_id').chosen({
  75. disable_search_threshold: 10,
  76. no_results_text: '没有选项',
  77. width: '200px !important'
  78. });
  79. //专属联动
  80. $('#decorate_target_type_id').chosen({
  81. disable_search_threshold: 10,
  82. no_results_text: '没有选项',
  83. width: '200px !important'
  84. });
  85. //有选项初始化
  86. if($("#decorate_target_id option").length > 1){
  87. $('#decorate_target_id').chosen({
  88. disable_search_threshold: 10,
  89. no_results_text: '没有选项',
  90. width: '200px !important'
  91. });
  92. }
  93. if($("#decorate_target_property_id option").length > 1){
  94. $('#decorate_target_property_id').chosen({
  95. disable_search_threshold: 10,
  96. no_results_text: '没有选项',
  97. width: '200px !important'
  98. });
  99. }
  100. $('#decorate_target_type_id').on('change', function(){
  101. var decorate_target_type_id = $(this).val();
  102. //销毁插件 、 删除选项
  103. if($("#decorate_target_property_id_chosen").length != 0){
  104. $("#decorate_target_property_id option:gt(0)").remove();
  105. $('#decorate_target_property_id').chosen('destroy');
  106. }
  107. if($("#decorate_target_id_chosen").length != 0){
  108. $("#decorate_target_id option:gt(0)").remove();
  109. $('#decorate_target_id').chosen("destroy");
  110. }
  111. //获取数据
  112. $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateTarget', {decorate_target_type_id : decorate_target_type_id}, function(responsedata){
  113. if(responsedata.code != 0){
  114. return false;
  115. }
  116. //设置option
  117. for(x in responsedata.data){
  118. $("#decorate_target_id").append("<option value='" + responsedata.data[x].id + "'>" + responsedata.data[x].name + "</option>");
  119. }
  120. //初始化插件
  121. $('#decorate_target_id').chosen({
  122. disable_search_threshold: 10,
  123. no_results_text: '没有选项',
  124. width: '200px !important',
  125. });
  126. },'JSON');
  127. //获取装饰类型数据
  128. $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', {decorate_target_type_id : decorate_target_type_id}, function(responsedata){
  129. if($("#decorate_type_id_chosen").length != 0){
  130. $("#decorate_type_id option:gt(0)").remove();
  131. $('#decorate_type_id').chosen("destroy");
  132. }
  133. if(responsedata.code != 0){
  134. $('#decorate_type_id').chosen({
  135. disable_search_threshold: 10,
  136. no_results_text: '没有选项',
  137. width: '200px !important',
  138. })
  139. return false;
  140. }
  141. //设置option
  142. for(x in responsedata.data){
  143. $("#decorate_type_id").append("<option value='" + responsedata.data[x].id + "'>" + responsedata.data[x].name + "</option>");
  144. }
  145. //初始化插件
  146. $('#decorate_type_id').chosen({
  147. disable_search_threshold: 10,
  148. no_results_text: '没有选项',
  149. width: '200px !important',
  150. })
  151. },'JSON');
  152. });
  153. $('#decorate_target_id').on('change', function(){
  154. var decorate_target_type_id = $("#decorate_target_type_id").val();
  155. var decorate_target_id = $(this).val();
  156. //销毁插件 、 删除选项
  157. if($("#decorate_target_property_id_chosen").length != 0){
  158. $("#decorate_target_property_id option:gt(0)").remove();
  159. $('#decorate_target_property_id').chosen('destroy');
  160. }
  161. //获取数据
  162. $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateTargetProperty', {
  163. decorate_target_type_id : decorate_target_type_id,
  164. decorate_target_id : decorate_target_id
  165. }, function(responsedata){
  166. if(responsedata.code != 0){
  167. return false;
  168. }
  169. //设置option
  170. for(x in responsedata.data){
  171. $("#decorate_target_property_id").append("<option value='" + responsedata.data[x].id + "'>" + responsedata.data[x].name + "</option>");
  172. }
  173. //初始化插件
  174. $('#decorate_target_property_id').chosen({
  175. disable_search_threshold: 10,
  176. no_results_text: '没有选项',
  177. width: '200px !important'
  178. });
  179. },'JSON');
  180. //获取装饰类型数据
  181. $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', {
  182. decorate_target_type_id : decorate_target_type_id,
  183. decorate_target_id : decorate_target_id
  184. }, function(responsedata){
  185. if($("#decorate_type_id_chosen").length != 0){
  186. $("#decorate_type_id option:gt(0)").remove();
  187. $('#decorate_type_id').chosen("destroy");
  188. }
  189. if(responsedata.code != 0){
  190. return false;
  191. }
  192. //设置option
  193. for(x in responsedata.data){
  194. $("#decorate_type_id").append("<option value='" + responsedata.data[x].id + "'>" + responsedata.data[x].name + "</option>");
  195. }
  196. //初始化插件
  197. $('#decorate_type_id').chosen({
  198. disable_search_threshold: 10,
  199. no_results_text: '没有选项',
  200. width: '200px !important',
  201. })
  202. },'JSON');
  203. });
  204. $('#decorate_target_property_id').on('change', function(){
  205. var decorate_target_type_id = $("#decorate_target_type_id").val();
  206. var decorate_target_id = $("#decorate_target_id").val();
  207. var decorate_target_property_id = $(this).val();
  208. //获取装饰类型数据
  209. $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', {
  210. decorate_target_type_id : decorate_target_type_id,
  211. decorate_target_id : decorate_target_id,
  212. decorate_target_property_id : decorate_target_property_id
  213. }, function(responsedata){
  214. if($("#decorate_type_id_chosen").length != 0){
  215. $("#decorate_type_id option:gt(0)").remove();
  216. $('#decorate_type_id').chosen("destroy");
  217. }
  218. if(responsedata.code != 0){
  219. return false;
  220. }
  221. //设置option
  222. for(x in responsedata.data){
  223. $("#decorate_type_id").append("<option value='" + responsedata.data[x].id + "'>" + responsedata.data[x].name + "</option>");
  224. }
  225. //初始化插件
  226. $('#decorate_type_id').chosen({
  227. disable_search_threshold: 10,
  228. no_results_text: '没有选项',
  229. width: '200px !important',
  230. })
  231. },'JSON');
  232. });
  233. });