editDialog.vue
5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-13 16:42:26
-->
<template>
<el-form ref="ruleForm" :model="ruleForm" label-width="100px" :rules="rules">
<el-row>
<el-col :span="24">
<el-form-item label="模板编码:" prop="tmpno">
<el-input v-model="ruleForm.tmpno" :disabled="editFlag"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="模板名称:" prop="tmpname">
<el-input v-model="ruleForm.tmpname" :disabled="editFlag"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="模板设计:">
<el-button type="primary" @click="designByPRGData(ruleForm.tmpcontent)">模板设计</el-button>
<i class="el-icon-loading" style="font-size:24px;margin-left:10px;" v-if="loadStatus == '1'"></i>
<i class="el-icon-circle-check" style="font-size:24px;margin-left:10px;color:green"
v-if="loadStatus == '2'"></i>
</el-form-item>
</el-col>
</el-row>
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" v-show="false">
<embed id="LODOP_EM" type="application/x-print-lodop" width=800 height=600 pluginspage="install_lodop32.exe" />
</object>
<textarea rows="0" id="S1" cols="0" v-show="false"></textarea>
<el-form-item class="text-center">
<el-button @click="closeDialog">取消</el-button>
<el-button type="primary" @click="submitForm" plain>确定</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { getLodop } from "@/utils/LodopFuncs"
import { mapGetters } from 'vuex'
import store from '@/store/index.js'
import { addPrintTemplate, editPrintTemplate } from "@/api/print.js"
export default {
computed: {
...mapGetters(['dictData']),
},
props: {
formData: {
type: Object,
default: () => { }
}
},
data () {
return {
editFlag: false,
//打印模板设计保存状态 0:未操作 1:保存中 2:已保存
loadStatus: '0',
//表单提交数据
ruleForm: {
tmpno: '',
tmpname: '',
tmpfont: '',
tmpfontsize: '',
tmpcontent: ''
},
rules: {
tmpno: [
{ required: true, message: '模板编号不能为空', trigger: 'blur' }
],
tmpname: [
{ required: true, message: '模板名称不能为空', trigger: 'blur' }
],
},
}
},
mounted () {
if (JSON.stringify(this.formData) != "{}") this.getDetailInfo(this.formData)
},
methods: {
//表单提交
/**
* @description: 表单提交
* @author: renchao
*/
submitForm () {
if (this.loadStatus == '1') {
return this.$message.error("模板设计保存中,请等待...")
}
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.editFlag) {
this.editTemplate();
} else {
this.addTemplate();
}
} else {
return false;
}
});
},
//新增
/**
* @description: 新增
* @author: renchao
*/
addTemplate () {
addPrintTemplate(this.ruleForm).then(res => {
if (res.code == 200) {
store.dispatch('user/refreshPage', true);
this.$message.success('保存成功');
this.$popupCacel()
} else {
this.$message.error(res.message)
}
})
},
//编辑
/**
* @description: 编辑
* @author: renchao
*/
editTemplate () {
editPrintTemplate(this.ruleForm).then(res => {
if (res.code == 200) {
store.dispatch('user/refreshPage', true);
this.$message.success('保存成功');
this.$popupCacel()
} else {
this.$message.error(res.message)
}
})
},
/**
* @description: closeDialog
* @author: renchao
*/
closeDialog () {
this.$popupCacel()
this.ruleForm = {
tmpno: '',
tmpname: '',
tmpfont: '',
tmpfontsize: '',
tmpcontent: ''
}
this.loadStatus = '0'
this.editFlag = false;
},
/**
* @description: getDetailInfo
* @param {*} row
* @author: renchao
*/
getDetailInfo (item) {
this.ruleForm = item;
this.editFlag = true;
},
//设计打印模板
/**
* @description: 设计打印模板
* @author: renchao
*/
designByPRGData () {
let that = this;
that.loadStatus = '1';
let LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
LODOP.ADD_PRINT_DATA("ProgramData", this.ruleForm.tmpcontent); //装载模板
//窗口关闭后,回调函数中保存的设计代码
if (LODOP.CVERSION)
CLODOP.On_Return = function (TaskID, printList) {
if (LODOP.CVERSION)
LODOP.On_Return = function (TaskID, Value) {
document.getElementById("S1").value = Value;
};
document.getElementById("S1").value = LODOP.GET_VALUE(
"ProgramData",
0
);
setTimeout(() => {
that.ruleForm.tmpcontent = document.getElementById("S1").value;
that.loadStatus = '2';
}, 1000);
};
LODOP.PRINT_DESIGN(); //打印设计或者打印维护需要放到最后
}
}
}
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/dialogBoxheader.scss";
.font-red {
color: red;
}
.middle-margin-bottom {
margin-top: 20px;
}
</style>