tb-business-car-add.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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,
  22. .c-panel .el-form .el-textarea__inner {
  23. width: 250px;
  24. }
  25. .china-car-size .el-input__inner {
  26. width: 130px;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  32. <!-- ------- 内容部分 ------- -->
  33. <div class="s-body">
  34. <div class="c-panel">
  35. <div class="c-title" v-if="id == 0">数据添加</div>
  36. <div class="c-title" v-else>数据修改</div>
  37. <el-form v-if="m">
  38. <sa-item type="text" name="车牌号" v-model="m.carNo" br></sa-item>
  39. <div class="c-item">
  40. <label class="c-label"><span style="color: red;">*</span>车辆规格:</label>
  41. <el-input-number class="china-car-size" v-model="m.carSize" controls-position="right"
  42. :min="4.2" :max="50"></el-input-number>
  43. </div>
  44. <div class="c-item">
  45. <label class="c-label">联系人:</label>
  46. <el-input v-model="m.driverName" placeholder="联系人" readonly>
  47. </el-input>
  48. </div>
  49. <div class="c-item">
  50. <label class="c-label">联系号码:</label>
  51. <el-input v-model="m.driverPhone" placeholder="联系人" readonly>
  52. </el-input>
  53. </div>
  54. <sa-item name="" class="s-ok" br>
  55. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  56. </sa-item>
  57. </el-form>
  58. </div>
  59. </div>
  60. <!-- ------- 底部按钮 ------- -->
  61. <div class="s-foot">
  62. <el-button type="primary" @click="ok()">确定</el-button>
  63. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  64. </div>
  65. </div>
  66. <script>
  67. var app = new Vue({
  68. components: {
  69. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  70. },
  71. el: '.vue-box',
  72. data: {
  73. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  74. m: {
  75. id: '', //
  76. businessId: sa.p('businessId', -1), //
  77. carNo: '', //
  78. carSize: '', //
  79. driverName: '', //
  80. money: '', //
  81. driverPhone: '', //
  82. }, // 实体对象
  83. },
  84. methods: {
  85. // 提交数据
  86. ok: function () {
  87. // 表单校验
  88. let m = this.m;
  89. sa.checkNull(m.carNo, '请输入 [车牌号]');
  90. sa.checkNull(m.carSize, '请输入 [车辆规格]');
  91. let phone = m.driverPhone;
  92. if (phone && !sa.isPhone(phone)) {
  93. sa.error('联系号码不正确')
  94. return;
  95. }
  96. // 开始增加或修改
  97. if (this.id <= 0) { // 添加
  98. sa.ajax('/TbBusinessCar/add', m, function (res) {
  99. sa.alert('增加成功', this.clean);
  100. }.bind(this));
  101. } else { // 修改
  102. sa.ajax('/TbBusinessCar/update', m, function (res) {
  103. sa.alert('修改成功', this.clean);
  104. }.bind(this));
  105. }
  106. },
  107. // 添加/修改 完成后的动作
  108. clean: function () {
  109. if (this.id == 0) {
  110. this.m = this.createModel();
  111. } else {
  112. parent.app.f5(); // 刷新父页面列表
  113. sa.closeCurrIframe(); // 关闭本页
  114. }
  115. }
  116. },
  117. mounted: function () {
  118. // 初始化数据
  119. if (this.id > 0) {
  120. sa.ajax('/TbBusinessCar/getById?id=' + this.id, function (res) {
  121. this.m = res.data;
  122. if (res.data == null) {
  123. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  124. }
  125. }.bind(this))
  126. }
  127. }
  128. })
  129. </script>
  130. </body>
  131. </html>