tb-company-add.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css js 资源 -->
  8. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="../../static/kj/vue.min.js"></script>
  11. <script src="../../static/kj/element-ui/index.js"></script>
  12. <script src="../../static/kj/httpVueLoader.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <script src="../../static/kj/upload-util.js"></script>
  17. <style type="text/css">
  18. .c-panel .el-form .c-label{width: 7em !important;}
  19. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
  20. </style>
  21. </head>
  22. <body>
  23. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  24. <!-- ------- 内容部分 ------- -->
  25. <div class="s-body">
  26. <div class="c-panel">
  27. <div class="c-title" v-if="id == 0">数据添加</div>
  28. <div class="c-title" v-else>数据修改</div>
  29. <el-form size="mini" v-if="m">
  30. <el-row>
  31. <el-col span=12>
  32. <div class="c-item">
  33. <label class="c-label"><span style="color: red;">*</span>互市区:</label>
  34. <el-select v-model="m.tradeAreaName" placeholder="请选择" filterable size="mini">
  35. <el-option v-for="(item,index) in tradeAreaList" :key="index" :label="item.name" :value="item"> </el-option>
  36. </el-select>
  37. </div>
  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" style="vertical-align: top;"><label
  79. style="color: red">*</label>营业执照:</label>
  80. <div class="c-item-mline image-box">
  81. <div class="image-box-2" v-for="item in m.businessLicense_arr">
  82. <img :src="item" @click="sa.showImage(item, '500px', '400px')" />
  83. <p>
  84. <i class="el-icon-close" style="position: relative; top: 2px;"></i>
  85. <el-link @click="sa.arrayDelete(m.businessLicense_arr, item)"
  86. style="color: #999;">删除 </el-link>
  87. </p>
  88. </div>
  89. <!-- 上传图集 -->
  90. <div class="image-box-2 up_img"
  91. @click="sa.uploadImageList(src => m.businessLicense_arr.push(src))">
  92. <img src="../../static/img/up-icon.png">
  93. </div>
  94. </div>
  95. </div>
  96. </el-col>
  97. </el-row>
  98. <!-- date-create字段: m.createTime - 创建时间 -->
  99. <div class="c-item br s-ok">
  100. <label class="c-label"></label>
  101. <el-button size="mini" type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  102. </div>
  103. </el-form>
  104. </div>
  105. </div>
  106. <!-- ------- 底部按钮 ------- -->
  107. <div class="s-foot">
  108. <el-button size="mini" type="primary" @click="ok()">确定</el-button>
  109. <el-button size="mini" @click="sa.closeCurrIframe()">取消</el-button>
  110. </div>
  111. </div>
  112. <script>
  113. var app = new Vue({
  114. components: {
  115. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  116. },
  117. el: '.vue-box',
  118. data: {
  119. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  120. m: null, // 实体对象
  121. bankList: [],
  122. options: [],
  123. tradeAreaList:[]
  124. },
  125. methods: {
  126. getTradeArea() {
  127. sa.ajax('/level-one-server/TbTradeArea/getList', {
  128. pageSize: 100,
  129. pageNo: 1
  130. }, function(resp) {
  131. let list=resp.data;
  132. if(list.length>0&&this.id<=0){
  133. this.m.tradeAreaId=list[0].id;
  134. }
  135. this.tradeAreaList = list;
  136. }.bind(this));
  137. },
  138. getAddress() {
  139. sa.ajax('/sp-admin/TbDistrict/getTreeData', function(resp) {
  140. this.options = resp.data;
  141. }.bind(this));
  142. },
  143. getBankList() {
  144. sa.ajax('/sp-admin/TbBank/getAll', function(resp) {
  145. this.bankList = resp.data;
  146. }.bind(this));
  147. },
  148. // 创建一个 默认Model
  149. createModel: function() {
  150. return {
  151. id: '', //
  152. name: '', // 名称
  153. legalPerson: '', // 法人
  154. idCard: '', // 身份证号
  155. contact: '', // 手机号码
  156. businessLicense: '', // 营业执照
  157. businessLicense_arr: [], // 营业执照 - 转数组
  158. bankNo: '', // 银行编号(CMB= 招商银行)
  159. bankName: '', // 银行名称
  160. bankAccount: '', // 银行账号
  161. dutyParagraph: '', // 税号
  162. addressIds: '', // 地址全路径如1,22,333
  163. detail: '', // 详细地址
  164. tradeAreaId:''
  165. }
  166. },
  167. // 提交数据
  168. ok: function(){
  169. // 表单校验
  170. var m = this.m; // 获取 m对象
  171. let bankNo = m.bankNo;
  172. sa.checkNull(m.tradeAreaId, '请选择 [互市区]');
  173. sa.checkNull(m.name, '请输入 [名称]');
  174. sa.checkNull(m.legalPerson, '请输入 [法人]');
  175. sa.checkNull(m.idCard, '请输入 [身份证号]');
  176. sa.checkNull(m.contact, '请输入 [手机号码]');
  177. sa.checkEmptyArray(m.address_arry, '请选择 [地址]');
  178. sa.checkEmptyArray(m.businessLicense_arr, '请上传 [营业执照]');
  179. sa.checkNull(bankNo, '请选择 [银行]');
  180. sa.checkNull(m.bankAccount, '请输入 [银行账号]');
  181. let bankList = this.bankList;
  182. let bank = bankList.filter(bank => bank.bankCode === bankNo)[0];
  183. this.m.bankName = bank.bankName;
  184. // 开始增加或修改
  185. this.m.addressIds = this.m.address_arry.join(',');
  186. // 验证
  187. this.m.businessLicense = this.m.businessLicense_arr.join(','); // 图片数组转字符串
  188. this.m.tradeAreaName=this.tradeAreaList.filter(obj=>obj.id==m.tradeAreaId).pop().name;
  189. // 开始增加或修改
  190. if(this.id <= 0) { // 添加
  191. sa.ajax('/level-two-server/TbCompany/add', m, function(res){
  192. sa.alert('增加成功', this.clean);
  193. }.bind(this));
  194. } else { // 修改
  195. sa.ajax('/level-two-server/TbCompany/update', m, function(res){
  196. sa.alert('修改成功', this.clean);
  197. }.bind(this));
  198. }
  199. },
  200. // 添加/修改 完成后的动作
  201. clean: function() {
  202. if(this.id == 0) {
  203. this.m = this.createModel();
  204. } else {
  205. parent.app.f5(); // 刷新父页面列表
  206. sa.closeCurrIframe(); // 关闭本页
  207. }
  208. }
  209. },
  210. mounted: function(){
  211. this.getAddress();
  212. this.getBankList();
  213. this.getTradeArea();
  214. // 初始化数据
  215. if(this.id <= 0) {
  216. this.m = this.createModel();
  217. } else {
  218. sa.ajax('/level-two-server/TbCompany/getById?id=' + this.id, function(res) {
  219. res.data.businessLicense_arr = sa.isNull(res.data.businessLicense) ? [] : res
  220. .data.businessLicense.split(','); // 营业执照 字符串转数组
  221. this.m = res.data;
  222. if(res.data == null) {
  223. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  224. }
  225. this.m.address_arry = this.m.addressIds.split(',');
  226. }.bind(this))
  227. }
  228. }
  229. })
  230. </script>
  231. </body>
  232. </html>