clay commit : bug基本修复完成

This commit is contained in:
clay
2022-10-06 00:53:43 +08:00
parent be112b68d6
commit 7ec353ad6c
11 changed files with 586 additions and 122 deletions

View File

@@ -41,7 +41,7 @@
"axios": "0.18.1", "axios": "0.18.1",
"ckeditor4-vue": "^1.4.0", "ckeditor4-vue": "^1.4.0",
"clipboard": "2.0.4", "clipboard": "2.0.4",
"codemirror": "^5.59.2", "codemirror": "^5.65.9",
"core-js": "3.6.5", "core-js": "3.6.5",
"diff-match-patch": "^1.0.5", "diff-match-patch": "^1.0.5",
"echarts": "4.2.1", "echarts": "4.2.1",

View File

@@ -55,7 +55,6 @@ export default {
}, },
data () { data () {
return { return {
// 默认有这么多菜单meanArray有值以meanArray为准 // 默认有这么多菜单meanArray有值以meanArray为准
defaultMeanus: [ defaultMeanus: [
'head', 'head',

View File

@@ -0,0 +1,137 @@
<template>
<div class="editor" :style="styles" ref="editor"></div>
</template>
<script>
import Editor from 'wangeditor'
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: ''
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
meanArray: {
// 自定义菜单
type: Array,
default: null
}
},
model: {
prop: 'value',
event: 'change'
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height+50}px`;
}
return style;
},
},
watch: {
value: function (value) {
if (value !== this.editor.txt.html()) {
this.editor.txt.html(this.value)
}
}
// value为编辑框输入的内容这里我监听了一下值当父组件调用得时候如果给value赋值了子组件将会显示父组件赋给的值
},
data () {
return {
// 默认有这么多菜单meanArray有值以meanArray为准
defaultMeanus: [
'head',
'bold',
'fontSize',
'fontName',
'italic',
'underline',
'strikeThrough',
'indent',
'lineHeight',
'foreColor',
'backColor',
'link',
'list',
'justify',
'quote',
'emoticon',
'image',
'video',
'table',
'code',
'splitLine',
'undo',
'redo'
],
editor: ''
}
},
methods: {
init () {
const _this = this
this.editor = new Editor(this.$refs.editor)
this.editor.config.uploadImgAccept = ['doc', 'docx', 'png', 'gif', 'bmp', 'webp']
this.editor.config.uploadImgShowBase64 = true // 使用 base64 保存图片
this.editor.config.height = this.height
this.editor.config.pasteFilterStyle = false
this.editor.config.zIndex = 10
this.setMenus() // 设置菜单
this.editor.config.onchange = (html) => {
_this.$emit('change', html) // 将内容同步到父组件中
}
this.editor.create() // 创建编辑器
},
setMenus () {
// 设置菜单
if (this.meanArray) {
this.editor.config.menus = this.meanArray
} else {
this.editor.config.menus = this.defaultMeanus
}
},
getHtml () {
// 得到文本内容
return this.editor.txt.html()
},
setHtml (txt) {
// 设置富文本里面的值
this.editor.txt.html(txt)
}
},
mounted () {
const that = this
that.$nextTick(function () {
that.init()
})
}
}
</script>
<style scoped lang="scss">
.editor{
z-index: 1!important;
white-space: pre-wrap!important;
line-height: normal !important;
}
</style>

View File

@@ -6,7 +6,6 @@ import {setToken} from "@/utils/auth";
export default { export default {
name: "cas-login", name: "cas-login",
mounted() { mounted() {
debugger
let search = window.location.search; let search = window.location.search;
let token = search.slice(search.indexOf("=") + 1) let token = search.slice(search.indexOf("=") + 1)
setToken(token) setToken(token)

View File

@@ -83,6 +83,7 @@
<el-table-column label="标题" align="left" prop="title" /> <el-table-column label="标题" align="left" prop="title" />
<el-table-column label="英文标题" align="left" prop="enTitle" /> <el-table-column label="英文标题" align="left" prop="enTitle" />
<el-table-column label="站点类型" align="center" prop="sitetype" :formatter="sitetypeFormat"/> <el-table-column label="站点类型" align="center" prop="sitetype" :formatter="sitetypeFormat"/>
<el-table-column label="排序" align="center" prop="sort"/>
<el-table-column label="轮播类型" align="center" prop="type":formatter="bannerStyleFormat" /> <el-table-column label="轮播类型" align="center" prop="type":formatter="bannerStyleFormat" />
<el-table-column label="图表路径" align="center"> <el-table-column label="图表路径" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
@@ -146,6 +147,9 @@
<el-form-item label="英文标题" prop="enTitle"> <el-form-item label="英文标题" prop="enTitle">
<el-input v-model="form.enTitle" placeholder="请输入英文标题" /> <el-input v-model="form.enTitle" placeholder="请输入英文标题" />
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort">
<el-input-number v-model="form.sort" placeholder="请输入排序序号" />
</el-form-item>
<el-form-item prop="imgurl"> <el-form-item prop="imgurl">
<UploadFile v-model="form.imgurl" <UploadFile v-model="form.imgurl"
file-type="image" file-type="image"

View File

@@ -77,10 +77,10 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="上级" prop="pid"> <el-form-item label="上级" prop="pid">
<treeselect v-model="form.pid" :options="empleeOptions" :normalizer="normalizer" placeholder="请选择父id"/> <treeselect v-model="form.pid" :options="empleeOptions" :normalizer="normalizer" @select="handleNodeSelect" placeholder="请选择父id"/>
</el-form-item> </el-form-item>
<el-form-item label="层" prop="level"> <el-form-item label="层" prop="level">
<el-input-number type="number" :min="1" :max="3" v-model="form.level" placeholder="请输入层"/> <el-input disabled v-model="form.level" placeholder="请输入层"/>
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort">
<el-input-number v-model="form.sort" placeholder="排序"/> <el-input-number v-model="form.sort" placeholder="排序"/>
@@ -88,9 +88,9 @@
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称"/> <el-input v-model="form.name" placeholder="请输入名称"/>
</el-form-item> </el-form-item>
<el-form-item v-if="form.level === 3" label="跳转链接" prop="link"> <el-form-item v-if="form.level === 3 || form.level === 2" label="跳转链接" prop="link">
<el-input v-model="form.link" placeholder="请输跳转链接"> <el-input v-model="form.link" placeholder="请输跳转链接">
<template slot="prepend">Http://</template> <template slot="prepend"></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -144,6 +144,13 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
handleNodeSelect(data){
let level = data.level + 1
if (level > 3){
this.msgError("最多为3层结构")
}
this.form.level = level
},
/** 查询层级结构列表 */ /** 查询层级结构列表 */
getList() { getList() {
this.loading = true this.loading = true
@@ -162,6 +169,7 @@ export default {
return { return {
id: node.id, id: node.id,
label: node.name, label: node.name,
level:node.level,
children: node.children children: node.children
} }
}, },
@@ -170,7 +178,7 @@ export default {
listEmplee({ type: this.direId, siteType: this.siteType }).then(response => { listEmplee({ type: this.direId, siteType: this.siteType }).then(response => {
console.log(response) console.log(response)
this.empleeOptions = [] this.empleeOptions = []
const data = { id: 0, name: '顶级节点', children: [] } const data = { id: 0, level:0, name: '顶级节点', children: [] }
if (response.code == 200) { if (response.code == 200) {
data.children = this.handleTree(response.data, 'id', 'pid') data.children = this.handleTree(response.data, 'id', 'pid')
} }
@@ -267,30 +275,3 @@ export default {
} }
} }
</script> </script>
<!--<template>-->
<!-- <div>-->
<!-- {{ direId }}-->
<!-- </div>-->
<!--</template>-->
<!--<script>-->
<!--export default {-->
<!-- name: "direData",-->
<!-- data() {-->
<!-- return {-->
<!-- direId: this.$route.params && this.$route.params.direId,-->
<!-- }-->
<!-- },-->
<!-- created() {-->
<!-- let direId = this.$route.params && this.$route.params.direId;-->
<!-- console.log(direId)-->
<!-- }-->
<!--}-->
<!--</script>-->
<!--<style scoped>-->
<!--</style>-->

View File

@@ -35,7 +35,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['sist:dire:add']" v-hasPermi="['sist:dire:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@@ -46,7 +47,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['sist:dire:edit']" v-hasPermi="['sist:dire:edit']"
>修改</el-button> >修改
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@@ -57,7 +59,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['sist:dire:remove']" v-hasPermi="['sist:dire:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@@ -67,23 +70,25 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['sist:dire:export']" v-hasPermi="['sist:dire:export']"
>导出</el-button> >导出
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center"/>
<!-- <el-table-column label="层级数据编码" align="center" prop="dictCode" />--> <!-- <el-table-column label="层级数据编码" align="center" prop="dictCode" />-->
<el-table-column label="网站类型" align="center" prop="attribute2" :formatter="attribute2Format" /> <el-table-column label="网站类型" align="center" prop="attribute2" :formatter="attribute2Format"/>
<el-table-column label="层级数据" align="center" prop="dictLabel" > <el-table-column label="层级数据" align="center" prop="dictLabel">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/dire/data/' + scope.row.dictValue+'/'+scope.row.cssClass" class="link-type"> <router-link :to="'/dire/data/' + scope.row.dictValue+'/'+scope.row.cssClass" class="link-type">
<span>{{ scope.row.dictLabel }}</span> <span>{{ scope.row.dictLabel }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> <el-table-column label="使用模板" align="center" prop="attribute1" :formatter="templateFormatter"/>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
@@ -98,7 +103,8 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['sist:dire:edit']" v-hasPermi="['sist:dire:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@@ -106,7 +112,8 @@
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['sist:dire:remove']" v-hasPermi="['sist:dire:remove']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -123,18 +130,29 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="层级数据" prop="dictLabel"> <el-form-item label="层级数据" prop="dictLabel">
<el-input v-model="form.dictLabel" placeholder="请输入数据" /> <el-input v-model="form.dictLabel" placeholder="请输入数据"/>
</el-form-item> </el-form-item>
<el-form-item label="显示排序" prop="dictSort"> <el-form-item label="显示排序" prop="dictSort">
<el-input-number v-model="form.dictSort" controls-position="right" :min="0" /> <el-input-number v-model="form.dictSort" controls-position="right" :min="0"/>
</el-form-item>
<el-form-item label="模板类型" prop="attribute1">
<el-radio-group v-model="form.attribute1">
<el-radio-button
v-for="item in templateOptions"
:key="item.key"
:label="item.key"
>{{ item.label }}
</el-radio-button>
</el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="网站类型" prop="attribute2"> <el-form-item label="网站类型" prop="attribute2">
<el-radio-group v-model="form.attribute2"> <el-radio-group v-model="form.attribute2">
<el-radio <el-radio-button
v-for="dict in attribute2Options" v-for="dict in attribute2Options"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictValue" :label="dict.dictValue"
>{{dict.dictLabel}}</el-radio> >{{ dict.dictLabel }}
</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
@@ -150,10 +168,10 @@
</template> </template>
<script> <script>
import { listData, getData, delData, addData, updateData, exportData } from "@/api/sist/dire"; import { listData, getData, delData, addData, updateData, exportData } from '@/api/sist/dire'
export default { export default {
name: "Data", name: 'Data',
data() { data() {
return { return {
// 遮罩层 // 遮罩层
@@ -171,13 +189,23 @@ export default {
// 字典表格数据 // 字典表格数据
dataList: [], dataList: [],
// 默认字典类型 // 默认字典类型
defaultDictType: "", defaultDictType: '',
// 弹出层标题 // 弹出层标题
title: "", title: '',
// 是否显示弹出层 // 是否显示弹出层
open: false, open: false,
// 状态数据字典 // 状态数据字典
attribute2Options: [], attribute2Options: [],
templateOptions: [
{
key: '2',
label: '二层模板'
},
{
key: '1',
label: '三层模板'
},
],
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@@ -190,41 +218,56 @@ export default {
// 表单校验 // 表单校验
rules: { rules: {
dictLabel: [ dictLabel: [
{ required: true, message: "层级数据不能为空", trigger: "blur" } { required: true, message: '层级数据不能为空', trigger: 'blur' }
],
attribute1: [
{ required: true, message: '模板类型不能为空', trigger: 'blur' }
], ],
attribute2: [ attribute2: [
{ required: true, message: "网站类型不能为空", trigger: "blur" } { required: true, message: '网站类型不能为空', trigger: 'blur' }
], ],
dictSort: [ dictSort: [
{ required: true, message: "数据顺序不能为空", trigger: "blur" } { required: true, message: '数据顺序不能为空', trigger: 'blur' }
] ]
} }
}; }
}, },
created() { created() {
this.getList(); this.getList()
this.getDicts("unencrypted_site_type").then(response => { this.getDicts('unencrypted_site_type').then(response => {
this.attribute2Options = response.data; this.attribute2Options = response.data
}); })
}, },
methods: { methods: {
/** 模板转换器 */
templateFormatter(row){
let attribute1 = row.attribute1
if (null == attribute1){
return
}
for (let templateOption of this.templateOptions) {
if (templateOption.key == attribute1){
return templateOption.label
}
}
},
/** 查询字典数据列表 */ /** 查询字典数据列表 */
getList() { getList() {
this.loading = true; this.loading = true
listData(this.queryParams).then(response => { listData(this.queryParams).then(response => {
this.dataList = response.rows; this.dataList = response.rows
this.total = response.total; this.total = response.total
this.loading = false; this.loading = false
}); })
}, },
// 数据状态字典翻译 // 数据状态字典翻译
attribute2Format(row, column) { attribute2Format(row, column) {
return this.selectDictLabel(this.attribute2Options, row.attribute2); return this.selectDictLabel(this.attribute2Options, row.attribute2)
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false; this.open = false
this.reset(); this.reset()
}, },
// 表单重置 // 表单重置
reset() { reset() {
@@ -233,94 +276,99 @@ export default {
dictLabel: undefined, dictLabel: undefined,
dictValue: undefined, dictValue: undefined,
dictSort: 0, dictSort: 0,
status: "0", status: '0',
attribute2: "1", attribute2: '1',
remark: undefined remark: undefined
}; }
this.resetForm("form"); this.resetForm('form')
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm('queryForm')
this.queryParams.dictType = this.defaultDictType; this.queryParams.dictType = this.defaultDictType
this.handleQuery(); this.handleQuery()
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset()
this.open = true; this.open = true
this.title = "添加层级数据"; this.title = '添加层级数据'
this.form.dictType = this.queryParams.dictType; this.form.dictType = this.queryParams.dictType
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictCode) this.ids = selection.map(item => item.dictCode)
this.single = selection.length!=1 this.single = selection.length != 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset()
const dictCode = row.dictCode || this.ids const dictCode = row.dictCode || this.ids
getData(dictCode).then(response => { getData(dictCode).then(response => {
this.form = response.data; this.form = response.data
this.open = true; if (this.form.attribute2 == 1) {
this.title = "修改层级数据"; this.form.attribute2 = '1'
}); } else {
this.form.attribute2 = '2'
}
this.open = true
this.title = '修改层级数据'
})
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.form.dictType = 'dire_type' this.form.dictType = 'dire_type'
if (this.form.dictCode != undefined) { if (this.form.dictCode != undefined) {
updateData(this.form).then(response => { updateData(this.form).then(response => {
this.msgSuccess("修改成功"); this.msgSuccess('修改成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} else { } else {
addData(this.form).then(response => { addData(this.form).then(response => {
this.msgSuccess("新增成功"); this.msgSuccess('新增成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} }
} }
}); })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictCodes = row.dictCode || this.ids; const dictCodes = row.dictCode || this.ids
this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", { this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', '警告', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(function() { }).then(function() {
return delData(dictCodes); return delData(dictCodes)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.msgSuccess("删除成功"); this.msgSuccess('删除成功')
}) })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams
this.$confirm('是否确认导出所有数据项?', "警告", { this.$confirm('是否确认导出所有数据项?', '警告', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(function() { }).then(function() {
return exportData(queryParams); return exportData(queryParams)
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg)
}) })
} }
} }
}; }
</script> </script>

View File

@@ -137,7 +137,7 @@
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="缩略图" prop="isThumbnail" v-show="articleSelShow"> <el-form-item label="缩略图" prop="isThumbnail" v-show="isThumbnailShow">
<el-radio-group v-model="form.isThumbnail"> <el-radio-group v-model="form.isThumbnail">
<el-radio-button <el-radio-button
v-for="dict in thumbnailOptions" v-for="dict in thumbnailOptions"
@@ -147,6 +147,16 @@
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="模板" prop="isSimple" v-show="isThumbnailShow">
<el-radio-group v-model="form.isSimple">
<el-radio-button
v-for="dict in simpleOptions"
:key="dict.key"
:label="dict.key"
>{{ dict.label }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="内容类型" prop="refId" v-show="articleSelShow">--> <!-- <el-form-item label="内容类型" prop="refId" v-show="articleSelShow">-->
<!-- <el-select v-model="form.refId" placeholder="请选择内容类型" clearable :style="{width: '100%'}">--> <!-- <el-select v-model="form.refId" placeholder="请选择内容类型" clearable :style="{width: '100%'}">-->
<!-- <el-option--> <!-- <el-option-->
@@ -192,6 +202,9 @@
</div> </div>
</el-dialog> </el-dialog>
<el-dialog title="编辑详情" :visible="detailsShow" width="1100px" :close-on-click-modal="false" @close="detailsClose()" <el-dialog title="编辑详情" :visible="detailsShow" width="1100px" :close-on-click-modal="false" @close="detailsClose()"
append-to-body append-to-body
> >
@@ -207,7 +220,9 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :offset="1" :span="22"> <el-col :offset="1" :span="22">
<Editor v-model="formData.content" :height="500"/> <Editor ref="editor" v-model="formData.content" :height="500"/>
<!-- <CodeEdit ref="codeEdit" v-model="formData.content" :height="500"/>-->
<!-- <CustomEditor v-model="formData.content" :height="500"/>-->
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
@@ -235,7 +250,8 @@ import {
} from '@/api/sist/navigation' } from '@/api/sist/navigation'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import Editor from '@/components/Editor' import Editor from '@/views/utils/Editor'
import CodeEdit from '@/views/utils/CodeEdit'
import UploadFile from '@/views/utils/uploadFile' import UploadFile from '@/views/utils/uploadFile'
import { getArticleNav } from '../../../api/sist/article' import { getArticleNav } from '../../../api/sist/article'
@@ -243,6 +259,7 @@ export default {
name: 'Navigation', name: 'Navigation',
components: { components: {
Treeselect, Treeselect,
CodeEdit,
Editor, Editor,
UploadFile UploadFile
}, },
@@ -258,6 +275,7 @@ export default {
// 显示搜索条件 // 显示搜索条件
showSearch: true, showSearch: true,
articleSelShow: false, articleSelShow: false,
isThumbnailShow:false,
empleeSelShow: false, empleeSelShow: false,
imageShow: false, imageShow: false,
// 导航表格数据 // 导航表格数据
@@ -272,6 +290,16 @@ export default {
label: '有' label: '有'
} }
], ],
simpleOptions:[
{
key: 0,
label: '正常列表'
},
{
key: 1,
label: '简单列表'
}
],
// 导航树选项 // 导航树选项
navigationList: [], navigationList: [],
articleTypeOptions: [], articleTypeOptions: [],
@@ -408,6 +436,7 @@ export default {
}, },
// 表单重置 // 表单重置
reset() { reset() {
this.isThumbnailShow = false
this.articleSelShow = false this.articleSelShow = false
this.imageShow = false this.imageShow = false
this.empleeSelShow = false this.empleeSelShow = false
@@ -455,6 +484,11 @@ export default {
this.formData = res.data this.formData = res.data
}) })
}, },
code(){
let html = this.$refs.editor.getHtml()
this.$refs.editor.setHtml(html)
console.log(this.$refs.editor.getHtml())
},
save() { save() {
updateDetails(this.formData).then(res => { updateDetails(this.formData).then(res => {
this.msgSuccess('修改成功') this.msgSuccess('修改成功')
@@ -468,7 +502,8 @@ export default {
// } // }
this.articleTypeOptions = [] this.articleTypeOptions = []
this.direTypeOptions = [] this.direTypeOptions = []
if (type == 2) { if (type == "2") {
this.isThumbnailShow = true
this.articleSelShow = true this.articleSelShow = true
this.empleeSelShow = false this.empleeSelShow = false
if (this.form.sitetype == 1) { if (this.form.sitetype == 1) {
@@ -476,9 +511,10 @@ export default {
} else if (this.form.sitetype == 2) { } else if (this.form.sitetype == 2) {
this.articleTypeOptions = this.labArticleTypeOption this.articleTypeOptions = this.labArticleTypeOption
} }
} else if (type == 3) { } else if (type == "3") {
this.articleSelShow = false this.articleSelShow = false
this.empleeSelShow = true this.empleeSelShow = true
this.isThumbnailShow = false
if (this.form.sitetype == 1) { if (this.form.sitetype == 1) {
this.direTypeOptions = this.sistDireTypeOptions this.direTypeOptions = this.sistDireTypeOptions
} else if (this.form.sitetype == 2) { } else if (this.form.sitetype == 2) {
@@ -489,7 +525,7 @@ export default {
this.empleeSelShow = false this.empleeSelShow = false
} }
if (this.form.type == 0) { if (this.form.type == "0") {
this.imageShow = false this.imageShow = false
} else { } else {
this.imageShow = true this.imageShow = true
@@ -529,6 +565,7 @@ export default {
} else { } else {
this.imageShow = true this.imageShow = true
} }
this.navigationTypeChang(this.form.type)
this.open = true this.open = true
this.title = '修改导航' this.title = '修改导航'
}) })

View File

@@ -0,0 +1,122 @@
<template>
<div class="in-coder-panel">
<textarea ref="textarea"></textarea>
</div>
</template>
<script>
// 引入全局实例
import _CodeMirror from 'codemirror'
// 核心样式
import 'codemirror/lib/codemirror.css'
// 引入主题后还需要在 options 中指定主题才会生效
import 'codemirror/theme/cobalt.css'
// 需要引入具体的语法高亮库才会有对应的语法高亮效果
// codemirror 官方其实支持通过 /addon/mode/loadmode.js 和 /mode/meta.js 来实现动态加载对应语法高亮库
// 但 vue 貌似没有无法在实例初始化后再动态加载对应 JS ,所以此处才把对应的 JS 提前引入
import 'codemirror/mode/javascript/javascript.js'
import 'codemirror/mode/xml/xml.js'
import 'codemirror/mode/vue/vue.js'
// 尝试获取全局实例
const CodeMirror = window.CodeMirror || _CodeMirror
export default {
name: 'codeEdit.vue',
props: {
// 外部传入的内容,用于实现双向绑定
value: String,
// 外部传入的语法类型
language: {
type: String,
default: null
}
},
data() {
return {
// 内部真实的内容
code: this.value,
// 默认的语法类型
mode: 'javascript',
// 编辑器实例
coder: null,
// 默认配置
options: {
// 缩进格式
tabSize: 2,
// 主题,对应主题库 JS 需要提前引入
theme: 'cobalt',
// 显示行号
lineNumbers: true,
line: true
},
// 支持切换的语法高亮类型,对应 JS 已经提前引入
// 使用的是 MIME-TYPE ,不过作为前缀的 text/ 在后面指定时写死了
}
},
watch : {
value(val){
this.code = val
}
},
created(){
this._initialize()
},
// mounted() {
// // 初始化
// this._initialize()
// },
methods: {
// 初始化
_initialize() {
console.log(this.value)
// 初始化编辑器实例,传入需要被实例化的文本域对象和默认配置
this.coder = CodeMirror.fromTextArea(this.$refs.textarea, this.options)
// 编辑器赋值
this.coder.setValue(this.value || this.code)
// 支持双向绑定
this.coder.on('change', (coder) => {
this.code = coder.getValue()
if (this.$emit) {
this.$emit('input', this.code)
}
})
},
}
}
</script>
<style lang="scss">
.in-coder-panel {
flex-grow: 1;
display: flex;
position: relative;
.CodeMirror {
flex-grow: 1;
z-index: 1;
.CodeMirror-code {
line-height: 19px;
.code-mode-select {
position: absolute;
z-index: 2;
righ: 10px;
top: 10px;
max-width: 130px;
}
}
}
}
</style>

View File

@@ -40,7 +40,7 @@ export default {
style.minHeight = `${this.minHeight}px`; style.minHeight = `${this.minHeight}px`;
} }
if (this.height) { if (this.height) {
style.height = `${this.height}px`; style.height = `${this.height+50}px`;
} }
return style; return style;
}, },
@@ -89,7 +89,11 @@ export default {
init () { init () {
const _this = this const _this = this
this.editor = new Editor(this.$refs.editor) this.editor = new Editor(this.$refs.editor)
this.editor.config.uploadImgAccept = ['doc', 'docx', 'png', 'gif', 'bmp', 'webp']
this.editor.config.uploadImgShowBase64 = true // 使用 base64 保存图片 this.editor.config.uploadImgShowBase64 = true // 使用 base64 保存图片
this.editor.config.height = this.height
this.editor.config.pasteFilterStyle = false
this.editor.config.zIndex = 10
this.setMenus() // 设置菜单 this.setMenus() // 设置菜单
this.editor.config.onchange = (html) => { this.editor.config.onchange = (html) => {
_this.$emit('change', html) // 将内容同步到父组件中 _this.$emit('change', html) // 将内容同步到父组件中
@@ -123,9 +127,11 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.editor{ .editor{
z-index: 1!important; z-index: 1!important;
white-space: pre-wrap!important; white-space: pre-wrap!important;
line-height: normal !important; line-height: normal !important;
} }
</style> </style>

View File

@@ -0,0 +1,131 @@
<template>
<div class="editor" :style="styles" ref="editor"></div>
</template>
<script>
import Editor from 'wangeditor'
export default {
name: "Editor",
props: {
/* 编辑器的内容 */
value: {
type: String,
default: ''
},
/* 高度 */
height: {
type: Number,
default: null,
},
/* 最小高度 */
minHeight: {
type: Number,
default: null,
},
meanArray: {
// 自定义菜单
type: Array,
default: null
}
},
model: {
prop: 'value',
event: 'change'
},
computed: {
styles() {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: function (value) {
if (value !== this.editor.txt.html()) {
this.editor.txt.html(this.value)
}
}
// value为编辑框输入的内容这里我监听了一下值当父组件调用得时候如果给value赋值了子组件将会显示父组件赋给的值
},
data () {
return {
// 默认有这么多菜单meanArray有值以meanArray为准
defaultMeanus: [
'head',
'bold',
'fontSize',
'fontName',
'italic',
'underline',
'strikeThrough',
'indent',
'lineHeight',
'foreColor',
'backColor',
'link',
'list',
'justify',
'quote',
'emoticon',
'image',
'video',
'table',
'code',
'splitLine',
'undo',
'redo'
],
editor: ''
}
},
methods: {
init () {
const _this = this
this.editor = new Editor(this.$refs.editor)
this.editor.config.uploadImgShowBase64 = true // 使用 base64 保存图片
this.setMenus() // 设置菜单
this.editor.config.onchange = (html) => {
_this.$emit('change', html) // 将内容同步到父组件中
}
this.editor.create() // 创建编辑器
},
setMenus () {
// 设置菜单
if (this.meanArray) {
this.editor.config.menus = this.meanArray
} else {
this.editor.config.menus = this.defaultMeanus
}
},
getHtml () {
// 得到文本内容
return this.editor.txt.html()
},
setHtml (txt) {
// 设置富文本里面的值
this.editor.txt.html(txt)
}
},
mounted () {
const that = this
that.$nextTick(function () {
that.init()
})
}
}
</script>
<style scoped lang="scss">
.editor{
z-index: 1!important;
white-space: pre-wrap!important;
line-height: normal !important;
}
</style>