tb-shop-add.html 5.9 KB

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