説明なし

UpdateInfo.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div class="updateInfo">
  3. <div class="content-wrapper block-wrapper">
  4. <el-form :model="ruleFormUpdate" :rules="rules" ref="ruleFormUpdate" label-width="80px" class="update-wrapper demo-ruleForm">
  5. <div class="update-logo">
  6. <el-upload
  7. class="avatar-uploader"
  8. :action="uploadUrl"
  9. :show-file-list="false"
  10. ref="uploadLogo"
  11. :on-success="handleAvatarSuccess"
  12. :before-upload="beforeAvatarUpload">
  13. <img v-if="imageUrl" :src="imageUrl" class="avatar">
  14. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  15. </el-upload>
  16. <div class="update-tip">PNG/JPG/JPEG格式<br>大小2M以内</div>
  17. </div>
  18. <div class="update-main">
  19. <div class="update-title">{{plf_name}}</div>
  20. <el-form-item label="联系人" prop="linkman">
  21. <el-input v-model="ruleFormUpdate.linkman" class="shortW" placeholder="请填写平台联系人姓名"></el-input>
  22. </el-form-item>
  23. <el-form-item label="联系电话" prop="tel">
  24. <el-input v-model="ruleFormUpdate.tel" placeholder="请填写联系电话"></el-input>
  25. </el-form-item>
  26. <el-form-item label="联系邮箱" prop="mail">
  27. <el-input v-model="ruleFormUpdate.mail" placeholder="请填写联系邮箱"></el-input>
  28. </el-form-item>
  29. <CityPick
  30. :labelW="80"
  31. :widthselect="200"
  32. :prov="province"
  33. :city="city"
  34. v-on:selectProv="getSelectProv($event)"
  35. v-on:selectCity="getSelectCity($event)">
  36. </CityPick>
  37. <!-- <el-form-item label="所在城市" prop="selectedOptions">
  38. <el-cascader
  39. :options="optionsCity"
  40. v-model="selectedOptions"
  41. class="shortW"
  42. placeholder="请选择所在的城市">
  43. </el-cascader>
  44. </el-form-item> -->
  45. <el-form-item label="联系地址" prop="address">
  46. <el-input v-model="ruleFormUpdate.address" placeholder="如:北京市海淀区学院路方兴大厦"></el-input>
  47. </el-form-item>
  48. <el-form-item label="官方网址" prop="website">
  49. <el-input v-model="ruleFormUpdate.website" placeholder="如:www.ekexiu.com"></el-input>
  50. </el-form-item>
  51. <dynamicTags :tagInfo="tagInfo" :dyStr="ruleFormUpdate.industry" v-on:turnTags="turnTags($event)" :dynamicTagsLength="10"></dynamicTags>
  52. <el-form-item label="平台介绍" prop="desc">
  53. <el-input type="textarea" :rows="8" v-model="ruleFormUpdate.desc" placeholder="请填写一个简单的介绍,让大家更好地了解平台"></el-input>
  54. </el-form-item>
  55. <el-form-item></el-form-item>
  56. <el-form-item>
  57. <el-button type="primary" @click="submitForm('ruleFormUpdate')">保存</el-button>
  58. <el-button @click="resetForm">取消</el-button>
  59. </el-form-item>
  60. </div>
  61. </el-form>
  62. </div>
  63. </div>
  64. </template>
  65. <script type="text/ecmascript-6">
  66. // import Vue from 'vue';
  67. // import {
  68. // provinceAndCityData,
  69. // CodeToText,
  70. // TextToCode
  71. // } from 'element-china-area-data';
  72. import Cookies from 'js-cookie';
  73. import util from '@/libs/util';
  74. import httpUrl from '@/libs/http';
  75. import dynamicTags from '../sub-component/DynamicTags';
  76. export default {
  77. inject: ['reload'],
  78. props: {
  79. plat: {
  80. type: Object
  81. }
  82. },
  83. data() {
  84. return {
  85. tagInfo: {
  86. lableTit: '面向行业',
  87. placeholder: '请填写园区面向的行业,如:互联网/智能制造/新材料'
  88. },
  89. plf_user: '',
  90. plf_name: '',
  91. imageUrl: '', // 临时地址
  92. imgName: '', // 图片的name
  93. uploadUrl: httpUrl.hQuery.baseInfo.upload,
  94. // optionsCity: provinceAndCityData,
  95. // selectedOptions: [],
  96. dynamicTags: [],
  97. isShowAdd: true,
  98. inputVisible: false,
  99. inputValue: '',
  100. province: '',
  101. city: '',
  102. ruleFormUpdate: {
  103. linkman: '',
  104. tel: '',
  105. mail: '',
  106. address: '',
  107. website: '',
  108. industry: '',
  109. desc: ''
  110. },
  111. rules: {
  112. linkman: [
  113. { required: true, message: '请填写平台联系人姓名', trigger: 'blur' },
  114. { max: 10, message: '不得超过10个字', trigger: 'blur' }
  115. ],
  116. tel: [
  117. { required: true, message: '请填写联系电话', trigger: 'blur' },
  118. { max: 50, message: '不得超过50个字', trigger: 'blur' }
  119. ],
  120. mail: [
  121. { required: true, message: '请填写联系邮箱', trigger: 'blur' },
  122. { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' },
  123. { max: 50, message: '不得超过50个字', trigger: 'blur' }
  124. ],
  125. desc: [
  126. { required: true, message: '请填写平台介绍', trigger: 'blur' },
  127. { max: 1000, message: '不得超过1000个字', trigger: 'blur' }
  128. ],
  129. address: [
  130. { max: 50, message: '不得超过50个字', trigger: 'blur' }
  131. ],
  132. website: [
  133. { max: 50, message: '不得超过50个字', trigger: 'blur' }
  134. ]
  135. }
  136. };
  137. },
  138. computed: {
  139. },
  140. created() {
  141. this.plf_user = Cookies.get('plf_user');
  142. this.getPlatInfo(this.plf_user);
  143. },
  144. methods: {
  145. turnTags(msg) {
  146. this.ruleFormUpdate.industry = msg;
  147. },
  148. getSelectProv(prov) {
  149. this.province = prov;
  150. },
  151. getSelectCity(city) {
  152. this.city = city;
  153. },
  154. getPlatInfo(id) {
  155. this.$axios.get(httpUrl.hQuery.baseInfo.query, {
  156. params: {
  157. id: id
  158. }
  159. }).then((res) => {
  160. console.log(res);
  161. let str = res.data;
  162. this.plf_name = str.name;
  163. this.imageUrl = str.logo ? util.ImageUrl('platform' + str.logo) : util.defaultSet.img.plat;
  164. this.imgName = str.logo;
  165. this.ruleFormUpdate.linkman = str.linkman;
  166. this.ruleFormUpdate.tel = str.linkphone;
  167. this.ruleFormUpdate.mail = str.linkemail;
  168. if (str.province) {
  169. this.province = str.province;
  170. }
  171. if (str.city) {
  172. this.city = str.city;
  173. }
  174. this.ruleFormUpdate.address = str.addr;
  175. this.ruleFormUpdate.website = str.url;
  176. if (str.industry) {
  177. this.ruleFormUpdate.industry = str.industry;
  178. this.dynamicTags = str.industry.split(',');
  179. if (this.dynamicTags.length === 10) {
  180. this.isShowAdd = false;
  181. }
  182. }
  183. this.ruleFormUpdate.desc = str.descp;
  184. });
  185. },
  186. submitForm(formName) {
  187. this.$refs[formName].validate((valid) => {
  188. if (valid) {
  189. this.$refs.uploadLogo.submit(); // 确认上传图片
  190. if (this.province) {
  191. if (!this.city) {
  192. this.$alert('请您选择所在城市', '提示', {
  193. confirmButtonText: '确定',
  194. type: 'warning',
  195. center: true
  196. });
  197. return;
  198. }
  199. }
  200. let paramsData = {
  201. 'id': this.plf_user,
  202. 'name': this.plf_name,
  203. 'linkman': this.ruleFormUpdate.linkman,
  204. 'logo': this.imgName,
  205. 'linkphone': this.ruleFormUpdate.tel,
  206. 'linkemail': this.ruleFormUpdate.mail,
  207. 'province': this.province,
  208. 'city': this.city,
  209. 'addr': this.ruleFormUpdate.address,
  210. 'url': this.ruleFormUpdate.website,
  211. 'industry': this.ruleFormUpdate.industry,
  212. 'descp': this.ruleFormUpdate.desc
  213. };
  214. this.$axios.post(httpUrl.hQuery.baseInfo.update, paramsData).then((res) => {
  215. this.$message({
  216. message: '平台信息修改成功!',
  217. type: 'success'
  218. });
  219. Cookies.set('plf_logo', this.imgName);
  220. this.$router.push({path: '/WorkHome'});
  221. this.reload();
  222. }).catch(error => {
  223. console.log(error);
  224. });
  225. } else {
  226. console.log('error submit!!');
  227. return false;
  228. }
  229. });
  230. },
  231. resetForm(formName) {
  232. this.$router.push({path: '/WorkHome'});
  233. },
  234. // upload img
  235. handleAvatarSuccess(res, file) {
  236. this.imageUrl = URL.createObjectURL(file.raw);
  237. this.imgName = res.data[0].uri;
  238. },
  239. beforeAvatarUpload(file) {
  240. const isJPG = file.type === 'image/jpeg';
  241. const isPNG = file.type === 'image/png';
  242. const isLt2M = file.size / 1024 / 1024 < 2;
  243. if (!isJPG && !isPNG) {
  244. this.$message.error('请上传PNG/JPG/JPEG格式的图片');
  245. }
  246. if (!isLt2M) {
  247. this.$message.error('上传logo大小不能超过 2MB!');
  248. }
  249. return (!isJPG || !isPNG) && isLt2M;
  250. },
  251. // upload img
  252. // add tag
  253. handleClose(tag) {
  254. this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
  255. this.ruleFormUpdate.industry = this.dynamicTags.join(',');
  256. if (this.dynamicTags.length < 10) {
  257. this.isShowAdd = true;
  258. }
  259. },
  260. showInput() {
  261. this.inputVisible = true;
  262. this.$nextTick(_ => {
  263. this.$refs.saveTagInput.$refs.input.focus();
  264. });
  265. },
  266. handleInputConfirm() {
  267. let inputValue = this.inputValue;
  268. if (inputValue.length > 15) {
  269. this.$message.error('面向行业不得超过15个字,添加失败!');
  270. }
  271. if (this.dynamicTags.length === 10) {
  272. this.isShowAdd = false;
  273. }
  274. if (inputValue && inputValue.length < 15 && this.dynamicTags.length < 10) {
  275. this.dynamicTags.push(inputValue);
  276. }
  277. this.ruleFormUpdate.industry = this.dynamicTags.join(',');
  278. this.inputVisible = false;
  279. this.inputValue = '';
  280. }
  281. // add tag
  282. },
  283. components: {
  284. dynamicTags
  285. }
  286. };
  287. </script>
  288. <style lang="stylus" rel="stylesheet/stylus">
  289. .updateInfo
  290. .update-wrapper
  291. display:flex
  292. .update-logo
  293. width:280px
  294. .avatar-uploader
  295. .el-upload
  296. center-items(280px,187px)
  297. border: 1px dashed #d9d9d9
  298. cursor: pointer
  299. position: relative
  300. &:hover
  301. border-color: $mainColor
  302. .avatar-uploader-icon
  303. font-size: 40px
  304. color: #8c939d
  305. width: 280px
  306. height: 187px
  307. line-height: 187px
  308. text-align: center
  309. .update-tip
  310. margin-top:15px
  311. text-align:center
  312. font-size:14px
  313. color:$secondaryFont
  314. .update-main
  315. flex:1 0 280px
  316. padding-left:25px
  317. .update-title
  318. font-size:30px
  319. line-height:54px
  320. margin-bottom:16px
  321. padding-left:10px
  322. .el-tag + .el-tag
  323. margin-left: 10px
  324. .button-new-tag
  325. height: 32px
  326. line-height: 30px
  327. padding-top: 0
  328. padding-bottom: 0
  329. .input-new-tag
  330. width: 90px
  331. margin-left: 10px
  332. vertical-align: bottom
  333. .shortW
  334. width:300px
  335. </style>