tb-business-sort-add.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. .item-num .el-input__inner {
  26. width: 130px;
  27. display: inline;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  33. <!-- ------- 内容部分 ------- -->
  34. <div class="s-body">
  35. <div class="c-panel">
  36. <div class="c-title" v-if="id == 0">数据添加</div>
  37. <div class="c-title" v-else>数据修改</div>
  38. <el-form v-if="m">
  39. <div v-for="item in list" :key="item.index">
  40. <div class="c-item" v-if="item.index>0">
  41. <label class="c-label">间隔(分):</label>
  42. <el-input-number class="item-num" v-model="item.interval" :step="10" :min="1" :max="9999">
  43. </el-input-number>
  44. </div>
  45. <div class="c-item">
  46. <label class="c-label">第{{item.index+1}}个:</label>
  47. <el-select v-model="item.typeId" placeholder="请选择">
  48. <el-option :label="type.name" :value="type.id"
  49. v-for="(type,index) in item.businessTypeList">
  50. </el-option>
  51. </el-select>
  52. <el-button @click="handlerAdd" v-if="item.index==0">添加项</el-button>
  53. <el-button @click="handlerDel(item.index)" v-if="item.index>0">删除项</el-button>
  54. </div>
  55. </div>
  56. <sa-item name="" class="s-ok" br>
  57. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  58. </sa-item>
  59. </el-form>
  60. </div>
  61. </div>
  62. <!-- ------- 底部按钮 ------- -->
  63. <div class="s-foot">
  64. <el-button type="primary" @click="ok()">确定</el-button>
  65. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  66. </div>
  67. </div>
  68. <script>
  69. var app = new Vue({
  70. components: {
  71. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  72. },
  73. el: '.vue-box',
  74. data: {
  75. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  76. m: null, // 实体对象
  77. list: [],
  78. businessTypeList:[],
  79. },
  80. methods: {
  81. handlerAdd(){
  82. let list=this.list;
  83. this.list.push({
  84. index: list.length,
  85. typeId: '',
  86. interval: 30,
  87. businessTypeList: this.businessTypeList
  88. })
  89. },
  90. handlerDel(index){
  91. let list=this.list;
  92. list.splice(index,1);
  93. for(let i in list){
  94. let obj=list[i];
  95. if(obj.index>index){
  96. obj.index=obj.index-1;
  97. }
  98. }
  99. this.list=list;
  100. },
  101. getBusinessType() {
  102. this.list = [];
  103. sa.ajax('/TbCostomer/getTypeList', function(resp) {
  104. let list=resp.data;
  105. this.businessTypeList=list;
  106. this.list.push({
  107. index: 0,
  108. typeId: '',
  109. interval: 30,
  110. businessTypeList: list
  111. })
  112. }.bind(this))
  113. },
  114. // 创建一个 默认Model
  115. createModel: function() {
  116. return {
  117. id: '', //
  118. name: '', //
  119. typeId: '',
  120. typeName: '', //
  121. sort: '', //
  122. }
  123. },
  124. // 提交数据
  125. ok: function() {
  126. // 表单校验
  127. let m = this.m;
  128. sa.checkNull(m.id, '请输入 []');
  129. sa.checkNull(m.name, '请输入 []');
  130. sa.checkNull(m.typeName, '请输入 []');
  131. sa.checkNull(m.sort, '请输入 []');
  132. // 开始增加或修改
  133. if (this.id <= 0) { // 添加
  134. sa.ajax('/TbBusinessOrder/add', m, function(res) {
  135. sa.alert('增加成功', this.clean);
  136. }.bind(this));
  137. } else { // 修改
  138. sa.ajax('/TbBusinessOrder/update', m, function(res) {
  139. sa.alert('修改成功', this.clean);
  140. }.bind(this));
  141. }
  142. },
  143. // 添加/修改 完成后的动作
  144. clean: function() {
  145. if (this.id == 0) {
  146. this.m = this.createModel();
  147. } else {
  148. parent.app.f5(); // 刷新父页面列表
  149. sa.closeCurrIframe(); // 关闭本页
  150. }
  151. }
  152. },
  153. mounted: function() {
  154. this.getBusinessType();
  155. // 初始化数据
  156. if (this.id <= 0) {
  157. this.m = this.createModel();
  158. } else {
  159. sa.ajax('/TbBusinessOrder/getById?id=' + this.id, function(res) {
  160. this.m = res.data;
  161. if (res.data == null) {
  162. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  163. }
  164. }.bind(this))
  165. }
  166. }
  167. })
  168. </script>
  169. </body>
  170. </html>