tb-item-add.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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, .c-panel .el-form .el-textarea__inner {
  22. width: 250px;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  28. <!-- ------- 内容部分 ------- -->
  29. <div class="s-body">
  30. <div class="c-panel">
  31. <div class="c-title" v-if="id == 0">数据添加</div>
  32. <div class="c-title" v-else>数据修改</div>
  33. <el-form v-if="m">
  34. <el-row>
  35. <el-col span="12">
  36. <sa-item type="text" name="项目编号" v-model="m.itemCode" placeholder="请输入项目编号" br></sa-item>
  37. <sa-item type="text" name="项目名称" v-model="m.itemName" placeholder="请输入项目名称" br></sa-item>
  38. <div class="c-item">
  39. <label class="c-label">项目类型:</label>
  40. <el-select v-model="m.typeId" style="width: 120px;" placeholder="请选择项目类型">
  41. <el-option
  42. v-for="type in itemTypeList"
  43. :key="type.id"
  44. :label="type.name"
  45. :value="type.id">
  46. </el-option>
  47. </el-select>
  48. </div>
  49. <sa-item type="num" name="项目金额(元)" v-model="m.price" placeholder="请输入项目金额" br></sa-item>
  50. <sa-item type="text" name="金额单位" v-model="m.unit" placeholder="请输入金额单位,如:元/车" br></sa-item>
  51. </el-col>
  52. <el-col span="12">
  53. <sa-item type="num" name="车长(米)" v-model="m.carLength" placeholder="请输入车长" br></sa-item>
  54. <sa-item type="num" name="最大载重(吨)" v-model="m.maxWeight" placeholder="请输入最大载重" br></sa-item>
  55. <!--<sa-item type="enum" name="当前状态" v-model="m.status" :jv="{1: '启用', 0: '禁用'}" jtype="3" br></sa-item>-->
  56. </el-col>
  57. </el-row>
  58. <sa-item name="" class="s-ok" br>
  59. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  60. </sa-item>
  61. </el-form>
  62. </div>
  63. </div>
  64. <!-- ------- 底部按钮 ------- -->
  65. <div class="s-foot">
  66. <el-button type="primary" @click="ok()">确定</el-button>
  67. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  68. </div>
  69. </div>
  70. <script>
  71. var app = new Vue({
  72. components: {
  73. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  74. },
  75. el: '.vue-box',
  76. data: {
  77. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  78. m: {
  79. id: '', // 主键
  80. typeId: '',
  81. typeName: '',
  82. itemName: '',
  83. itemCode: '',
  84. price: '',
  85. unit: '',
  86. carLength: '', //车长
  87. maxWeight: '', //最大载重
  88. status: '', //转态
  89. }, // 实体对象
  90. itemTypeList: [],
  91. },
  92. methods: {
  93. // 创建一个 默认Model
  94. createModel: function () {
  95. return {
  96. id: '', // 主键
  97. typeId: '', //类型id
  98. typeName: '', //类型
  99. itemName: '', //项目名
  100. itemCode: '', //项目编号
  101. price: '', //费用
  102. unit: '', //单位
  103. carLength: '', //车长
  104. maxWeight: '', //最大载重
  105. status: 1, //转态
  106. }
  107. },
  108. // 提交数据
  109. ok: function () {
  110. // 表单校验
  111. let m = this.m;
  112. // sa.checkNull(m.id, '请输入 [主键]');
  113. sa.checkNull(m.itemCode, '请输入 [项目编号]');
  114. sa.checkNull(m.itemName, '请输入 [项目名称]');
  115. sa.checkNull(m.typeId, '请选择 [项目类型]');
  116. sa.checkNull(m.price, '请输入 [项目金额]');
  117. sa.checkNull(m.unit, '请输入 [金额单位]');
  118. sa.checkNull(m.carLength, '请输入 [车长]');
  119. sa.checkNull(m.maxWeight, '请输入 [最大载重]');
  120. let typeList = this.itemTypeList;
  121. let typeId = m.typeId;
  122. let typeName = '';
  123. for (let i in typeList) {
  124. if (typeId == typeList[i].id) {
  125. typeName = typeList[i].name;
  126. }
  127. }
  128. m.typeName = typeName;
  129. // 开始增加或修改
  130. if (this.id <= 0) { // 添加
  131. sa.ajax('/TbItem/add', m, function (res) {
  132. sa.alert('增加成功', this.clean);
  133. }.bind(this));
  134. } else { // 修改
  135. sa.ajax('/TbItem/update', m, function (res) {
  136. sa.alert('修改成功', this.clean);
  137. }.bind(this));
  138. }
  139. },
  140. // 添加/修改 完成后的动作
  141. clean: function () {
  142. if (this.id == 0) {
  143. this.m = this.createModel();
  144. } else {
  145. parent.app.f5(); // 刷新父页面列表
  146. sa.closeCurrIframe(); // 关闭本页
  147. }
  148. },
  149. getItemTypeList() {
  150. sa.ajax('/TbItemType/getList', function (resp) {
  151. this.itemTypeList = resp.data;
  152. }.bind(this));
  153. },
  154. },
  155. mounted: function () {
  156. this.getItemTypeList();
  157. // 初始化数据
  158. if (this.id <= 0) {
  159. this.m = this.createModel();
  160. } else {
  161. sa.ajax('/TbItem/getById?id=' + this.id, function (res) {
  162. this.m = res.data;
  163. if (res.data == null) {
  164. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  165. }
  166. }.bind(this))
  167. }
  168. }
  169. })
  170. </script>
  171. </body>
  172. </html>