tb-mild-car-add.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>4.2~9.6车辆管理-添加/修改</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. <script src="../../static/kj/upload-util.js"></script>
  18. <style type="text/css">
  19. .c-panel .el-form .c-label {
  20. width: 7em !important;
  21. }
  22. .item-num .el-input__inner {
  23. width: 130px;
  24. }
  25. .c-panel .el-form .el-input,
  26. .c-panel .el-form .el-textarea__inner {
  27. width: 250px;
  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. <el-row>
  40. <el-col :span="12">
  41. <sa-item type="text" name="车牌号" v-model="m.carNo" br need></sa-item>
  42. <sa-item type="text" name="所属公司" v-model="m.company" br></sa-item>
  43. <sa-item type="text" name="联系人" v-model="m.contact" br></sa-item>
  44. <sa-item type="text" name="联系电话" v-model="m.contactPhone" br></sa-item>
  45. </el-col>
  46. <el-col :span="12">
  47. <sa-item type="text" name="车辆类型" v-model="m.carType" br></sa-item>
  48. <div class="c-item">
  49. <label class="c-label">
  50. <span style="color: red;">*</span>
  51. 车长度(米):</label>
  52. <el-input-number class="item-num" v-model="m.carLength" :min="4.3" :max="9.6">
  53. </el-input-number>
  54. </div>
  55. <div class="c-item">
  56. <label class="c-label">
  57. 载重(kg):</label>
  58. <el-input-number class="item-num" v-model="m.carWeight" :min="1" :max="999999">
  59. </el-input-number>
  60. </div>
  61. <sa-item type="img-list" name="行驶证" v-model="m.carCertificate" br></sa-item>
  62. </el-col>
  63. </el-row>
  64. <sa-item name="" class="s-ok" br>
  65. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  66. </sa-item>
  67. </el-form>
  68. </div>
  69. </div>
  70. <!-- ------- 底部按钮 ------- -->
  71. <div class="s-foot">
  72. <el-button type="primary" @click="ok()">确定</el-button>
  73. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  74. </div>
  75. </div>
  76. <script>
  77. var app = new Vue({
  78. components: {
  79. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  80. },
  81. el: '.vue-box',
  82. data: {
  83. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  84. m: null, // 实体对象
  85. },
  86. methods: {
  87. // 创建一个 默认Model
  88. createModel: function() {
  89. return {
  90. id: '', // 主键
  91. company: '', // 所属公司
  92. carNo: '', // 车牌号
  93. carType: '', // 车辆类型
  94. carLength: 4.2, // 车长度
  95. carWeight: '', // 载重
  96. contact: '', // 联系人
  97. contactPhone: '', // 联系电话
  98. carCertificate: '', // 行驶证
  99. createTime: '', // 创建时间
  100. updateTime: '', // 更新时间
  101. createBy: '', // 创建人
  102. updateBy: '', // 更新时间
  103. }
  104. },
  105. // 提交数据
  106. ok: function() {
  107. // 表单校验
  108. let m = this.m;
  109. sa.checkNull(m.carNo, '请输入 [车牌号]');
  110. sa.checkNull(m.carLength, '请输入 [车长度]');
  111. // 开始增加或修改
  112. if (this.id <= 0) { // 添加
  113. sa.ajax('/TbMildCar/add', m, function(res) {
  114. sa.alert('增加成功', this.clean);
  115. }.bind(this));
  116. } else { // 修改
  117. sa.ajax('/TbMildCar/update', m, function(res) {
  118. sa.alert('修改成功', this.clean);
  119. }.bind(this));
  120. }
  121. },
  122. // 添加/修改 完成后的动作
  123. clean: function() {
  124. if (this.id == 0) {
  125. this.m = this.createModel();
  126. } else {
  127. parent.app.f5(); // 刷新父页面列表
  128. sa.closeCurrIframe(); // 关闭本页
  129. }
  130. }
  131. },
  132. mounted: function() {
  133. // 初始化数据
  134. if (this.id <= 0) {
  135. this.m = this.createModel();
  136. } else {
  137. sa.ajax('/TbMildCar/getById?id=' + this.id, function(res) {
  138. this.m = res.data;
  139. if (res.data == null) {
  140. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  141. }
  142. }.bind(this))
  143. }
  144. }
  145. })
  146. </script>
  147. </body>
  148. </html>