tb-group-add.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. <sa-item type="text" name="名称" v-model="m.orgName" br></sa-item>
  36. <sa-item type="text" name="编号" v-model="m.code" br></sa-item>
  37. <div class="c-item">
  38. <label class="c-label"><span style="color: red;">*</span>互市区:</label>
  39. <el-select @change="getPeopleByTradeAreaId" v-model="m.tradeAreaName" placeholder="请选择" filterable size="mini">
  40. <el-option v-for="(item,index) in tradeAreaList" :key="index" :label="item.name" :value="item"> </el-option>
  41. </el-select>
  42. </div>
  43. <div class="c-item">
  44. <label class="c-label">组长:</label>
  45. <el-select @change="getpersonList" v-model="m.leaderName" placeholder="请选择" filterable size="mini" :disabled="!m.tradeAreaId">
  46. <el-option v-for="(item,index) in personList" :key="index" :label="item.name" :value="item"> </el-option>
  47. </el-select>
  48. </div>
  49. <sa-item name="" class="s-ok" br>
  50. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  51. </sa-item>
  52. </el-form>
  53. </div>
  54. </div>
  55. <!-- ------- 底部按钮 ------- -->
  56. <div class="s-foot">
  57. <el-button type="primary" @click="ok()">确定</el-button>
  58. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. components: {
  64. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  65. },
  66. el: '.vue-box',
  67. data: {
  68. tradeAreaList: [],
  69. personList: [],
  70. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  71. m: null, // 实体对象
  72. },
  73. methods: {
  74. getTradeArea() {
  75. sa.ajax('/level-one-server/TbTradeArea/getList', {
  76. pageSize: 100,
  77. pageNo: 1
  78. }, function(resp) {
  79. this.tradeAreaList = resp.data;
  80. }.bind(this));
  81. },
  82. getPeopleByTradeAreaId(item){
  83. // 互市区信息加入到互助组管理表
  84. this.m.address = item.address
  85. this.m.addressIds = item.addressIds
  86. this.m.detailAddress = item.detailAddress
  87. this.m.tradeAreaId = item.id
  88. this.m.tradeAreaName = item.name
  89. sa.ajax('/level-one-server/TbPeople/getPeopleForGroup', {tradeAreaId:item.id}, function(resp) {
  90. this.personList = resp.data;
  91. }.bind(this));
  92. },
  93. getpersonList(item) {
  94. this.m.leaderId = item.id
  95. this.m.leaderName = item.name
  96. this.m.leaderPhone = item.phone
  97. console.log("this.m",this.m)
  98. },
  99. // 创建一个 默认Model
  100. createModel: function() {
  101. return {
  102. orgName: '', // 名称
  103. leaderId: '', // 组长ID
  104. leaderName: '', // 组长名
  105. leaderPhone: '', // 组长电话
  106. tradeAreaId:'',
  107. code: '', //
  108. }
  109. },
  110. // 提交数据
  111. ok: function() {
  112. // 表单校验
  113. let m = this.m;
  114. sa.checkNull(m.orgName, '请输入 [名称]');
  115. sa.checkNull(m.code, '请输入 [编号]');
  116. sa.checkNull(m.tradeAreaId, '请选择 [互市区]');
  117. // 开始增加或修改
  118. if (this.id <= 0) { // 添加
  119. sa.ajax('/level-one-server/TbGroup/add', m, function(res) {
  120. sa.alert('增加成功', this.clean);
  121. }.bind(this));
  122. } else { // 修改
  123. sa.ajax('/level-one-server/TbGroup/update', m, function(res) {
  124. sa.alert('修改成功', this.clean);
  125. }.bind(this));
  126. }
  127. },
  128. // 添加/修改 完成后的动作
  129. clean: function() {
  130. if (this.id == 0) {
  131. this.m = this.createModel();
  132. } else {
  133. parent.app.f5(); // 刷新父页面列表
  134. sa.closeCurrIframe(); // 关闭本页
  135. }
  136. }
  137. },
  138. mounted: function() {
  139. this.getTradeArea();
  140. // 初始化数据
  141. if (this.id <= 0) {
  142. this.m = this.createModel();
  143. } else {
  144. sa.ajax('/level-one-server/TbGroup/getById?id=' + this.id, function(res) {
  145. this.m = res.data;
  146. if (res.data == null) {
  147. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  148. }
  149. }.bind(this))
  150. }
  151. }
  152. })
  153. </script>
  154. </body>
  155. </html>