Commit 0b8e89dd7586e673cb2393a95666b6a70f27ac0f
1 parent
56c4bcb5
重构系统消息模板功能
Showing
3 changed files
with
112 additions
and
23 deletions
ant-design-vue-jeecg/src/views/modules/message/SysMessageTemplateList.vue
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | </a-col> | 24 | </a-col> |
25 | <a-col :md="6" :sm="8"> | 25 | <a-col :md="6" :sm="8"> |
26 | <a-form-item label="模板类型"> | 26 | <a-form-item label="模板类型"> |
27 | - <a-input placeholder="请输入模板类型" v-model="queryParam.templateType"></a-input> | 27 | + <j-dict-select-tag placeholder="请选择模板类型" v-model="queryParam.templateType" dictCode="msgType"></j-dict-select-tag> |
28 | </a-form-item> | 28 | </a-form-item> |
29 | </a-col> | 29 | </a-col> |
30 | </template> | 30 | </template> |
@@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
51 | @change="handleImportExcel"> | 51 | @change="handleImportExcel"> |
52 | <a-button type="primary" icon="import">导入</a-button> | 52 | <a-button type="primary" icon="import">导入</a-button> |
53 | </a-upload> | 53 | </a-upload> |
54 | - <a-dropdown v-if="selectedRowKeys.length > 0"> | 54 | +<!-- <a-dropdown v-if="selectedRowKeys.length > 0"> |
55 | <a-menu slot="overlay"> | 55 | <a-menu slot="overlay"> |
56 | <a-menu-item key="1" @click="batchDel"> | 56 | <a-menu-item key="1" @click="batchDel"> |
57 | <a-icon type="delete"/> | 57 | <a-icon type="delete"/> |
@@ -61,7 +61,7 @@ | @@ -61,7 +61,7 @@ | ||
61 | <a-button style="margin-left: 8px"> 批量操作 | 61 | <a-button style="margin-left: 8px"> 批量操作 |
62 | <a-icon type="down"/> | 62 | <a-icon type="down"/> |
63 | </a-button> | 63 | </a-button> |
64 | - </a-dropdown> | 64 | + </a-dropdown>--> |
65 | </div> | 65 | </div> |
66 | 66 | ||
67 | <!-- table区域-begin --> | 67 | <!-- table区域-begin --> |
@@ -91,14 +91,21 @@ | @@ -91,14 +91,21 @@ | ||
91 | 91 | ||
92 | 92 | ||
93 | <span slot="action" slot-scope="text, record"> | 93 | <span slot="action" slot-scope="text, record"> |
94 | - <a @click="handleEdit(record)">编辑</a> | 94 | + <a @click="handleMyEdit(record)">编辑</a> |
95 | 95 | ||
96 | <a-divider type="vertical"/> | 96 | <a-divider type="vertical"/> |
97 | <a-dropdown> | 97 | <a-dropdown> |
98 | <a class="ant-dropdown-link">更多 <a-icon type="down"/></a> | 98 | <a class="ant-dropdown-link">更多 <a-icon type="down"/></a> |
99 | <a-menu slot="overlay"> | 99 | <a-menu slot="overlay"> |
100 | <a-menu-item> | 100 | <a-menu-item> |
101 | - <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> | 101 | + <a @click="handleUse(record)">应用</a> |
102 | + </a-menu-item> | ||
103 | + <a-menu-item> | ||
104 | + <a @click="handleNotUse(record)">停用</a> | ||
105 | + </a-menu-item> | ||
106 | + | ||
107 | + <a-menu-item> | ||
108 | + <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)"> | ||
102 | <a>删除</a> | 109 | <a>删除</a> |
103 | </a-popconfirm> | 110 | </a-popconfirm> |
104 | </a-menu-item> | 111 | </a-menu-item> |
@@ -125,14 +132,19 @@ | @@ -125,14 +132,19 @@ | ||
125 | import SysMessageTestModal from './modules/SysMessageTestModal' | 132 | import SysMessageTestModal from './modules/SysMessageTestModal' |
126 | import {JeecgListMixin} from '@/mixins/JeecgListMixin' | 133 | import {JeecgListMixin} from '@/mixins/JeecgListMixin' |
127 | import JEllipsis from "@/components/jeecg/JEllipsis"; | 134 | import JEllipsis from "@/components/jeecg/JEllipsis"; |
128 | - | 135 | + import {httpAction} from '@/api/manage' |
136 | + import { deleteAction } from '@/api/manage' | ||
137 | + import JDictSelectTag from '@/components/dict/JDictSelectTag.vue' | ||
138 | + | ||
139 | + | ||
129 | export default { | 140 | export default { |
130 | name: "SysMessageTemplateList", | 141 | name: "SysMessageTemplateList", |
131 | mixins: [JeecgListMixin], | 142 | mixins: [JeecgListMixin], |
132 | components: { | 143 | components: { |
133 | JEllipsis, | 144 | JEllipsis, |
134 | SysMessageTemplateModal, | 145 | SysMessageTemplateModal, |
135 | - SysMessageTestModal | 146 | + SysMessageTestModal, |
147 | + JDictSelectTag | ||
136 | }, | 148 | }, |
137 | data() { | 149 | data() { |
138 | return { | 150 | return { |
@@ -171,16 +183,22 @@ | @@ -171,16 +183,22 @@ | ||
171 | dataIndex: 'templateType', | 183 | dataIndex: 'templateType', |
172 | customRender: function (text) { | 184 | customRender: function (text) { |
173 | if(text=='1') { | 185 | if(text=='1') { |
174 | - return "短信"; | 186 | + return "文本"; |
175 | } | 187 | } |
176 | if(text=='2') { | 188 | if(text=='2') { |
177 | - return "邮件"; | 189 | + return "富文本"; |
178 | } | 190 | } |
179 | - if(text=='3') { | ||
180 | - return "微信"; | ||
181 | - } | ||
182 | - if(text=='4') { | ||
183 | - return "系统"; | 191 | + } |
192 | + }, | ||
193 | + { | ||
194 | + title: '是否应用', | ||
195 | + align: "center", | ||
196 | + dataIndex: 'useStatus', | ||
197 | + customRender: function (text) { | ||
198 | + if(text=='1') { | ||
199 | + return "是"; | ||
200 | + }else{ | ||
201 | + return '否' | ||
184 | } | 202 | } |
185 | } | 203 | } |
186 | }, | 204 | }, |
@@ -209,8 +227,60 @@ | @@ -209,8 +227,60 @@ | ||
209 | handleTest(record){ | 227 | handleTest(record){ |
210 | this.$refs.testModal.open(record); | 228 | this.$refs.testModal.open(record); |
211 | this.$refs.testModal.title = "发送测试"; | 229 | this.$refs.testModal.title = "发送测试"; |
212 | - } | 230 | + }, |
231 | + //update-begin-author:taoyan date:2022-7-8 for: 修改应用状态 | ||
232 | + updateUseStatus(record, useStatus){ | ||
233 | + let formData = { | ||
234 | + id: record.id, useStatus: useStatus | ||
235 | + } | ||
236 | + httpAction("/sys/message/sysMessageTemplate/edit", formData, 'put').then((res) => { | ||
237 | + if (res.success) { | ||
238 | + this.$message.success(res.message); | ||
239 | + } else { | ||
240 | + this.$message.warning(res.message); | ||
241 | + } | ||
242 | + }).finally(() => { | ||
243 | + this.loadData() | ||
244 | + }) | ||
245 | + }, | ||
246 | + handleUse(record){ | ||
247 | + this.updateUseStatus(record, '1') | ||
248 | + }, | ||
249 | + handleNotUse(record){ | ||
250 | + this.updateUseStatus(record, '0') | ||
251 | + }, | ||
252 | + handleMyEdit(record){ | ||
253 | + if(record.useStatus == '1'){ | ||
254 | + this.$message.warning('此模板已被应用,禁止编辑!'); | ||
255 | + }else{ | ||
256 | + this.handleEdit(record); | ||
257 | + } | ||
258 | + }, | ||
259 | + //update-end-author:taoyan date:2022-7-8 for: 修改应用状态 | ||
213 | 260 | ||
261 | + handleDelete: function (record) { | ||
262 | + if(!this.url.delete){ | ||
263 | + this.$message.error("请设置url.delete属性!") | ||
264 | + return | ||
265 | + } | ||
266 | + if(record.useStatus=='1'){ | ||
267 | + this.$message.error("该模板已被应用禁止删除!") | ||
268 | + return | ||
269 | + } | ||
270 | + let id = record.id; | ||
271 | + var that = this; | ||
272 | + deleteAction(that.url.delete, {id: id}).then((res) => { | ||
273 | + if (res.success) { | ||
274 | + //重新计算分页问题 | ||
275 | + that.reCalculatePage(1) | ||
276 | + that.$message.success(res.message); | ||
277 | + that.loadData(); | ||
278 | + } else { | ||
279 | + that.$message.warning(res.message); | ||
280 | + } | ||
281 | + }); | ||
282 | + }, | ||
283 | + | ||
214 | } | 284 | } |
215 | } | 285 | } |
216 | </script> | 286 | </script> |
ant-design-vue-jeecg/src/views/modules/message/modules/SysMessageTemplateModal.vue
@@ -50,6 +50,17 @@ | @@ -50,6 +50,17 @@ | ||
50 | </a-form-item> | 50 | </a-form-item> |
51 | </a-col> | 51 | </a-col> |
52 | </a-row> | 52 | </a-row> |
53 | + <a-row class="form-row" :gutter="24" > | ||
54 | + <a-col :span="24" pull="2"> | ||
55 | + <a-form-item | ||
56 | + :labelCol="labelCol" | ||
57 | + :wrapperCol="wrapperCol" | ||
58 | + label="是否应用" | ||
59 | + style="margin-left: -15px"> | ||
60 | + <j-switch v-decorator="['useStatus', validatorRules.useStatus]" :options="['1', '0']"></j-switch> | ||
61 | + </a-form-item> | ||
62 | + </a-col> | ||
63 | + </a-row> | ||
53 | <a-row class="form-row" :gutter="24"> | 64 | <a-row class="form-row" :gutter="24"> |
54 | <a-col :span="24" pull="4"> | 65 | <a-col :span="24" pull="4"> |
55 | <a-form-item | 66 | <a-form-item |
@@ -85,11 +96,13 @@ | @@ -85,11 +96,13 @@ | ||
85 | import pick from 'lodash.pick' | 96 | import pick from 'lodash.pick' |
86 | import { duplicateCheck } from '@/api/api' | 97 | import { duplicateCheck } from '@/api/api' |
87 | import JEditor from '@/components/jeecg/JEditor' | 98 | import JEditor from '@/components/jeecg/JEditor' |
99 | + import JSwitch from '@/components/jeecg/JSwitch' | ||
88 | 100 | ||
89 | export default { | 101 | export default { |
90 | name: "SysMessageTemplateModal", | 102 | name: "SysMessageTemplateModal", |
91 | components:{ | 103 | components:{ |
92 | - JEditor | 104 | + JEditor, |
105 | + JSwitch | ||
93 | }, | 106 | }, |
94 | data() { | 107 | data() { |
95 | return { | 108 | return { |
@@ -111,6 +124,7 @@ | @@ -111,6 +124,7 @@ | ||
111 | templateCode: {rules: [{required: true, message: '请输入模板CODE!' },{validator: this.validateTemplateCode}]}, | 124 | templateCode: {rules: [{required: true, message: '请输入模板CODE!' },{validator: this.validateTemplateCode}]}, |
112 | templateName: {rules: [{required: true, message: '请输入模板标题!'}]}, | 125 | templateName: {rules: [{required: true, message: '请输入模板标题!'}]}, |
113 | templateContent: {rules: []}, | 126 | templateContent: {rules: []}, |
127 | + useStatus:{rules: []}, | ||
114 | templateType: {rules: [{required: true, message: '请输入模板类型!'}]}, | 128 | templateType: {rules: [{required: true, message: '请输入模板类型!'}]}, |
115 | }, | 129 | }, |
116 | url: { | 130 | url: { |
@@ -140,9 +154,9 @@ | @@ -140,9 +154,9 @@ | ||
140 | this.visible = true; | 154 | this.visible = true; |
141 | this.$nextTick(() => { | 155 | this.$nextTick(() => { |
142 | if(this.useEditor){ | 156 | if(this.useEditor){ |
143 | - this.form.setFieldsValue(pick(this.model, 'templateCode', 'templateName', 'templateTestJson', 'templateType')) | 157 | + this.form.setFieldsValue(pick(this.model, 'useStatus', 'templateCode', 'templateName', 'templateTestJson', 'templateType')) |
144 | }else{ | 158 | }else{ |
145 | - this.form.setFieldsValue(pick(this.model, 'templateCode', 'templateContent', 'templateName', 'templateTestJson', 'templateType')) | 159 | + this.form.setFieldsValue(pick(this.model, 'useStatus', 'templateCode', 'templateContent', 'templateName', 'templateTestJson', 'templateType')) |
146 | } | 160 | } |
147 | }); | 161 | }); |
148 | }, | 162 | }, |
ant-design-vue-jeecg/src/views/modules/message/modules/SysMessageTestModal.vue
@@ -34,14 +34,15 @@ | @@ -34,14 +34,15 @@ | ||
34 | label="消息类型"> | 34 | label="消息类型"> |
35 | <j-dict-select-tag | 35 | <j-dict-select-tag |
36 | v-model="msgType" | 36 | v-model="msgType" |
37 | + type="radio" | ||
37 | placeholder="请选择消息类型" | 38 | placeholder="请选择消息类型" |
38 | - dictCode="msgType"/> | 39 | + dictCode="messageType"/> |
39 | </a-form-item> | 40 | </a-form-item> |
40 | <a-form-item | 41 | <a-form-item |
41 | :labelCol="labelCol" | 42 | :labelCol="labelCol" |
42 | :wrapperCol="wrapperCol" | 43 | :wrapperCol="wrapperCol" |
43 | label="消息接收方"> | 44 | label="消息接收方"> |
44 | - <a-input placeholder="请输入消息接收方" v-model="receiver"/> | 45 | + <j-select-user-by-dep placeholder="请选择消息接收方" v-model="receiver"></j-select-user-by-dep> |
45 | </a-form-item> | 46 | </a-form-item> |
46 | </a-form> | 47 | </a-form> |
47 | </a-spin> | 48 | </a-spin> |
@@ -50,9 +51,13 @@ | @@ -50,9 +51,13 @@ | ||
50 | 51 | ||
51 | <script> | 52 | <script> |
52 | import {httpAction} from '@/api/manage' | 53 | import {httpAction} from '@/api/manage' |
53 | - | 54 | + import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep' |
55 | + | ||
54 | export default { | 56 | export default { |
55 | name: "SysMessageTestModal", | 57 | name: "SysMessageTestModal", |
58 | + components:{ | ||
59 | + JSelectUserByDep | ||
60 | + }, | ||
56 | data() { | 61 | data() { |
57 | return { | 62 | return { |
58 | title: "操作", | 63 | title: "操作", |
@@ -74,7 +79,7 @@ | @@ -74,7 +79,7 @@ | ||
74 | templateName: "", | 79 | templateName: "", |
75 | templateContent: "", | 80 | templateContent: "", |
76 | receiver: "", | 81 | receiver: "", |
77 | - msgType: "", | 82 | + msgType: "system", |
78 | testData: "", | 83 | testData: "", |
79 | sendParams: {} | 84 | sendParams: {} |
80 | } | 85 | } |
@@ -89,7 +94,7 @@ | @@ -89,7 +94,7 @@ | ||
89 | }, | 94 | }, |
90 | close() { | 95 | close() { |
91 | this.receiver = ""; | 96 | this.receiver = ""; |
92 | - this.msgType = ""; | 97 | + this.msgType = "system"; |
93 | this.sendParams = {}; | 98 | this.sendParams = {}; |
94 | this.visible = false; | 99 | this.visible = false; |
95 | }, | 100 | }, |