setting.php 11 KB

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