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
<template>
<div style="display: inline;" class="save-temp">
<el-button type="text" size="mini" @click="openSavDialog()"><span>保存模板</span></el-button>
<el-dialog custom-class="save-dialog" :visible.sync="dialogSavFormVisible" title="保存模板" :modal-append-to-body="false"
:lock-scroll="false" :show-close="true" :close-on-click-modal="false" :close-on-press-escape="false" v-dialogDrag @close="cancelDialog()">
<el-form ref="dialogForm" :model="tdtmplDialog" label-width="120px" label-position="right" label-suffix=":" :rules="rules">
<el-row>
<el-col :span="22">
<el-form-item label="模板名称" prop="tmplnam">
<span>{{tdtmplDialog.tmpltyp}}-{{transName.toUpperCase()}}-{{tdtmplDialog.ownref}}-</span>
<el-input style="width:60%;" v-model="tdtmplDialog.tmplnam" maxlength="60"></el-input>
</el-form-item>
</el-col>
<el-col :span="22">
<el-form-item label="模板类型" prop="tmpltyp">
<el-radio-group v-model="tdtmplDialog.tmpltyp">
<el-radio label="C" :disabled="isDisabled">公共</el-radio>
<el-radio label="O">机构</el-radio>
<el-radio label="P">个人</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelDialog">取 消</el-button>
<el-button type="primary" @click="submitDialog" :loading="loadingSavStatus">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import TdTmplModel, { Pattern } from "~/page/Statics/TdTmpl/TdTmplModel.js";
import { saveInfo } from "~/service/manage/tdtmpl.js";
import Utils from "~/utils";
import Api from '~/service/Api';
export default {
data() {
return {
tdtmplDialog: new TdTmplModel().data.TdTmpl,
rules: Pattern,
dialogSavFormVisible:false,
loadingSavStatus: false,
}
},
props: {
rowData: {
type: Object,
default: () => {}
}
},
computed: {
isDisabled () {
if (this.$store.state.UserContext.currentOrg && this.$store.state.UserContext.currentOrg.level === 0) {
return false;
} else {
return true;
}
},
transName () {
return this.rowData.inifrm.toLowerCase()
}
},
mounted() {
},
methods: {
// 打开模态框
openSavDialog(){
this.tdtmplDialog.tmpltyp = 'O';
this.dialogSavFormVisible = true;
},
getModuleRouter() {
let router = this.$router
let moduleRouter = ''
router.options.routes.forEach((item1) => {
if (item1.name == 'index') {
item1.children.forEach((item2) => {
if (item2.path == '/business') {
for(let i = 0; i < item2.children.length; i++) {
let item3 = item2.children[i]
let path = item3.path.toLowerCase()
if (path == this.transName) {
moduleRouter = item3.meta.module || 'business'
break;
}
}
}
})
}
})
return moduleRouter;
},
initModelData () {
return new Promise(async (resolve) => {
this.tdtmplDialog.tmpltrn = this.transName
let grp = this.rowData.objtyp.toLowerCase() + 'grp'
let params = {
transName: this.tdtmplDialog.tmpltrn,
businessInr: this.rowData.inr,
businessType: 'TRN',
operation: 'view',
[grp]: {
rec: {}
}
};
this.loadingSavStatus = true;
let moduleRouter = this.getModuleRouter()
const rtnmsg = await Api.post(`/${moduleRouter}/${this.transName}/init`, params);
this.loadingSavStatus = false;
if (rtnmsg.respCode === SUCCESS) {
this.tdtmplDialog.tmpltxt = JSON.stringify(rtnmsg.data);
resolve('1')
}
})
},
submitDialog () {
this.$refs.dialogForm.validate((validated) => {
console.log('111', validated)
if(validated){
this.loadingSavStatus = true;
console.log('222')
this.initModelData().then((resModel) => {
if (resModel == '1') {
saveInfo(this.tdtmplDialog).then((res)=>{
if(res.respCode == 'AAAAAA'){
this.$notify.success("保存成功!");
} else {
this.$notify.error(res.respMsg);
}
// 关闭弹框
this.cancelDialog();
this.loadingSavStatus = false;
}).catch((err)=>{
this.loadingSavStatus = false;
this.$notify.error(err.respMsg);
});
}
})
} else {
Utils.formValidateTips(this.$refs.dialogForm.fields)
}
})
},
// 【取消】按钮
cancelDialog(){
this.dialogSavFormVisible = false;
this.tdtmplDialog.inr = '';
this.tdtmplDialog.ownref = '';
this.tdtmplDialog.tmplnam = '';
this.tdtmplDialog.tmpltyp = '';
this.tdtmplDialog.tmpltxt = '';
this.tdtmplDialog.tmplbchs = [];
this.tdtmplDialog.tmpltrn = '';
this.tdtmplDialog.tmplusr = '';
this.tdtmplDialog.tmpldat = '';
this.$refs['dialogForm'].resetFields();
},
}
}
</script>
<style lang="less" scoped>
.save-temp {
/deep/ .el-dialog__body {
height: calc(100% - 110px)!important;
}
}
</style>