tb-manager-add.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css js 资源 -->
  8. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="../../static/kj/vue.min.js"></script>
  11. <script src="../../static/kj/element-ui/index.js"></script>
  12. <script src="../../static/kj/httpVueLoader.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <style type="text/css">
  17. .c-panel .el-form .c-label{width: 7em !important;}
  18. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
  19. .c1-label{width: 8em; color: #333; padding-right: 4px; display: inline-block; text-align: right; vertical-align: top;}
  20. </style>
  21. </head>
  22. <body>
  23. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  24. <!-- ------- 内容部分 ------- -->
  25. <div class="s-body">
  26. <div class="c-panel">
  27. <div class="c-title" v-if="id == 0">数据添加</div>
  28. <div class="c-title" v-else>数据修改</div>
  29. <el-form v-if="m">
  30. <sa-item type="text" name="姓名" v-model="m.name" br need></sa-item>
  31. <sa-item type="text" name="联系号码" v-model="m.phone" br need></sa-item>
  32. <div class="c-item">
  33. <label class="c-label"><span style="color: red;">*</span>部门:</label>
  34. <el-select v-model="m.deptId" @change="deptChange">
  35. <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id"
  36. :label="item.name" :value="item.id"></el-option>
  37. </el-select>
  38. </div>
  39. <sa-item type="text" name="职能" v-model="m.position" br need></sa-item>
  40. <!-- <sa-item type="text" name="场所ID" v-model="m.venuesId" br></sa-item>-->
  41. <div class="c-item">
  42. <label class="c-label"><span style="color: red;">*</span>场所:</label>
  43. <el-select v-model="m.venuesId" @change="venuesChange">
  44. <el-option label="请选择" v-for="(item,index) in venuesList" :key="item.id"
  45. :label="item.name" :value="item.id"></el-option>
  46. </el-select>
  47. </div>
  48. <sa-item type="text" name="值班地点" v-model="m.venuesName" br need></sa-item>
  49. <!-- <sa-item type="text" name="值班开始时间" v-model="m.workStartTime" br></sa-item>-->
  50. <div class="c-item">
  51. <label class="c-label"><span style="color: red;">*</span>值班开始时间:</label>
  52. <el-time-picker value-format="HH:mm:ss" v-model="m.workStartTime"></el-time-picker>
  53. </div>
  54. <!-- <sa-item type="text" name="值班结束时间" v-model="m.workEndTime" br></sa-item>-->
  55. <div class="c-item">
  56. <label class="c-label"><span style="color: red;">*</span>值班结束时间:</label>
  57. <el-time-picker value-format="HH:mm:ss" v-model="m.workEndTime"></el-time-picker>
  58. </div>
  59. <sa-item type="text" name="备注" v-model="m.remark" br></sa-item>
  60. <sa-item name="" class="s-ok" br>
  61. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  62. </sa-item>
  63. </el-form>
  64. </div>
  65. </div>
  66. <!-- ------- 底部按钮 ------- -->
  67. <div class="s-foot">
  68. <el-button type="primary" @click="ok()">确定</el-button>
  69. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  70. </div>
  71. </div>
  72. <script>
  73. var app = new Vue({
  74. components: {
  75. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  76. },
  77. el: '.vue-box',
  78. data: {
  79. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  80. m: null, // 实体对象
  81. deptList: [],
  82. venuesList: [],
  83. },
  84. methods: {
  85. // 创建一个 默认Model
  86. createModel: function() {
  87. return {
  88. id: '', // 主键
  89. name: '', // 姓名
  90. phone: '', // 联系号码
  91. deptId: '', // 部门ID
  92. deptName: '',
  93. position: '', // 职能
  94. venuesId: '', // 场所ID
  95. venuesName: '', // 值班地点
  96. workStartTime: '', // 值班开始时间
  97. workEndTime: '', // 值班结束时间
  98. remark: '', // 备注
  99. }
  100. },
  101. // 提交数据
  102. ok: function(){
  103. // 表单校验
  104. let m = this.m;
  105. // sa.checkNull(m.id, '请输入 [主键]');
  106. sa.checkNull(m.name, '请输入 [姓名]');
  107. sa.checkNull(m.deptId, '请选择 [部门]');
  108. sa.checkNull(m.position, '请输入 [职能]');
  109. sa.checkNull(m.venuesId, '请输入 [场所]');
  110. sa.checkNull(m.venuesName, '请输入 [值班地点]');
  111. sa.checkNull(m.workStartTime, '请输入 [值班开始时间]');
  112. sa.checkNull(m.workEndTime, '请输入 [值班结束时间]');
  113. let phone = m.phone;
  114. if (!sa.isPhone(phone)) {
  115. sa.error('请输入正确的联系号码');
  116. return false;
  117. }
  118. // 开始增加或修改
  119. if(this.id <= 0) { // 添加
  120. sa.ajax('/TbManager/add', m, function(res){
  121. sa.alert('增加成功', this.clean);
  122. }.bind(this));
  123. } else { // 修改
  124. sa.ajax('/TbManager/update', m, function(res){
  125. sa.alert('修改成功', this.clean);
  126. }.bind(this));
  127. }
  128. },
  129. deptChange(val) {
  130. let dept = this.deptList.filter(obj => obj.id === val).pop();
  131. this.m.deptName = dept.name;
  132. },
  133. venuesChange(val) {
  134. let venue = this.venuesList.filter(obj => obj.id === val).pop();
  135. this.m.venuesName = venue.name;
  136. },
  137. getDeptList() {
  138. console.log(1);
  139. sa.ajax('/TbVenues/getList', {
  140. pId: -1
  141. }, function(resp) {
  142. this.venuesList = resp.data;
  143. }.bind(this))
  144. },
  145. getVenuesList() {
  146. console.log(2);
  147. sa.ajax('/TbDept/getList', function(resp) {
  148. this.deptList = resp.data;
  149. }.bind(this))
  150. },
  151. // 添加/修改 完成后的动作
  152. clean: function() {
  153. if(this.id == 0) {
  154. this.m = this.createModel();
  155. } else {
  156. parent.app.f5(); // 刷新父页面列表
  157. sa.closeCurrIframe(); // 关闭本页
  158. }
  159. }
  160. },
  161. mounted: function(){
  162. // 初始化数据
  163. this.getDeptList();
  164. this.getVenuesList();
  165. if(this.id <= 0) {
  166. this.m = this.createModel();
  167. } else {
  168. sa.ajax('/TbManager/getById?id=' + this.id, function(res) {
  169. this.m = res.data;
  170. if(res.data == null) {
  171. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  172. }
  173. }.bind(this))
  174. }
  175. }
  176. })
  177. </script>
  178. </body>
  179. </html>