Commit d7ec1baf by zhangquan

修改富文本插件

1 parent a48b5f4b
This diff could not be displayed because it is too large.
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^1.0.2",
"core-js": "^3.4.4", "core-js": "^3.4.4",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"el-tree-transfer": "^2.2.6", "el-tree-transfer": "^2.2.6",
...@@ -17,8 +19,7 @@ ...@@ -17,8 +19,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vuex": "^3.1.2", "vuex": "^3.1.2"
"wangeditor": "^4.7.12"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0", "@vue/cli-plugin-babel": "^4.1.0",
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
"number-precision": "^1.6.0", "number-precision": "^1.6.0",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.0",
"snabbdom": "^3.5.1",
"vue-cli-plugin-element": "^1.0.1", "vue-cli-plugin-element": "^1.0.1",
"vue-quill-editor": "^3.0.6", "vue-quill-editor": "^3.0.6",
"vue-template-compiler": "^2.6.10" "vue-template-compiler": "^2.6.10"
......
export function attachmentToHtml(elem, childrenHtml) {
// JS 语法
// 获取附件元素的数据
const { key = '', name = '' } = elem
// 生成 HTML 代码
const html = `<span data-w-e-type="text" data-key="${key}" data-name="${name}">${name}</span>`
return html
}
<template> <template>
<div> <div class="editor-ctnr">
<div :id="'div-demo' + idName"></div> <!-- <el-button @click="insertNode">插入元素</el-button>
<div @click="setHtml">456456</div> <el-button @click="insertOtherNode">插入其他元素</el-button>
<el-button @click="getData">获取内容</el-button>
<el-button @click="setData">设置内容</el-button> -->
<label v-if="label" for="" :class="['content-label', { 'required-field': required }]">{{ label }}</label>
<div class="editor" style="border: 1px solid #ccc;">
<Toolbar v-if="hasTool" style="border-bottom: 1px solid #ccc" :editor="editor" :defaultConfig="toolbarConfig" :mode="mode" />
<Editor style="min-height: 52px; overflow-y: hidden;" @onChange="onChange" v-model="value" :defaultConfig="editorConfig" :mode="mode" @onCreated="onCreated" />
</div>
</div> </div>
</template> </template>
<script> <script>
import E from 'wangeditor' import Vue from 'vue'
export default { import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
name: 'textBox', import { Boot, DomEditor } from '@wangeditor/editor'
data() {
return { import { withBreakAndDelete } from './withimage'
editor: '', Boot.registerPlugin(withBreakAndDelete)
content: '',
editorOption: {} import { attachmentToHtml } from './attachmentToHtml'
} const elemToHtmlConf = {
type: 'text', // 新元素的 type ,重要!!!
elemToHtml: attachmentToHtml
}
Boot.registerElemToHtml(elemToHtmlConf)
import { renderAttachment } from './renderAttachment'
const renderElemConf = {
type: 'text', // 新元素 type ,重要!!!
renderElem: renderAttachment
}
Boot.registerRenderElem(renderElemConf)
import { parseAttachmentHtml } from './parseAttachmentHtml'
const parseHtmlConf = {
selector: 'span[data-w-e-type="text"]', // CSS 选择器,匹配特定的 HTML 标签
parseElemHtml: parseAttachmentHtml
}
Boot.registerParseElemHtml(parseHtmlConf)
export default Vue.extend({
components: { Editor, Toolbar },
model: {
prop: 'value',
event: 'change'
}, },
props: { props: {
excludeMenus: { required: {
type: Array, type: Boolean,
default: () => ['code', 'video'] default: false
},
hasTool: {
type: Boolean,
default: true
}, },
boxHeight: { value: {
type: Number, type: Object
default: 240
}, },
idName: { label: {
type: String, type: String,
default: ''
},
operateList: {
type: Array,
default: () => { default: () => {
return (Math.random(5) * 10000).toFixed(0) return []
} }
},
disabled: {
type: Boolean,
default: false
} }
}, },
mounted() {
this.getEdit() data() {
return {
editor: null,
html: '',
toolbarConfig: {
toolbarKeys: ['fontSize', 'lineHeight', 'underline', 'through', 'color', 'bgColor', 'insertTable', 'undo', 'redo', 'clearStyle']
// toolbarKeys: ['fontSize', 'lineHeight', 'underline', 'through', 'color', 'bgColor', 'insertTable', 'undo', 'redo', 'clearStyle']
}, },
methods: { editorConfig: {
getEdit() { placeholder: '请输入内容...'
const _this = this },
this.editor = new E(`#div-demo${this.idName}`) mode: 'default' // or 'simple'
this.editor.config.uploadImgShowBase64 = true
this.editor.config.showMenuTooltips = true
this.editor.config.menuTooltipPosition = 'down'
this.editor.config.height = this.boxHeight
this.editor.config.width = 500
this.editor.config.excludeMenus = this.excludeMenus
this.editor.config.onchange = html => {
// console.log(html);
this.content = html // 绑定当前逐渐地值
this.$emit('change', this.content) // 将内容同步到父组件中
}
this.editor.config.onfocus = () => {
this.$emit('focus')
}
// 上传图片
this.editor.config.customUploadImg = function(resultFiles, insertImgFn) {
var file = resultFiles[0]
var reader = new FileReader()
// 默认1MB
const limitSize = 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
_this.$message.error('上传图片大小不能超过' + limitSize + 'MB!')
return true
}
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
_this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
// console.log(res)
insertImgFn(res)
} }
}) },
// resultFiles 是 input 中选中的文件列表 methods: {
// insertImgFn 是获取图片 url 后,插入到编辑器的方法 onChange(editer) {
// 上传图片,返回结果,将图片插入到编辑器中 this.$emit('change', this.editor.getHtml())
},
onCreated(editor) {
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
},
setData() {
this.editor.setHtml(`<p>模拟 Ajax 异步设置内容 HTML<span data-w-e-type="text" data-key="#{sadasd}" data-name="张三">张三</span>`)
},
getData() {
const toolbar = DomEditor.getToolbar(this.editor)
const curToolbarConfig = toolbar.getConfig()
console.log(curToolbarConfig.toolbarKeys)
event.preventDefault()
console.log(this.editor.getHtml())
// return false
},
insertNode() {
event.preventDefault()
// const dom = {
// // JS 语法
// type: 'text',
// name: '张三',
// key: '#{packagdasdasdiod}',
// children: [{ text: '' }]
// }
const resume = {
// JS 语法
type: 'text',
name: '张三',
key: '#{packagePeriod}',
children: [{ text: '' }]
} }
this.editor.insertNode(resume)
setTimeout(() => {
this.editor.focus()
this.editor.move(1)
}, 300)
},
insertOtherNode() {
event.preventDefault()
const dom = {
// JS 语法
type: 'text',
name: '李四',
key: '#{packageP三生三世骚eriod}',
children: [{ text: '' }]
} }
// 上传视频 this.editor.insertNode(dom)
this.editor.config.customUploadVideo = function(resultFiles, insertVideoFn) { setTimeout(() => {
var file = resultFiles[0] this.editor.focus()
var reader = new FileReader() this.editor.move(1)
// 默认1MB }, 300)
const limitSize = 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
_this.$message.error('上传视频大小不能超过' + limitSize + 'MB!')
return true
} }
reader.readAsDataURL(file) },
reader.onload = e => { mounted() {},
const videoFile = e.target.result beforeDestroy() {
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + videoFile.split(',')[1] const editor = this.editor
_this.$apis.common.pictureUpload({ file: base64 }).then(res => { if (editor == null) return
if (res) { editor.destroy() // 组件销毁时,及时销毁编辑器
// console.log(res)
insertVideoFn(res)
} }
}) })
// resultFiles 是 input 中选中的文件列表 </script>
// insertImgFn 是获取图片 url 后,插入到编辑器的方法 <style src="@wangeditor/editor/dist/css/style.css"></style>
// 上传图片,返回结果,将图片插入到编辑器中 <style scoped lang="scss">
.editor-ctnr {
width: 100%;
height: 100%;
display: flex;
.editor {
background: #fff;
} }
.content-label {
flex-shrink: 0;
width: 154px;
display: inline-block;
vertical-align: top;
height: 20px;
font-weight: 400;
font-size: 14px;
color: #333333;
text-align: right;
line-height: 20px;
} }
this.editor.config.onchangeTimeout = 5000 /deep/ .w-e-text-container {
this.editor.create() p {
}, margin: 0;
setEdit(html) {
this.$nextTick(() => {
this.editor.txt.html(`<div contenteditable="false">456456</div>`)
})
},
setHtml() {
this.$nextTick(() => {
console.log(this.editor)
this.editor.txt.append(`<span contenteditable="false">456456</span>`)
})
},
forbidEdit() {
// this.editor.$textElem.attr('contenteditable', false)
this.editor.disable()
} }
} }
} }
</script>
<style lang="scss" scoped>
#div-demo {
// margin: 16px 300px 0 0;
}
.el-form .editor {
margin-top: 20px;
}
.myQuillEditor {
background-color: #fff;
height: 200px;
}
</style>
<style>
.w-e-text-container {
z-index: 1 !important;
}
.w-e-toolbar {
z-index: 2 !important;
}
</style> </style>
export function parseAttachmentHtml(domElem, children, editor) {
const key = domElem.getAttribute('data-key') || ''
const name = domElem.getAttribute('data-name') || ''
console.log(domElem, children, editor)
// 生成“附件”元素(按照此前约定的数据结构)
const myResume = {
type: 'text',
name,
key,
children: [{ text: '' }]
}
return myResume
}
import { h } from 'snabbdom'
/**
* 渲染“附件”元素到编辑器
* @param elem 附件元素,即上文的 myResume
* @param children 元素子节点,void 元素可忽略
* @param editor 编辑器实例
* @returns vnode 节点(通过 snabbdom.js 的 h 函数生成)
*/
export function renderAttachment(elem, children, editor) {
const { name = '' } = elem
const Vnode = h(
'span',
{
props: { contentEditable: false },
style: { color: '#5f5efb' }
},
// 子节点
[name]
)
return Vnode
}
import { DomEditor } from '@wangeditor/editor'
export function withBreakAndDelete(editor) {
const { isInline, isVoid } = editor
const newEditor = editor
newEditor.isInline = elem => {
const type = DomEditor.getNodeType(elem)
if (type === 'text') return true
return isInline(elem)
}
newEditor.isVoid = elem => {
const type = DomEditor.getNodeType(elem)
if (type === 'text') return true
return isVoid(elem)
}
return newEditor // 返回 newEditor ,重要!!!
}
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
<div class="main"> <div class="main">
<div class="edit-bar"> <div class="edit-bar">
<FoldFrame :name="item.title" v-for="item in contentList" :key="item.key"> <FoldFrame :name="item.title" v-for="item in contentList" :key="item.key">
<div v-if="item.type=='img'" class="bar-content"> <div v-if="item.type == 'img'" class="bar-content">
<div v-if="item.key=='electronicSealUrl'" class="input-content"> <div v-if="item.key == 'electronicSealUrl'" class="input-content">
<label class="required-field" for="">服务主体:</label> <label class="required-field" for="">服务主体:</label>
<el-input size="small" type="text" v-model="contentObj.serviceSubject" ></el-input> <el-input size="small" type="text" v-model="contentObj.serviceSubject"></el-input>
</div> </div>
<Upload :required="true" @uploadSuccess="uploadSuccess" @delImage="delImage" class="upload" :name="item.label+':'" :attr="item.key" :url="contentObj[item.key]" :defaultStyle="{width:'208px'}"></Upload> <Upload :required="true" @uploadSuccess="uploadSuccess" @delImage="delImage" class="upload" :name="item.label + ':'" :attr="item.key" :url="contentObj[item.key]" :defaultStyle="{ width: '208px' }"></Upload>
<span class="upload-tip">建议高度:48px</span> <span class="upload-tip">建议高度:48px</span>
</div> </div>
<div v-if="item.type=='richText'" class="bar-content"> <div v-if="item.type == 'richText'" class="bar-content">
<div v-if="item.key=='contractIntroduce'" class="input-content"> <div v-if="item.key == 'contractIntroduce'" class="input-content">
<label class="required-field" for="">合同标题:</label> <label class="required-field" for="">合同标题:</label>
<el-input size="small" type="text" v-model="contentObj.contractTitle"></el-input> <el-input size="small" type="text" v-model="contentObj.contractTitle"></el-input>
</div> </div>
<Editor :required="true" :ref="item.key+'Ref'" :operateList="item.key=='useConditions' ? placeholderList : []" :label="item.label" v-model="contentObj[item.key]"></Editor> <Editor :required="true" :ref="item.key + 'Ref'" :operateList="item.key == 'useConditions' ? placeholderList : []" :label="item.label" v-model="contentObj[item.key]"></Editor>
</div> </div>
</FoldFrame> </FoldFrame>
</div> </div>
...@@ -49,7 +49,7 @@ import Editor from '@/components/Editor' ...@@ -49,7 +49,7 @@ import Editor from '@/components/Editor'
import pdfDialog from '@/views/beforeSale/pdfDialog' import pdfDialog from '@/views/beforeSale/pdfDialog'
export default { export default {
name: 'AddTmpl', name: 'AddTmpl',
components:{ components: {
Editor, Editor,
Upload, Upload,
FoldFrame, FoldFrame,
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
isPdfVisible: false, isPdfVisible: false,
pdfUrl: '', pdfUrl: '',
placeholderList: [], placeholderList: [],
pdfObj :{ pdfObj: {
merchantId: '', merchantId: '',
packageCode: '' packageCode: ''
}, },
...@@ -138,13 +138,12 @@ export default { ...@@ -138,13 +138,12 @@ export default {
label: '电子章图片', label: '电子章图片',
key: 'electronicSealUrl', key: 'electronicSealUrl',
type: 'img' type: 'img'
}, }
] ]
} }
}, },
created(){ created() {},
},
mounted() { mounted() {
this.getContractDetail() this.getContractDetail()
...@@ -152,49 +151,55 @@ export default { ...@@ -152,49 +151,55 @@ export default {
methods: { methods: {
getContractDetail() { getContractDetail() {
this.$apis.contractManager.getContractDetailApi({id: this.$route.params.id}).then(res => { this.$apis.contractManager.getContractDetailApi({ id: this.$route.params.id }).then(res => {
if(res && res.templateConfig){ if (res && res.templateConfig) {
this.placeholderList = res.placeholderList this.placeholderList = res.placeholderList
for(const key in this.contentObj){ for (const key in this.contentObj) {
if (key != 'useConditions') {
this.contentObj[key] = res.templateConfig[key] this.contentObj[key] = res.templateConfig[key]
} else {
for (var i = 0; i < res.placeholderList.length; i++) {
var placeholder = res.placeholderList[i]
let targetStr = `<span data-w-e-type="text" data-key="${placeholder.key}" data-name="${placeholder.name}">${placeholder.name}</span>`
res.templateConfig.useConditions = res.templateConfig.useConditions.replace(new RegExp(placeholder.key, 'g'), targetStr)
}
this.contentObj.useConditions = res.templateConfig.useConditions
}
} }
this.pdfObj = { this.pdfObj = {
merchantId: res.templateConfig.merchantId, merchantId: res.templateConfig.merchantId,
packageCode: res.templateConfig.packageCode packageCode: res.templateConfig.packageCode
}, }
this.$nextTick(()=>{
this.$refs.useConditionsRef[0].replaceText()
})
} }
}) })
}, },
handelCancel(){ handelCancel() {
this.$router.push('/ContractManager/index') this.$router.push('/ContractManager/index')
}, },
getParams(){ getParams() {
let params = this.$common.utils.deepClone(this.contentObj) let params = this.$common.utils.deepClone(this.contentObj)
let errorTip = ''; let errorTip = ''
params.useConditions = params.useConditions?.replace(/<span.*?class.*?keyname="(.*?)".*?<\/span>/g,'$1') params.useConditions = params.useConditions?.replace(/<span.*?data-w-e-type.*?data-key="(.*?)".*?<\/span>/g, '$1')
for(const key in params){ for (const key in params) {
if(key!='id' && !params[key]){ if (key != 'id' && !params[key]) {
if(key == 'electronicSealUrl' || key == 'logoUrl'){ if (key == 'electronicSealUrl' || key == 'logoUrl') {
errorTip = `请上传${key == 'logoUrl' ? 'Logo图': '电子章图片'}` errorTip = `请上传${key == 'logoUrl' ? 'Logo图' : '电子章图片'}`
}else{ } else {
errorTip = `${errorTipObj[key]}不能为空` errorTip = `${errorTipObj[key]}不能为空`
} }
} }
} }
if(errorTip) return {status: -1, errorTip} if (errorTip) return { status: -1, errorTip }
return params return params
}, },
commitTemplate(type){ commitTemplate(type) {
const params = this.getParams() const params = this.getParams()
if(params.status == -1) return this.$message.error(params.errorTip) if (params.status == -1) return this.$message.error(params.errorTip)
this.$apis.contractManager.saveContractTemplateApi({...params}).then(res => { this.$apis.contractManager.saveContractTemplateApi({ ...params }).then(res => {
if(res){ if (res) {
if(type=='preview'){ if (type == 'preview') {
this.handlePdf() this.handlePdf()
}else{ } else {
this.$message.success('编辑成功') this.$message.success('编辑成功')
this.$router.push('/ContractManager/index') this.$router.push('/ContractManager/index')
} }
...@@ -211,27 +216,27 @@ export default { ...@@ -211,27 +216,27 @@ export default {
spinner: 'el-icon-loading', spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)' background: 'rgba(0, 0, 0, 0.3)'
}) })
this.$apis.contractManager.printContractApi({ packageCode : this.pdfObj.packageCode , merchantId: this.pdfObj.merchantId }).then(res => { this.$apis.contractManager.printContractApi({ packageCode: this.pdfObj.packageCode, merchantId: this.pdfObj.merchantId }).then(res => {
this.pdfUrl = res this.pdfUrl = res
this.handlePdfClose() this.handlePdfClose()
loading.close() loading.close()
}) })
}, },
uploadSuccess(e){ uploadSuccess(e) {
this.contentObj[e.attr] = e.url this.contentObj[e.attr] = e.url
}, },
delImage(e){ delImage(e) {
this.contentObj[e.attr] = '' this.contentObj[e.attr] = ''
}, }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container{ .container {
background-color: #fff; background-color: #fff;
margin-bottom: 60px; margin-bottom: 60px;
.footer-btn-wrap{ .footer-btn-wrap {
width: 100%; width: 100%;
height: 60px; height: 60px;
line-height: 60px; line-height: 60px;
...@@ -243,15 +248,15 @@ export default { ...@@ -243,15 +248,15 @@ export default {
right: 0; right: 0;
box-shadow: 0 -2px 10px 0 #7a7a7a33; box-shadow: 0 -2px 10px 0 #7a7a7a33;
} }
.footer-btn{ .footer-btn {
text-align: center; text-align: center;
margin-top: 16px; margin-top: 16px;
} }
.input-content{ .input-content {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 24px; margin-bottom: 24px;
label{ label {
flex-shrink: 0; flex-shrink: 0;
width: 154px; width: 154px;
white-space: nowrap; white-space: nowrap;
...@@ -260,24 +265,24 @@ export default { ...@@ -260,24 +265,24 @@ export default {
font-size: 14px; font-size: 14px;
color: #333333; color: #333333;
} }
/deep/ .el-input__inner{ /deep/ .el-input__inner {
width: 342px; width: 342px;
} }
} }
.main{ .main {
padding: 10px 20px 32px; padding: 10px 20px 32px;
.edit-bar{ .edit-bar {
.bar-content{ .bar-content {
background: #F9F9F9; background: #f9f9f9;
padding: 20px; padding: 20px;
margin-bottom: 10px; margin-bottom: 10px;
/deep/ .editor{ /deep/ .editor {
width: 935px!important; width: 935px !important;
} }
.upload{ .upload {
display: inline-block; display: inline-block;
} }
.upload-tip{ .upload-tip {
height: 20px; height: 20px;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
...@@ -290,4 +295,3 @@ export default { ...@@ -290,4 +295,3 @@ export default {
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<!-- <el-button size="small" @click="toggleAll">全选</el-button> --> <!-- <el-button size="small" @click="toggleAll">全选</el-button> -->
<!-- <el-checkbox v-model="checkbox" @change="toggleAll" style="margin-left:20px">全选</el-checkbox> --> <!-- <el-checkbox v-model="checkbox" @change="toggleAll" style="margin-left:20px">全选</el-checkbox> -->
<div style="float: right;" class="primary_plain_btn"> <div style="float: right;" class="primary_plain_btn">
<el-button size="small" plain @click="batchOpenSale()">批量开通驻店销售</el-button>
<el-button size="small" plain @click="batchOperation(1)">批量开通</el-button> <el-button size="small" plain @click="batchOperation(1)">批量开通</el-button>
<el-button size="small" @click="batchOperation(2)">批量关闭</el-button> <el-button size="small" @click="batchOperation(2)">批量关闭</el-button>
<el-button size="small" @click="exportTable">导出</el-button> <el-button size="small" @click="exportTable">导出</el-button>
...@@ -259,6 +260,11 @@ export default { ...@@ -259,6 +260,11 @@ export default {
this.searchForm[this.searchSelectObj.idOrName.attr] = this.searchSelectObj.idOrName.value this.searchForm[this.searchSelectObj.idOrName.attr] = this.searchSelectObj.idOrName.value
this.$refs.table.refreshTable() this.$refs.table.refreshTable()
}, },
batchOpenSale(){
const data = this.$refs.table?.mutiSelectArr?.[this.tableParams.mutiSelectName] || []
const ids = data.map(item => item.id)
console.log(ids)
},
// ['开通', '关闭'] // // ['开通', '关闭'] //
batchOperation(status) { batchOperation(status) {
let { configIndexMutiTable } = this.$refs.table.$refs let { configIndexMutiTable } = this.$refs.table.$refs
......
...@@ -5,16 +5,18 @@ ...@@ -5,16 +5,18 @@
<th rowspan="2">规格</th> <th rowspan="2">规格</th>
<th rowspan="2">价格区间(万元)</th> <th rowspan="2">价格区间(万元)</th>
<th rowspan="2">价格系数</th> <th rowspan="2">价格系数</th>
<th colspan="2" v-for="(item, index) in tableData.salePeriodData" :key="index">{{item.servicePeriod}}年版</th> <th colspan="2" v-for="(item, index) in tableData.salePeriodData" :key="index">{{ item.servicePeriod }}年版</th>
</tr> </tr>
<tr> <tr>
<template v-for="(item, index) in tableData.salePeriodData"> <template v-for="(item, index) in tableData.salePeriodData">
<th :key="index">上架成本 <th :key="index">
上架成本
<!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top"> <!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top">
<img class="tip" :src="require('@/assets/tip.png')" /> <img class="tip" :src="require('@/assets/tip.png')" />
</el-tooltip> --> </el-tooltip> -->
</th> </th>
<th :key="index">销售成本 <th :key="index">
销售成本
<!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top"> <!-- <el-tooltip class="item" effect="dark" content="提示待运营提供" placement="top">
<img class="tip" :src="require('@/assets/tip.png')" /> <img class="tip" :src="require('@/assets/tip.png')" />
</el-tooltip> --> </el-tooltip> -->
...@@ -27,7 +29,7 @@ ...@@ -27,7 +29,7 @@
<td>-</td> <td>-</td>
<template v-for="(item, index) in tableData.salePeriodData"> <template v-for="(item, index) in tableData.salePeriodData">
<td :key="index"><el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardShelfCost')" :disabled="disabled" v-model="item.standardShelfCost"></el-input></td> <td :key="index"><el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardShelfCost')" :disabled="disabled" v-model="item.standardShelfCost"></el-input></td>
<td :key="index"> <el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardSalesCost')" :disabled="disabled" v-model="item.standardSalesCost"></el-input></td> <td :key="index"><el-input :placeholder="placeholder" @input="changePrice($event, item, 'standardSalesCost')" :disabled="disabled" v-model="item.standardSalesCost"></el-input></td>
</template> </template>
</tr> </tr>
<tr v-for="(item, index) in tableData.gradeConfigList" :key="index"> <tr v-for="(item, index) in tableData.gradeConfigList" :key="index">
...@@ -38,36 +40,36 @@ ...@@ -38,36 +40,36 @@
</td> </td>
<td><el-input :placeholder="placeholder" @input="changePrice($event, item, 'priceCoefficient')" :disabled="disabled" @blur="formatPrice($event, item, 'priceCoefficient', 100)" v-model="item.priceCoefficient"></el-input></td> <td><el-input :placeholder="placeholder" @input="changePrice($event, item, 'priceCoefficient')" :disabled="disabled" @blur="formatPrice($event, item, 'priceCoefficient', 100)" v-model="item.priceCoefficient"></el-input></td>
<template v-for="(ele, eIdx) in tableData.salePeriodData"> <template v-for="(ele, eIdx) in tableData.salePeriodData">
<td :key="eIdx">{{calcPrice(ele.standardShelfCost, item.priceCoefficient)}}</td> <td :key="eIdx">{{ calcPrice(ele.standardShelfCost, item.priceCoefficient) }}</td>
<td :key="eIdx">{{calcPrice(ele.standardSalesCost, item.priceCoefficient)}}</td> <td :key="eIdx">{{ calcPrice(ele.standardSalesCost, item.priceCoefficient) }}</td>
</template> </template>
</tr> </tr>
<tr class="desc-wrap"> <tr class="desc-wrap">
<td class="desc-td" :colspan="tableData.salePeriodData.length*2 + 3"> <td class="desc-td" :colspan="tableData.salePeriodData.length * 2 + 3">
<div class="desc"> <div class="desc">
<label for="">服务条款概述:</label> <label for="">服务条款概述:</label>
<Editor :disabled="disabled" :editorOption="overviewOption" v-model="tableData.serviceOverview"></Editor> <Editor :disabled="disabled" :hasTool="false" :editorOption="overviewOption" v-model="tableData.serviceOverview"></Editor>
</div> </div>
</td> </td>
</tr> </tr>
<tr class="desc-wrap"> <tr class="desc-wrap">
<td class="desc-td" :colspan="tableData.salePeriodData.length*2+3"> <td class="desc-td" :colspan="tableData.salePeriodData.length * 2 + 3">
<div class="desc"> <div class="desc">
<label for="">规格详细描述:</label> <label for="">规格详细描述:</label>
<Editor :disabled="disabled" :editorOption="DetailOption" v-model="tableData.serviceDetail"></Editor> <Editor :disabled="disabled" :hasTool="false" :editorOption="DetailOption" v-model="tableData.serviceDetail"></Editor>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
</template> </template>
<script> <script>
import Editor from '@/components/Editor' import Editor from '@/components/Editor'
export default { export default {
name: 'ServicesTable', name: 'ServicesTable',
components:{ components: {
Editor, Editor
}, },
props: { props: {
name: { name: {
...@@ -76,7 +78,7 @@ ...@@ -76,7 +78,7 @@
}, },
tableData: { tableData: {
type: String, type: String,
default: ()=>{ default: () => {
return {} return {}
} }
}, },
...@@ -102,8 +104,8 @@ ...@@ -102,8 +104,8 @@
toolbar: false, toolbar: false,
clipboard: { clipboard: {
// 粘贴版,处理粘贴时候的自带样式 // 粘贴版,处理粘贴时候的自带样式
matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]], matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]]
}, }
} }
}, },
DetailOption: { DetailOption: {
...@@ -112,24 +114,34 @@ ...@@ -112,24 +114,34 @@
toolbar: false, toolbar: false,
clipboard: { clipboard: {
// 粘贴版,处理粘贴时候的自带样式 // 粘贴版,处理粘贴时候的自带样式
matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]], matchers: [[Node.ELEMENT_NODE, this.HandleCustomMatcher]]
}, }
} }
} }
} }
}, },
methods: { methods: {
changePrice(value, item , key){ changePrice(value, item, key) {
item[key] = value ? value.replace(/^0\d/g, '0').replace(/[^\d.]/g, '').replace(/^\./g, '').replace(/^\d{6}\d+(\.\d+)?/g, value.substr(0,6)).replace(/\.{2,}/g, '').replace('.', '$#$') item[key] = value
.replace(/\./g, '').replace('$#$', '.').replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3') : '' ? value
.replace(/^0\d/g, '0')
.replace(/[^\d.]/g, '')
.replace(/^\./g, '')
.replace(/^\d{6}\d+(\.\d+)?/g, value.substr(0, 6))
.replace(/\.{2,}/g, '')
.replace('.', '$#$')
.replace(/\./g, '')
.replace('$#$', '.')
.replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
: ''
}, },
formatPrice(e, item, key, maxNum){ formatPrice(e, item, key, maxNum) {
let num = e.target.value let num = e.target.value
if(num>maxNum){ if (num > maxNum) {
item[key] = maxNum item[key] = maxNum
} }
}, },
calcPrice(price1, price2){ calcPrice(price1, price2) {
price1 = price1 || 0 price1 = price1 || 0
price2 = price2 || 0 price2 = price2 || 0
return Number((price1 * price2).toFixed(2)) return Number((price1 * price2).toFixed(2))
...@@ -140,78 +152,76 @@ ...@@ -140,78 +152,76 @@
Delta.ops.forEach(op => { Delta.ops.forEach(op => {
if (op.insert && typeof op.insert === 'string') { if (op.insert && typeof op.insert === 'string') {
ops.push({ ops.push({
insert: op.insert, insert: op.insert
}) })
} }
}) })
Delta.ops = ops Delta.ops = ops
return Delta return Delta
},
} }
} }
</script> }
<style lang="scss" scoped> </script>
.table-wrap{ <style lang="scss" scoped>
.tip{ .table-wrap {
.tip {
width: 14px; width: 14px;
vertical-align: middle; vertical-align: middle;
margin-bottom: 2px; margin-bottom: 2px;
cursor: pointer; cursor: pointer;
} }
/deep/ .el-input__inner{ /deep/ .el-input__inner {
padding: 0 2px; padding: 0 2px;
text-align: center; text-align: center;
} }
th, td{ th,
border: 1px solid #E5E5E5; td {
border: 1px solid #e5e5e5;
padding: 0 16px; padding: 0 16px;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
} }
th{ th {
background: #F4F6FC; background: #f4f6fc;
font-weight: 600; font-weight: 600;
font-size: 14px; font-size: 14px;
color: #333333; color: #333333;
} }
td{ td {
font-weight: 400; font-weight: 400;
height: 56px; height: 56px;
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
} }
.price{ .price {
width: 136px; width: 136px;
.sign{ .sign {
margin: 0 6px; margin: 0 6px;
} }
.el-input{ .el-input {
width: 50px; width: 50px;
} }
} }
.desc-wrap{ .desc-wrap {
height: 88px; height: 88px;
.desc-td{ .desc-td {
padding: 12px 16px; padding: 12px 16px;
} }
.desc{ .desc {
display: flex; display: flex;
height: 100%; height: 100%;
label{ label {
white-space: nowrap; white-space: nowrap;
} }
/deep/ .editor-ctnr{ /deep/ .editor {
height: 100%; width: 100%;
.ql-container{ text-align: left;
border-radius: 4px;
.w-e-text-container {
border-radius: 4px; border-radius: 4px;
.ql-editor{
padding: 8px;
}
}
} }
} }
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
}
</style>
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
</div> </div>
<GLTable ref="equityRef" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn"> <GLTable ref="equityRef" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<div slot="statusSlot" slot-scope="scope"> <div slot="statusSlot" slot-scope="scope">
<span class="statsu-circle" :style="{'background-color': scope.scope.serviceStatus == 0 ? '#FDB757' : '#2CCA74'}"></span> <span class="statsu-circle" :style="{ 'background-color': scope.scope.serviceStatus == 0 ? '#FDB757' : '#2CCA74' }"></span>
<span>{{ scope.scope.serviceStatus == 0 ? '待配置': '已配置' }}</span> <span>{{ scope.scope.serviceStatus == 0 ? '待配置' : '已配置' }}</span>
</div> </div>
<span slot="auth-button" slot-scope="scope" :data="scope.scope"> <span slot="auth-button" slot-scope="scope" :data="scope.scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton> <GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
...@@ -22,13 +22,12 @@ ...@@ -22,13 +22,12 @@
</div> </div>
</template> </template>
<script> <script>
import * as dayjs from 'dayjs' import * as dayjs from 'dayjs'
import utils from '../../util/util' import utils from '../../util/util'
export default { export default {
name: 'equityList', name: 'equityList',
components:{ components: {},
},
data() { data() {
return { return {
size: 'small', size: 'small',
...@@ -42,7 +41,7 @@ ...@@ -42,7 +41,7 @@
type: 'text' type: 'text'
}, },
listeners: { listeners: {
click: row => this.addClause(2,row.scope) click: row => this.addClause(2, row.scope)
} }
}, },
{ {
...@@ -54,7 +53,7 @@ ...@@ -54,7 +53,7 @@
type: 'text' type: 'text'
}, },
listeners: { listeners: {
click: row => this.addClause(3,row.scope) click: row => this.addClause(3, row.scope)
} }
} }
], ],
...@@ -70,7 +69,7 @@ ...@@ -70,7 +69,7 @@
label: '服务名称', label: '服务名称',
name: 'serviceName', name: 'serviceName',
type: 'input', type: 'input',
isClear: true, isClear: true
}, },
{ {
label: '状态', label: '状态',
...@@ -92,7 +91,7 @@ ...@@ -92,7 +91,7 @@
], ],
optionId: 'id', optionId: 'id',
optionLabel: 'label', optionLabel: 'label',
isClear: true, isClear: true
}, },
{ {
label: '创建时间', label: '创建时间',
...@@ -132,7 +131,12 @@ ...@@ -132,7 +131,12 @@
minWidth: 280, minWidth: 280,
prop: 'salePeriod', prop: 'salePeriod',
formatter: cellValue => { formatter: cellValue => {
return cellValue.salePeriod?.length ? cellValue.salePeriod.split(',').map(item => item = item+'年').join('、') : '--' return cellValue.salePeriod?.length
? cellValue.salePeriod
.split(',')
.map(item => (item = item + '年'))
.join('、')
: '--'
} }
}, },
{ {
...@@ -169,12 +173,11 @@ ...@@ -169,12 +173,11 @@
} }
] ]
}, },
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }, pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
} }
}, },
mounted() { mounted() {},
},
methods: { methods: {
getParams() { getParams() {
...@@ -189,7 +192,7 @@ ...@@ -189,7 +192,7 @@
} }
delete params.createdDate delete params.createdDate
delete params.updatedDate delete params.updatedDate
return {...params} return { ...params }
}, },
beforeSearchFn() { beforeSearchFn() {
...@@ -236,7 +239,7 @@ ...@@ -236,7 +239,7 @@
let query = { let query = {
type type
} }
if(type!=1){ if (type != 1) {
query.id = id query.id = id
query.serviceCode = serviceCode query.serviceCode = serviceCode
query.serviceName = serviceName query.serviceName = serviceName
...@@ -245,22 +248,21 @@ ...@@ -245,22 +248,21 @@
this.$router.push('/serviceConfig/addService/' + queryStr) this.$router.push('/serviceConfig/addService/' + queryStr)
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container{ .container {
background-color: #ffffff; background-color: #ffffff;
padding: 20px; padding: 20px;
.statsu-circle{ .statsu-circle {
display: inline-block; display: inline-block;
width: 6px; width: 6px;
height: 6px; height: 6px;
border-radius: 50%; border-radius: 50%;
background-color: #FDB757; background-color: #fdb757;
margin-right: 8px; margin-right: 8px;
vertical-align: middle; vertical-align: middle;
} }
}
</style>
\ No newline at end of file \ No newline at end of file
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!