Commit 44144c70 by zhangquan

添加预览操作

1 parent 6f07c77e
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
</div> </div>
<div class="footer-btn"> <div class="footer-btn">
<el-button @click="handelCancel">取消</el-button> <el-button @click="handelCancel">取消</el-button>
<el-button type="primary" @click="commitTemplate('preview')">预览</el-button>
<el-button type="primary" @click="commitTemplate">提交</el-button> <el-button type="primary" @click="commitTemplate">提交</el-button>
</div> </div>
</div> </div>
<pdf-dialog :isVisible="isPdfVisible" title="合同" :pdfUrl="pdfUrl" @closeDialog="handlePdfClose"></pdf-dialog>
</div> </div>
</template> </template>
...@@ -44,17 +46,24 @@ const errorTipObj = { ...@@ -44,17 +46,24 @@ const errorTipObj = {
import FoldFrame from './components/FoldFrame' import FoldFrame from './components/FoldFrame'
import Upload from '@/components/Upload' import Upload from '@/components/Upload'
import Editor from '@/components/Editor' import Editor from '@/components/Editor'
const replaceArr = ['contractIntroduce', 'relevantDefinition', 'useConditions','serviceScope', 'exclusionLiability','serviceData', 'specialStatement'] import pdfDialog from '@/views/beforeSale/pdfDialog'
export default { export default {
name: 'AddTmpl', name: 'AddTmpl',
components:{ components:{
Editor, Editor,
Upload, Upload,
FoldFrame FoldFrame,
pdfDialog
}, },
data() { data() {
return { return {
isPdfVisible: false,
pdfUrl: '',
placeholderList: [], placeholderList: [],
pdfObj :{
merchantId: '',
packageCode: ''
},
contentObj: { contentObj: {
id: '', id: '',
logoUrl: '', logoUrl: '',
...@@ -149,6 +158,10 @@ export default { ...@@ -149,6 +158,10 @@ export default {
for(const key in this.contentObj){ for(const key in this.contentObj){
this.contentObj[key] = res.templateConfig[key] this.contentObj[key] = res.templateConfig[key]
} }
this.pdfObj = {
merchantId: res.templateConfig.merchantId,
packageCode: res.templateConfig.packageCode
},
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.useConditionsRef[0].replaceText() this.$refs.useConditionsRef[0].replaceText()
}) })
...@@ -159,7 +172,7 @@ export default { ...@@ -159,7 +172,7 @@ export default {
this.$router.push('/ContractManager/index') this.$router.push('/ContractManager/index')
}, },
getParams(){ getParams(){
const 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.*?class.*?keyname="(.*?)".*?<\/span>/g,'$1')
for(const key in params){ for(const key in params){
...@@ -174,14 +187,34 @@ export default { ...@@ -174,14 +187,34 @@ export default {
if(errorTip) return {status: -1, errorTip} if(errorTip) return {status: -1, errorTip}
return params return params
}, },
commitTemplate(){ 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'){
this.handlePdf()
}else{
this.$message.success('编辑成功') this.$message.success('编辑成功')
this.$router.push('/ContractManager/index') this.$router.push('/ContractManager/index')
} }
}
})
},
handlePdfClose() {
this.isPdfVisible = !this.isPdfVisible
},
handlePdf() {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
this.$apis.contractManager.printContractApi({ packageCode : this.pdfObj.packageCode , merchantId: this.pdfObj.merchantId }).then(res => {
this.pdfUrl = res
this.handlePdfClose()
loading.close()
}) })
}, },
uploadSuccess(e){ uploadSuccess(e){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!