hc-camera-add.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.name" br need></sa-item>
  43. <sa-item type="text" name="IP地址" v-model="m.ip" br need></sa-item>
  44. <sa-item type="text" name="端口" v-model="m.port" br need></sa-item>
  45. <sa-item type="text" name="用户名" v-model="m.uname" br need></sa-item>
  46. <sa-item type="password" name="密码" v-model="m.pwd" br need></sa-item>
  47. <sa-item name="" class="s-ok" br>
  48. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  49. </sa-item>
  50. </el-form>
  51. </div>
  52. </div>
  53. <!-- ------- 底部按钮 ------- -->
  54. <div class="s-foot">
  55. <el-button type="primary" @click="ok()">确定</el-button>
  56. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  57. </div>
  58. </div>
  59. <script>
  60. var app = new Vue({
  61. components: {
  62. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  63. },
  64. el: '.vue-box',
  65. data: {
  66. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  67. m: {
  68. id: '', // 主键
  69. venuesId: '', // 所在场所
  70. name: '', // 名称
  71. ip: '', // IP地址
  72. port: '8000', // 端口
  73. uname: 'admin', // 用户名
  74. pwd: 'ap123456', // 密码
  75. }, // 实体对象
  76. venuesList: [],
  77. },
  78. methods: {
  79. getVenuesList() {
  80. sa.ajax('/TbVenues/getParentList', function(res) {
  81. this.venuesList = res.data; // 数据
  82. }.bind(this));
  83. },
  84. // 提交数据
  85. ok: function() {
  86. // 表单校验
  87. let m = this.m;
  88. sa.checkNull(m.venuesId, '请选择 [场所]');
  89. sa.checkNull(m.name, '请输入 [名称]');
  90. sa.checkNull(m.ip, '请输入 [IP地址]');
  91. sa.checkNull(m.port, '请输入 [端口]');
  92. sa.checkNull(m.uname, '请输入 [用户名]');
  93. sa.checkNull(m.pwd, '请输入 [密码]');
  94. // 开始增加或修改
  95. if (this.id <= 0) { // 添加
  96. sa.ajax('/HcCamera/add', m, function(res) {
  97. sa.alert('增加成功', this.clean);
  98. }.bind(this));
  99. } else { // 修改
  100. sa.ajax('/HcCamera/update', m, function(res) {
  101. sa.alert('修改成功', this.clean);
  102. }.bind(this));
  103. }
  104. },
  105. // 添加/修改 完成后的动作
  106. clean: function() {
  107. if (this.id == 0) {
  108. this.m = this.createModel();
  109. } else {
  110. parent.app.f5(); // 刷新父页面列表
  111. sa.closeCurrIframe(); // 关闭本页
  112. }
  113. }
  114. },
  115. mounted: function() {
  116. this.getVenuesList();
  117. // 初始化数据
  118. if (this.id > 0) {
  119. sa.ajax('/HcCamera/getById?id=' + this.id, function(res) {
  120. this.m = res.data;
  121. if (res.data == null) {
  122. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  123. }
  124. }.bind(this))
  125. }
  126. }
  127. })
  128. </script>
  129. </body>
  130. </html>