adddeliver.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .design-sketch div{display: inline-block;border: 1px solid #ccc;padding: 10px;margin: 8px;border-radius: 2px;color: #555;white-space: nowrap;user-select: none;background-color: #fff;line-height: 1;}
  5. .design-sketch div i{position: absolute;top: -10px;right: -10px;display: none;width: 20px;height: 20px;border-radius: 10px;background-color: rgba(0, 0, 0, .5);color: #FFFFFF;text-align: center;line-height: 20px;z-index: 99;}
  6. .form-row{margin-top: 0;margin-left: 220px;}
  7. .express-sheet-rule .form-row{margin-left: 200px;}
  8. </style>
  9. {/block}
  10. {block name="main"}
  11. <div class="layui-form">
  12. <div class="layui-card card-common card-brief">
  13. <div class="layui-card-header">
  14. <span class="card-title">配送员信息</span>
  15. </div>
  16. <div class="layui-card-body">
  17. <div class="layui-form-item">
  18. <label class="layui-form-label"><span class="required">*</span>配送员名称:</label>
  19. <div class="layui-input-inline">
  20. <input type="text" name="deliver_name" lay-verify="required|deliverName" class="layui-input len-long">
  21. </div>
  22. </div>
  23. <div class="layui-form-item">
  24. <label class="layui-form-label"><span class="required">*</span>配送员手机号:</label>
  25. <div class="layui-input-block">
  26. <input type="text" name="deliver_mobile" lay-verify="required|deliverMobile" class="layui-input len-long">
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <input type="hidden" value="{$store_id ?? 0}" name="store_id">
  32. <div class="form-row">
  33. <button class="layui-btn" lay-submit lay-filter="save">保存</button>
  34. <button type="reset" class="layui-btn layui-btn-primary" onclick="back()">返回</button>
  35. </div>
  36. </div>
  37. {/block}
  38. {block name="script"}
  39. <script>
  40. layui.use(['form'], function() {
  41. var form = layui.form,
  42. repeat_flag = false; //防重复标识
  43. form.render();
  44. /**
  45. * 监听提交
  46. */
  47. form.on('submit(save)', function(data) {
  48. if (repeat_flag) return;
  49. repeat_flag = true;
  50. $.ajax({
  51. url: ns.url("shop/local/addDeliver"),
  52. data: data.field,
  53. dataType: 'JSON',
  54. type: 'POST',
  55. success: function(res) {
  56. repeat_flag = false;
  57. if (res.code == 0) {
  58. layer.confirm('添加成功', {
  59. title:'操作提示',
  60. btn: ['返回列表', '继续添加'],
  61. closeBtn: 0,
  62. yes: function(){
  63. if($('input[name="store_id"]').val() > 0){
  64. location.href = ns.url("shop/store/deliverLists",{'store_id':$('input[name="store_id"]').val()})
  65. }else{
  66. location.href = ns.url("shop/local/deliverLists")
  67. }
  68. },
  69. btn2: function () {
  70. if($('input[name="store_id"]').val() > 0){
  71. location.href = ns.url("shop/store/addDeliver",{'store_id':$('input[name="store_id"]').val()})
  72. }else{
  73. location.href = ns.url("shop/local/addDeliver")
  74. }
  75. }
  76. });
  77. } else {
  78. layer.msg(res.message);
  79. }
  80. }
  81. });
  82. });
  83. /**
  84. * 表单验证
  85. */
  86. form.verify({
  87. deliverName: function(value){
  88. if (value == '') {
  89. return '配送员名称不能为空!';
  90. }
  91. },
  92. deliverMobile: function (value) {
  93. if (value == '') {
  94. return '手机号不能为空!';
  95. }
  96. if (!ns.parse_mobile(value)) {
  97. return '请输入合法的手机号!'
  98. }
  99. }
  100. });
  101. });
  102. function back(){
  103. if($('input[name="store_id"]').val() > 0){
  104. location.href = ns.url("shop/store/deliverLists",{'store_id':$('input[name="store_id"]').val()})
  105. }else{
  106. location.href = ns.url("shop/local/deliverLists");
  107. }
  108. }
  109. </script>
  110. {/block}