exhibitorSetting.vue 20 KB

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