123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <a-modal
- :visible="visible"
- title="创建房间"
- :after-close="onCancel"
- width="912px"
- @cancel="visible = false"
- >
- <template #footer>
- <a-button class="action-bottom" size="middle" @click="visible = false">
- 取消
- </a-button>
- <a-button
- class="action-bottom"
- type="primary"
- size="middle"
- @click="saveRoom"
- >
- 保存
- </a-button>
- <a-button
- class="action-bottom"
- type="primary"
- size="middle"
- @click="onSave && onSave(current)"
- >
- 开始带看
- </a-button>
- </template>
- <div class="edit-room-layout">
- <div class="scene">
- <template v-if="!current.scenes.length">
- {{ current }}
- </template>
- <iframe
- v-else
- :src="`https://test.4dkankan.com/spg.html?m=${current.scenes[0].num}`"
- frameborder="0"
- />
- </div>
- <a-form
- ref="formRef"
- class="info"
- :label-col="{ span: 24 }"
- :wrapper-col="{ span: 24 }"
- :model="current"
- >
- <h4>房间信息</h4>
- <a-form-item
- label="标题"
- name="title"
- :rules="[{ required: true, message: '标题为必填字段' }]"
- >
- <a-input v-model:value="current.title" :maxlength="15" show-count />
- </a-form-item>
- <a-form-item label="简介" name="desc">
- <a-textarea
- v-model:value="current.desc"
- no
- :maxlength="200"
- show-count
- />
- </a-form-item>
- <h4>主持人信息</h4>
- <a-form-item
- label="昵称"
- name="leaderName"
- :rules="[{ required: true, message: '请输入昵称' }]"
- >
- <a-input
- v-model:value="current.leaderName"
- :maxlength="15"
- show-count
- />
- </a-form-item>
- <h4>选择场景</h4>
- <EditScenes
- :scenes="current.scenes"
- @delete="deleteScene"
- @insert="scene => current.scenes.push(scene)"
- />
- </a-form>
- </div>
- </a-modal>
- </template>
- <script lang="ts">
- import { ref, defineComponent, reactive } from 'vue'
- import { createRoom } from '@/store'
- import { props } from './props'
- import EditScenes from './scene-list.vue'
- import type { RoomScene } from '@/store'
- import { FormInstance, message } from 'ant-design-vue'
- export default defineComponent({
- name: 'EditRoom',
- components: { EditScenes },
- props,
- setup(props) {
- const visible = ref(true)
- const formRef = ref<FormInstance>()
- const current = reactive(createRoom(props.room || {}))
- const deleteScene = (scene: RoomScene) => {
- const index = current.scenes.indexOf(scene)
- if (~index) {
- current.scenes.splice(index, 1)
- }
- }
- const saveRoom = async () => {
- try {
- await formRef.value?.validate()
- if (!current.scenes.length) {
- return message.error('至少添加一个场景')
- }
- current.cover = current.scenes[0].cover
- props.onSave && props.onSave(current)
- visible.value = false
- } catch (config: any) {
- if (config && config.errorFields && config.errorFields.length) {
- message.error(config.errorFields[0].errors.join(','))
- }
- }
- }
- return {
- visible,
- current,
- formRef,
- deleteScene,
- saveRoom
- }
- }
- })
- </script>
- <style lang="scss" scoped>
- .edit-room-layout {
- display: flex;
- }
- .scene {
- flex: none;
- width: 320px;
- margin-right: 30px;
- height: 692px;
- background: #f7f8fa;
- iframe {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- flex: 1;
- h4 {
- font-size: 18px;
- color: #333;
- font-weight: 400;
- &:not(:first-child) {
- margin-top: 20px;
- }
- }
- }
- </style>
- <style lang="scss">
- .edit-room-layout {
- .ant-form-item {
- margin-bottom: 16px;
- }
- .ant-input-affix-wrapper,
- .ant-input {
- border-radius: 4px 4px 4px 4px;
- opacity: 1;
- border: 1px solid #ebedf0;
- padding: 6px 11px;
- // height: 36px;
- }
- textarea.ant-input {
- resize: none;
- height: 120px;
- }
- .ant-input-textarea {
- position: relative;
- &::after {
- position: absolute;
- bottom: 4px;
- right: 8px;
- margin: 0;
- }
- }
- .ant-form-item-label {
- padding-bottom: 0;
- > label {
- color: #646566;
- }
- }
- }
- .action-bottom {
- border-radius: 4px;
- min-width: 100px;
- }
- </style>
|