tb-shop-add.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 size="mini" v-if="m">
  35. <div class="c-item br">
  36. <label class="c-label"><label style="color: red">*</label>名称:</label>
  37. <el-input size="mini" v-model="m.name"></el-input>
  38. </div>
  39. <div class="c-item br">
  40. <label class="c-label"><label style="color: red">*</label>编号:</label>
  41. <el-input size="mini" v-model="m.no"></el-input>
  42. </div>
  43. <div class="c-item br">
  44. <label class="c-label">所属互市区:</label>
  45. <el-select v-model="m.tradeAreaId" placeholder="请选择" filterable size="mini">
  46. <el-option label="请选择" :value="0" disabled></el-option>
  47. <el-option v-for="(item,index) in tradeAreaList" :key="index" :label="item.name"
  48. :value="item.id"> </el-option>
  49. </el-select>
  50. </div>
  51. <div class="c-item br">
  52. <label class="c-label">入住商户:</label>
  53. <el-select v-model="m.enterpriseId" filterable size="mini" placeholder="请选择">
  54. <el-option
  55. v-for="item in enterpriseList"
  56. :key="item.id"
  57. :label="item.name"
  58. :value="item.id">
  59. </el-option>
  60. </el-select>
  61. </div>
  62. <div class="c-item br">
  63. <label class="c-label" style="vertical-align: top;">备注:</label>
  64. <div style="display: inline-block;">
  65. <el-input size="mini" v-model="m.remark" type="textarea"
  66. :autosize="{ minRows: 3, maxRows: 5}"></el-input>
  67. </div>
  68. </div>
  69. <div class="c-item br s-ok">
  70. <label class="c-label"></label>
  71. <el-button size="mini" type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  72. </div>
  73. </el-form>
  74. </div>
  75. </div>
  76. <!-- ------- 底部按钮 ------- -->
  77. <div class="s-foot">
  78. <el-button size="mini" type="primary" @click="ok()">确定</el-button>
  79. <el-button size="mini" @click="sa.closeCurrIframe()">取消</el-button>
  80. </div>
  81. </div>
  82. <script>
  83. var app = new Vue({
  84. el: '.vue-box',
  85. data: {
  86. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  87. m: null, // 实体对象
  88. options: [],
  89. tradeAreaList: [],
  90. enterpriseList:[]
  91. },
  92. methods: {
  93. getEnterpriseList(){
  94. sa.ajax('/level-one-server/TbEnterprise/getAll', function(resp) {
  95. this.enterpriseList = resp.data;
  96. }.bind(this));
  97. },
  98. getTradeArea() {
  99. sa.ajax('/level-one-server/TbTradeArea/getList', {
  100. pageSize: 100,
  101. pageNo: 1
  102. }, function(resp) {
  103. let list = resp.data;
  104. if (list.length == 1) {
  105. this.m.tradeAreaId = list[0].id;
  106. }
  107. this.tradeAreaList = list;
  108. }.bind(this));
  109. },
  110. // 创建一个 默认Model
  111. createModel: function() {
  112. return {
  113. id: '', // 主键
  114. name: '', // 名称
  115. no: '', // 编号
  116. tradeAreaId: '', // 编号
  117. address: '', // 编号
  118. address_arry: [], // 编号
  119. enterpriseId: '', //
  120. status: '1', // 是否可用(0=否,1=是)
  121. remark: '', //
  122. }
  123. },
  124. // 表单验证
  125. submitCheck: function() {
  126. try {
  127. var m = this.m; // 获取 m对象
  128. let tradeAreaId=m.tradeAreaId;
  129. sa.checkNull(m.name, '请输入 [名称]');
  130. sa.checkNull(m.no, '请输入 [编号]');
  131. sa.checkNull(m.tradeAreaId, '请选择 [所在互市区]');
  132. let tradeAreaList=this.tradeAreaList;
  133. m.tradeAreaName=tradeAreaList.filter(obj=>obj.id=tradeAreaId).pop().name;
  134. return 'ok'; // 全部通过验证,返回ok 表示正确
  135. } catch (e) {
  136. sa.error(e);
  137. }
  138. },
  139. // 提交数据
  140. ok: function() {
  141. // 验证
  142. if (this.submitCheck() != 'ok') {
  143. return;
  144. }
  145. // 开始增加或修改
  146. if (this.id <= 0) { // 添加
  147. sa.ajax('/level-one-server/TbShop/add', this.m, function(res) {
  148. sa.alert('增加成功', this.clean);
  149. }.bind(this));
  150. } else { // 修改
  151. sa.ajax('/level-one-server/TbShop/update', this.m, function(res) {
  152. sa.alert('修改成功', this.clean);
  153. }.bind(this));
  154. }
  155. },
  156. // 添加/修改 完成后的动作
  157. clean: function() {
  158. if (this.id == 0) {
  159. this.m = this.createModel();
  160. } else {
  161. parent.app.f5(); // 刷新父页面列表
  162. sa.closeCurrIframe(); // 关闭本页
  163. }
  164. },
  165. initFn() {
  166. // 初始化数据
  167. if (this.id <= 0) {
  168. this.m = this.createModel();
  169. } else {
  170. sa.ajax('/level-one-server/TbShop/getById?id=' + this.id, function(res) {
  171. this.m = res.data;
  172. if (res.data == null) {
  173. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  174. }
  175. }.bind(this))
  176. }
  177. }
  178. },
  179. mounted: function() {
  180. this.initFn();
  181. this.getEnterpriseList();
  182. this.getTradeArea();
  183. }
  184. })
  185. </script>
  186. </body>
  187. </html>