yujialong 1 year ago
parent 838abe42b8
commit 90055cb2e3
  1. 191
      src/components/quill1/index.vue
  2. 15
      src/components/quill1/options.js
  3. 18
      src/views/Transaction.vue

@ -1,191 +0,0 @@
<template>
<div class="quill" :class="[classes,readonly ? 'readonly' : '']">
<div :ref="toref" :style="styles" v-loading="loading"></div>
<el-upload :action="this.api.fileupload" :before-upload="beforeUpload" :on-success="editorUploadSuccess" style="display: none">
<el-button class="editorUpload" size="small" type="primary">点击上传</el-button>
</el-upload>
</div>
</template>
<script>
import Quill from 'quill';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
import toolbarOptions from './options'
export default {
name: 'quill',
props: {
toref: {
type: String,
default: 'editor'
},
value: {
type: String,
default: ''
},
readonly: {
type: Boolean,
default: false
},
toTop: {
type: Boolean,
default: true
},
border: {
type: Boolean,
default: false
},
height: {
type: Number
},
minHeight: {
type: Number
}
},
data () {
return {
Quill: null,
currentValue: '',
options: {
theme: 'snow',
bounds: document.body,
debug: 'warn',
modules: {
toolbar: {
container: this.readonly ? [] : toolbarOptions,
handlers: {
'image': function (value) {
if (value) {
// iview
document.querySelector('.editorUpload').click()
} else {
this.Quill.format('image', false);
}
}
}
}
},
placeholder: '',
readOnly: this.readonly
},
loading: false
}
},
computed: {
classes () {
return [
{
'quill-no-border': !this.border
}
];
},
styles () {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
}
},
watch: {
value: {
handler (val) {
if (val !== this.currentValue) {
this.currentValue = val;
if (this.Quill) {
this.Quill.pasteHTML(this.value);
}
}
},
immediate: true
}
},
mounted () {
this.init();
},
beforeDestroy () {
//
this.Quill = null;
},
methods: {
init () {
let toeval = "this.$refs."+this.toref
const editor = eval(toeval)
//
this.Quill = new Quill(editor, this.options);
console.log(33,this.Quill)
//
this.Quill.pasteHTML(this.currentValue);
if(this.toTop){
this.$nextTick(() => {
window.scrollTo(0,0)
})
}
//
this.Quill.on('text-change', (delta, oldDelta, source) => {
const html = this.$refs[this.toref].children[0].innerHTML;
const text = this.Quill.getText();
const quill = this.Quill;
//
this.currentValue = html;
// v-model
this.$emit('input', html);
//
this.$emit('on-change', { html, text, quill });
});
// quill
this.Quill.on('text-change', (delta, oldDelta, source) => {
this.$emit('on-text-change', delta, oldDelta, source);
});
this.Quill.on('selection-change', (range, oldRange, source) => {
this.$emit('on-selection-change', range, oldRange, source);
});
this.Quill.on('editor-change', (eventName, ...args) => {
this.$emit('on-editor-change', eventName, ...args);
});
},
beforeUpload(file){
this.loading = true
},
editorUploadSuccess (res) {
//
let toeval = "this.$refs."+this.toref+'.quill'
// console.log("toeval",toeval);
// let quill = eval(toeval);
let quill = this.Quill
//
console.log(11,toeval,this.toref,this.Quill,quill,quill.selection)
if (res.data.filesResult.fileUrl) {
//
let length = quill.selection.savedRange.index;
// res
quill.insertEmbed(length, 'image', res.data.filesResult.fileUrl)
//
quill.setSelection(length + 1)
} else {
this.$message.success('图片插入失败')
}
this.loading = false
},
}
}
</script>
<style lang="scss" scoped>
.quill-no-border{
.ql-toolbar.ql-snow{
border: none;
border-bottom: 1px solid #e8eaec;
}
.ql-container.ql-snow{
border: none;
}
}
</style>

@ -1,15 +0,0 @@
export default [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean'],
['link', 'image', 'video']
]

@ -61,7 +61,7 @@
:append-to-body="false">
<div class="flex-between mgb20">
<div style="width: 100%;height: 400px;overflow: auto;margin: auto;background: #F5F5F5">
<!-- <el-tree class="add-tree"
<el-tree class="add-tree"
style="background: #F5F5F5"
:data="treeData"
@check="currentChecked"
@ -77,7 +77,7 @@
<em class="exist"
v-if="data.exist">已导入</em>
</span>
</el-tree> -->
</el-tree>
</div>
</div>
<span slot="footer"
@ -466,11 +466,11 @@
type="text"
@click="handleSave(scope.row, scope.$index)">保存
</el-button>
<el-button v-show="!scope.row.isDisabled"
<!-- <el-button v-show="!scope.row.isDisabled"
size="mini"
type="text"
@click="handleCancel(scope.row, scope.$index)">取消
</el-button>
</el-button> -->
<el-button v-show="scope.row.isDisabled"
size="mini"
type="text"
@ -627,6 +627,7 @@ export default {
item.i = index
//
let lists = JSON.parse(JSON.stringify(this.treeData))
// let lists = this.treeData
if (item.operationIds) {
let list = lists
item.operationIData = []
@ -645,9 +646,11 @@ export default {
// await this.getSubjectData(item.emptyOne, index);
}
});
console.log("🚀 ~ file: Transaction.vue:646 ~ this.tableData.forEach ~ this.tableData:", this.tableData)
this.setIndex()
this.loading = false
this.$nextTick(() => {
this.loading = false
})
console.log("🚀 ~ file: Transaction.vue:646 ~ this.tableData.forEach ~ this.tableData:", this.treeData)
} else {
this.$message.warning(res.message);
this.loading = false
@ -929,7 +932,6 @@ export default {
if (status == 200) {
if (process.length) {
this.$store.commit('setTreeDataStore', { treeDataStore: process })
console.log("🚀 ~ file: Transaction.vue:932 ~ this.$post ~ process:", process)
this.treeData = this.toTreeId(process);
this.loading = false
if (this.$route.query.lcId) {
@ -1171,7 +1173,7 @@ export default {
},
handleEdit (row) { //
this.judgePoints = true
this.tableDataCopy = deepCopy(this.tableData); //
// this.tableDataCopy = deepCopy(this.tableData); //
row.isDisabled = false;
row.isSave = false;
},

Loading…
Cancel
Save