tb-gate-terminal-add.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. </style>
  26. </head>
  27. <body>
  28. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  29. <!-- ------- 内容部分 ------- -->
  30. <div class="s-body">
  31. <div class="c-panel">
  32. <div class="c-title" v-if="id == 0">数据添加</div>
  33. <div class="c-title" v-else>数据修改</div>
  34. <el-form v-if="m">
  35. <sa-item type="text" name="名称" v-model="m.name" br need></sa-item>
  36. <div class="c-item">
  37. <label class="c-label"><span style="color: red;">*</span>场所通道:</label>
  38. <el-select v-model="m.channelId" placeholder="请选择">
  39. <el-option-group v-for="(area,index) in areaList" :key="index" :label="area.name">
  40. <el-option v-for="item in area.children" :key="item.id" :label="item.name"
  41. :value="item.id">
  42. </el-option>
  43. </el-option-group>
  44. </el-select>
  45. </div>
  46. <sa-item type="enum" name="方向" v-model="m.direction" :jv="{1: '入场', 2: '离场'}" jtype="3" br></sa-item>
  47. <sa-item type="text" name="IP地址" v-model="m.ip" br need></sa-item>
  48. <sa-item name="" class="s-ok" br>
  49. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  50. </sa-item>
  51. </el-form>
  52. </div>
  53. </div>
  54. <!-- ------- 底部按钮 ------- -->
  55. <div class="s-foot">
  56. <el-button type="primary" @click="ok()">确定</el-button>
  57. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  58. </div>
  59. </div>
  60. <script>
  61. var app = new Vue({
  62. components: {
  63. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  64. },
  65. el: '.vue-box',
  66. data: {
  67. areaList: [],
  68. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  69. m: null, // 实体对象
  70. },
  71. methods: {
  72. // 创建一个 默认Model
  73. createModel: function() {
  74. return {
  75. id: '', // 主键
  76. name: '', // 名称
  77. deptId: '', // 单位id
  78. direction: 1, // 序列号
  79. ip: '', // IP地址
  80. state: '', // 状态
  81. createTime: '', // 创建时间
  82. updateTime: '', // 更新时间
  83. }
  84. },
  85. getVenuesList() {
  86. sa.ajax('/TbVenues/getTree', function(res) {
  87. this.areaList = res.data; // 数据
  88. }.bind(this));
  89. },
  90. // 提交数据
  91. ok: function() {
  92. // 表单校验
  93. let m = this.m;
  94. // sa.checkNull(m.id, '请输入 [主键]');
  95. sa.checkNull(m.name, '请输入 [名称]');
  96. sa.checkNull(m.channelId, '请选择道闸通道');
  97. sa.checkNull(m.ip, '请填写IP地址');
  98. // 开始增加或修改
  99. if (this.id <= 0) { // 添加
  100. sa.ajax('/TbGateTerminal/add', m, function(res) {
  101. sa.alert('增加成功', this.clean);
  102. }.bind(this));
  103. } else { // 修改
  104. sa.ajax('/TbGateTerminal/update', m, function(res) {
  105. sa.alert('修改成功', this.clean);
  106. }.bind(this));
  107. }
  108. },
  109. // 添加/修改 完成后的动作
  110. clean: function() {
  111. if (this.id == 0) {
  112. this.m = this.createModel();
  113. } else {
  114. parent.app.f5(); // 刷新父页面列表
  115. sa.closeCurrIframe(); // 关闭本页
  116. }
  117. }
  118. },
  119. mounted: function() {
  120. this.getVenuesList();
  121. // 初始化数据
  122. if (this.id <= 0) {
  123. this.m = this.createModel();
  124. } else {
  125. sa.ajax('/TbGateTerminal/getById?id=' + this.id, function(res) {
  126. this.m = res.data;
  127. if (res.data == null) {
  128. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  129. }
  130. }.bind(this))
  131. }
  132. }
  133. })
  134. </script>
  135. </body>
  136. </html>