tb-car-edit.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. .num .el-input__inner {
  22. width: 96px;
  23. }
  24. .c-panel .el-form .el-input,
  25. .c-panel .el-form .el-textarea__inner {
  26. width: 250px;
  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. <el-row>
  39. <el-col span=12>
  40. <div class="c-item">
  41. <label class="c-label">归属:</label>
  42. <el-select v-model="m.customerId" placeholder="请选择" size="mini" filterable>
  43. <el-option v-for="item in customerList" :key="item.id" :label="item.name"
  44. :value="item.id">
  45. </el-option>
  46. </el-select>
  47. </div>
  48. <div class="c-item">
  49. <label class="c-label">类型:</label>
  50. <el-select v-model="m.carType" placeholder="请选择" size="mini">
  51. <el-option v-for="item in typeList" :key="item.value" :label="item.name"
  52. :value="item.value">
  53. </el-option>
  54. </el-select>
  55. </div>
  56. <sa-item type="text" name="车牌号" v-model="m.cardNo" placeholder="请输入车牌号" br></sa-item>
  57. <div class="c-item">
  58. <label class="c-label">车长(米):</label>
  59. <el-input-number class="num" step="0.5" :min="2" :max="40" size="small"
  60. v-model="m.cardSize" controls-position="right"></el-input-number>
  61. </div>
  62. <div class="c-item">
  63. <label class="c-label">载重(吨):</label>
  64. <el-input-number class="num" step="0.5" :min="2" :max="40" size="small"
  65. v-model="m.weight" controls-position="right"></el-input-number>
  66. </div>
  67. </el-col>
  68. <el-col span=12>
  69. <sa-item type="text" name="联系人" v-model="m.people" placeholder="联系人" br></sa-item>
  70. <sa-item type="text" name="联系电话" v-model="m.phone" placeholder="联系电话" br></sa-item>
  71. <sa-item type="textarea" name="备注" v-model="m.remark" placeholder="备注" br></sa-item>
  72. </el-col>
  73. </el-row>
  74. <sa-item name="" class="s-ok" br>
  75. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  76. </sa-item>
  77. </el-form>
  78. </div>
  79. </div>
  80. <!-- ------- 底部按钮 ------- -->
  81. <div class="s-foot">
  82. <el-button type="primary" @click="ok()" v-if="sa.isAuth('tb-car-edit')">确定</el-button>
  83. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  84. </div>
  85. </div>
  86. <script>
  87. var app = new Vue({
  88. components: {
  89. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  90. },
  91. el: '.vue-box',
  92. data: {
  93. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  94. m: {
  95. id: '', // 主键
  96. cardNo: '', // 名称
  97. cardSize: '', // 规格
  98. customerId: '',
  99. carType: 1,
  100. weight: 4.8,
  101. phone: '',
  102. people: '',
  103. remark: ''
  104. }, // 实体对象
  105. customerList: [],
  106. typeList: [{
  107. value: 0,
  108. name: '临时车'
  109. },
  110. {
  111. value: 1,
  112. name: '行政车'
  113. },
  114. {
  115. value: 2,
  116. name: '业务车'
  117. },
  118. ]
  119. },
  120. methods: {
  121. getCustomerList() {
  122. sa.ajax('/TbCostomer/getListAndAdmin', function (resp) {
  123. let list = resp.data;
  124. this.customerList = list;
  125. }.bind(this))
  126. },
  127. // 提交数据
  128. ok: function () {
  129. // 表单校验
  130. let m = this.m;
  131. let carNo = m.cardNo;
  132. sa.checkNull(carNo, '请输入 [车牌号]');
  133. m.cardNo = carNo.toUpperCase();
  134. // if(!sa.isCarNo(carNo)){
  135. // sa.error('请输入正确的车牌号');
  136. // return;
  137. // }
  138. let phone = m.phone;
  139. if (phone && !sa.isPhone(phone)) {
  140. sa.error('请输入正确手机号');
  141. return;
  142. }
  143. let customerId = m.customerId;
  144. m.customerName = this.customerList.filter(obj => obj.id == customerId)[0].name;
  145. // 开始增加或修改
  146. if (this.id <= 0) { // 添加
  147. sa.ajax('/TbCar/add', m, function (res) {
  148. sa.alert('增加成功', this.clean);
  149. }.bind(this));
  150. } else { // 修改
  151. sa.ajax('/TbCar/update', m, function (res) {
  152. sa.alert('修改成功', this.clean);
  153. }.bind(this));
  154. }
  155. },
  156. // 添加/修改 完成后的动作
  157. clean: function () {
  158. if (this.id == 0) {
  159. } else {
  160. parent.app.f5(); // 刷新父页面列表
  161. sa.closeCurrIframe(); // 关闭本页
  162. }
  163. }
  164. },
  165. mounted: function () {
  166. this.getCustomerList();
  167. // 初始化数据
  168. sa.ajax('/TbCar/getById?id=' + this.id, function (res) {
  169. this.m = res.data;
  170. if (res.data == null) {
  171. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  172. }
  173. }.bind(this))
  174. }
  175. })
  176. </script>
  177. </body>
  178. </html>