tb-car-visit-record-add.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. <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. .c-panel .el-form .el-input,
  23. .c-panel .el-form .el-textarea__inner {
  24. width: 250px;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  30. <!-- ------- 内容部分 ------- -->
  31. <div class="s-body">
  32. <div class="c-panel">
  33. <div class="c-title" v-if="id == 0">数据添加</div>
  34. <div class="c-title" v-else>数据修改</div>
  35. <el-form v-if="m">
  36. <div class="c-item" v-if="sa.isAdmin()">
  37. <label class="c-label"><span style="color: red;">*</span>所属组织:</label>
  38. <el-select v-model="m.deptId">
  39. <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id"
  40. :label="item.name" :value="item.id"></el-option>
  41. </el-select>
  42. </div>
  43. <div class="c-item">
  44. <label class="c-label"><span style="color: red;">*</span>通道:</label>
  45. <el-select v-model="m.channelId" placeholder="请选择">
  46. <el-option-group v-for="(area,index) in areaList" :key="index" :label="area.name">
  47. <el-option v-for="item in area.children" :key="item.id" :label="item.name"
  48. :value="item.id">
  49. </el-option>
  50. </el-option-group>
  51. </el-select>
  52. </div>
  53. <sa-item type="text" name="车牌" v-model="m.carNo" br need></sa-item>
  54. <sa-item type="text" name="联系人" v-model="m.driverName" br need></sa-item>
  55. <sa-item type="text" name="联系电话" v-model="m.driverContact" br></sa-item>
  56. <sa-item type="enum" name="出/入" v-model="m.direction" :jv="{1: '入场', 2: '离场'}" jtype="1" br>
  57. </sa-item>
  58. <sa-item type="datetime" name="时间" v-model="m.visitTime" br need></sa-item>
  59. </el-form>
  60. </div>
  61. </div>
  62. <!-- ------- 底部按钮 ------- -->
  63. <div class="s-foot">
  64. <el-button type="primary" @click="ok()">确定</el-button>
  65. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  66. </div>
  67. </div>
  68. <script>
  69. var app = new Vue({
  70. components: {
  71. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  72. },
  73. el: '.vue-box',
  74. data: {
  75. areaList: [],
  76. deptList: [],
  77. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  78. m: null, // 实体对象
  79. },
  80. methods: {
  81. getDeptList() {
  82. sa.ajax('/TbDept/getList', {
  83. pageNo: 1,
  84. pageSize: 100
  85. }, function(resp) {
  86. let list = resp.data;
  87. this.deptList = list;
  88. }.bind(this))
  89. },
  90. getVenuesList() {
  91. sa.ajax('/TbVenues/getTree', function(res) {
  92. this.areaList = res.data; // 数据
  93. }.bind(this));
  94. },
  95. // 创建一个 默认Model
  96. createModel: function() {
  97. return {
  98. id: '', // 主键
  99. channelId: '', // 通道
  100. carNo: '', // 车牌
  101. visitTime: '', // 通过时间
  102. direction: 1, // 方向(1=入,2=出)
  103. image: '', // 图片
  104. type: '', // 类型(1=临时,2=内部)
  105. driverName: '', // 联系人
  106. driverContact: '', // 联系电话
  107. driverIdCard: '', // 联系人身份证
  108. recordType: '', // 方式(1=手动,2=自动)
  109. }
  110. },
  111. // 提交数据
  112. ok: function() {
  113. // 表单校验
  114. let m = this.m;
  115. sa.checkNull(m.deptId, '请选择 [所属组织]');
  116. sa.checkNull(m.channelId, '请选择 [通道]');
  117. sa.checkNull(m.carNo, '请输入 [车牌]');
  118. sa.checkNull(m.visitTime, '请输入 [通过时间]');
  119. sa.checkNull(m.driverName, '请输入 [联系人]');
  120. m = sa.removeNull(m);
  121. // 开始增加或修改
  122. if (this.id <= 0) { // 添加
  123. sa.ajax('/TbCarVisitRecord/add', m, function(res) {
  124. sa.alert('增加成功', this.clean);
  125. }.bind(this));
  126. } else { // 修改
  127. sa.ajax('/TbCarVisitRecord/update', m, function(res) {
  128. sa.alert('修改成功', this.clean);
  129. }.bind(this));
  130. }
  131. },
  132. // 添加/修改 完成后的动作
  133. clean: function() {
  134. if (this.id == 0) {
  135. this.m = this.createModel();
  136. } else {
  137. parent.app.f5(); // 刷新父页面列表
  138. sa.closeCurrIframe(); // 关闭本页
  139. }
  140. }
  141. },
  142. mounted: function() {
  143. if (sa.isAdmin()) {
  144. this.getDeptList();
  145. }
  146. this.getVenuesList();
  147. // 初始化数据
  148. if (this.id <= 0) {
  149. this.m = this.createModel();
  150. } else {
  151. sa.ajax('/TbCarVisitRecord/getById?id=' + this.id, function(res) {
  152. this.m = res.data;
  153. if (res.data == null) {
  154. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  155. }
  156. }.bind(this))
  157. }
  158. }
  159. })
  160. </script>
  161. </body>
  162. </html>