调整工程结构,并进行了优化
This commit is contained in:
@@ -1,289 +0,0 @@
|
||||
<template>
|
||||
<ai-detail>
|
||||
<template slot="title">
|
||||
<ai-title :title="isEdit ? '编辑项目' : '添加项目'" isShowBack isShowBottomBorder @onBackClick="cancel"/>
|
||||
</template>
|
||||
<template slot="content">
|
||||
<el-form ref="form" :model="form" label-width="110px" label-position="right">
|
||||
<ai-card title="基本信息">
|
||||
<template #content>
|
||||
<div class="ai-form">
|
||||
<el-form-item label="名称" prop="name"
|
||||
:rules="[{ required: true, message: '请输入大屏项目名称', trigger: 'blur' }]">
|
||||
<el-input size="small" :maxlength="30" placeholder="请输入大屏项目名称" v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" style="width: 100%;" prop="description">
|
||||
<el-input size="small" :maxlength="200" :rows="5" type="textarea" style="width: 100%;"
|
||||
placeholder="请输入描述"
|
||||
v-model="form.description"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否开启" style="width: 100%;" prop="status">
|
||||
<el-switch
|
||||
v-model="form.status"
|
||||
active-value="1"
|
||||
inactive-value="0">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</ai-card>
|
||||
<ai-card title="大屏" v-if="isEdit">
|
||||
<template #right>
|
||||
<el-button @click="gotoDesign()" type="primary">添加大屏</el-button>
|
||||
<el-button @click="dialog=true" type="primary">定制大屏</el-button>
|
||||
</template>
|
||||
<template #content>
|
||||
<ai-table
|
||||
:tableData="tableData"
|
||||
:col-configs="colConfigs"
|
||||
:total="total"
|
||||
style="margin-top: 6px;"
|
||||
:border="true"
|
||||
row-key="id"
|
||||
:isShowPagination="false"
|
||||
@getList="() => {}">
|
||||
<el-table-column slot="options" label="状态" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-switch
|
||||
v-model="row.status"
|
||||
active-value="1"
|
||||
@change="() => onStatusChange(row.id)">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column slot="options" width="160px" fixed="right" label="操作" align="center">
|
||||
<template slot-scope="{ row, column, $index }">
|
||||
<div class="table-options">
|
||||
<el-button type="text" @click="toEdit(row.id, row.isCustom, row)">编辑</el-button>
|
||||
<el-button type="text" @click="toViewer(row.id)">预览</el-button>
|
||||
<el-button type="text" @click="remove($index)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
</template>
|
||||
</ai-card>
|
||||
</el-form>
|
||||
<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-item label="大屏标题" prop="title">
|
||||
<el-input v-model="custom.title" clearable placeholder="请填写"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择大屏" prop="dv">
|
||||
<ai-select v-model="custom.dv" :selectList="dict.getDict('customizedDVs')"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="静态数据">
|
||||
<el-input type="textarea" rows="5" v-model="custom.meta"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ai-dialog>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
<el-button type="primary" @click="confirm">提交</el-button>
|
||||
</template>
|
||||
</ai-detail>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Layout from './Layout.vue'
|
||||
import Sortable from 'sortablejs'
|
||||
import {mapActions} from "vuex"
|
||||
|
||||
export default {
|
||||
name: 'Add',
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
urlPrefix: String
|
||||
},
|
||||
inject: {
|
||||
home: {default: ''}
|
||||
},
|
||||
components: {
|
||||
Layout
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
info: {},
|
||||
department: [],
|
||||
form: {
|
||||
name: '',
|
||||
relationLsIds: '',
|
||||
relationLsNames: '',
|
||||
status: '1',
|
||||
description: ''
|
||||
},
|
||||
screenId: '',
|
||||
query: {},
|
||||
total: 0,
|
||||
colConfigs: [
|
||||
{prop: 'title', label: '标题'},
|
||||
{prop: 'id', label: 'ID'}
|
||||
],
|
||||
tableData: [],
|
||||
id: '',
|
||||
dialog: false,
|
||||
custom: {},
|
||||
rules: {
|
||||
dv: [{required: true, message: "请选择 定制大屏"}],
|
||||
title: [{required: true, message: "请输入 大屏标题"}],
|
||||
},
|
||||
config: {
|
||||
backgroundImage: []
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isEdit: v => !!v.$route.query.id
|
||||
},
|
||||
created() {
|
||||
this.dict.load('customizedDVs')
|
||||
this.getInfo()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['closePage']),
|
||||
getInfo() {
|
||||
let {id} = this.$route.query
|
||||
if (!id) return Promise.reject()
|
||||
return this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenProjectDetailById?id=${id}`).then(res => {
|
||||
if (res?.data) {
|
||||
this.form = {
|
||||
...res.data
|
||||
}
|
||||
if (res.data.relationLsIds) {
|
||||
this.tableData = res.data.lsList.map(v => {
|
||||
let conf = JSON.parse(v.config || '') || {}
|
||||
return {
|
||||
id: v.id,
|
||||
title: v.title,
|
||||
dv: conf.custom || '',
|
||||
meta: JSON.stringify(conf.meta),
|
||||
isCustom: !!conf.custom,
|
||||
status: v.status
|
||||
}
|
||||
})
|
||||
this.total = res.data.lsList.length
|
||||
this.$nextTick(() => {
|
||||
this.rowDrop()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onStatusChange(id) {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/enableLargeScreen?id=${id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success('操作成功')
|
||||
}
|
||||
})
|
||||
},
|
||||
rowDrop() {
|
||||
const tbody = document.querySelector('.el-table__body-wrapper tbody')
|
||||
const _this = this
|
||||
Sortable.create(tbody, {
|
||||
onEnd({newIndex, oldIndex}) {
|
||||
const currRow = _this.tableData.splice(oldIndex, 1)[0]
|
||||
_this.tableData.splice(newIndex, 0, currRow)
|
||||
}
|
||||
})
|
||||
},
|
||||
toViewer(id) {
|
||||
this.$router.push({query: {id}, hash: "#preview"})
|
||||
},
|
||||
onChange(e) {
|
||||
const ids = this.tableData.map(v => v.id)
|
||||
if (ids.indexOf(e.id) < 0) {
|
||||
this.tableData.push({
|
||||
title: e.title,
|
||||
id: e.id,
|
||||
status: '1'
|
||||
})
|
||||
} else {
|
||||
const index = this.tableData.findIndex(v => v.id === e.id)
|
||||
this.$set(this.tableData[index], 'title', e.title)
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (this.$route.query.id) {
|
||||
const ids = this.tableData.map(v => v.id).join(',')
|
||||
const names = this.tableData.map(v => v.name).join(',')
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, {
|
||||
...this.form,
|
||||
relationLsIds: ids,
|
||||
relationLsNames: names
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
gotoDesign(did) {
|
||||
const {id} = this.$route.query
|
||||
this.$router.push({hash: "#design", query: {id, did, name: this.form.name}})
|
||||
},
|
||||
toEdit(id, isCustom, form) {
|
||||
if (!isCustom) {
|
||||
this.gotoDesign(id)
|
||||
} else {
|
||||
this.dialog = true
|
||||
this.custom = form
|
||||
}
|
||||
},
|
||||
|
||||
remove(index) {
|
||||
this.tableData.splice(index, 1)
|
||||
},
|
||||
|
||||
confirm() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const ids = this.tableData.map(v => v.id).join(',')
|
||||
const names = this.tableData.map(v => v.name).join(',')
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, {
|
||||
...this.form,
|
||||
relationLsIds: ids,
|
||||
relationLsNames: names
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('提交成功')
|
||||
|
||||
this.home && this.home.refreshDvOptions && this.home.refreshDvOptions()
|
||||
setTimeout(() => {
|
||||
this.cancel()
|
||||
}, 600)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.closePage()
|
||||
this.$router.push({})
|
||||
},
|
||||
|
||||
handleCustomizedDV() {
|
||||
this.$refs.CustomDVFrom.validate(v => {
|
||||
if (v) {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreen`, {
|
||||
config: JSON.stringify({
|
||||
custom: this.custom.dv,
|
||||
meta: JSON.parse(this.custom.meta?.replace(/\\n/g, '') || null)
|
||||
}),
|
||||
status: 1,
|
||||
id: this.custom.id,
|
||||
title: this.custom.title,
|
||||
}).then(res => {
|
||||
if (res?.code == 0 && res?.data) {
|
||||
this.$message.success('保存成功')
|
||||
this.onChange(res.data)
|
||||
this.dialog = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
@@ -13,7 +13,7 @@
|
||||
</config-item>
|
||||
</ai-fold>
|
||||
<ai-fold title="标记点连线">
|
||||
<ai-dialog-btn :modal="false" dialog-title="设置标记点连线" :customFooter="false" @onConfirm="savePolylines"
|
||||
<ai-dialog-btn :modal="false" dialog-title="设置标记点连线" :customFooter="false" @confirm="savePolylines"
|
||||
@open="handleMapPolylines">
|
||||
<code-editor slot="btn" readonly :value="JSON.stringify(options.staticData.polylines, null, 2)" lang="json"
|
||||
theme="github" width="100%" height="250" placeholder="测试默认值"/>
|
||||
@@ -36,25 +36,8 @@
|
||||
<config-item label="图表模板">
|
||||
<chart-picker v-model="chart.chart"/>
|
||||
</config-item>
|
||||
<config-item label="数据类型">
|
||||
<ai-select v-model="chart.dataType" placeholder="请选择数据类型" :select-list="dataTypes"/>
|
||||
</config-item>
|
||||
<config-item v-if="chart.dataType=='dynamicData'" label="数据源">
|
||||
<ai-select v-model="chart.sourceDataId" placeholder="请选择数据源" :select-list="sourceData"
|
||||
:prop="{label:'description'}"/>
|
||||
</config-item>
|
||||
<div class="layout-config__code" v-else-if="chart.dataType === 'staticData'">
|
||||
<ai-dialog-btn :modal="false" dialog-title="编辑器" :customFooter="false"
|
||||
@confirm="chart.data=JSON.parse(json)"
|
||||
@open="json=JSON.stringify(chart.data||null)">
|
||||
<code-editor slot="btn" readonly :value="JSON.stringify(chart.data)" lang="json" theme="github"
|
||||
width="100%" height="250"/>
|
||||
<code-editor v-model="json" lang="json" theme="github" width="100%" height="440"/>
|
||||
</ai-dialog-btn>
|
||||
</div>
|
||||
<config-item label="接口地址" v-else-if="chart.dataType=='apiData'">
|
||||
<el-input size="mini" v-model="chart.api"/>
|
||||
</config-item>
|
||||
<datasource-picker v-model="chart.ds" :instance="instance"
|
||||
@input="chart={...chart,...chart.ds},$emit('change')"/>
|
||||
<config-item label="数据维度" v-if="chart.dataType !== 'staticData'">
|
||||
<code-editor v-model="chart.djson" lang="json" theme="github" width="100%" height="100"
|
||||
placeholder="参照echarts配置数据维度,为一个数组,数组的第一个值为维度值"
|
||||
@@ -71,24 +54,7 @@
|
||||
</div>
|
||||
<div class="layout-config__group" v-else>
|
||||
<h2>基础设置</h2>
|
||||
<config-item label="数据类型">
|
||||
<ai-select v-model="options.dataType" placeholder="请选择数据类型" :select-list="dataTypes"/>
|
||||
</config-item>
|
||||
<div class="layout-config__code" v-if="options.dataType === 'staticData'">
|
||||
<ai-dialog-btn :modal="false" dialog-title="编辑器" :customFooter="false" @onConfirm="onConfirm"
|
||||
@open="showEditor">
|
||||
<code-editor slot="btn" readonly :value="JSON.stringify(options.staticData)" lang="json" theme="github"
|
||||
width="100%" height="250"/>
|
||||
<code-editor v-model="json" lang="json" theme="github" width="100%" height="440"/>
|
||||
</ai-dialog-btn>
|
||||
</div>
|
||||
<config-item v-else-if="options.dataType === 'dynamicData'" label="数据源">
|
||||
<ai-select v-model="options.sourceDataId" placeholder="请选择数据源" :select-list="sourceData"
|
||||
:prop="{label:'description'}" @change="onDataChange"/>
|
||||
</config-item>
|
||||
<config-item label="接口地址" v-else>
|
||||
<el-input size="mini" v-model="options.api" @change="onApiChange"/>
|
||||
</config-item>
|
||||
<datasource-picker v-model="options" :instance="instance" @input="$emit('change')"/>
|
||||
</div>
|
||||
<div v-if="options.dataType!='staticData'&&options.type=='monitor'&&['cmcc','slw'].includes(options.monitorType)"
|
||||
class="layout-config__group">
|
||||
@@ -163,8 +129,10 @@ import 'brace/theme/github';
|
||||
import 'brace/theme/monokai';
|
||||
import AiDialogBtn from "dui/packages/layout/AiDialogBtn.vue";
|
||||
import AiFold from "dui/packages/layout/AiFold.vue";
|
||||
import ChartPicker from "../chartPicker.vue";
|
||||
import {DvCompData} from "../../config";
|
||||
import ChartPicker from "./chartPicker.vue";
|
||||
import {DvCompData} from "../config";
|
||||
import ConfigItem from "./configItem.vue";
|
||||
import DatasourcePicker from "./datasourcePicker.vue";
|
||||
|
||||
export default {
|
||||
name: 'dataConfig',
|
||||
@@ -181,8 +149,6 @@ export default {
|
||||
return {
|
||||
dataTypes: Object.entries(DvCompData.types).map(e => ({id: e[0], label: e[1]})),
|
||||
json: "",
|
||||
sourceDataId: '',
|
||||
sourceData: [],
|
||||
keys: [],
|
||||
monitorList: [],
|
||||
list: [],
|
||||
@@ -194,21 +160,12 @@ export default {
|
||||
markers: v => v.options.staticData?.markers || [],
|
||||
},
|
||||
components: {
|
||||
DatasourcePicker,
|
||||
ConfigItem,
|
||||
ChartPicker,
|
||||
AiFold,
|
||||
AiDialogBtn,
|
||||
CodeEditor,
|
||||
configItem: {
|
||||
props: {
|
||||
label: String
|
||||
},
|
||||
render(h) {
|
||||
return h('div', {class: 'layout-config__item'}, [
|
||||
h('label', this.label),
|
||||
h('div', {class: 'layout-config__item--right fill'}, this.$slots.default)
|
||||
])
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.options.type == "map" && Array.isArray(this.options.staticData)) {//处理历史数据,并更新最新数据结构
|
||||
@@ -218,7 +175,6 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getDataList()
|
||||
if ((this.options.dataY && this.options.dataY.length && this.options.dataX) || this.options.type === 'monitor') {
|
||||
const api = this.options.dataType === 'apiData' ? this.options.api : `/app/appdiylargescreen/statisticsByLsid?id=${this.options.sourceDataId}`
|
||||
this.instance.post(api).then(res => {
|
||||
@@ -246,10 +202,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showEditor() {
|
||||
this.json = JSON.stringify(this.options.staticData, null, 2)
|
||||
},
|
||||
|
||||
onMoniterId(e) {
|
||||
this.instance.post(`/app/appzyvideoequipment/getWebSdkUrl?deviceId=${e}`).then(res => {
|
||||
if (res.code == 0) {
|
||||
@@ -257,64 +209,6 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getDataList() {
|
||||
this.instance.post(`/app/appdiylargescreen/allDatasourceByPage`, null, {
|
||||
params: {
|
||||
current: 1,
|
||||
size: 10000
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.sourceData = res.data.records
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onApiChange() {
|
||||
this.options.dataX = ''
|
||||
this.options.dataY = []
|
||||
this.instance.post(this.options.api).then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data.length) {
|
||||
if (this.options.type === 'table' || this.options.type === 'AiDvTable') {
|
||||
const keys = Object.keys(res.data[0])
|
||||
const list = res.data
|
||||
this.options.apiData = keys.map(v => {
|
||||
let obj = {}
|
||||
list.forEach((item, index) => {
|
||||
obj[`v${index}`] = item[v]
|
||||
})
|
||||
|
||||
return {
|
||||
row: v,
|
||||
...obj
|
||||
}
|
||||
})
|
||||
} else if (this.options.type === 'summary') {
|
||||
if (this.options.display === 'summary9') {
|
||||
this.options.apiData = res.data
|
||||
} else {
|
||||
this.options.apiData = Object.keys(res.data[0]).map(item => {
|
||||
return {
|
||||
key: item,
|
||||
value: res.data[0][item]
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (this.options.type === 'monitor') {
|
||||
this.monitorList = res.data
|
||||
} else {
|
||||
this.list = res.data
|
||||
this.keys = Object.keys(res.data[0])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.options.dynamicData = []
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onChooseChange() {
|
||||
let arr = []
|
||||
if (this.options.dataX && this.options.dataY.length) {
|
||||
@@ -328,53 +222,9 @@ export default {
|
||||
...obj
|
||||
})
|
||||
})
|
||||
|
||||
this.options[this.options.dataType] = arr
|
||||
}
|
||||
},
|
||||
|
||||
onDataChange(e) {
|
||||
this.options.dataX = ''
|
||||
this.options.dataY = []
|
||||
this.instance.post(`/app/appdiylargescreen/statisticsByLsid?id=${e}`).then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data.length) {
|
||||
if (this.options.type === 'table' || this.options.type === 'AiDvTable') {
|
||||
const keys = Object.keys(res.data[0])
|
||||
const list = res.data
|
||||
this.options.dynamicData = keys.map(v => {
|
||||
let obj = {}
|
||||
list.forEach((item, index) => {
|
||||
obj[`v${index}`] = item[v]
|
||||
})
|
||||
|
||||
return {
|
||||
row: v,
|
||||
...obj
|
||||
}
|
||||
})
|
||||
} else if (this.options.type === 'summary') {
|
||||
this.options.dynamicData = Object.keys(res.data[0]).map(item => {
|
||||
return {
|
||||
key: item,
|
||||
value: res.data[0][item]
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.list = res.data
|
||||
this.keys = Object.keys(res.data[0])
|
||||
}
|
||||
} else {
|
||||
this.options.dynamicData = []
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.$set(this.options, 'staticData', JSON.parse(this.json))
|
||||
this.$emit('change')
|
||||
},
|
||||
handleMapMarker(v = {}, index) {
|
||||
this.form = this.$copy({...v, index})
|
||||
this.showMapEditor = true
|
||||
@@ -423,8 +273,6 @@ export default {
|
||||
}
|
||||
|
||||
.layout-config__group--wrapper {
|
||||
.layout-config__code .bin-ace-editor {
|
||||
}
|
||||
|
||||
:deep(.layout-config__group) {
|
||||
padding: 10px 10px 20px;
|
||||
@@ -434,10 +282,6 @@ export default {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.layout-config__code {
|
||||
position: relative;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
& > h2 {
|
||||
margin-bottom: 20px;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,167 +0,0 @@
|
||||
<template>
|
||||
<ai-list>
|
||||
<ai-title slot="title" title="大屏列表" isShowBottomBorder/>
|
||||
<template slot="content">
|
||||
<ai-search-bar>
|
||||
<template #left>
|
||||
<ai-select
|
||||
v-model="search.status"
|
||||
@change="search.current = 1, getList()"
|
||||
placeholder="发布状态"
|
||||
:selectList="dict.getDict('cwpStatus')">
|
||||
</ai-select>
|
||||
<el-button type="primary" @click="toEdit('')">添加大屏</el-button>
|
||||
<el-button type="primary" @click="toAddData">数据源管理</el-button>
|
||||
</template>
|
||||
<template #right>
|
||||
<el-input
|
||||
v-model="search.name"
|
||||
size="small"
|
||||
placeholder="请输入模板名称或创建人"
|
||||
clearable
|
||||
v-throttle="() => {search.current = 1, getList()}"
|
||||
@clear="search.current = 1, search.title = '', getList()"
|
||||
suffix-icon="iconfont iconSearch">
|
||||
</el-input>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
:tableData="tableData"
|
||||
:col-configs="colConfigs"
|
||||
:total="total"
|
||||
v-loading="loading"
|
||||
style="margin-top: 6px;"
|
||||
:current.sync="search.current"
|
||||
:size.sync="search.size"
|
||||
@getList="getList" :dict="dict">
|
||||
<el-table-column slot="options" width="160px" fixed="right" label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<div class="table-options">
|
||||
<el-button type="text" @click="toEdit(row.id)">编辑</el-button>
|
||||
<el-button type="text" @click="copy(row.id)">复制</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
<ai-dialog
|
||||
:visible.sync="isShowAdd"
|
||||
width="780px"
|
||||
title="复制大屏"
|
||||
@close="onClose"
|
||||
@onConfirm="onConfirm">
|
||||
<el-form ref="form" :model="form" label-width="110px" label-position="right">
|
||||
<div class="ai-form" :model="form" label-width="110px" label-position="right">
|
||||
<el-form-item label="名称" prop="name" style="width: 100%;" :rules="[{ required: true, message: '请输入名称', trigger: 'blur' }]">
|
||||
<el-input size="small" placeholder="请输入名称" v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</ai-dialog>
|
||||
</template>
|
||||
</ai-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'FormList',
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
areaId: String,
|
||||
urlPrefix: String
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
search: {
|
||||
current: 1,
|
||||
status: '',
|
||||
size: 10,
|
||||
name: ''
|
||||
},
|
||||
form: {
|
||||
name: ''
|
||||
},
|
||||
id: '',
|
||||
isShowAdd: false,
|
||||
colConfigs: [
|
||||
{prop: 'name', label: '模板名称'},
|
||||
{prop: 'createUserName', align: 'center', label: '创建人'},
|
||||
{prop: 'description', align: 'center', label: '描述'},
|
||||
{prop: 'status', align: 'center', label: '状态', dict:"cwpStatus"},
|
||||
{prop: 'createTime', align: 'center', label: '创建时间'}
|
||||
],
|
||||
tableData: [],
|
||||
total: 0,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
|
||||
this.dict.load('cwpStatus').then(() => {
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.loading = true
|
||||
},
|
||||
|
||||
methods: {
|
||||
copy(id) {
|
||||
this.id = id
|
||||
this.isShowAdd = true
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.id = ''
|
||||
this.form.name = ''
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/copyLargeScreenProject`, null, {
|
||||
params: {
|
||||
...this.form,
|
||||
id: this.id
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success('复制成功')
|
||||
this.isShowAdd = false
|
||||
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getList() {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/allLargeScreenProjectByPage`, null, {
|
||||
params: {
|
||||
...this.search
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.tableData = res.data.records
|
||||
this.total = res.data.total
|
||||
this.loading = false
|
||||
} else {
|
||||
this.loading = false
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
toEdit(id) {
|
||||
this.$router.push({hash: "#add", query: {id}})
|
||||
},
|
||||
toAddData() {
|
||||
this.$router.push({hash: "#sourceData"})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,460 +0,0 @@
|
||||
<template>
|
||||
<ai-detail>
|
||||
<template slot="title">
|
||||
<ai-title title="数据源" isShowBack isShowBottomBorder @onBackClick="cancel">
|
||||
</ai-title>
|
||||
</template>
|
||||
<template slot="content">
|
||||
<ai-card title="数据源列表">
|
||||
<template #right>
|
||||
<el-button type="primary" @click="isShow = true">添加数据源</el-button>
|
||||
</template>
|
||||
<template #content>
|
||||
<ai-search-bar class="search-bar">
|
||||
<template slot="right">
|
||||
<el-input
|
||||
v-model="search.name"
|
||||
size="small"
|
||||
v-throttle="() => {search.current = 1, getList()}"
|
||||
placeholder="请输入名字"
|
||||
clearable
|
||||
@clear="search.current = 1, search.name = '', getList()"
|
||||
suffix-icon="iconfont iconSearch">
|
||||
</el-input>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
:tableData="tableData"
|
||||
:col-configs="colConfigs"
|
||||
:total="total"
|
||||
style="margin-top: 6px;"
|
||||
:border="true"
|
||||
:current.sync="search.current"
|
||||
:size.sync="search.size"
|
||||
@getList="getList">
|
||||
<el-table-column slot="options" width="160px" fixed="right" label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<div class="table-options">
|
||||
<el-button type="text" @click="toEdit(row)">编辑</el-button>
|
||||
<el-button type="text" @click="remove(row.id)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
</template>
|
||||
</ai-card>
|
||||
<ai-dialog
|
||||
:visible.sync="isShow"
|
||||
width="920px"
|
||||
title="数据源"
|
||||
@close="onClose"
|
||||
@onConfirm="onConfirm">
|
||||
<el-form ref="form" :model="form" label-width="110px" label-position="right">
|
||||
<div class="ai-form">
|
||||
<el-form-item label="数据源描述" style="width: 100%;" prop="description" :rules="[{ required: true, message: '请输入数据源描述', trigger: 'blur' }]">
|
||||
<el-input
|
||||
size="small"
|
||||
placeholder="请输入数据源描述"
|
||||
v-model="form.description">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" style="width: 100%;" prop="dataRange" :rules="[{ required: true, message: '请选择数据范围', trigger: 'change' }]">
|
||||
<el-radio-group v-model="form.type">
|
||||
<el-radio label="0">村微应用</el-radio>
|
||||
<el-radio label="1">SQL</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type === '1'" label="sql语句" style="width: 100%;" prop="description"
|
||||
:rules="[{ required: true, message: '请输入sql语句', trigger: 'blur' }]">
|
||||
<el-input
|
||||
:rows="8"
|
||||
size="small"
|
||||
type="textarea"
|
||||
placeholder="请输入数据源描述"
|
||||
v-model="form.sqlContent">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type === '0'" label="村微应用" style="width: 100%;" prop="appId"
|
||||
:rules="[{ required: true, message: '请选择村微应用', trigger: 'change' }]">
|
||||
<el-select size="small" style="width: 100%;" v-model="form.appId" placeholder="请选择村微应用" @change="onAppChange">
|
||||
<el-option
|
||||
v-for="item in appList"
|
||||
:key="item.id"
|
||||
:label="item.appName"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type === '0'" label="数据范围" style="width: 100%;" prop="dataRange"
|
||||
:rules="[{ required: true, message: '请选择数据范围', trigger: 'change' }]">
|
||||
<el-radio-group v-model="form.dataRange">
|
||||
<el-radio label="0">全部</el-radio>
|
||||
<el-radio label="1">自定义条数</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据条数" style="width: 100%;" v-if="form.dataRange === '1' && form.type === '0'" prop="count"
|
||||
:rules="[{ required: true, message: '请输入数据条数', trigger: 'blur' }]">
|
||||
<el-input
|
||||
size="small"
|
||||
placeholder="请输入数据条数"
|
||||
v-model="form.count">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<div v-if="form.type === '0'">
|
||||
<el-form-item :label="'统计项' + index" style="width: 100%;" v-for="(item, index) in form.statisticsConfigs" :key="'statisticsConfigs' + index">
|
||||
<div class="form-flex">
|
||||
<div>
|
||||
<el-select size="small" style="width: 160px;" v-model="item.fieldName" @change="e => onChooseField('statisticsConfigs', e, index)"
|
||||
placeholder="请选择" clearable>
|
||||
<el-option
|
||||
v-for="(item, index) in filedList"
|
||||
:key="index"
|
||||
:label="item.fieldCnName"
|
||||
:value="item.fieldName">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-select size="small" style="margin: 0 10px; width: 160px;" v-model="item.calcType" placeholder="请选择" clearable>
|
||||
<el-option
|
||||
v-for="item in dict.getDict('diyLargeScreenDatasourceCalcType2')"
|
||||
:key="item.id"
|
||||
:label="item.dictName"
|
||||
:value="item.dictValue">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-input size="small" style="width: 165px;" placeholder="请输入别名" v-model="item.alias"></el-input>
|
||||
</div>
|
||||
<el-button type="danger" v-if="index > 0" @click="removeConfig('statisticsConfigs', index)">删除</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item style="width: 100%;" v-if="form.type === '0'">
|
||||
<el-button type="primary" @click="add('statisticsConfigs')">添加统计项</el-button>
|
||||
</el-form-item>
|
||||
<div v-if="form.type === '0'">
|
||||
<el-form-item :label="'分组' + index" style="width: 100%;" v-for="(item, index) in form.groupConfigs" :key="'groupConfigs' + item.fieldName">
|
||||
<div class="form-flex">
|
||||
<div>
|
||||
<el-select size="small" style="width: 160px;" v-model="item.fieldName" placeholder="请选择" clearable>
|
||||
<el-option
|
||||
v-for="item in filedList"
|
||||
:key="item.id"
|
||||
:label="item.fieldCnName"
|
||||
:value="item.fieldName">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button type="danger" @click="removeConfig('groupConfigs', index)">删除</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item style="width: 100%;" v-if="form.type === '0'">
|
||||
<el-button type="primary" @click="add('groupConfigs')">添加分组</el-button>
|
||||
</el-form-item>
|
||||
<div v-if="form.type === '0'">
|
||||
<el-form-item :label="'统计项' + index" style="width: 100%;" v-for="(item, index) in form.orderConfigs" :key="'orderConfigs' + item.fieldName">
|
||||
<div class="form-flex">
|
||||
<div>
|
||||
<el-select size="small" style="width: 160px;" v-model="item.fieldName" placeholder="请选择" clearable>
|
||||
<el-option
|
||||
v-for="item in filedList"
|
||||
:key="item.id"
|
||||
:label="item.fieldCnName"
|
||||
:value="item.fieldName">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-select size="small" style="width: 160px; margin-left: 10px;" v-model="item.orderType" placeholder="请选择" clearable>
|
||||
<el-option
|
||||
v-for="item in orderTypeDict"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button type="danger" @click="removeConfig('orderConfigs', index)">删除</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item style="width: 100%;" v-if="form.type === '0'">
|
||||
<el-button type="primary" @click="add('orderConfigs')">添加排序</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</ai-dialog>
|
||||
</template>
|
||||
</ai-detail>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SourceData',
|
||||
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
params: Object,
|
||||
urlPrefix: String
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
isShow: false,
|
||||
search: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
name: ''
|
||||
},
|
||||
total: 0,
|
||||
colConfigs: [
|
||||
{prop: 'appName', label: '应用名'},
|
||||
{prop: 'appTableName', align: 'center', label: '表名'},
|
||||
{prop: 'description', align: 'center', label: '描述'},
|
||||
{prop: 'type', align: 'center', label: '类型', format: v => v === '0' ? '村微应用' : 'sql语句'},
|
||||
{prop: 'createUserName', align: 'center', label: '创建人'},
|
||||
{prop: 'createTime', align: 'center', label: '创建时间'}
|
||||
],
|
||||
tableData: [],
|
||||
filedList: [],
|
||||
appList: [],
|
||||
form: {
|
||||
orderType: 'asc',
|
||||
dataRange: '0',
|
||||
type: '0',
|
||||
sqlContent: '',
|
||||
appId: '',
|
||||
description: '',
|
||||
appName: '',
|
||||
appTableName: '',
|
||||
count: '100',
|
||||
statisticsConfigs: [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}],
|
||||
orderConfigs: [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}],
|
||||
groupConfigs: [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}]
|
||||
},
|
||||
id: '',
|
||||
orderTypeDict: [
|
||||
{
|
||||
value: 'asc',
|
||||
label: '升序'
|
||||
},
|
||||
{
|
||||
value: 'desc',
|
||||
label: '降序'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.dict.load(['diyLargeScreenDatasourceCalcType2']).then(() => {
|
||||
this.getList()
|
||||
this.getAppList()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
getInfo(id) {
|
||||
this.instance.post(`${this.urlPrefix}/wxcp/wxuser/queryDetailById?id=${id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.form = {
|
||||
...res.data
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onChooseField(type, fieldName, index) {
|
||||
const dictCode = this.filedList.filter(v => v.fieldName === fieldName)[0].dictCode
|
||||
this.$set(this.form[type][index], 'dictCode', dictCode)
|
||||
},
|
||||
|
||||
add(type) {
|
||||
this.form[type].push({
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
})
|
||||
},
|
||||
|
||||
removeConfig(type, index) {
|
||||
this.form[type].splice(index, 1)
|
||||
},
|
||||
|
||||
toEdit(e) {
|
||||
this.id = e.id
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryDatasourceDetailById?id=${e.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.form = {
|
||||
...res.data
|
||||
}
|
||||
|
||||
this.form.dataRange = this.form.dataRange === '0' ? '0' : '1'
|
||||
this.form.count = res.data.dataRange
|
||||
this.filedList = this.appList.filter(v => v.id === res.data.appId).length && this.appList.filter(v => v.id === res.data.appId)[0].fields.map(item => {
|
||||
let value = []
|
||||
res.data.configs.forEach(v => {
|
||||
if (v.fieldName === item.fieldName) {
|
||||
value.push(v.calcType)
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
...item,
|
||||
value
|
||||
}
|
||||
})
|
||||
this.isShow = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
remove(id) {
|
||||
this.$confirm('确定删除该数据?').then(() => {
|
||||
this.instance.post(`${this.urlPrefix}/appquestionnairetemplate/delete?id=${id}`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('删除成功!')
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
getList() {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/allDatasourceByPage`, null, {
|
||||
params: {
|
||||
...this.search
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.tableData = res.data.records
|
||||
this.total = res.data.total
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getAppList() {
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/allDatasourceApp`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.appList = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.id = ''
|
||||
this.form.orderType = 'asc'
|
||||
this.form.dataRange = 0
|
||||
this.form.appId = ''
|
||||
this.form.description = ''
|
||||
this.form.appName = ''
|
||||
this.form.appTableName = ''
|
||||
this.form.count = 100
|
||||
},
|
||||
|
||||
onAppChange(e) {
|
||||
const value = this.appList.filter(v => v.id === e)[0]
|
||||
this.form.appTableName = value.appTableName
|
||||
this.form.appName = value.appName
|
||||
this.form.statisticsConfigs = [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}]
|
||||
this.form.orderConfigs = [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}]
|
||||
this.form.groupConfigs = [{
|
||||
alias: '',
|
||||
calcType: '',
|
||||
dictCode: '',
|
||||
fieldCnName: '',
|
||||
fieldName: ''
|
||||
}]
|
||||
this.filedList = value.fields.map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
let configs = []
|
||||
|
||||
if (this.filedList.length) {
|
||||
this.filedList.forEach(item => {
|
||||
if (item.value.length) {
|
||||
item.value.forEach(v => {
|
||||
configs.push({
|
||||
alias: item.fieldCnName,
|
||||
calcType: v,
|
||||
fieldCnName: item.fieldCnName,
|
||||
fieldName: item.fieldName,
|
||||
dictCode: item.dictCode,
|
||||
orderType: this.orderType
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateDatasource`, {
|
||||
...this.form,
|
||||
configs,
|
||||
id: this.id ? this.id : '',
|
||||
dataRange: this.form.dataRange === '0' ? 0 : this.form.count
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(this.id ? '编辑成功' : '添加成功')
|
||||
this.search.current = 1
|
||||
this.isShow = false
|
||||
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.$router.push({})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.form-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
86
packages/bigscreen/designer/components/configItem.vue
Normal file
86
packages/bigscreen/designer/components/configItem.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<section class="configItem">
|
||||
<label v-text="label"/>
|
||||
<div class="content fill">
|
||||
<slot v-if="$slots.default"/>
|
||||
<div v-else-if="value" v-html="value"/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "configItem",
|
||||
props: {
|
||||
label: String,
|
||||
value: {default: null}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {},
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.configItem {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
& > label {
|
||||
flex-shrink: 0;
|
||||
width: 60px;
|
||||
color: #FFFFFF;
|
||||
font-size: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.el-select .el-tag {
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.el-input__icon {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.el-switch__label {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.el-select,.ai-select {
|
||||
width: 100%;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
input {
|
||||
background: #262C33;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
border: 1px solid #030411;
|
||||
}
|
||||
|
||||
.el-input__icon {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-collapse) {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
margin-left: 30px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
75
packages/bigscreen/designer/components/datasourcePicker.vue
Normal file
75
packages/bigscreen/designer/components/datasourcePicker.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<section class="datasourcePicker">
|
||||
<config-item label="数据类型">
|
||||
<ai-select v-model="options.dataType" placeholder="请选择数据类型" :select-list="dataTypes"/>
|
||||
</config-item>
|
||||
<div class="codeEditor" v-if="['htmlData','staticData'].includes(options.dataType)">
|
||||
<ai-dialog-btn :modal="false" dialog-title="编辑器" :customFooter="false"
|
||||
@confirm="changeData" @open="content=contentstr">
|
||||
<code-editor slot="btn" readonly :value="contentstr" :lang="dataLang" theme="github" width="100%" height="250"/>
|
||||
<code-editor v-model="content" :lang="dataLang" theme="github" width="100%" height="440" wrap/>
|
||||
</ai-dialog-btn>
|
||||
</div>
|
||||
<config-item v-else-if="options.dataType === 'dynamicData'" label="数据源">
|
||||
<ai-select v-model="options.sourceDataId" placeholder="请选择数据源" :instance="instance"
|
||||
:prop="{label:'description'}" @change="changeData"
|
||||
action="/app/appdiylargescreen/allDatasourceByPage"/>
|
||||
</config-item>
|
||||
<config-item label="接口地址" v-else-if="options.dataType === 'apiData'">
|
||||
<el-input size="small" v-model="options.api" @change="changeData" placeholder="请输入数据接口URL"/>
|
||||
</config-item>
|
||||
</section>
|
||||
</template>
|
||||
<script>
|
||||
import AiDialogBtn from "dui/packages/layout/AiDialogBtn.vue";
|
||||
import ConfigItem from "./configItem.vue";
|
||||
import {DvCompData} from "../config";
|
||||
import CodeEditor from 'bin-ace-editor'
|
||||
import 'brace/mode/json'
|
||||
import 'brace/snippets/json';
|
||||
import 'brace/theme/github';
|
||||
import 'brace/theme/monokai';
|
||||
|
||||
export default {
|
||||
name: "datasourcePicker",
|
||||
components: {ConfigItem, AiDialogBtn, CodeEditor},
|
||||
model: {
|
||||
event: "input",
|
||||
prop: "options"
|
||||
},
|
||||
props: {
|
||||
options: Object,
|
||||
instance: Function
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dataTypes: Object.entries(DvCompData.types).map(e => ({id: e[0], label: e[1]})),
|
||||
content: "",
|
||||
sourceData: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
contentstr: v => JSON.stringify(v.options.staticData),
|
||||
dataLang: v => v.options.dataType == 'htmlData' ? 'html' : 'json'
|
||||
},
|
||||
methods: {
|
||||
updateOptions() {
|
||||
this.$emit("input", this.options)
|
||||
},
|
||||
changeData() {
|
||||
new DvCompData(this.options.dataType, this.options, this.instance).getData().then(data => {
|
||||
this.options[this.options.dataType] = data
|
||||
this.updateOptions()
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.datasourcePicker {
|
||||
.codeEditor {
|
||||
position: relative;
|
||||
padding-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<section class="preview">
|
||||
<ai-dv-wrapper :views="[{label: '返回'}]" :theme="config.theme" @change="handleBack" v-if="screenId" :title="info.name" :background="bgImg">
|
||||
<ai-dv-viewer :urlPrefix="urlPrefix" :instance="instance" :dict="dict" :id="screenId"/>
|
||||
</ai-dv-wrapper>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapActions} from "vuex"
|
||||
|
||||
export default {
|
||||
name: "preview",
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
permissions: Function,
|
||||
urlPrefix: {
|
||||
type: String,
|
||||
default: '/app'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
screenId: v => v.$route.query.id,
|
||||
bgImg: v => v.config.theme == 1 ? 'https://cdn.cunwuyun.cn/dvcp/dv/img/dj_bg.png' : (v.config.backgroundImage?.[0]?.url || "")
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
info: {},
|
||||
config: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['closePage']),
|
||||
getDvData() {
|
||||
let {id} = this.$route.query
|
||||
this.instance.post(`/app/appdiylargescreen/queryLargeScreenDetailById?id=${id}`).then(res => {
|
||||
if (res?.data) {
|
||||
this.info = res.data
|
||||
this.config = JSON.parse(res.data.config).dashboard
|
||||
}
|
||||
})
|
||||
},
|
||||
handleBack() {
|
||||
this.$router.back()
|
||||
this.closePage()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getDvData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.preview {
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user