exhibitorSetting.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <script>
  2. import Vue from 'vue'
  3. import { saveExpo, getMyExpoInfo } from '@/api/expo'
  4. import { getFormList } from '@/api/form'
  5. import { upload } from '@/api/system'
  6. export default Vue.extend({
  7. name: 'ExhibitorSetting',
  8. data() {
  9. return {
  10. exhibitorSetting: {
  11. id: '',
  12. expo_name: '',
  13. start_date: '',
  14. end_date: '',
  15. location: '',
  16. organizer: '',
  17. contact_phone: '',
  18. contact_email: '',
  19. content: '',
  20. logo: '/common/2025/0915/68c7b25cc9e26.webp',
  21. images: ['/common/2025/0915/68c7b263bc4b1.webp'],
  22. social_links: {
  23. facebook: ''
  24. },
  25. form_template_id: '',
  26. urla: '',
  27. seo_title: '',
  28. seo_description: '',
  29. seo_keywords: '',
  30. show_official_footer: '1'
  31. },
  32. isShowMore: false,
  33. formList: [],
  34. loading: false,
  35. ossUrl: process.env.VUE_APP_OSS_DOMAIN
  36. }
  37. },
  38. mounted() {
  39. this.init()
  40. },
  41. methods: {
  42. init() {
  43. if (this.$route.params.id) {
  44. this.loading = true
  45. this.exhibitorSetting.id = this.$route.params.id
  46. getMyExpoInfo(this.exhibitorSetting.id).then(res => {
  47. this.exhibitorSetting = res.data
  48. this.exhibitorSetting.images = JSON.parse(this.exhibitorSetting.images)
  49. this.exhibitorSetting.social_links = JSON.parse(this.exhibitorSetting.social_links)
  50. this.loading = false
  51. }).catch(err => {
  52. this.$notify({
  53. title: '提示',
  54. message: '获取被复制展会数据失败:' + err,
  55. type: 'error'
  56. })
  57. this.loading = false
  58. })
  59. }
  60. if (this.$route.query.copy) {
  61. this.loading = true
  62. getMyExpoInfo(this.$route.query.copy).then(res => {
  63. this.exhibitorSetting = res.data
  64. this.exhibitorSetting.images = JSON.parse(this.exhibitorSetting.images)
  65. this.exhibitorSetting.social_links = JSON.parse(this.exhibitorSetting.social_links)
  66. this.exhibitorSetting.id = ''
  67. this.loading = false
  68. }).catch(err => {
  69. this.$notify({
  70. title: '提示',
  71. message: '获取被复制展会数据失败:' + err,
  72. type: 'error'
  73. })
  74. this.loading = false
  75. })
  76. }
  77. getFormList(1, 1000).then(res => {
  78. this.formList = res.data.data
  79. }).catch(err => {
  80. this.$notify({
  81. title: '提示',
  82. message: '获取预登记表单数据失败:' + err,
  83. type: 'error'
  84. })
  85. })
  86. },
  87. uploadImage(event, type) {
  88. this.loading = true
  89. upload(event.target.files[0]).then(res => {
  90. if (type === 'logo') {
  91. this.exhibitorSetting.logo = res.data.file
  92. }
  93. if (type === 'cover') {
  94. this.exhibitorSetting.images[0] = res.data.file
  95. this.exhibitorSetting.images.push()
  96. }
  97. this.loading = false
  98. }).catch(err => {
  99. this.loading = false
  100. this.$notify({
  101. title: '提示',
  102. message: '图片上传失败:' + err,
  103. type: 'error'
  104. })
  105. })
  106. },
  107. save() {
  108. if (
  109. this.exhibitorSetting.expo_name === '' ||
  110. this.exhibitorSetting.start_date === '' ||
  111. this.exhibitorSetting.end_date === '' ||
  112. this.exhibitorSetting.location === '' ||
  113. this.exhibitorSetting.organizer === '' ||
  114. this.exhibitorSetting.contact_phone === '' ||
  115. this.exhibitorSetting.contact_email === ''
  116. ) {
  117. this.$notify({
  118. title: '提示',
  119. message: '请将展会数据填写完整',
  120. type: 'warning'
  121. })
  122. return
  123. }
  124. if (this.loading) {
  125. return
  126. }
  127. if (this.exhibitorSetting.urla === '') {
  128. this.exhibitorSetting.urla = this.exhibitorSetting.expo_name
  129. }
  130. this.loading = true
  131. saveExpo(
  132. this.exhibitorSetting.id,
  133. this.exhibitorSetting.expo_name,
  134. this.exhibitorSetting.start_date,
  135. this.exhibitorSetting.end_date,
  136. this.exhibitorSetting.location,
  137. this.exhibitorSetting.organizer,
  138. this.exhibitorSetting.contact_phone,
  139. this.exhibitorSetting.contact_email,
  140. this.exhibitorSetting.content,
  141. this.exhibitorSetting.logo,
  142. this.exhibitorSetting.images,
  143. this.exhibitorSetting.social_links,
  144. this.exhibitorSetting.form_template_id,
  145. this.exhibitorSetting.page_template_id,
  146. this.exhibitorSetting.urla,
  147. this.exhibitorSetting.seo_title,
  148. this.exhibitorSetting.seo_description,
  149. this.exhibitorSetting.seo_keywords
  150. ).then(res => {
  151. this.$notify({
  152. title: '提示',
  153. message: '展会保存成功',
  154. type: 'success'
  155. })
  156. this.loading = false
  157. this.$router.push('/exhibitor/list')
  158. }).catch(err => {
  159. this.loading = false
  160. this.$notify({
  161. title: '提示',
  162. message: '保存展会失败:' + err,
  163. type: 'error'
  164. })
  165. })
  166. },
  167. canAddSocialShow() {
  168. if (this.exhibitorSetting.social_links.facebook === undefined ||
  169. this.exhibitorSetting.social_links.twitter === undefined ||
  170. this.exhibitorSetting.social_links.linkedin === undefined) {
  171. return true
  172. } else {
  173. return false
  174. }
  175. },
  176. removeSocial(key) {
  177. delete this.exhibitorSetting.social_links[key]
  178. this.exhibitorSetting.social_links = { ...this.exhibitorSetting.social_links }
  179. },
  180. addSocial() {
  181. console.log(this.exhibitorSetting.social_links)
  182. if (this.exhibitorSetting.social_links.facebook === undefined) {
  183. this.exhibitorSetting.social_links.facebook = ''
  184. this.exhibitorSetting.social_links = { ...this.exhibitorSetting.social_links }
  185. return
  186. }
  187. if (this.exhibitorSetting.social_links.twitter === undefined) {
  188. this.exhibitorSetting.social_links.twitter = ''
  189. this.exhibitorSetting.social_links = { ...this.exhibitorSetting.social_links }
  190. return
  191. }
  192. if (this.exhibitorSetting.social_links.linkedin === undefined) {
  193. this.exhibitorSetting.social_links.linkedin = ''
  194. this.exhibitorSetting.social_links = { ...this.exhibitorSetting.social_links }
  195. return
  196. }
  197. },
  198. socialInput(key, value) {
  199. this.exhibitorSetting.social_links[key] = value
  200. },
  201. changeSocialType(oldType, type) {
  202. console.log(oldType, type)
  203. this.exhibitorSetting.social_links[type] = this.exhibitorSetting.social_links[oldType]
  204. delete this.exhibitorSetting.social_links[oldType]
  205. this.exhibitorSetting.social_links = { ...this.exhibitorSetting.social_links }
  206. }
  207. }
  208. })
  209. </script>
  210. <template>
  211. <div v-loading="loading" class="main-box">
  212. <div class="save">
  213. <el-button v-permission="'exhibitor.save'" type="primary" @click="save">{{ exhibitorSetting.id?'保存修改':'新建展商' }}</el-button>
  214. </div>
  215. <div class="info">
  216. <div class="scroll">
  217. <div class="form-item required">
  218. <div class="label">展会名称 </div>
  219. <el-input v-model="exhibitorSetting.expo_name" class="input" placeholder="请输入展会名称" />
  220. </div>
  221. <div class="form-item required">
  222. <div class="label">展会时间</div>
  223. <div class="time-cont">
  224. <el-date-picker
  225. v-model="exhibitorSetting.start_date"
  226. type="date"
  227. placeholder="开始时间"
  228. value-format="yyyy-MM-dd"
  229. style="width: 100%;"
  230. />
  231. <el-date-picker
  232. v-model="exhibitorSetting.end_date"
  233. type="date"
  234. placeholder="结束时间"
  235. value-format="yyyy-MM-dd"
  236. style="width: 100%;"
  237. />
  238. </div>
  239. </div>
  240. <div class="form-item required">
  241. <div class="label">展会地点</div>
  242. <el-input v-model="exhibitorSetting.location" class="input" placeholder="请输入展会地点" />
  243. </div>
  244. <div class="form-item required">
  245. <div class="label">主办单位</div>
  246. <el-input v-model="exhibitorSetting.organizer" class="input" placeholder="请输入主办单位" />
  247. </div>
  248. <div class="form-item required">
  249. <div class="label">联系电话</div>
  250. <el-input v-model="exhibitorSetting.contact_phone" class="input" placeholder="请输入联系电话" />
  251. </div>
  252. <div class="form-item required">
  253. <div class="label">联系邮箱</div>
  254. <el-input v-model="exhibitorSetting.contact_email" class="input" placeholder="请输入联系邮箱" />
  255. </div>
  256. <div class="form-item">
  257. <div class="label">社交账号</div>
  258. <div class="social-list">
  259. <div v-for="(value,key) in exhibitorSetting.social_links" class="social-item">
  260. <el-input :value="value" :placeholder="'请输入'+key+'主页地址'" @input="socialInput(key,$event)">
  261. <el-select slot="prepend" :value="key" @change="changeSocialType(key,$event)">
  262. <el-option :disabled="exhibitorSetting.social_links.facebook!==undefined" value="facebook" label="facebook" />
  263. <el-option :disabled="exhibitorSetting.social_links.twitter!==undefined" value="twitter" label="twitter" />
  264. <el-option :disabled="exhibitorSetting.social_links.linkedin!==undefined" value="linkedin" label="linkedin" />
  265. </el-select>
  266. <el-button slot="append" icon="el-icon-delete" @click="removeSocial(key)" />
  267. </el-input>
  268. </div>
  269. <el-button v-if="canAddSocialShow()" type="primary" class="add-social el-icon-plus" @click="addSocial()">添加</el-button>
  270. </div>
  271. </div>
  272. <div class="form-item">
  273. <div class="label">表单模板</div>
  274. <el-select v-model="exhibitorSetting.form_template_id">
  275. <el-option v-for="item in formList" :key="item.id" :value="item.id" :label="item.template_name" />
  276. </el-select>
  277. </div>
  278. <div v-permission="'exhibitor.copyright'" class="form-item required">
  279. <div class="label">表单底部显示系统信息</div>
  280. <el-switch v-model="exhibitorSetting.show_official_footer" active-value="1" inactive-value="0" class="input" />
  281. </div>
  282. <div class="form-item">
  283. <div class="label">高级设置</div>
  284. <el-switch v-model="isShowMore" />
  285. </div>
  286. <template v-if="isShowMore">
  287. <div class="form-item required">
  288. <div class="label">url短名称</div>
  289. <el-input v-model="exhibitorSetting.urla" class="input" placeholder="请输入url" />
  290. </div>
  291. <div class="form-item">
  292. <div class="label">SEO标题</div>
  293. <el-input v-model="exhibitorSetting.seo_title" class="input" placeholder="请输入SEO标题" />
  294. </div>
  295. <div class="form-item">
  296. <div class="label">SEO关键字</div>
  297. <el-input v-model="exhibitorSetting.seo_keywords" class="input" placeholder="请输入SEO关键字" />
  298. </div>
  299. <div class="form-item">
  300. <div class="label">SEO描述</div>
  301. <el-input v-model="exhibitorSetting.seo_description" class="input" placeholder="请输入SEO描述" />
  302. </div>
  303. </template>
  304. </div>
  305. </div>
  306. <div class="desc">
  307. <div class="scroll">
  308. <div class="vision-cont">
  309. <img :src="ossUrl + exhibitorSetting.images[0]" alt="" class="image loading">
  310. <div class="avatar-name">
  311. <img :src="ossUrl + exhibitorSetting.logo" alt="" class="avatar loading">
  312. <div>
  313. <div class="name">
  314. {{ exhibitorSetting.expo_name||'示例展会名称' }}
  315. </div>
  316. <div class="exhibitor">
  317. {{ exhibitorSetting.organizer||'示例主办方名称' }}
  318. </div>
  319. </div>
  320. <div class="avatar-upload">
  321. <div class="upload-icon">
  322. <span class="el-icon-upload icon" />
  323. <span class="text">上传logo</span>
  324. </div>
  325. <input type="file" class="uploader" @change="uploadImage($event,'logo')">
  326. </div>
  327. </div>
  328. <div class="cover-upload">
  329. <div class="upload-icon">
  330. <span class="el-icon-upload icon" />
  331. <span class="text">上传主视觉图</span>
  332. </div>
  333. <input type="file" class="uploader" @change="uploadImage($event,'cover')">
  334. </div>
  335. </div>
  336. <el-input v-model="exhibitorSetting.content" rows="12" type="textarea" class="text-area" placeholder="请输入展会介绍" />
  337. </div>
  338. </div>
  339. </div>
  340. </template>
  341. <style scoped lang="scss">
  342. .main-box{
  343. height: 100%;
  344. width: 100%;
  345. display: grid;
  346. grid-gap: 16px;
  347. grid-template-columns: 1fr 1fr;
  348. grid-template-rows: auto 1fr;
  349. .save{
  350. display: flex;
  351. justify-content: flex-end;
  352. grid-column: span 2;
  353. }
  354. .info{
  355. position: relative;
  356. height: 100%;
  357. width: 100%;
  358. .scroll{
  359. position: absolute;
  360. top: 0;
  361. left: 0;
  362. height: 100%;
  363. width: 100%;
  364. overflow: hidden;
  365. overflow-y: auto;
  366. }
  367. .form-item{
  368. margin: 16px 0;
  369. .el-select{
  370. width: 100%;
  371. }
  372. .label{
  373. margin-bottom: 8px;
  374. }
  375. .social-list{
  376. margin-bottom: 12px;
  377. display: flex;
  378. flex-direction: column;
  379. grid-gap: 8px;
  380. .add-social{
  381. margin-left: auto;
  382. width: fit-content;
  383. }
  384. .social-item{
  385. position: relative;
  386. margin-bottom: 6px;
  387. .el-select{
  388. width: 120px;
  389. }
  390. }
  391. }
  392. .time-cont{
  393. display: grid;
  394. grid-template-columns: 1fr 1fr;
  395. grid-gap: 16px;
  396. }
  397. &.required{
  398. .label::after{
  399. content: '*';
  400. color: red;
  401. margin-left: 4px;
  402. }
  403. }
  404. }
  405. }
  406. .desc{
  407. height: 100%;
  408. width: 100%;
  409. position: relative;
  410. .scroll{
  411. padding: 8px;
  412. position: absolute;
  413. top: 0;
  414. left: 0;
  415. height: 100%;
  416. width: 100%;
  417. overflow: hidden;
  418. overflow-y: auto;
  419. }
  420. .text-area{
  421. margin-top: 24px;
  422. }
  423. .vision-cont{
  424. position: relative;
  425. box-shadow: 0 0 8px 0 #00000022;
  426. overflow: hidden;
  427. width: 100%;
  428. border-radius: 16px;
  429. transition-duration: 300ms;
  430. &:hover{
  431. transform: translateY(-2px);
  432. box-shadow: 0 2px 12px 0 #00000022;
  433. }
  434. .cover-upload{
  435. position: absolute;
  436. top: 0;
  437. left: 0;
  438. width: 100%;
  439. aspect-ratio: 2.4;
  440. .upload-icon{
  441. overflow: hidden;
  442. transition-duration: 300ms;
  443. opacity: 0;
  444. color: gray;
  445. width: 100%;
  446. height: 100%;
  447. display: flex;
  448. flex-direction: column;
  449. align-items: center;
  450. justify-content: center;
  451. backdrop-filter: blur(0px);
  452. .icon{
  453. font-size: 48px;
  454. }
  455. }
  456. &:hover{
  457. .upload-icon{
  458. backdrop-filter: blur(8px);
  459. opacity: 1;
  460. }
  461. }
  462. .uploader{
  463. opacity: 0;
  464. width: 100%;
  465. height: 100%;
  466. position: absolute;
  467. left: 0;
  468. top: 0;
  469. }
  470. }
  471. .avatar-name{
  472. position: relative;
  473. padding: 24px;
  474. display: grid;
  475. grid-template-columns: auto 1fr;
  476. align-items: center;
  477. grid-gap: 24px;
  478. .avatar-upload{
  479. position: absolute;
  480. top: 24px;
  481. left: 24px;
  482. width: 80px;
  483. height: 80px;
  484. .upload-icon{
  485. border-radius: 50%;
  486. transition-duration: 300ms;
  487. opacity: 0;
  488. color: gray;
  489. width: 100%;
  490. height: 100%;
  491. display: flex;
  492. flex-direction: column;
  493. align-items: center;
  494. justify-content: center;
  495. .icon{
  496. margin-top: -8px;
  497. font-size: 32px;
  498. }
  499. .text{
  500. line-height: 1;
  501. font-size: 12px;
  502. }
  503. }
  504. &:hover{
  505. .upload-icon{
  506. backdrop-filter: blur(8px);
  507. opacity: 1;
  508. }
  509. }
  510. .uploader{
  511. opacity: 0;
  512. width: 100%;
  513. height: 100%;
  514. position: absolute;
  515. left: 0;
  516. top: 0;
  517. }
  518. }
  519. .avatar{
  520. width: 80px;
  521. height: 80px;
  522. border-radius: 50%;
  523. }
  524. .name{
  525. font-size: 24px;
  526. font-weight: bold;
  527. }
  528. .exhibitor{
  529. color: gray;
  530. }
  531. }
  532. .image{
  533. object-fit: cover;
  534. width: 100%;
  535. aspect-ratio: 2.4;
  536. }
  537. }
  538. }
  539. }
  540. </style>