forked from github/dataease
Merge pull request #2829 from dataease/pr@dev@feat_rich-text-view
feat(视图): 新增富文本视图
This commit is contained in:
commit
00487979db
@ -119,6 +119,9 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initCurFields()
|
this.initCurFields()
|
||||||
|
if (this.element.type === 'view') {
|
||||||
|
bus.$on('initCurFields-' + this.element.id, this.initCurFields)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
detailsShow() {
|
detailsShow() {
|
||||||
@ -218,9 +221,12 @@ export default {
|
|||||||
},
|
},
|
||||||
initCurFields() {
|
initCurFields() {
|
||||||
if (this.element.type === 'view') {
|
if (this.element.type === 'view') {
|
||||||
const chartDetails = JSON.parse(this.panelViewDetailsInfo[this.element.propValue.viewId])
|
const chartInfo = this.panelViewDetailsInfo[this.element.propValue.viewId]
|
||||||
if (chartDetails.type === 'richTextView') {
|
if (chartInfo) {
|
||||||
const checkAllAxisStr = chartDetails.xaxis + chartDetails.xaxisExt + chartDetails.yaxis + chartDetails.yaxisExt + chartDetails.drillFields
|
this.curFields = []
|
||||||
|
const chartDetails = JSON.parse(chartInfo)
|
||||||
|
if (chartDetails.type === 'richTextView' && chartDetails.data && chartDetails.data.sourceFields) {
|
||||||
|
const checkAllAxisStr = chartDetails.xaxis + chartDetails.xaxisExt + chartDetails.yaxis + chartDetails.yaxisExt
|
||||||
chartDetails.data.sourceFields.forEach(field => {
|
chartDetails.data.sourceFields.forEach(field => {
|
||||||
if (checkAllAxisStr.indexOf(field.id) > -1) {
|
if (checkAllAxisStr.indexOf(field.id) > -1) {
|
||||||
this.curFields.push(field)
|
this.curFields.push(field)
|
||||||
@ -228,6 +234,7 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
positionCheck(position) {
|
positionCheck(position) {
|
||||||
return this.showPosition.includes(position)
|
return this.showPosition.includes(position)
|
||||||
|
@ -105,61 +105,58 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
// 监听内容变化
|
// 监听内容变化
|
||||||
active(val) {
|
active(val) {
|
||||||
const _this = this
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.canEdit = false
|
this.canEdit = false
|
||||||
this.reShow()
|
this.reShow()
|
||||||
this.$nextTick(() => {
|
this.myValue = this.assignment(this.element.propValue.textValue)
|
||||||
_this.element.propValue.textValue = _this.myValue
|
|
||||||
_this.myValue = _this.assignment(_this.myValue)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
myValue(newValue) {
|
myValue(newValue) {
|
||||||
console.log('myValue===' + newValue)
|
if (this.canEdit) {
|
||||||
// this.element.propValue.textValue = newValue
|
this.element.propValue.textValue = newValue
|
||||||
// this.$store.state.styleChangeTimes++
|
}
|
||||||
|
this.$store.state.styleChangeTimes++
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on('fieldSelect-' + this.element.propValue.viewId, this.fieldSelect)
|
bus.$on('fieldSelect-' + this.element.propValue.viewId, this.fieldSelect)
|
||||||
tinymce.init({})
|
tinymce.init({})
|
||||||
this.myValue = this.assignment(this.element.propValue.textValue)
|
this.myValue = this.assignment(this.element.propValue.textValue)
|
||||||
|
bus.$on('initCurFields-' + this.element.id, this.initCurFieldsChange)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
bus.$off('fieldSelect-' + this.element.propValue.viewId)
|
bus.$off('fieldSelect-' + this.element.propValue.viewId)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initCurFieldsChange() {
|
||||||
|
if (!this.canEdit) {
|
||||||
|
this.myValue = this.assignment(this.element.propValue.textValue)
|
||||||
|
}
|
||||||
|
},
|
||||||
assignment(content) {
|
assignment(content) {
|
||||||
|
const _this = this
|
||||||
const on = content.match(/\[(.+?)\]/g)
|
const on = content.match(/\[(.+?)\]/g)
|
||||||
if (on) {
|
if (on) {
|
||||||
on.forEach(itm => {
|
on.forEach(itm => {
|
||||||
const ele = itm.slice(1, -1)
|
const ele = itm.slice(1, -1)
|
||||||
content = content.replace(itm, this.dataRowNameSelect[ele])
|
content = content.replace(itm, _this.dataRowNameSelect[ele] ? _this.dataRowNameSelect[ele] : '[字段已经删除]')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return content
|
return content
|
||||||
},
|
},
|
||||||
fieldSelect(field) {
|
fieldSelect(field) {
|
||||||
const value = '[' + field.name + ']'
|
const value = '[' + field.name + ']'
|
||||||
const ed = tinymce.get('tinymce-view-' + this.element.id)
|
tinymce.editors['tinymce-view-' + this.element.id].insertContent(value)
|
||||||
const range = ed.selection.getRng()
|
|
||||||
const divNode = ed.getDoc().createElement('span')
|
|
||||||
divNode.innerHTML = value
|
|
||||||
range.insertNode(divNode)
|
|
||||||
},
|
},
|
||||||
onClick(e) {
|
onClick(e) {
|
||||||
this.$emit('onClick', e, tinymce)
|
this.$emit('onClick', e, tinymce)
|
||||||
},
|
},
|
||||||
setEdit() {
|
setEdit() {
|
||||||
if (this.editStatus) {
|
if (this.editStatus) {
|
||||||
const _this = this
|
|
||||||
this.canEdit = true
|
this.canEdit = true
|
||||||
this.element['editing'] = true
|
this.element['editing'] = true
|
||||||
this.reShow()
|
this.reShow()
|
||||||
this.$nextTick(() => {
|
this.myValue = this.element.propValue.textValue
|
||||||
_this.myValue = _this.element.propValue.textValue
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reShow() {
|
reShow() {
|
||||||
|
@ -609,6 +609,7 @@ export default {
|
|||||||
} else if (!err.response) {
|
} else if (!err.response) {
|
||||||
this.httpRequest.status = false
|
this.httpRequest.status = false
|
||||||
} else {
|
} else {
|
||||||
|
if (err.response) {
|
||||||
this.httpRequest.status = err.response.data.success
|
this.httpRequest.status = err.response.data.success
|
||||||
this.httpRequest.msg = err.response.data.message
|
this.httpRequest.msg = err.response.data.message
|
||||||
if (err && err.response && err.response.data) {
|
if (err && err.response && err.response.data) {
|
||||||
@ -617,6 +618,7 @@ export default {
|
|||||||
this.message = err
|
this.message = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.isFirstLoad = false
|
this.isFirstLoad = false
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -624,7 +626,10 @@ export default {
|
|||||||
},
|
},
|
||||||
initCurFields(chartDetails) {
|
initCurFields(chartDetails) {
|
||||||
this.curFields = []
|
this.curFields = []
|
||||||
const checkAllAxisStr = chartDetails.xaxis + chartDetails.xaxisExt + chartDetails.yaxis + chartDetails.yaxisExt + chartDetails.drillFields
|
this.dataRowSelect = []
|
||||||
|
this.dataRowNameSelect = []
|
||||||
|
if (chartDetails.data && chartDetails.data.sourceFields) {
|
||||||
|
const checkAllAxisStr = chartDetails.xaxis + chartDetails.xaxisExt + chartDetails.yaxis + chartDetails.yaxisExt
|
||||||
chartDetails.data.sourceFields.forEach(field => {
|
chartDetails.data.sourceFields.forEach(field => {
|
||||||
if (checkAllAxisStr.indexOf(field.id) > -1) {
|
if (checkAllAxisStr.indexOf(field.id) > -1) {
|
||||||
this.curFields.push(field)
|
this.curFields.push(field)
|
||||||
@ -644,7 +649,13 @@ export default {
|
|||||||
this.dataRowSelect[nameIdMap[key]] = rowData[key]
|
this.dataRowSelect[nameIdMap[key]] = rowData[key]
|
||||||
this.dataRowNameSelect[sourceFieldNameIdMap[key]] = rowData[key]
|
this.dataRowNameSelect[sourceFieldNameIdMap[key]] = rowData[key]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Vue.set(this.element.propValue, 'innerType', chartDetails.type)
|
Vue.set(this.element.propValue, 'innerType', chartDetails.type)
|
||||||
|
if (chartDetails.type === 'richTextView') {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
bus.$emit('initCurFields-' + this.element.id)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
viewIdMatch(viewIds, viewId) {
|
viewIdMatch(viewIds, viewId) {
|
||||||
return !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
return !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
||||||
|
Loading…
Reference in New Issue
Block a user