emis-frontend/src/views/emis/emisPrintTpl/designerPanel.vue
2024-08-13 22:37:11 +08:00

144 lines
3.5 KiB
Vue

<template>
<div >
<KrPrintDesigner ref="printDesigner" :temp-value="value" :widget-options="widgets" @save="handleSave" />
</div>
</template>
<!-- <template>
<kr-print-designer ref="printDesigner" :temp-value="value" :widget-options="widgets" @save="handleSave" />
</template> -->
<script>
import { listEmisPrintTpl, getEmisPrintTpl, delEmisPrintTpl, addEmisPrintTpl, updateEmisPrintTpl } from "@/api/emis/emisPrintTpl";
import KrPrintDesigner from "@/components/PrintDesigner/index.vue";
import "@/components/PrintDesigner/assets/style/index.scss";
import { OutStockOptions, InStockOptions } from '@/views/emis/emisPrintTpl/data/options.js'
export default {
props:{
id:{
type:[Number,Array]
}
},
components: { KrPrintDesigner },
data() {
return {
// 遮罩层
loading: true,
// 表单参数
form: {},
// 表单校验
rules: {
id: [
{ required: true, message: "id不能为空", trigger: "blur" }
],
status: [
{ required: true, message: "0-初始不能为空", trigger: "blur" }
],
},
index: '',
value: {
title: 'demo',
width: 750,
height: 550,
pageWidth: 750,
pageHeight: 550,
tempItems: [],
},
widgets: OutStockOptions,
}
},
created() {
// try {
// // let tempList = JSON.parse(localStorage.getItem('tempList')) || []
// // this.value = tempList[this.index]
// // this.widgets = this.value.type == 1 ? OutStockOptions : InStockOptions
// } catch (err) {
// console.error(err)
// }
this.initData();
},
methods: {
onTplUploaded(val){
// this.form.tplEncData=Base64.decode(val);
},
initData() {
if(this.id !=null) {
this.loading = true;
getEmisPrintTpl(this.id).then(response => {
this.form = response.data;
this.form.tplData={
title: 'demo',
width: 750,
height: 550,
pageWidth: 750,
pageHeight: 550,
tempItems: [],
}
this.loading = false;
});
}else{
this.reset();
}
},
// 取消按钮
cancel() {
this.reset();
this.$emit("on-cancel");
},
// 表单重置
reset() {
this.form = {
id: null,
code: null,
name: null,
version: null,
isPublic: null,
merchId: null,
expressType: null,
tplData: null,
tplEncData: null,
tplPdfData: null,
tplPicUrl: null,
status: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
createSite: null,
updateSite: null
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEmisPrintTpl(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
}
}
});
},
handleSave(data) {
// let tempList = JSON.parse(localStorage.getItem('tempList')) || []
// tempList[this.index] = data
// localStorage.setItem('tempList', JSON.stringify(tempList))
},
// 手动初始话模板数据
initTemp(){
// this.$refs.printDesigner.initTemp(this.value,this.widgets)
}
},
}
</script>