tb-sort-group-edit.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: 8em !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. <sa-item type="text" name="组名称" v-model="m.name" br></sa-item>
  40. <sa-item type="enum" name="是否启用" v-model="m.status" :jv="{0: '否', 1: '是'}" jtype="3" br>
  41. </sa-item>
  42. <sa-item type="enum" name="完整性支付" v-model="m.completePay" :jv="{0: '否', 1: '是'}" jtype="3" br>
  43. </sa-item>
  44. <sa-item name="" class="s-ok" br>
  45. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  46. </sa-item>
  47. <el-divider></el-divider>
  48. <h4>规则设置</h4>
  49. <div style="width: 850px;margin-top: 20px;">
  50. <div v-for="item in list" :key="item.index">
  51. <div class="c-item" v-if="item.index>0">
  52. <label class="c-label">项目间隔(分):</label>
  53. <el-input-number class="item-num" v-model="item.intervalTime" :step="10" :min="0"
  54. :max="9999">
  55. </el-input-number>
  56. </div>
  57. <div class="c-item">
  58. <label class="c-label">第{{item.index + 1}}个:</label>
  59. <el-select v-model="item.typeId" placeholder="请选择">
  60. <el-option :label="type.name" :value="type.id"
  61. v-for="(type,index) in item.businessTypeList">
  62. </el-option>
  63. </el-select>
  64. <label class="c-label" style="width: 160px;">单项间隔(小时):</label>
  65. <el-input-number class="item-num" v-model="item.singleIntervalTime" :step="1"
  66. :min="1" :max="48">
  67. </el-input-number>
  68. <label style="position: relative;left: 50px;">
  69. <el-button style="cursor: pointer;" @click="handlerAdd"
  70. v-if="item.index==0&&list.length<businessTypeList.length">添加项
  71. </el-button>
  72. <el-button @click="handlerDel(item.index)" v-if="item.index>0">删除项</el-button>
  73. </label>
  74. </div>
  75. </div>
  76. </div>
  77. </el-form>
  78. </div>
  79. </div>
  80. <!-- ------- 底部按钮 ------- -->
  81. <div class="s-foot">
  82. <el-button type="primary" @click="ok()">确定</el-button>
  83. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  84. </div>
  85. </div>
  86. <script>
  87. var app = new Vue({
  88. components: {
  89. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  90. },
  91. el: '.vue-box',
  92. data: {
  93. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  94. m: null, // 实体对象
  95. list: [],
  96. businessTypeList: [],
  97. },
  98. methods: {
  99. handlerAdd() {
  100. let list = this.list;
  101. this.list.push({
  102. index: list.length,
  103. typeId: '',
  104. intervalTime: 30,
  105. singleIntervalTime: 12,
  106. businessTypeList: this.businessTypeList
  107. })
  108. },
  109. handlerDel(index) {
  110. let list = this.list;
  111. list.splice(index, 1);
  112. for (let i in list) {
  113. let obj = list[i];
  114. if (obj.index > index) {
  115. obj.index = obj.index - 1;
  116. }
  117. }
  118. this.list = list;
  119. },
  120. getBusinessType() {
  121. sa.ajax('/TbItemType/getList', {
  122. business: 0,
  123. sortType: 0
  124. }, function (resp) {
  125. let list = resp.data;
  126. this.businessTypeList = list;
  127. this.getById();
  128. }.bind(this))
  129. },
  130. // 创建一个 默认Model
  131. createModel: function () {
  132. return {
  133. id: '', //
  134. name: '', // 名称
  135. status: 1, // 是否启用(0=否,1=是)
  136. createTime: '', // 创建时间
  137. }
  138. },
  139. // 提交数据
  140. ok: function () {
  141. // 表单校验
  142. let m = this.m;
  143. sa.checkNull(m.name, '请输入 [名称]');
  144. let list = this.list.filter(obj => obj.typeId !== null && obj.typeId !== '');
  145. m.items = JSON.stringify(list);
  146. m.sorts = null;
  147. sa.ajax('/TbSortGroup/update', sa.removeNull(m), function (res) {
  148. sa.alert('修改成功', this.clean);
  149. }.bind(this));
  150. },
  151. // 添加/修改 完成后的动作
  152. clean: function () {
  153. if (this.id == 0) {
  154. this.m = this.createModel();
  155. } else {
  156. parent.app.f5(); // 刷新父页面列表
  157. sa.closeCurrIframe(); // 关闭本页
  158. }
  159. },
  160. getById() {
  161. sa.ajax('/TbSortGroup/getById?id=' + this.id, function (res) {
  162. let data = res.data;
  163. if (data == null) {
  164. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  165. return;
  166. }
  167. let sorts = data.sorts;
  168. let businessTypeList = this.businessTypeList;
  169. let list = [];
  170. for (let i in sorts) {
  171. let sort = sorts[i];
  172. let obj = {
  173. id: sort.id,
  174. index: parseInt(i),
  175. typeId: sort.typeId,
  176. intervalTime: sort.intervalTime,
  177. singleIntervalTime: sort.singleIntervalTime,
  178. businessTypeList: businessTypeList
  179. }
  180. list.push(obj);
  181. }
  182. this.m = data;
  183. this.list = list;
  184. }.bind(this))
  185. }
  186. },
  187. mounted() {
  188. this.getBusinessType()
  189. }
  190. })
  191. </script>
  192. </body>
  193. </html>