tb-discount-add.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>折扣管理-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  8. <!-- 所有的 css js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <style type="text/css">
  18. .c-panel .el-form .c-label {
  19. width: 7em !important;
  20. }
  21. .c-panel .el-form .el-input,
  22. .c-panel .el-form .el-textarea__inner {
  23. width: 250px;
  24. }
  25. .discount .el-input__inner {
  26. width: 130px;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  32. <!-- ------- 内容部分 ------- -->
  33. <div class="s-body">
  34. <div class="c-panel">
  35. <div class="c-title" v-if="id == 0">数据添加</div>
  36. <div class="c-title" v-else>数据修改</div>
  37. <el-form v-if="m">
  38. <sa-item type="text" name="标题" placeholder="优惠标题" v-model="m.title" br></sa-item>
  39. <div class="c-item" class="br">
  40. <label class="c-label">类型:</label>
  41. <el-radio-group v-model="m.type" @change="typeChangeFn">
  42. <el-radio :label="1">折扣</el-radio>
  43. <el-radio :label="2">满减</el-radio>
  44. </el-radio-group>
  45. </div>
  46. <div class="c-item" class="br">
  47. <label class="c-label">充值金额:</label>
  48. <el-input-number class="discount" v-model="m.money" :step="100" controls-position="right" :min="1"
  49. :max="99999">
  50. </el-input-number>
  51. <label>元</label>
  52. </div>
  53. <div class="c-item" class="br" v-if="m.type==1">
  54. <label class="c-label">折扣:</label>
  55. <el-input-number class="discount" v-model="m.discount" :step="0.1" controls-position="right"
  56. :min="1" :max="10">
  57. </el-input-number>
  58. <label>折</label>
  59. </div>
  60. <div class="c-item" class="br" v-if="m.type==2">
  61. <label class="c-label">优惠金额:</label>
  62. <el-input-number class="discount" v-model="m.subtract" :step="5" controls-position="right" :min="0"
  63. :max="9999">
  64. </el-input-number>
  65. <label>元</label>
  66. </div>
  67. <sa-item name="" class="s-ok" br>
  68. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  69. </sa-item>
  70. </el-form>
  71. </div>
  72. </div>
  73. <!-- ------- 底部按钮 ------- -->
  74. <div class="s-foot">
  75. <el-button type="primary" @click="ok()">确定</el-button>
  76. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  77. </div>
  78. </div>
  79. <script>
  80. var app = new Vue({
  81. components: {
  82. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  83. },
  84. el: '.vue-box',
  85. data: {
  86. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  87. m: null, // 实体对象
  88. },
  89. methods: {
  90. // 创建一个 默认Model
  91. createModel: function () {
  92. return {
  93. id: '', // 主键
  94. title: '', // 标题
  95. type: 1, // 类型[j]
  96. discount: 10, // 折扣
  97. subtract: 0,
  98. money: 100, // 充值金额
  99. status: '1', // 状态[j]
  100. createTime: '', // 创建时间
  101. }
  102. },
  103. typeChangeFn(value) {
  104. console.log(value)
  105. },
  106. // 提交数据
  107. ok: function () {
  108. // 表单校验
  109. let m = this.m;
  110. sa.checkNull(m.title, '请输入 [标题]');
  111. sa.checkNull(m.money, '请输入 [充值金额]');
  112. // 开始增加或修改
  113. if (this.id <= 0) { // 添加
  114. sa.ajax('/TbDiscount/add', m, function (res) {
  115. sa.alert('增加成功', this.clean);
  116. }.bind(this));
  117. } else { // 修改
  118. sa.ajax('/TbDiscount/update', m, function (res) {
  119. sa.alert('修改成功', this.clean);
  120. }.bind(this));
  121. }
  122. },
  123. // 添加/修改 完成后的动作
  124. clean: function () {
  125. if (this.id == 0) {
  126. this.m = this.createModel();
  127. } else {
  128. parent.app.f5(); // 刷新父页面列表
  129. sa.closeCurrIframe(); // 关闭本页
  130. }
  131. }
  132. },
  133. mounted: function () {
  134. // 初始化数据
  135. if (this.id <= 0) {
  136. this.m = this.createModel();
  137. } else {
  138. sa.ajax('/TbDiscount/getById?id=' + this.id, function (res) {
  139. this.m = res.data;
  140. if (res.data == null) {
  141. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  142. }
  143. }.bind(this))
  144. }
  145. }
  146. })
  147. </script>
  148. </body>
  149. </html>