211 lines
6.1 KiB
Plaintext
211 lines
6.1 KiB
Plaintext
<template>
|
|
<div class="app-container">
|
|
<div style="margin-top:20px;margin-left:10px;">
|
|
<el-form ref="form" :model="row" label-width="85px">
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="模板名称">
|
|
<el-input v-model="row.templateName"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="6">
|
|
<el-form-item label="axisX">
|
|
<el-input v-model="axisX"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item label="axisY">
|
|
<el-input v-model="axisY"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item label="宽" label-width="50px">
|
|
<el-input v-model="width"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item label="高" label-width="50px">
|
|
<el-input v-model="height"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<!-- <el-col :span="6">
|
|
<el-form-item label="条码参数">
|
|
<el-input v-model="barsContent"></el-input>
|
|
</el-form-item>
|
|
</el-col> -->
|
|
</el-row>
|
|
<el-row >
|
|
<el-col :span="6">
|
|
<el-form-item label="条码模式">
|
|
<el-select v-model="dictType" >
|
|
<el-option
|
|
v-for="(dict, index) in dictTypeList"
|
|
:key="index"
|
|
:label="dict.text"
|
|
:value="dict.key"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="18">
|
|
<el-form-item label="替换参数">
|
|
<el-input v-model="paramsContent" placeholder="以,隔开"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
</div>
|
|
<div style="margin-left:10px;display: flex;flex-direction: row;height: 400px;align-items: center;justify-content: center">
|
|
<div style="flex: 5">
|
|
<el-input
|
|
type="textarea"
|
|
v-model="row.templateContent"
|
|
/>
|
|
</div>
|
|
|
|
<div style="flex: 1;padding-left: 30px">
|
|
<div v-html="row.templateContent">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="text-align: center">
|
|
<el-button type="primary" @click="OnSubmit">提交</el-button>
|
|
<el-button @click="close">取消</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'edit',
|
|
data() {
|
|
return {
|
|
axisX:"",
|
|
axisY:"",
|
|
width:"",
|
|
height:"",
|
|
barsContent:"",
|
|
paramsContent:"",
|
|
dictType:"",
|
|
row: {},
|
|
rowIndex: 50,
|
|
dictTypeList:[
|
|
{text:'条形码',key:"1"},
|
|
{text:'二维码',key:"2"}
|
|
]
|
|
}
|
|
},
|
|
async mounted() {
|
|
console.log(this.form,'1098')
|
|
if (this.formType==2){
|
|
this.row = this.form
|
|
|
|
let resp=await this.$printTemplate.getPrinterTemplate(this.row.templateName)
|
|
|
|
let printTemplateList = resp.data.data.printTemplateList;
|
|
let content=[]
|
|
printTemplateList.forEach(o=>{
|
|
if(o.dictType==0){
|
|
content.push(o.paramsContent)
|
|
}
|
|
else{
|
|
this.axisX=o.axisX
|
|
this.axisY=o.axisY
|
|
this.width=o.width
|
|
this.height=o.height
|
|
this.barsContent=o.paramsContent
|
|
this.dictType=String(o.dictType)
|
|
}
|
|
})
|
|
this.paramsContent=content.join(",")
|
|
}
|
|
|
|
},
|
|
created() {
|
|
},
|
|
props: {
|
|
layerid: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
formType:{
|
|
type:Number,
|
|
default:0,
|
|
},
|
|
lydata: {
|
|
type: Object,
|
|
default: () => {
|
|
return {}
|
|
}
|
|
},
|
|
form: {}
|
|
},
|
|
methods: {
|
|
close() {
|
|
this.$layer.close(this.layerid)
|
|
},
|
|
async OnSubmit() {
|
|
|
|
let printTemplateList=[]
|
|
printTemplateList.push({axisX:this.axisX,axisY:this.axisY,width:this.width,height:this.height,paramsContent:this.barsContent,dictType:this.dictType})//条码
|
|
let paramsContentArray=this.paramsContent.split(",")//替换参数
|
|
paramsContentArray.forEach(o=>{
|
|
printTemplateList.push({axisX:null,axisY:null,width:null,height:null,paramsContent:o,dictType:0})//条码
|
|
})
|
|
let printerType=this.row
|
|
|
|
if (this.formType==1){
|
|
console.log(this.templateName,'0')
|
|
let res0=await this.$printTemplate.getList({ pageNo: 1,pageSize: 50})
|
|
let tempObj=res0.data.data.data.find(o=>{return o.templateName==this.row.templateName});
|
|
if(tempObj!=undefined){
|
|
this.$message.warning('跟已有条码模板名称重复!请修改名称')
|
|
return
|
|
}
|
|
//上面几行先判断是否跟现有的名字重复
|
|
let params = {printTemplateList:printTemplateList,printerType:printerType}
|
|
this.$printTemplate.add(params).then((resp) => {
|
|
if (resp.data.code == 200) {
|
|
this.$parent.getList()
|
|
this.$layer.close(this.layerid)
|
|
this.$message.success('添加成功!')
|
|
}
|
|
})
|
|
}else {
|
|
|
|
printTemplateList.forEach(o=>{o.templateId=this.row.id})
|
|
let resp=await this.$printTemplate.update(this.row)
|
|
if (resp.data.code == 200) {
|
|
let params={baPrinterTypeArgsList:printTemplateList,templateId:this.row.id}
|
|
let resp1=await this.$printTemplate.updateArgs(params)
|
|
if(resp1.data.code==200)
|
|
{
|
|
this.$parent.getList()
|
|
this.$layer.close(this.layerid)
|
|
this.$message.success('修改成功!')
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.app-container {
|
|
padding: 0;
|
|
height: 100%;
|
|
width: 90%;
|
|
}
|
|
|
|
> > > .el-textarea__inner {
|
|
height: 330px;
|
|
}
|
|
</style>
|