tb-business-sort-add.html 6.9 KB

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