tb-person-black-add.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.deptId" :disabled="currentUser.deptId!=='9999999'">-->
  38. <el-select v-model="m.deptId" >
  39. <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id"
  40. :label="item.name" :value="item.id"></el-option>
  41. </el-select>
  42. </div>
  43. <sa-item type="text" name="名字" v-model="m.name" br need></sa-item>
  44. <sa-item type="text" name="身份证" v-model="m.idCard" br need></sa-item>
  45. <sa-item type="datetime" name="开始时间" v-model="m.startTime" br need></sa-item>
  46. <sa-item type="datetime" name="结束时间" v-model="m.endTime" br need></sa-item>
  47. <sa-item type="textarea" name="禁行原因" v-model="m.reason" br></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. currentUser: sa.$sys.getCurrUser(),
  68. deptList:[],
  69. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  70. m: null, // 实体对象
  71. },
  72. methods: {
  73. getDeptList() {
  74. sa.ajax('/TbDept/getList', {
  75. pageNo: 1,
  76. pageSize: 100
  77. }, function(resp) {
  78. let list = resp.data;
  79. // let deptId = this.currentUser.deptId;
  80. // if (deptId != '9999999') {
  81. // this.m.deptId = deptId;
  82. // }
  83. this.deptList = list;
  84. }.bind(this))
  85. },
  86. // 创建一个 默认Model
  87. createModel: function() {
  88. return {
  89. deptId: '', // 单位ID
  90. name: '', // 名字
  91. idCard: '', // 身份证
  92. reason: '', // 禁行原因
  93. startTime: '', // 禁行开始
  94. endTime: '', // 禁行结束
  95. }
  96. },
  97. // 提交数据
  98. ok: function() {
  99. // 表单校验
  100. let m = this.m;
  101. sa.checkNull(m.deptId, '请选择单位');
  102. sa.checkNull(m.name, '请输入 [名字]');
  103. sa.checkNull(m.idCard, '请输入 [身份证]');
  104. let idCard = m.idCard;
  105. if (idCard.length < 15) {
  106. sa.error('请输入正确的身份证');
  107. return false;
  108. }
  109. sa.checkNull(m.startTime, '请选择 [禁行开始时间]');
  110. sa.checkNull(m.endTime, '请选择 [禁行结束时间]');
  111. m = sa.removeNull(m);
  112. // 开始增加或修改
  113. if (this.id <= 0) { // 添加
  114. sa.ajax('/TbPersonBlack/add', m, function(res) {
  115. sa.alert('增加成功', this.clean);
  116. }.bind(this));
  117. } else { // 修改
  118. sa.ajax('/TbPersonBlack/update', m, function(res) {
  119. sa.alert('修改成功', this.clean);
  120. }.bind(this));
  121. }
  122. },
  123. // 添加/修改 完成后的动作
  124. clean: function() {
  125. if (this.id == 0) {
  126. this.m = this.createModel();
  127. } else {
  128. parent.app.f5(); // 刷新父页面列表
  129. sa.closeCurrIframe(); // 关闭本页
  130. }
  131. }
  132. },
  133. mounted: function() {
  134. this.getDeptList();
  135. // 初始化数据
  136. if (this.id <= 0) {
  137. this.m = this.createModel();
  138. } else {
  139. sa.ajax('/TbPersonBlack/getById?id=' + this.id, function(res) {
  140. this.m = res.data;
  141. if (res.data == null) {
  142. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  143. }
  144. }.bind(this))
  145. }
  146. }
  147. })
  148. </script>
  149. </body>
  150. </html>