priceSetting.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php use common\widgets\UeditorWidget; ?>
  2. <script src="/js/mobiscroll/mobiscroll.core-2.5.2.js" type="text/javascript"></script>
  3. <script src="/js/mobiscroll/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>
  4. <link href="/css/mobiscroll/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css"/>
  5. <link href="/css/mobiscroll/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css"/>
  6. <script src="/js/mobiscroll/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
  7. <script src="/js/mobiscroll/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>
  8. <!-- S 可根据自己喜好引入样式风格文件 -->
  9. <script src="/js/mobiscroll/mobiscroll.android-ics-2.5.2.js" type="text/javascript"></script>
  10. <link href="/css/mobiscroll/mobiscroll.android-ics-2.5.2.css" rel="stylesheet" type="text/css"/>
  11. <!-- E 可根据自己喜好引入样式风格文件 -->
  12. <?php
  13. use backend\widgets\TabWidget;
  14. echo TabWidget::widget(['list' => $this->context->menuList, 'currentMenu' => $this->context->id]);
  15. ?>
  16. <div class="panel panel-default">
  17. <?php
  18. use backend\widgets\SubTabWidget;
  19. echo SubTabWidget::widget(['list' => $this->context->subMenuList, 'currentMenu' => $this->context->action->id]);
  20. ?>
  21. <div class="panel-body">
  22. <form role="form" class="form-horizontal">
  23. <div class="form-group">
  24. <label class="col-sm-2 control-label" for="field-4">*涨价方式</label>
  25. <div class="col-sm-10">
  26. <?php foreach ($riseTypeName as $riseKey => $riseVal) { ?>
  27. <div class="radio-inline">
  28. <label> <input type="radio" <?php if ($set['riseType'] == $riseKey) {
  29. echo 'checked';
  30. } ?> name="riseType" value="<?= $riseKey ?>">
  31. <?= $riseVal ?>
  32. </label>
  33. </div>
  34. <?php } ?>
  35. </div>
  36. </div>
  37. <div name="riseArea">
  38. <div class="form-group">
  39. <label class="col-sm-2 control-label">*涨价时段:</label>
  40. <div class="col-sm-10">
  41. <input type="text" id="startTime" <?php if (!empty($set['startRiseTime'])) {
  42. echo 'checkStatus="yes"';
  43. } ?> value="<?php if (!empty($set['startRiseTime'])) {
  44. echo date("Y-m-d H:i:s", $set['startRiseTime']);
  45. } ?>" style="width:40%;display:inline-block;" class="form-control" name="startTime" placeholder="请填写开始时间">
  46. <input type="text" id="endTime" <?php if (!empty($set['endRiseTime'])) {
  47. echo 'checkStatus="yes"';
  48. } ?> value="<?php if (!empty($set['endRiseTime'])) {
  49. echo date("Y-m-d H:i:s", $set['endRiseTime']);
  50. } ?>" style="width:40%;display:inline-block;" class="form-control" name="endTime" placeholder="请填写结束时间">
  51. <p></p>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label class="col-sm-2 control-label">*涨价金额:</label>
  56. <div class="col-sm-10">
  57. <input type="text" class="form-control" value="<?= $set['riseAmount'] ?>" name="riseAmount" placeholder="全部商品上涨20%请填写20,上涨100元请填写100">
  58. <p></p>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="form-group-separator"></div>
  63. <div class="form-group">
  64. <label class="col-sm-2 control-label" for="field-3">*商品简要说明:</label>
  65. <div class="col-sm-10">
  66. <?= UeditorWidget::widget(['name' => 'goodSIntroduce', 'content' => $set['goodSIntroduce']]); ?>
  67. <p></p>
  68. </div>
  69. </div>
  70. <div class="form-group-separator"></div>
  71. <div class="form-group" style="text-align:center;">
  72. <button type="button" onclick="setSubmit('click',this)" class="btn btn-info btn-single">确认</button>
  73. <button type="button" onclick="history.go(-1);" class="btn btn-info btn-single">返回</button>
  74. </div>
  75. </form>
  76. </div>
  77. </div>
  78. <!-- footer -->
  79. <?php
  80. use backend\widgets\FooterWidget;
  81. ?>
  82. <?= FooterWidget::widget() ?>
  83. <!-- footer -->
  84. <script>
  85. //验证流程
  86. var startTime = $("input[name=startTime]");
  87. var endTime = $("input[name=endTime]");
  88. var riseAmount = $("input[name=riseAmount]");
  89. var goodSIntroduce = $("textarea[name=goodSIntroduce]");
  90. var needValidate = [];
  91. var riseType = <?php echo isset($set['riseType']) && strlen($set['riseType']) > 0 ? $set['riseType'] : 0; ?>;//不涨价
  92. <?php if($set['riseType'] == $noRise){ ?>
  93. $("div[name=riseArea]").css("display", "none");
  94. <?php }else{ ?>
  95. needValidate = [riseAmount];
  96. $("div[name=riseArea]").css("display", "block");
  97. <?php } ?>
  98. $(":radio[name=riseType]").click(function () {
  99. riseType = $(":radio[name=riseType]:checked").val();
  100. needValidate = [];
  101. if (riseType == <?= $noRise ?>) {//如果涨价再开启验证
  102. $("div[name=riseArea]").css("display", "none");
  103. } else {
  104. needValidate = [riseAmount];
  105. $("div[name=riseArea]").css("display", "block");
  106. }
  107. });
  108. setStats(riseAmount, '请填写涨价金额或百分数', function (val, mess) {
  109. var info = [false, mess];
  110. if (getLength(val) > 0) {
  111. info[0] = true;
  112. info[1] = '填写正确';
  113. if (Math.floor(val) != val) {
  114. info[0] = false;
  115. info[1] = '请填写整数';
  116. }
  117. }
  118. return info;
  119. });
  120. UE.getEditor('goodSIntroduce').addListener("focus", function (type, event) {
  121. goodSIntroduce.removeAttr('checkStatus');
  122. goodSIntroduce.siblings('p').removeClass('help-error-mention').html('');
  123. goodSIntroduce.parent().parent().removeClass("has-success").removeClass('has-error');
  124. })
  125. UE.getEditor('goodSIntroduce').addListener("blur", function (type, event) {
  126. var goodSIntroduceVal = UE.getEditor('goodSIntroduce').getContent();
  127. if (getLength(goodSIntroduceVal) > 0) {
  128. goodSIntroduce.attr('checkStatus', 'yes');
  129. goodSIntroduce.siblings('p').removeClass('help-error-mention').html('');
  130. goodSIntroduce.parent().parent().addClass("has-success").removeClass("has-error");
  131. } else {
  132. goodSIntroduce.attr('checkStatus', 'no');
  133. goodSIntroduce.siblings('p').addClass('help-error-mention').html('简要说明不能为空');
  134. goodSIntroduce.parent().parent().addClass("has-error").removeClass("has-success");
  135. }
  136. });
  137. function setSubmit() {
  138. var verifyStatus = true;
  139. for (var m = 0; m < needValidate.length; m++) {
  140. var singleObj = needValidate[m];
  141. if (singleObj.attr('checkStatus') == undefined) {
  142. singleObj.blur();
  143. }
  144. if (singleObj.attr('checkStatus') == 'no') {
  145. verifyStatus = false;
  146. continue;
  147. }
  148. }
  149. if (riseType == <?= $noRise ?>) {//要涨价
  150. if (startTime.attr('checkStatus') == undefined || startTime.attr('checkStatus') == 'no') {
  151. verifyStatus = false;
  152. startTime.attr('checkStatus', 'no');
  153. startTime.siblings('p').addClass('help-error-mention').html('请填写开始时间');
  154. startTime.parent().parent().addClass("has-error").removeClass("has-success");
  155. }
  156. if (endTime.attr('checkStatus') == undefined || endTime.attr('checkStatus') == 'no') {
  157. verifyStatus = false;
  158. endTime.attr('checkStatus', 'no');
  159. endTime.siblings('p').addClass('help-error-mention').html('请填写结束时间');
  160. endTime.parent().parent().addClass("has-error").removeClass("has-success");
  161. }
  162. }
  163. <?php
  164. if(!empty($set['goodSIntroduce'])){
  165. ?>
  166. goodSIntroduce.attr('checkStatus', 'yes');
  167. <?php } ?>
  168. if (goodSIntroduce.attr('checkStatus') == undefined || goodSIntroduce.attr('checkStatus') == 'no') {
  169. goodSIntroduce.attr('checkStatus', 'no');
  170. goodSIntroduce.siblings('p').addClass('help-error-mention').html('简要说明不能为空');
  171. goodSIntroduce.parent().parent().addClass("has-error").removeClass("has-success");
  172. verifyStatus = false;
  173. }
  174. if (verifyStatus == false) {
  175. return;
  176. }
  177. var data = "&_csrf=<?= Yii::$app->request->csrfToken ?>&startRiseTime=" + startTime.val() + '&endRiseTime=' + endTime.val() + "&";
  178. data += "goodSIntroduce=" + goodSIntroduce.val() + "&riseType=" + riseType + "&riseAmount=" + riseAmount.val();
  179. $.ajax({
  180. type: "POST",
  181. url: '/goods/setting-replace',
  182. data: data,
  183. dataType: 'json',
  184. async: false,
  185. success: function (data) {
  186. xhPopMsg(data.msg, 1300);
  187. if (data.code == 'A0001') {
  188. }
  189. }
  190. });
  191. }
  192. function setStats(obj, mess, check) {
  193. obj.focus(function () {
  194. $(this).removeAttr('checkStatus');
  195. $(this).siblings('p').removeClass('help-error-mention').html('');
  196. $(this).parent().parent().removeClass("has-success").removeClass('has-error');
  197. });
  198. obj.blur(function () {
  199. var objVal = obj.val();
  200. var info = check(objVal, mess);
  201. if (info[0]) {
  202. $(this).attr('checkStatus', 'yes');
  203. $(this).siblings('p').removeClass('help-error-mention').html('');
  204. $(this).parent().parent().addClass("has-success").removeClass("has-error");
  205. } else {
  206. $(this).attr('checkStatus', 'no');
  207. $(this).siblings('p').addClass('help-error-mention').html(info[1]);
  208. $(this).parent().parent().addClass("has-error").removeClass("has-success");
  209. }
  210. });
  211. }
  212. //选择创建时间
  213. $(function () {
  214. var currYear = (new Date()).getFullYear();
  215. var opt = {};
  216. opt.date = {preset: 'date'};
  217. opt.datetime = {preset: 'datetime'};
  218. opt.time = {preset: 'time'};
  219. opt.default = {
  220. theme: 'android-ics light', //皮肤样式
  221. display: 'modal', //显示方式
  222. mode: 'scroller', //日期选择模式
  223. lang: 'zh',
  224. dateFormat: 'yy-mm-dd',
  225. showNow: true,
  226. nowText: "今天",
  227. startYear: currYear - 10, //开始年份
  228. endYear: currYear + 10 //结束年份
  229. };
  230. var optDateTime = $.extend(opt['datetime'], opt['default']);
  231. $("#startTime").mobiscroll(optDateTime).datetime(optDateTime).bind("change", function (e) {
  232. $("#startTime").attr('checkStatus', 'yes');
  233. $("#startTime").siblings('p').removeClass('help-error-mention').html('');
  234. $("#startTime").parent().parent().addClass("has-success").removeClass("has-error");
  235. });
  236. $("#endTime").mobiscroll(optDateTime).datetime(optDateTime).bind("change", function (e) {
  237. $("#endTime").attr('checkStatus', 'yes');
  238. $("#endTime").siblings('p').removeClass('help-error-mention').html('');
  239. $("#endTime").parent().parent().addClass("has-success").removeClass("has-error");
  240. });
  241. });
  242. </script>