hc-camera-add.html 4.5 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. </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.venuesId">
  38. <el-option label="请选择" v-for="(item,index) in venuesList" :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.channelName" br need></sa-item>
  43. <sa-item type="text" name="名称" v-model="m.name" br need></sa-item>
  44. <sa-item type="text" name="IP地址" v-model="m.ip" br need></sa-item>
  45. <sa-item type="text" name="端口" v-model="m.port" br need></sa-item>
  46. <sa-item type="text" name="用户名" v-model="m.uname" br need></sa-item>
  47. <sa-item type="password" name="密码" v-model="m.pwd" 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. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  68. m: {
  69. id: '', // 主键
  70. venuesId: '', // 所在场所
  71. name: '', // 名称
  72. ip: '', // IP地址
  73. channelName: '',
  74. port: '8000', // 端口
  75. uname: 'admin', // 用户名
  76. pwd: 'ap123456', // 密码
  77. }, // 实体对象
  78. venuesList: [],
  79. },
  80. methods: {
  81. getVenuesList() {
  82. sa.ajax('/TbVenues/getParentList', function(res) {
  83. this.venuesList = res.data; // 数据
  84. }.bind(this));
  85. },
  86. // 提交数据
  87. ok: function() {
  88. // 表单校验
  89. let m = this.m;
  90. sa.checkNull(m.venuesId, '请选择 [场所]');
  91. sa.checkNull(m.name, '请输入 [名称]');
  92. sa.checkNull(m.channelName, '请输入 [通道名称]');
  93. sa.checkNull(m.ip, '请输入 [IP地址]');
  94. sa.checkNull(m.port, '请输入 [端口]');
  95. sa.checkNull(m.uname, '请输入 [用户名]');
  96. sa.checkNull(m.pwd, '请输入 [密码]');
  97. // 开始增加或修改
  98. if (this.id <= 0) { // 添加
  99. sa.ajax('/HcCamera/add', m, function(res) {
  100. sa.alert('增加成功', this.clean);
  101. }.bind(this));
  102. } else { // 修改
  103. sa.ajax('/HcCamera/update', m, function(res) {
  104. sa.alert('修改成功', this.clean);
  105. }.bind(this));
  106. }
  107. },
  108. // 添加/修改 完成后的动作
  109. clean: function() {
  110. if (this.id == 0) {
  111. this.m = this.createModel();
  112. } else {
  113. parent.app.f5(); // 刷新父页面列表
  114. sa.closeCurrIframe(); // 关闭本页
  115. }
  116. }
  117. },
  118. mounted: function() {
  119. this.getVenuesList();
  120. // 初始化数据
  121. if (this.id > 0) {
  122. sa.ajax('/HcCamera/getById?id=' + this.id, function(res) {
  123. this.m = res.data;
  124. if (res.data == null) {
  125. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  126. }
  127. }.bind(this))
  128. }
  129. }
  130. })
  131. </script>
  132. </body>
  133. </html>