tb-car-black-add.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <div class="c-item">
  36. <label class="c-label"><span style="color: red;">*</span>所属组织:</label>
  37. <el-select v-model="m.deptId">
  38. <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id"
  39. :label="item.name" :value="item.id"></el-option>
  40. </el-select>
  41. </div>
  42. <sa-item type="text" name="车牌号" v-model="m.carNo" br need></sa-item>
  43. <sa-item type="datetime" name="开始时间" v-model="m.startTime" br need></sa-item>
  44. <sa-item type="datetime" name="结束时间" v-model="m.endTime" br need></sa-item>
  45. <sa-item type="textarea" name="禁行原因" v-model="m.reason" br need></sa-item>
  46. <sa-item name="" class="s-ok" br>
  47. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  48. </sa-item>
  49. </el-form>
  50. </div>
  51. </div>
  52. <!-- ------- 底部按钮 ------- -->
  53. <div class="s-foot">
  54. <el-button type="primary" @click="ok()">确定</el-button>
  55. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  56. </div>
  57. </div>
  58. <script>
  59. var app = new Vue({
  60. components: {
  61. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  62. },
  63. el: '.vue-box',
  64. data: {
  65. currentUser: sa.$sys.getCurrUser(),
  66. deptList: [],
  67. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  68. m: null, // 实体对象
  69. },
  70. methods: {
  71. getDeptList() {
  72. sa.ajax('/TbDept/getList', {
  73. pageNo: 1,
  74. pageSize: 100
  75. }, function(resp) {
  76. let list = resp.data;
  77. this.deptList = list;
  78. }.bind(this))
  79. },
  80. // 创建一个 默认Model
  81. createModel: function() {
  82. return {
  83. id: '', // 主键
  84. deptId: '', // 单位ID
  85. carNo: '', // 车牌号
  86. reason: '', // 禁行原因
  87. startTime: '', // 禁行开始
  88. endTime: '', // 禁行结束
  89. createTime: '', // 创建时间
  90. createBy: '', // 创建人
  91. updateTime: '', // 更新时间
  92. updateBy: '', // 更新人
  93. }
  94. },
  95. // 提交数据
  96. ok: function() {
  97. // 表单校验
  98. let m = this.m;
  99. sa.checkNull(m.deptId, '请选择单位');
  100. sa.checkNull(m.startTime, '请输入 [禁行开始]');
  101. sa.checkNull(m.endTime, '请输入 [禁行结束]');
  102. m = sa.removeNull(m);
  103. // 开始增加或修改
  104. if (this.id <= 0) { // 添加
  105. sa.ajax('/TbCarBlack/add', m, function(res) {
  106. sa.alert('增加成功', this.clean);
  107. }.bind(this));
  108. } else { // 修改
  109. sa.ajax('/TbCarBlack/update', m, function(res) {
  110. sa.alert('修改成功', this.clean);
  111. }.bind(this));
  112. }
  113. },
  114. // 添加/修改 完成后的动作
  115. clean: function() {
  116. if (this.id == 0) {
  117. this.m = this.createModel();
  118. } else {
  119. parent.app.f5(); // 刷新父页面列表
  120. sa.closeCurrIframe(); // 关闭本页
  121. }
  122. }
  123. },
  124. mounted: function() {
  125. this.getDeptList();
  126. // 初始化数据
  127. if (this.id <= 0) {
  128. this.m = this.createModel();
  129. } else {
  130. sa.ajax('/TbCarBlack/getById?id=' + this.id, function(res) {
  131. this.m = res.data;
  132. if (res.data == null) {
  133. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  134. }
  135. }.bind(this))
  136. }
  137. }
  138. })
  139. </script>
  140. </body>
  141. </html>