|
@@ -95,6 +95,17 @@
|
|
|
:dark="false"
|
|
|
@close="showPreview = false"
|
|
|
/>
|
|
|
+ <div class="dialog" style="z-index: 10" v-if="isShowMaterialSelector">
|
|
|
+ <MaterialSelector
|
|
|
+ title="选择素材"
|
|
|
+ @cancle="isShowMaterialSelector = false"
|
|
|
+ @submit="handleSubmitFromMaterialSelector"
|
|
|
+ :selectableType="['pano', '3D']"
|
|
|
+ :isMultiSelection="true"
|
|
|
+ :workId="newWorkId"
|
|
|
+ initialMaterialType="pano"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -104,12 +115,16 @@ import preview from "@/components/preview";
|
|
|
import workCardSkeleton from "@/components/workCardSkeleton.vue";
|
|
|
import config from "@/config";
|
|
|
import { debounce } from "@/utils/other.js"
|
|
|
+import MaterialSelector from "@/components/materialSelectorForManageCenter.vue";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import Popup from "@/components/shared/popup";
|
|
|
|
|
|
import {
|
|
|
addWorks,
|
|
|
getWorksList,
|
|
|
delWorks,
|
|
|
- getPanoInfo
|
|
|
+ getPanoInfo,
|
|
|
+ saveWorks,
|
|
|
} from "@/api";
|
|
|
|
|
|
export default {
|
|
@@ -117,6 +132,12 @@ export default {
|
|
|
share,
|
|
|
preview,
|
|
|
workCardSkeleton,
|
|
|
+ MaterialSelector,
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters([
|
|
|
+ 'info',
|
|
|
+ ])
|
|
|
},
|
|
|
data(){
|
|
|
return {
|
|
@@ -141,6 +162,9 @@ export default {
|
|
|
isShowBackTopBtn: false,
|
|
|
|
|
|
isShowMask: false,
|
|
|
+
|
|
|
+ isShowMaterialSelector: false,
|
|
|
+ newWorkId: '',
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
@@ -190,9 +214,102 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
add(){
|
|
|
- addWorks({},(data)=>{
|
|
|
- window.open(`./edit.html?id=${data.data.id}`)
|
|
|
- })
|
|
|
+ // 新建作品,弹窗让用户给作品选择素材。
|
|
|
+ addWorks(
|
|
|
+ {},
|
|
|
+ (res) => {
|
|
|
+ this.newWorkId = res.data.id
|
|
|
+ this.isShowMaterialSelector = true
|
|
|
+ },
|
|
|
+ )
|
|
|
+ },
|
|
|
+ handleSubmitFromMaterialSelector(selected) {
|
|
|
+ // 拿新作品的初始数据
|
|
|
+ getPanoInfo(
|
|
|
+ this.newWorkId,
|
|
|
+ // 拿到了。
|
|
|
+ (data) => {
|
|
|
+ // 往里边添加用户选中的素材。
|
|
|
+ this.$store.commit("SetInfo", data);
|
|
|
+ for (const item of selected) {
|
|
|
+ if (item.materialType === 'pano') {
|
|
|
+ this.info.scenes.push({
|
|
|
+ icon: item.icon,
|
|
|
+ sceneCode: item.sceneCode,
|
|
|
+ sceneTitle: item.name,
|
|
|
+ category: this.info.catalogs[0].id,
|
|
|
+ type: "pano",
|
|
|
+ id: 's_' + this.$randomWord(true, 8, 8)
|
|
|
+ })
|
|
|
+ } else if (item.materialType === '3D') {
|
|
|
+ this.info.scenes.push({
|
|
|
+ icon: item.thumb,
|
|
|
+ sceneCode: item.num,
|
|
|
+ sceneTitle: item.sceneName,
|
|
|
+ category: this.info.catalogs[0].id,
|
|
|
+ type: "4dkk",
|
|
|
+ id:'s_'+this.$randomWord(true,8,8)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存新作品
|
|
|
+ saveWorks(
|
|
|
+ {
|
|
|
+ id: this.newWorkId,
|
|
|
+ password: '',
|
|
|
+ someData: { ...this.info, status: 1 },
|
|
|
+ },
|
|
|
+ // 保存成功
|
|
|
+ () => {
|
|
|
+ // 隐藏素材选择弹窗
|
|
|
+ this.isShowMaterialSelector = false
|
|
|
+
|
|
|
+ // 刷新作品列表
|
|
|
+ this.list = []
|
|
|
+ this.isRequestingMoreData = false
|
|
|
+ this.hasMoreData = true
|
|
|
+ this.requestMoreData().then(() => {
|
|
|
+ // 刷新成功
|
|
|
+
|
|
|
+ // 弹出提示窗口
|
|
|
+ this.$confirm({
|
|
|
+ title:'提示',
|
|
|
+ content: "您已成功创建作品!",
|
|
|
+ okText: '预览一下',
|
|
|
+ ok: () => {
|
|
|
+ this.handlePreview(this.list[0])
|
|
|
+ this.newWorkId = ''
|
|
|
+ this.$store.commit("SetInfo", {});
|
|
|
+ },
|
|
|
+ ok2Text: '继续编辑',
|
|
|
+ ok2: () => {
|
|
|
+ window.open(`./edit.html?id=${this.newWorkId}`)
|
|
|
+ this.newWorkId = ''
|
|
|
+ this.$store.commit("SetInfo", {});
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }).catch(() => {
|
|
|
+ this.$msg.message('已成功新建作品,但刷新作品列表失败,请稍后手动刷新。')
|
|
|
+ console.error('已成功新建作品,但刷新作品列表失败。')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 保存失败,删除新建的作品。
|
|
|
+ (error) => {
|
|
|
+ console.error('保存失败:', error);
|
|
|
+ delWorks(this.newWorkId)
|
|
|
+ this.newWorkId = ''
|
|
|
+ this.$store.commit("SetInfo", {});
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ // 没拿到,删除新建的作品。
|
|
|
+ (error) => {
|
|
|
+ console.error('没拿到新建的作品数据:', error);
|
|
|
+ delWorks(this.newWorkId)
|
|
|
+ this.newWorkId = ''
|
|
|
+ }
|
|
|
+ )
|
|
|
},
|
|
|
edit(item){
|
|
|
window.open(`./edit.html?id=${item.id}`)
|
|
@@ -240,32 +357,36 @@ export default {
|
|
|
requestMoreData() {
|
|
|
this.isRequestingMoreData = true
|
|
|
const lastestUsedSearchKey = this.searchKey
|
|
|
- getWorksList(
|
|
|
- {
|
|
|
- pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
|
|
|
- pageSize: config.PAGE_SIZE,
|
|
|
- searchKey: this.searchKey,
|
|
|
- },
|
|
|
- (data) => {
|
|
|
- this.list = this.list.concat(data.data.list)
|
|
|
- if (this.list.length === data.data.total) {
|
|
|
- this.hasMoreData = false
|
|
|
- }
|
|
|
- this.isRequestingMoreData = false
|
|
|
- this.lastestUsedSearchKey = lastestUsedSearchKey
|
|
|
- if (!lastestUsedSearchKey) {
|
|
|
- this.workTotalNum = data.data.total
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWorksList(
|
|
|
+ {
|
|
|
+ pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
|
|
|
+ pageSize: config.PAGE_SIZE,
|
|
|
+ searchKey: this.searchKey,
|
|
|
+ },
|
|
|
+ (data) => {
|
|
|
+ this.list = this.list.concat(data.data.list)
|
|
|
+ if (this.list.length === data.data.total) {
|
|
|
+ this.hasMoreData = false
|
|
|
+ }
|
|
|
+ this.isRequestingMoreData = false
|
|
|
+ this.lastestUsedSearchKey = lastestUsedSearchKey
|
|
|
+ if (!lastestUsedSearchKey) {
|
|
|
+ this.workTotalNum = data.data.total
|
|
|
+ }
|
|
|
+ // TODO: 这是干啥呢?
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.$bus.emit('refreshTips')
|
|
|
+ })
|
|
|
+ resolve()
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ this.isRequestingMoreData = false
|
|
|
+ this.lastestUsedSearchKey = lastestUsedSearchKey
|
|
|
+ reject()
|
|
|
}
|
|
|
- // TODO: 这是干啥呢?
|
|
|
- this.$nextTick(()=>{
|
|
|
- this.$bus.emit('refreshTips')
|
|
|
- })
|
|
|
- },
|
|
|
- () => {
|
|
|
- this.isRequestingMoreData = false
|
|
|
- this.lastestUsedSearchKey = lastestUsedSearchKey
|
|
|
- }
|
|
|
- );
|
|
|
+ );
|
|
|
+ })
|
|
|
},
|
|
|
onClickBackTop() {
|
|
|
if (this.isBackingTop) {
|