tb-sort-group-add.html 6.7 KB

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