tb-account-add.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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="https://unpkg.com/element-ui@2.13.0/lib/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. <script src="../../static/kj/upload-util.js"></script>
  18. <script src="../../static/node_modules/crypto-js/crypto-js.js"></script>
  19. <style type="text/css">
  20. .c-panel .el-form .c-label {
  21. width: 8em !important;
  22. }
  23. .c-panel .el-form .el-input,
  24. .c-panel .el-form .el-textarea__inner {
  25. width: 250px;
  26. }
  27. #ast .c-label:before {
  28. content: '*';
  29. color: red;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  35. <!-- ------- 内容部分 ------- -->
  36. <div class="s-body">
  37. <div class="c-panel" style="text-align:center; ">
  38. <div class="c-title">充值</div>
  39. <el-form v-if="m">
  40. <sa-item type="text" name="客户名称" v-model="m.customerName" :disabled="true" br></sa-item>
  41. <sa-item type="text" name="客户余额" v-model="m.totalMoney" :disabled="true" br></sa-item>
  42. <sa-item name="实际收款" br>
  43. <el-input type="number" step="0.01" @input="totalTopupInput" v-model="m.totalTopup" >
  44. <template slot="suffix">元</template>
  45. </el-input>
  46. </sa-item>
  47. <sa-item type="num" name="优惠金额" v-model="m.discountMoney" br></sa-item>
  48. <sa-item type="num" name="本次充值金额" v-model="preTopupMoney" disabled br></sa-item>
  49. <sa-item type="enum" name="付款方式" br>
  50. <el-select v-model="m.payingType">
  51. <el-option label="请选择" v-for="(item,index) in payingTypeList" :key="item.id"
  52. :label="item.name" :value="item.id">
  53. </el-option>
  54. </el-select>
  55. </sa-item>
  56. <sa-item type="textarea" name="充值说明" v-model="m.remark" :rows="2" br></sa-item>
  57. </el-form>
  58. </div>
  59. </div>
  60. <!-- ------- 底部按钮 ------- -->
  61. <div class="s-foot">
  62. <el-button type="primary" @click="ok()">确定</el-button>
  63. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  64. </div>
  65. </div>
  66. <script>
  67. var app = new Vue({
  68. components: {
  69. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  70. },
  71. el: '.vue-box',
  72. data: {
  73. id: sa.p('id', ''),
  74. customerId: sa.p('customerId', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  75. m: {
  76. id: '',
  77. customerId: sa.p('customerId', ''),
  78. customerName: '',
  79. totalMoney: 0,
  80. preTopupMoney: 0,
  81. discountMoney: 0,
  82. totalTopup: 0,
  83. payingType: '',
  84. salt: '',
  85. remark: '',
  86. },
  87. payingTypeList: [], //付款方式集合
  88. },
  89. computed: {
  90. preTopupMoney() {
  91. let money= parseFloat(this.m.totalTopup) + parseFloat(this.m.discountMoney);
  92. if(money<0){
  93. money=0;
  94. sa.error('金额不正确');
  95. }
  96. return money.toFixed(2);
  97. }
  98. },
  99. methods: {
  100. totalTopupInput(){
  101. let totalTopup=this.m.totalTopup;
  102. if(totalTopup&&totalTopup.indexOf('.')>-1){
  103. if(totalTopup.substr('.').length>2){
  104. this.m.totalTopup=totalTopup.substr(0,totalTopup.indexOf('.')+3);
  105. }
  106. }
  107. },
  108. // 提交数据
  109. ok: function() {
  110. this.m.preTopupMoney=this.preTopupMoney;
  111. sa.ajax('/TbAccount/recharge', sa.removeNull(this.m), function(res) {
  112. sa.alert('充值成功', this.clean);
  113. }.bind(this));
  114. },
  115. // 添加/修改 完成后的动作
  116. clean: function() {
  117. parent.app.f5(); // 刷新父页面列表
  118. sa.closeCurrIframe(); // 关闭本页
  119. },
  120. getPayingType() {
  121. sa.ajax('/TbAccount/getPayingType', function(res) {
  122. this.payingTypeList = res.data;
  123. }.bind(this))
  124. },
  125. computeChange(value) {
  126. let preMoney = this.m.preTopupMoney;
  127. if (preMoney <= 0) {
  128. sa.error('充值金额须大于0');
  129. return;
  130. }
  131. let disMoney = this.m.discountMoney;
  132. if (disMoney < 0) {
  133. sa.error('优惠金额须不能为负数');
  134. return;
  135. }
  136. },
  137. },
  138. mounted: function() {
  139. let customerId=this.customerId;
  140. this.getPayingType();
  141. sa.ajax('/TbAccount/getCustomerAccount', {
  142. customerId: customerId
  143. }, function(res) {
  144. let data=res.data;
  145. this.m={
  146. id: data.id,
  147. customerId: customerId,
  148. customerName: data.customerName,
  149. totalMoney: data.totalMoney,
  150. preTopupMoney: 0,
  151. discountMoney: 0,
  152. totalTopup: 0,
  153. payingType: 1,
  154. remark: '',
  155. }
  156. }.bind(this))
  157. }
  158. })
  159. </script>
  160. </body>
  161. </html>