exhibitorSetting.vue 19 KB

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