companyDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template> 
  2. <el-card class="form-container" shadow="never">
  3. <el-form :model="company" :rules="rules" ref="companyFrom" label-width="150px">
  4. <el-form-item label="供应商名称:" prop="compName">
  5. <el-input v-model="company.compName"></el-input>
  6. </el-form-item>
  7. <el-form-item label="供应商类型:">
  8. <el-input v-model="company.companyType"></el-input>
  9. </el-form-item>
  10. <el-form-item label="供应商评级">
  11. <el-input v-model="company.compLevel"></el-input>
  12. </el-form-item>
  13. <el-form-item label="供应商资质">
  14. <el-input v-model="company.compQual"></el-input>
  15. </el-form-item>
  16. <!-- <el-form-item label="企业logo图片">
  17. <single-upload v-model="company.compLogo"></single-upload>
  18. </el-form-item> -->
  19. <el-form-item label="供应商图片">
  20. <div>请按企业logo,供应商图片,供应商资质图片,公众号二维码图片顺序上传</div>
  21. <multi-upload v-model="thecompImgs"></multi-upload>
  22. </el-form-item>
  23. <!-- <el-form-item label="供应商资质图片">
  24. <single-upload v-model="company.compQualImgs"></single-upload>
  25. </el-form-item> -->
  26. <!-- <el-form-item label="公众号二维码图片">
  27. <single-upload v-model="company.compQr"></single-upload>
  28. </el-form-item> -->
  29. <el-form-item label="淘宝店地址">
  30. <el-input v-model="taobaourl"></el-input>
  31. </el-form-item>
  32. <el-form-item label="京东店地址">
  33. <el-input v-model="jdurl"></el-input>
  34. </el-form-item>
  35. <el-form-item label="自主商城地址">
  36. <el-input v-model="selfurl"></el-input>
  37. </el-form-item>
  38. <el-form-item label="是否认证">
  39. <el-switch
  40. :active-value="1"
  41. :inactive-value="0"
  42. v-model="company.isCert">
  43. </el-switch>
  44. </el-form-item>
  45. <el-form-item label="生产许可证号">
  46. <el-input v-model="company.compProdLicenseNum"></el-input>
  47. </el-form-item>
  48. <el-form-item label="经营许可证号">
  49. <el-input v-model="company.compManageLicenseNum"></el-input>
  50. </el-form-item>
  51. <el-form-item label="社会信用代码">
  52. <el-input v-model="company.compSocialCode"></el-input>
  53. </el-form-item>
  54. <el-form-item label="联系人">
  55. <el-input v-model="company.compConPerson"></el-input>
  56. </el-form-item>
  57. <el-form-item label="联系方式">
  58. <el-input v-model="company.compConType"></el-input>
  59. </el-form-item>
  60. <el-form-item label="对外企业qq">
  61. <el-input v-model="company.compQq"></el-input>
  62. </el-form-item>
  63. <el-form-item label="经营产品">
  64. <el-input v-model="company.compManageProduct"></el-input>
  65. </el-form-item>
  66. <el-form-item label="简介">
  67. <el-input
  68. placeholder="请输入内容"
  69. type="textarea"
  70. v-model="company.compSum"
  71. :autosize="true"></el-input>
  72. </el-form-item>
  73. <el-form-item label="所在省">
  74. <el-input v-model="company.provinceId"></el-input>
  75. </el-form-item>
  76. <el-form-item label="所在市">
  77. <el-input v-model="company.cityId"></el-input>
  78. </el-form-item>
  79. <el-form-item label="所在县">
  80. <el-input v-model="company.countyId"></el-input>
  81. </el-form-item>
  82. <el-form-item label="详细地址">
  83. <el-input v-model="company.detailAddress"></el-input>
  84. </el-form-item>
  85. <el-form-item label="经度(°)">
  86. <el-input placeholder="" style="width: 80%;" size="samll" v-model.number="company.longitude"></el-input>
  87. </el-form-item>
  88. <el-form-item label="维度(°)">
  89. <el-input v-model="company.latitude"></el-input>
  90. </el-form-item>
  91. <el-form-item>
  92. <baidu-map class="map" :center="center" :zoom="zoom" @ready="handlermap"
  93. :scroll-wheel-zoom="true"
  94. @click="clickEvent"
  95. ak="33B192o1jPaqOHASGGAIkoMuwi8W76j3">
  96. <!-- 地图控件位置 -->
  97. <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
  98. <!-- 获取城市列表 -->
  99. <bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT"></bm-city-list>
  100. <!-- 定位当前位置 -->
  101. <bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true" @locationSuccess="getLoctionSuccess" ></bm-geolocation>
  102. <!-- 地图容器 -->
  103. <bm-view :style="{width:'100%',height: '500px'}"></bm-view>
  104. </baidu-map>
  105. </el-form-item>
  106. <!-- <el-form-item label="带动农户人数">
  107. <el-input v-model="company.countyId"></el-input>
  108. </el-form-item>
  109. <el-form-item label="其中建档立卡人数">
  110. <el-input v-model="company.countyId"></el-input>
  111. </el-form-item> -->
  112. <el-form-item>
  113. <el-button type="primary" @click="onSubmit('companyFrom')">提交</el-button>
  114. <el-button v-if="!isEdit" @click="resetForm('companyFrom')">重置</el-button>
  115. </el-form-item>
  116. </el-form>
  117. </el-card>
  118. </template>
  119. <script>
  120. import {createCompany, getCompany, updateCompany} from '@/api/company'
  121. import SingleUpload from '@/components/Upload/singleUpload'
  122. import MultiUpload from '@/components/Upload/multiUpload'
  123. import {BaiduMap,BmNavigation,BmView,BmGeolocation,BmCityList} from 'vue-baidu-map'
  124. const defaultCompany={
  125. cityId: "",
  126. compConNum: "",
  127. compConPerson: "",
  128. compConType: null,
  129. compImgs: null,
  130. compLevel: null,
  131. compManageLicenseNum: null,
  132. compManageProduct: "",
  133. compName: "",
  134. compProdLicenseNum: "",
  135. compQq: "",
  136. compQual: "",
  137. compSocialCode: "",
  138. compStatus: null,
  139. compSum: "",
  140. compUrl: null,
  141. companyType: "",
  142. countyId: "",
  143. createId: null,
  144. createTime: "",
  145. detailAddress: "",
  146. files:[],
  147. id: null,
  148. isCert: 0,
  149. latitude: "",
  150. longitude: "",
  151. origins: null,
  152. provinceId: "",
  153. shops: [],
  154. townId: null,
  155. updateId: null,
  156. updateTime: null,
  157. villageId: null,
  158. };
  159. export default {
  160. name: 'companyDetail',
  161. components:{
  162. SingleUpload,
  163. MultiUpload,
  164. BaiduMap,
  165. BmNavigation,
  166. BmView,
  167. BmGeolocation,
  168. BmCityList,
  169. },
  170. props: {
  171. isEdit: {
  172. type: Boolean,
  173. default: false
  174. }
  175. },
  176. data() {
  177. return {
  178. company:Object.assign({}, defaultCompany),
  179. jdurl:'',
  180. taobaourl:'',
  181. selfurl:'',
  182. rules: {
  183. compName: [
  184. {required: true, message: '请输入品牌名称', trigger: 'blur'},
  185. {min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
  186. ],
  187. logo: [
  188. {required: true, message: '请输入品牌logo', trigger: 'blur'}
  189. ],
  190. sort: [
  191. {type: 'number', message: '排序必须为数字'}
  192. ],
  193. },
  194. center: {lng: 106.632713, lat: 26.653157},
  195. zoom: 12,
  196. mapVisible:false,
  197. clientHeight:document.documentElement.clientHeight-90, // 设置屏幕高度
  198. }
  199. },
  200. created() {
  201. if (this.isEdit) {
  202. getCompany(this.$route.query.id).then(response => {
  203. this.company = response.data;
  204. // 商城地址
  205. let jdshop = this.company.shops.filter( (item) => {
  206. return item.shopType == "jd"
  207. });
  208. if(jdshop.length>0){this.jdurl = jdshop[0].shopUrl;}
  209. let taobaoshop = this.company.shops.filter( (item) => {
  210. return item.shopType == "taobao"
  211. });
  212. if(taobaoshop.length>0){this.taobaourl = taobaoshop[0].shopUrl;}
  213. // 商城地址
  214. console.log('this.company',JSON.parse(JSON.stringify(this.company)));
  215. });
  216. }else{
  217. this.company = Object.assign({},defaultCompany);
  218. }
  219. },
  220. computed: {
  221. //供应商图片
  222. thecompImgs:{
  223. get:function () {
  224. let pics=[];
  225. if(this.company.files===undefined||this.company.files==null||this.company.files===''){
  226. return pics;
  227. }
  228. let compImgs = this.company.files;
  229. for(let i=0;i<compImgs.length;i++){
  230. pics.push(compImgs[i].fileUrl);
  231. }
  232. return pics;
  233. },
  234. set:function (newValue) {
  235. // console.log('newValue',newValue);
  236. if (newValue == null || newValue.length === 0) {
  237. this.company.files = null;
  238. } else {
  239. this.company.files = [];
  240. if (newValue.length >= 1) {
  241. for (let i = 0; i < newValue.length; i++) {
  242. this.company.files.push({fileUrl:newValue[i],fileType:"company"});
  243. // this.company.files += newValue[i];
  244. // if (i !== newValue.length - 1) {
  245. // this.company.files += ',';
  246. // }
  247. }
  248. }
  249. }
  250. }
  251. }
  252. },
  253. methods: {
  254. onSubmit(formName) {
  255. console.log('this.taobaourl',this.taobaourl);
  256. // 商城地址
  257. this.company.shops=[];
  258. if(this.taobaourl.length>0){
  259. this.company.shops.push({shopType:'taobao',shopUrl:this.taobaourl});
  260. }
  261. if(this.jdurl.length>0){
  262. this.company.shops.push({shopType:'jd',shopUrl:this.jdurl});
  263. }
  264. // 商城地址
  265. console.log('this.company',JSON.parse(JSON.stringify(this.company)))
  266. // return false;
  267. this.$refs[formName].validate((valid) => {
  268. if (valid) {
  269. this.$confirm('是否提交数据', '提示', {
  270. confirmButtonText: '确定',
  271. cancelButtonText: '取消',
  272. type: 'warning'
  273. }).then(() => {
  274. if (this.isEdit) {
  275. updateCompany(this.$route.query.id, this.company).then(response => {
  276. this.$refs[formName].resetFields();
  277. this.$message({
  278. message: '修改成功',
  279. type: 'success',
  280. duration:1000
  281. });
  282. setTimeout(() =>{
  283. this.$router.back();
  284. },1000);
  285. });
  286. } else {
  287. createCompany(this.company).then(response => {
  288. this.$refs[formName].resetFields();
  289. this.company = Object.assign({},defaultCompany);
  290. this.$message({
  291. message: '提交成功',
  292. type: 'success',
  293. duration:1000
  294. });
  295. setTimeout(() =>{
  296. this.$router.back();
  297. },1000);
  298. });
  299. }
  300. });
  301. } else {
  302. this.$message({
  303. message: '验证失败',
  304. type: 'error',
  305. duration:1000
  306. });
  307. return false;
  308. }
  309. });
  310. },
  311. resetForm(formName) {
  312. this.$refs[formName].resetFields();
  313. this.company = Object.assign({},defaultCompany);
  314. },
  315. handlermap ({BMap, map}) {
  316. let _this = this; // 设置一个临时变量指向vue实例;
  317. var geolocation = new BMap.Geolocation();
  318. geolocation.getCurrentPosition(function(r){
  319. // console.log(r);
  320. _this.center = {lng: r.longitude, lat: r.latitude}; // 设置center属性值
  321. _this.autoLocationPoint = {lng: r.longitude, lat: r.latitude}; // 自定义覆盖物
  322. _this.initLocation = true;
  323. },{enableHighAccuracy: true})
  324. window.map = map;
  325. },
  326. //点击地图监听
  327. clickEvent(e){
  328. map.clearOverlays();
  329. let Icon_0 = new BMap.Icon("static/zuobiao.gif", new BMap.Size(64, 64), {anchor: new BMap.Size(18, 32),imageSize: new BMap.Size(36, 36)});
  330. var myMarker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat),{icon: Icon_0});
  331. map.addOverlay(myMarker);
  332. //用所定位的经纬度查找所在地省市街道等信息
  333. var point = new BMap.Point(e.point.lng, e.point.lat);
  334. var gc = new BMap.Geocoder();
  335. let _this = this;
  336. gc.getLocation(point, function (rs) {
  337. var addComp = rs.addressComponents;
  338. // console.log(rs);//地址信息
  339. _this.company.provinceId = rs.addressComponents.province;
  340. _this.company.cityId = rs.addressComponents.city;
  341. _this.company.countyId = rs.addressComponents.district;
  342. _this.company.detailAddress = rs.address;
  343. });
  344. this.company.longitude = e.point.lng;
  345. this.company.latitude = e.point.lat;
  346. },
  347. //定位成功回调
  348. getLoctionSuccess(point, AddressComponent, marker){
  349. map.clearOverlays();
  350. let Icon_0 = new BMap.Icon("/static/zuobiao.gif", new BMap.Size(64, 64), {anchor: new BMap.Size(18, 32),imageSize: new BMap.Size(36, 36)});
  351. var myMarker = new BMap.Marker(new BMap.Point(point.point.lng, point.point.lat),{icon: Icon_0});
  352. map.addOverlay(myMarker);
  353. this.company.longitude = point.point.lng;
  354. this.company.latitude = point.point.lat;
  355. },
  356. findlocation(){
  357. this.$emit("findlocdata",this.company)
  358. this.mapVisible = false
  359. },
  360. mapShow(){
  361. this.mapVisible = true
  362. },
  363. }
  364. }
  365. </script>
  366. <style>
  367. </style>