tb-enterprise-add.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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="https://unpkg.com/element-ui@2.13.0/lib/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. <script src="../../static/kj/upload-util.js"></script>
  18. <style type="text/css">
  19. .c-panel .el-form .c-label {
  20. width: 7em !important;
  21. }
  22. .c-panel .el-form .el-input,
  23. .c-panel .el-form .el-textarea__inner {
  24. width: 250px;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  30. <!-- ------- 内容部分 ------- -->
  31. <div class="s-body">
  32. <div class="c-panel">
  33. <div class="c-title" v-if="id == 0">数据添加</div>
  34. <div class="c-title" v-else>数据修改</div>
  35. <el-form size="mini" v-if="m">
  36. <el-row>
  37. <el-col span=12>
  38. <div class="c-item br">
  39. <label class="c-label"><label style="color: red">*</label>名称:</label>
  40. <el-input size="mini" v-model="m.name"></el-input>
  41. </div>
  42. <div class="c-item br">
  43. <label class="c-label"><label style="color: red">*</label>法人:</label>
  44. <el-input size="mini" v-model="m.legalPerson"></el-input>
  45. </div>
  46. <div class="c-item br">
  47. <label class="c-label"><label style="color: red">*</label>身份证号:</label>
  48. <el-input size="mini" v-model="m.idCard"></el-input>
  49. </div>
  50. <div class="c-item br">
  51. <label class="c-label"><label style="color: red">*</label>手机号码:</label>
  52. <el-input size="mini" v-model="m.contact"></el-input>
  53. </div>
  54. </el-col>
  55. <el-col span=12>
  56. <div class="c-item br">
  57. <label class="c-label"><label style="color: red">*</label>银行:</label>
  58. <el-select v-model="m.bankNo" placeholder="请选择" filterable size="mini">
  59. <el-option label="请选择" :value="0" disabled></el-option>
  60. <el-option v-for="(item,index) in bankList" :key="index" :label="item.bankName"
  61. :value="item.bankCode"> </el-option>
  62. </el-select>
  63. </div>
  64. <div class="c-item br">
  65. <label class="c-label"><label style="color: red">*</label>银行账号:</label>
  66. <el-input size="mini" v-model="m.bankAccount"></el-input>
  67. </div>
  68. <div class="c-item br">
  69. <label class="c-label"><label style="color: red">*</label>税号:</label>
  70. <el-input size="mini" v-model="m.dutyParagraph"></el-input>
  71. </div>
  72. <div class="c-item br">
  73. <label class="c-label"><label style="color: red">*</label>地区:</label>
  74. <el-cascader size="mini" placeholder="请选择" v-model="m.address_arry"
  75. :options="options" :props={value:'id',label:'district'}></el-cascader>
  76. </div>
  77. <div class="c-item br">
  78. <label class="c-label"><label style="color: red">*</label>详细地址:</label>
  79. <el-input size="mini" v-model="m.detail"></el-input>
  80. </div>
  81. <div class="c-item br">
  82. <label class="c-label" style="vertical-align: top;"><label
  83. style="color: red">*</label>营业执照:</label>
  84. <div class="c-item-mline image-box">
  85. <div class="image-box-2" v-for="item in m.businessLicense_arr">
  86. <img :src="item" @click="sa.showImage(item, '500px', '400px')" />
  87. <p>
  88. <i class="el-icon-close" style="position: relative; top: 2px;"></i>
  89. <el-link @click="sa.arrayDelete(m.businessLicense_arr, item)"
  90. style="color: #999;">删除 </el-link>
  91. </p>
  92. </div>
  93. <!-- 上传图集 -->
  94. <div class="image-box-2 up_img"
  95. @click="sa.uploadImageList(src => m.businessLicense_arr.push(src))">
  96. <img src="../../static/img/up-icon.png">
  97. </div>
  98. </div>
  99. </div>
  100. </el-col>
  101. </el-row>
  102. <!-- date-create字段: m.createTime - 创建时间 -->
  103. <div class="c-item br s-ok">
  104. <label class="c-label"></label>
  105. <el-button size="mini" type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  106. </div>
  107. </el-form>
  108. </div>
  109. </div>
  110. <!-- ------- 底部按钮 ------- -->
  111. <div class="s-foot">
  112. <el-button size="mini" type="primary" @click="ok()">确定</el-button>
  113. <el-button size="mini" @click="sa.closeCurrIframe()">取消</el-button>
  114. </div>
  115. </div>
  116. <script>
  117. var app = new Vue({
  118. el: '.vue-box',
  119. data: {
  120. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  121. m: null, // 实体对象
  122. bankList: [],
  123. options: [],
  124. shopList: []
  125. },
  126. methods: {
  127. getAddress() {
  128. sa.ajax('/sp-admin/TbDistrict/getTreeData', function(resp) {
  129. this.options = resp.data;
  130. }.bind(this));
  131. },
  132. getBankList() {
  133. sa.ajax('/sp-admin/TbBank/getAll', function(resp) {
  134. this.bankList = resp.data;
  135. }.bind(this));
  136. },
  137. // 创建一个 默认Model
  138. createModel: function() {
  139. return {
  140. id: '', //
  141. name: '', // 名称
  142. legalPerson: '', // 法人
  143. idCard: '', // 身份证号
  144. contact: '', // 手机号码
  145. businessLicense: '', // 营业执照
  146. businessLicense_arr: [], // 营业执照 - 转数组
  147. agreement: '',
  148. shopId: '', // 所在铺位ID
  149. shopName: '', // 所在铺位名称(1=100-2)
  150. bankNo: '', // 银行编号(CMB= 招商银行)
  151. bankAccount: '', // 银行账号
  152. dutyParagraph: '', // 银行账号
  153. status: '', // 是否可用(0=可用,1=不可用)
  154. // createTime: '', // 创建时间
  155. }
  156. },
  157. // 表单验证
  158. submitCheck: function() {
  159. try {
  160. var m = this.m; // 获取 m对象
  161. let bankNo = m.bankNo;
  162. let shopId = m.shopId;
  163. sa.checkNull(m.name, '请输入 [商户名称]');
  164. sa.checkNull(m.legalPerson, '请输入 [法人]');
  165. sa.checkNull(m.idCard, '请输入 [身份证号]');
  166. sa.checkPhone(m.contact, '请输入 [正确手机号码]');
  167. sa.checkNull(m.businessLicense, '请上传 [营业执照]');
  168. sa.checkEmptyArray(m.address_arry, '请选择 [地址]');
  169. sa.checkNull(bankNo, '请选择 [银行]');
  170. sa.checkNull(m.bankAccount, '请输入 [银行账号]');
  171. sa.checkNull(m.detail,'请输入详细地址');
  172. let bankList = this.bankList;
  173. let bank = bankList.filter(bank => bank.bankCode === bankNo)[0];
  174. this.m.bankName = bank.bankName;
  175. return 'ok'; // 全部通过验证,返回ok 表示正确
  176. } catch (e) {
  177. sa.error(e.msg);
  178. }
  179. },
  180. // 提交数据
  181. ok: function() {
  182. // 验证
  183. this.m.businessLicense = this.m.businessLicense_arr.join(','); // 图片数组转字符串
  184. if (this.submitCheck() != 'ok') {
  185. return;
  186. }
  187. // 开始增加或修改
  188. this.m.addressIds = this.m.address_arry.join(',');
  189. if (this.id <= 0) { // 添加
  190. this.m.status = "1";
  191. sa.ajax('/level-one-server/TbEnterprise/add', this.m, function(res) {
  192. sa.alert('增加成功', this.clean);
  193. }.bind(this));
  194. } else { // 修改
  195. sa.ajax('/level-one-server/TbEnterprise/update', this.m, function(res) {
  196. sa.alert('修改成功', this.clean);
  197. }.bind(this));
  198. }
  199. },
  200. uploadAgreement() {
  201. let url = sa.cfg.api_url + '/upload-server/upload/document';
  202. sa.uploadFn(url, src => {
  203. this.m.agreement = src;
  204. sa.ok2('上传成功');
  205. });
  206. },
  207. // 添加/修改 完成后的动作
  208. clean: function() {
  209. if (this.id == 0) {
  210. this.m = this.createModel();
  211. } else {
  212. parent.app.f5(); // 刷新父页面列表
  213. sa.closeCurrIframe(); // 关闭本页
  214. }
  215. },
  216. initFn() {
  217. // 初始化数据
  218. if (this.id <= 0) {
  219. this.m = this.createModel();
  220. } else {
  221. sa.ajax('/level-one-server/TbEnterprise/getById?id=' + this.id, function(res) {
  222. res.data.businessLicense_arr = sa.isNull(res.data.businessLicense) ? [] : res
  223. .data.businessLicense.split(','); // 营业执照 字符串转数组
  224. this.m = res.data;
  225. if (res.data == null) {
  226. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  227. }
  228. this.m.address_arry = this.m.addressIds.split(',');
  229. }.bind(this))
  230. }
  231. }
  232. },
  233. mounted() {
  234. this.getAddress();
  235. this.initFn();
  236. this.getBankList();
  237. }
  238. })
  239. </script>
  240. </body>
  241. </html>