tb-venues-add.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. .item-num .el-input__inner {
  26. width: 130px;
  27. }
  28. .notice {
  29. margin: 10px 0 0 20px;
  30. line-height: 30px;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  36. <!-- ------- 内容部分 ------- -->
  37. <div class="s-body">
  38. <div class="c-panel">
  39. <div class="c-title" v-if="id == 0">数据添加</div>
  40. <div class="c-title" v-else>数据修改</div>
  41. <el-form v-if="m">
  42. <sa-item type="text" name="名称" v-model="m.name" br need></sa-item>
  43. <div class="c-item">
  44. <label class="c-label"><span style="color: red;">*</span>等级:</label>
  45. <el-input-number class="item-num" v-model="m.level" :min="1" step-strictly :step="1"
  46. :max="99" size="mini"></el-input-number>
  47. </div>
  48. <div class="notice">
  49. <div>
  50. <span style="color: red;">*</span>说明:
  51. </div>
  52. <div>
  53. <p>1、场所等级高的人员备案可以通行等级低的场所</p>
  54. <p>2、同等级的备案可以相互通行</p>
  55. <p>3、1表示等级最高</p>
  56. </div>
  57. <div v-if="id==0">
  58. <el-checkbox v-model="checked"><label style="color: red;">已阅读</label></el-checkbox>
  59. </div>
  60. </div>
  61. <sa-item name="" class="s-ok" br>
  62. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  63. </sa-item>
  64. </el-form>
  65. </div>
  66. </div>
  67. <!-- ------- 底部按钮 ------- -->
  68. <div class="s-foot">
  69. <el-button type="primary" @click="ok()">确定</el-button>
  70. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  71. </div>
  72. </div>
  73. <script>
  74. var app = new Vue({
  75. components: {
  76. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  77. },
  78. el: '.vue-box',
  79. data: {
  80. checked: false,
  81. departmentList: [],
  82. currentUser: sa.$sys.getCurrUser(),
  83. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  84. m: {
  85. departmentId: '',
  86. level: 1
  87. }, // 实体对象
  88. },
  89. methods: {
  90. // 创建一个 默认Model
  91. createModel: function() {
  92. return {
  93. id: '', //
  94. pId: sa.p('pId', '-1'), // 父ID
  95. name: '', // 名称
  96. type: 3,
  97. level: 1,
  98. departmentId: ''
  99. }
  100. },
  101. // 提交数据
  102. ok: function() {
  103. // 表单校验
  104. let m = this.m;
  105. sa.checkNull(m.departmentId, '请选择 [单位]');
  106. sa.checkNull(m.name, '请输入 [名称]');
  107. if (this.id == 0 && !this.checked) {
  108. sa.error('请勾选阅读')
  109. return;
  110. }
  111. // 开始增加或修改
  112. if (this.id <= 0) { // 添加
  113. sa.ajax('/TbVenues/add', m, function(res) {
  114. sa.alert('增加成功', this.clean);
  115. }.bind(this));
  116. } else { // 修改
  117. if (m.pid && !m.pId) {
  118. m.pId = m.pid;
  119. }
  120. sa.ajax('/TbVenues/update', m, function(res) {
  121. sa.alert('修改成功', this.clean);
  122. }.bind(this));
  123. }
  124. },
  125. // 添加/修改 完成后的动作
  126. clean: function() {
  127. parent.app.f5(); // 刷新父页面列表
  128. sa.closeCurrIframe(); // 关闭本页
  129. }
  130. },
  131. mounted: function() {
  132. // 初始化数据
  133. if (this.id <= 0) {
  134. this.m = this.createModel();
  135. } else {
  136. sa.ajax('/TbVenues/getById?id=' + this.id, function(res) {
  137. this.m = res.data;
  138. if (res.data == null) {
  139. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  140. }
  141. }.bind(this))
  142. }
  143. }
  144. })
  145. </script>
  146. </body>
  147. </html>