设计页面驻留调整

This commit is contained in:
aixianling
2022-11-09 11:54:15 +08:00
parent c48d86ee42
commit 8252fca39f
3 changed files with 92 additions and 134 deletions

View File

@@ -9,11 +9,12 @@ import List from './components/List.vue'
import Add from './components/Add' import Add from './components/Add'
import SourceData from './components/SourceData' import SourceData from './components/SourceData'
import Preview from "./components/preview"; import Preview from "./components/preview";
import DesignDashboard from "./components/Layout";
export default { export default {
name: 'AppDesigner', name: 'AppDesigner',
label: '大屏设计', label: '大屏设计',
components: {Preview, List, Add, SourceData}, components: {DesignDashboard, Preview, List, Add, SourceData},
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
@@ -29,7 +30,8 @@ export default {
const {hash} = this.$route const {hash} = this.$route
return hash == "#sourceData" ? SourceData : return hash == "#sourceData" ? SourceData :
hash == "#add" ? Add : hash == "#add" ? Add :
hash == "#preview" ? Preview : List hash == "#preview" ? Preview :
hash == "#design" ? DesignDashboard : List
}, },
tabs() { tabs() {
return [ return [

View File

@@ -27,7 +27,7 @@
</ai-card> </ai-card>
<ai-card title="大屏"> <ai-card title="大屏">
<template #right> <template #right>
<el-button @click="add('')" type="primary">添加大屏</el-button> <el-button @click="gotoDesign()" type="primary">添加大屏</el-button>
<el-button @click="dialog=true" type="primary">定制大屏</el-button> <el-button @click="dialog=true" type="primary">定制大屏</el-button>
</template> </template>
<template #content> <template #content>
@@ -62,16 +62,6 @@
</template> </template>
</ai-card> </ai-card>
</el-form> </el-form>
<Layout
v-if="isShowLayout"
:instance="instance"
:dict="dict"
:params="query"
@change="onChange"
:urlPrefix="urlPrefix"
:theme="config.theme"
@close="isShowLayout = false">
</Layout>
<ai-dialog :visible.sync="dialog" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV"> <ai-dialog :visible.sync="dialog" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV">
<el-form ref="CustomDVFrom" size="small" :model="custom" :rules="rules" label-width="80px"> <el-form ref="CustomDVFrom" size="small" :model="custom" :rules="rules" label-width="80px">
<el-form-item label="大屏标题" prop="title"> <el-form-item label="大屏标题" prop="title">
@@ -110,7 +100,6 @@ export default {
components: { components: {
Layout Layout
}, },
data() { data() {
return { return {
info: {}, info: {},
@@ -130,7 +119,6 @@ export default {
{prop: 'id', label: 'ID'} {prop: 'id', label: 'ID'}
], ],
tableData: [], tableData: [],
isShowLayout: false,
id: '', id: '',
dialog: false, dialog: false,
custom: {}, custom: {},
@@ -143,36 +131,32 @@ export default {
} }
} }
}, },
created() { created() {
this.dict.load('customizedDVs') this.dict.load('customizedDVs')
this.getInfo() this.getInfo().then(() => this.$route.params?.id && this.onChange(this.$route.params))
}, },
methods: {
getInfo() {
methods: { let {id} = this.$route.query
getInfo() { if (!id) return Promise.reject()
let {id} = this.$route.query return this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenProjectDetailById?id=${id}`).then(res => {
if (!id) return if (res?.data) {
this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenProjectDetailById?id=${id}`).then(res => { this.form = {
if (res?.data) { ...res.data
this.form = { }
...res.data if (res.data.relationLsIds) {
} this.tableData = res.data.lsList.map(v => {
if (res.data.relationLsIds) { let conf = JSON.parse(v.config || '') || {}
this.tableData = res.data.lsList.map(v => { return {
let conf = JSON.parse(v.config || '') || {} id: v.id,
return { title: v.title,
id: v.id, dv: conf.custom || '',
title: v.title, meta: JSON.stringify(conf.meta),
dv: conf.custom || '', isCustom: !!conf.custom,
meta: JSON.stringify(conf.meta), status: v.status
isCustom: !!conf.custom, }
status: v.status })
} this.total = res.data.lsList.length
})
this.total = res.data.lsList.length
this.$nextTick(() => { this.$nextTick(() => {
this.rowDrop() this.rowDrop()
}) })
@@ -180,15 +164,13 @@ export default {
} }
}) })
}, },
onStatusChange(id) {
onStatusChange (id) { this.instance.post(`${this.urlPrefix}/appdiylargescreen/enableLargeScreen?id=${id}`).then(res => {
this.instance.post(`${this.urlPrefix}/appdiylargescreen/enableLargeScreen?id=${id}`).then(res => { if (res.code === 0) {
if (res.code === 0) { this.$message.success('操作成功')
this.$message.success('操作成功') }
} })
}) },
},
rowDrop() { rowDrop() {
const tbody = document.querySelector('.el-table__body-wrapper tbody') const tbody = document.querySelector('.el-table__body-wrapper tbody')
const _this = this const _this = this
@@ -199,61 +181,46 @@ export default {
} }
}) })
}, },
toViewer(id) {
toViewer(id) { this.$router.push({query: {id}, hash: "#preview"})
this.$router.push({query: {id}, hash: "#preview"}) },
}, onChange(e) {
onChange(e) { const ids = this.tableData.map(v => v.id)
const ids = this.tableData.map(v => v.id) if (ids.indexOf(e.id) < 0) {
if (ids.indexOf(e.id) < 0) { this.tableData.push({
this.tableData.push({ title: e.title,
title: e.title, id: e.id,
id: e.id, status: '1'
status: '1' })
}) } else {
} else { const index = this.tableData.findIndex(v => v.id === e.id)
const index = this.tableData.findIndex(v => v.id === e.id) this.$set(this.tableData[index], 'title', e.title)
this.$set(this.tableData[index], 'title', e.title) }
} this.$nextTick(() => {
if (this.$route.query.id) {
this.$nextTick(() => { const ids = this.tableData.map(v => v.id).join(',')
if (this.$route.query.id) { const names = this.tableData.map(v => v.name).join(',')
const ids = this.tableData.map(v => v.id).join(',') this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, {
const names = this.tableData.map(v => v.name).join(',') ...this.form,
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, { relationLsIds: ids,
...this.form, relationLsNames: names
relationLsIds: ids, }).then(res => {
relationLsNames: names if (res.code == 0) {
}).then(res => { }
if (res.code == 0) { })
} }
}) })
} },
}) gotoDesign(did) {
}, const {id} = this.$route.query
this.$router.push({hash: "#design", query: {id, did, name: this.form.name}})
add() {
this.query = {
id: '',
name: this.form.name
}
this.isShowLayout = true
}, },
toEdit(id, isCustom, form) { toEdit(id, isCustom, form) {
if (!isCustom) { if (!isCustom) {
this.query = { this.gotoDesign(id)
id,
name: this.form.name
}
this.isShowLayout = true
} else { } else {
this.dialog = true this.dialog = true
this.custom = { this.custom = form
...form,
}
} }
}, },

View File

@@ -8,7 +8,7 @@
</div> </div>
<div class="layout-header__right"> <div class="layout-header__right">
<span type="text" @click="isShowImg = true">素材</span> <span type="text" @click="isShowImg = true">素材</span>
<span type="text" @click="back">退出</span> <span type="text" @click="back()">退出</span>
<span type="text" @click="save">保存</span> <span type="text" @click="save">保存</span>
</div> </div>
</div> </div>
@@ -60,7 +60,7 @@
width: bigscreenWidth + 'px', width: bigscreenWidth + 'px',
height: bigscreenHeight + 'px' height: bigscreenHeight + 'px'
}"> }">
<ai-dv-wrapper style="height: 100%" :title="params.name" :theme="dashboard.theme"> <ai-dv-wrapper style="height: 100%" :title="$route.query.name" :theme="dashboard.theme">
<div style="width: 100%; height: 100%"> <div style="width: 100%; height: 100%">
<AiDvBackground <AiDvBackground
:theme="dashboard.theme" :theme="dashboard.theme"
@@ -91,7 +91,7 @@
<div class="coordinate-top"></div> <div class="coordinate-top"></div>
<div class="coordinate-label">{{ item.left }}, {{ item.top }}</div> <div class="coordinate-label">{{ item.left }}, {{ item.top }}</div>
</div> </div>
<ai-dv-render :data="item" :theme="dashboard.theme" :index="index" :instance="instance" /> <ai-dv-render :data="item" :theme="dashboard.theme" :index="index" :instance="instance"/>
</vue-draggable-resizable> </vue-draggable-resizable>
</div> </div>
</ai-dv-wrapper> </ai-dv-wrapper>
@@ -242,7 +242,6 @@
ref="dataConfig" ref="dataConfig"
:instance="instance" :instance="instance"
:dict="dict" :dict="dict"
:urlPrefix="urlPrefix"
:options="currLayout" :options="currLayout"
@change="onChange('barChart')"> @change="onChange('barChart')">
</data-config> </data-config>
@@ -355,13 +354,11 @@ import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
import DataConfig from './form/DataConfig.vue' import DataConfig from './form/DataConfig.vue'
export default { export default {
name: "designDashboard",
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
params: Object,
urlPrefix: String
}, },
data() { data() {
return { return {
colConfigs: [ colConfigs: [
@@ -440,9 +437,7 @@ export default {
}, },
mounted() { mounted() {
if (this.params && this.params.id) { this.getInfo(this.$route.query.did)
this.getInfo(this.params.id)
}
this.$nextTick(() => { this.$nextTick(() => {
this.middleWidth = document.querySelector('.layout-wrapper').offsetWidth - 670 this.middleWidth = document.querySelector('.layout-wrapper').offsetWidth - 670
this.middleHeight = document.querySelector('.layout-wrapper').offsetHeight this.middleHeight = document.querySelector('.layout-wrapper').offsetHeight
@@ -451,15 +446,6 @@ export default {
}, },
methods: { methods: {
bindEvent() {
this.middleWidth = document.querySelector('.layout-wrapper').offsetWidth - 670
this.middleHeight = document.querySelector('.layout-wrapper').offsetHeight
this.$nextTick(() => {
this.initCanvas()
})
},
copy(link) { copy(link) {
let oInput = document.createElement('input') let oInput = document.createElement('input')
oInput.value = link oInput.value = link
@@ -506,7 +492,7 @@ export default {
}, },
getInfo(id) { getInfo(id) {
this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenDetailById?id=${id}`).then(res => { id && this.instance.post(`/app/appdiylargescreen/queryLargeScreenDetailById?id=${id}`).then(res => {
if (res.code === 0) { if (res.code === 0) {
const data = JSON.parse(res.data.config) const data = JSON.parse(res.data.config)
this.componentList = data.config this.componentList = data.config
@@ -516,29 +502,32 @@ export default {
}) })
}, },
back() { back(params) {
this.$emit('close') if (!!params) {
const {id} = this.$route.query
this.$router.push({hash: "#add", params, query: {id}})
} else {
this.$router.back()
}
}, },
save() { save() {
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreen`, { const {did: id} = this.$route.query, {dashboard} = this
this.instance.post(`/app/appdiylargescreen/addOrUpdateLargeScreen`, {
id,
config: JSON.stringify({ config: JSON.stringify({
config: this.componentList, config: this.componentList,
dashboard: this.dashboard, dashboard,
images: this.images images: this.images
}), }),
status: 1, status: 1,
title: this.dashboard.title, title: dashboard.title,
id: this.params.id || ''
}).then(res => { }).then(res => {
if (res.code == 0) { if (res?.code == 0) {
this.$message.success('保存成功') this.$message.success('保存成功')
this.$emit('change', res.data) this.back(res.data)
this.back()
} }
}) })
}, },
clone(e) { clone(e) {
this.componentList.push(this.deepClone(e)) this.componentList.push(this.deepClone(e))
}, },
@@ -617,8 +606,8 @@ export default {
}, },
initCanvas() { initCanvas() {
var widthScale = (this.middleWidth - this.widthPaddingTools) / this.bigscreenWidth let widthScale = (this.middleWidth - this.widthPaddingTools) / this.bigscreenWidth
var heightScale = (this.middleHeight - this.widthPaddingTools) / this.bigscreenHeight let heightScale = (this.middleHeight - this.widthPaddingTools) / this.bigscreenHeight
this.heightScale = Math.min(widthScale, heightScale) this.heightScale = Math.min(widthScale, heightScale)
} }
} }