tb-fee-item-add.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. </style>
  26. </head>
  27. <body>
  28. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  29. <!-- ------- 内容部分 ------- -->
  30. <div class="s-body">
  31. <div class="c-panel">
  32. <div class="c-title" v-if="id == 0">数据添加</div>
  33. <div class="c-title" v-else>数据修改</div>
  34. <el-form v-if="m">
  35. <sa-item type="text" name="费项名称" v-model="m.name" br></sa-item>
  36. <div class="c-item br">
  37. <label class="c-label"><label style="color: red">*</label>收费企业:</label>
  38. <el-select v-model="m.companyId" placeholder="请选择" filterable size="mini">
  39. <el-option v-for="(item,index) in companyList" :key="index" :label="item.name"
  40. :value="item.id"> </el-option>
  41. </el-select>
  42. </div>
  43. <sa-item type="enum" name="类型" v-model="m.feeType" :jv="{1: '按交易额收取', 2: '按次收取'}" jtype="3"
  44. br></sa-item>
  45. <sa-item type="num" v-if="m.feeType==1" name="百分比(%)" v-model="m.percent" br></sa-item>
  46. <sa-item type="num" v-if="m.feeType==2" name="金额(元)" v-model="m.feeMoney" br></sa-item>
  47. <sa-item type="enum" name="状态" v-model="m.status" :jv="{0: '禁用', 1: '启用'}" jtype="3"
  48. br></sa-item>
  49. <sa-item name="" class="s-ok" br>
  50. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  51. </sa-item>
  52. </el-form>
  53. </div>
  54. </div>
  55. <!-- ------- 底部按钮 ------- -->
  56. <div class="s-foot">
  57. <el-button type="primary" @click="ok()">确定</el-button>
  58. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. components: {
  64. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  65. },
  66. el: '.vue-box',
  67. data: {
  68. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  69. m: null, // 实体对象
  70. companyList: []
  71. },
  72. methods: {
  73. getCompanyList: function() {
  74. sa.ajax('/level-two-server/TbCompany/getList', {
  75. pageNo: 1,
  76. pageSize: 100
  77. }, function(res) {
  78. this.companyList = res.data; // 数据
  79. }.bind(this));
  80. },
  81. // 创建一个 默认Model
  82. createModel: function() {
  83. return {
  84. id: '', // 主键
  85. companyId: '', // 企业ID
  86. companyName: '', // 收费企业
  87. name: '', // 名称
  88. feeType: '2', // 类型(1=按交易额收取,2=按次收取)
  89. percent: '', // 百分比fee_type=1时生效
  90. feeMoney: '', // 收费金额 fee_type=2时生效
  91. status: '1', // 状态(0=禁用,1=启用)
  92. }
  93. },
  94. // 提交数据
  95. ok: function() {
  96. // 表单校验
  97. let m = this.m;
  98. sa.checkNull(m.name, '请输入 [名称]');
  99. sa.checkNull(m.companyId, '请选择 [收费企业]');
  100. if (m.feeType == 1 && !m.percent) {
  101. sa.error('请输入百分比')
  102. return;
  103. }
  104. if (m.feeType == 2 && !m.feeMoney) {
  105. sa.error('请输入金额')
  106. return;
  107. }
  108. if (m.feeType == 1) {
  109. m.feeMoney=0;
  110. }
  111. if (m.feeType == 2) {
  112. m.percent=0;
  113. }
  114. m.companyName=this.companyList.filter(obj=>obj.id==m.companyId).pop().name;
  115. // 开始增加或修改
  116. this.m.createTime = undefined; // 不提交属性:创建时间
  117. this.m.updateTime = undefined; // 不提交属性:更新时间
  118. if (this.id <= 0) { // 添加
  119. sa.ajax('/level-two-server/TbFeeItem/add', m, function(res) {
  120. sa.alert('增加成功', this.clean);
  121. }.bind(this));
  122. } else { // 修改
  123. sa.ajax('/level-two-server/TbFeeItem/update', m, function(res) {
  124. sa.alert('修改成功', this.clean);
  125. }.bind(this));
  126. }
  127. },
  128. // 添加/修改 完成后的动作
  129. clean: function() {
  130. if (this.id == 0) {
  131. this.m = this.createModel();
  132. } else {
  133. parent.app.f5(); // 刷新父页面列表
  134. sa.closeCurrIframe(); // 关闭本页
  135. }
  136. }
  137. },
  138. mounted: function() {
  139. this.getCompanyList();
  140. // 初始化数据
  141. if (this.id <= 0) {
  142. this.m = this.createModel();
  143. } else {
  144. sa.ajax('/level-two-server/TbFeeItem/getById?id=' + this.id, function(res) {
  145. this.m = res.data;
  146. if (res.data == null) {
  147. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  148. }
  149. }.bind(this))
  150. }
  151. }
  152. })
  153. </script>
  154. </body>
  155. </html>