tb-business-sort-list.html 7.9 KB

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