tb-venues-add.html 5.1 KB

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