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 | 24 | </a-col> |
25 | 25 | <a-col :md="6" :sm="8"> |
26 | 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 | 28 | </a-form-item> |
29 | 29 | </a-col> |
30 | 30 | </template> |
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | @change="handleImportExcel"> |
52 | 52 | <a-button type="primary" icon="import">导入</a-button> |
53 | 53 | </a-upload> |
54 | - <a-dropdown v-if="selectedRowKeys.length > 0"> | |
54 | +<!-- <a-dropdown v-if="selectedRowKeys.length > 0"> | |
55 | 55 | <a-menu slot="overlay"> |
56 | 56 | <a-menu-item key="1" @click="batchDel"> |
57 | 57 | <a-icon type="delete"/> |
... | ... | @@ -61,7 +61,7 @@ |
61 | 61 | <a-button style="margin-left: 8px"> 批量操作 |
62 | 62 | <a-icon type="down"/> |
63 | 63 | </a-button> |
64 | - </a-dropdown> | |
64 | + </a-dropdown>--> | |
65 | 65 | </div> |
66 | 66 | |
67 | 67 | <!-- table区域-begin --> |
... | ... | @@ -91,14 +91,21 @@ |
91 | 91 | |
92 | 92 | |
93 | 93 | <span slot="action" slot-scope="text, record"> |
94 | - <a @click="handleEdit(record)">编辑</a> | |
94 | + <a @click="handleMyEdit(record)">编辑</a> | |
95 | 95 | |
96 | 96 | <a-divider type="vertical"/> |
97 | 97 | <a-dropdown> |
98 | 98 | <a class="ant-dropdown-link">更多 <a-icon type="down"/></a> |
99 | 99 | <a-menu slot="overlay"> |
100 | 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 | 109 | <a>删除</a> |
103 | 110 | </a-popconfirm> |
104 | 111 | </a-menu-item> |
... | ... | @@ -125,14 +132,19 @@ |
125 | 132 | import SysMessageTestModal from './modules/SysMessageTestModal' |
126 | 133 | import {JeecgListMixin} from '@/mixins/JeecgListMixin' |
127 | 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 | 140 | export default { |
130 | 141 | name: "SysMessageTemplateList", |
131 | 142 | mixins: [JeecgListMixin], |
132 | 143 | components: { |
133 | 144 | JEllipsis, |
134 | 145 | SysMessageTemplateModal, |
135 | - SysMessageTestModal | |
146 | + SysMessageTestModal, | |
147 | + JDictSelectTag | |
136 | 148 | }, |
137 | 149 | data() { |
138 | 150 | return { |
... | ... | @@ -171,16 +183,22 @@ |
171 | 183 | dataIndex: 'templateType', |
172 | 184 | customRender: function (text) { |
173 | 185 | if(text=='1') { |
174 | - return "短信"; | |
186 | + return "文本"; | |
175 | 187 | } |
176 | 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 | 227 | handleTest(record){ |
210 | 228 | this.$refs.testModal.open(record); |
211 | 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 | 286 | </script> |
... | ... |
ant-design-vue-jeecg/src/views/modules/message/modules/SysMessageTemplateModal.vue
... | ... | @@ -50,6 +50,17 @@ |
50 | 50 | </a-form-item> |
51 | 51 | </a-col> |
52 | 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 | 64 | <a-row class="form-row" :gutter="24"> |
54 | 65 | <a-col :span="24" pull="4"> |
55 | 66 | <a-form-item |
... | ... | @@ -85,11 +96,13 @@ |
85 | 96 | import pick from 'lodash.pick' |
86 | 97 | import { duplicateCheck } from '@/api/api' |
87 | 98 | import JEditor from '@/components/jeecg/JEditor' |
99 | + import JSwitch from '@/components/jeecg/JSwitch' | |
88 | 100 | |
89 | 101 | export default { |
90 | 102 | name: "SysMessageTemplateModal", |
91 | 103 | components:{ |
92 | - JEditor | |
104 | + JEditor, | |
105 | + JSwitch | |
93 | 106 | }, |
94 | 107 | data() { |
95 | 108 | return { |
... | ... | @@ -111,6 +124,7 @@ |
111 | 124 | templateCode: {rules: [{required: true, message: '请输入模板CODE!' },{validator: this.validateTemplateCode}]}, |
112 | 125 | templateName: {rules: [{required: true, message: '请输入模板标题!'}]}, |
113 | 126 | templateContent: {rules: []}, |
127 | + useStatus:{rules: []}, | |
114 | 128 | templateType: {rules: [{required: true, message: '请输入模板类型!'}]}, |
115 | 129 | }, |
116 | 130 | url: { |
... | ... | @@ -140,9 +154,9 @@ |
140 | 154 | this.visible = true; |
141 | 155 | this.$nextTick(() => { |
142 | 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 | 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 | 34 | label="消息类型"> |
35 | 35 | <j-dict-select-tag |
36 | 36 | v-model="msgType" |
37 | + type="radio" | |
37 | 38 | placeholder="请选择消息类型" |
38 | - dictCode="msgType"/> | |
39 | + dictCode="messageType"/> | |
39 | 40 | </a-form-item> |
40 | 41 | <a-form-item |
41 | 42 | :labelCol="labelCol" |
42 | 43 | :wrapperCol="wrapperCol" |
43 | 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 | 46 | </a-form-item> |
46 | 47 | </a-form> |
47 | 48 | </a-spin> |
... | ... | @@ -50,9 +51,13 @@ |
50 | 51 | |
51 | 52 | <script> |
52 | 53 | import {httpAction} from '@/api/manage' |
53 | - | |
54 | + import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep' | |
55 | + | |
54 | 56 | export default { |
55 | 57 | name: "SysMessageTestModal", |
58 | + components:{ | |
59 | + JSelectUserByDep | |
60 | + }, | |
56 | 61 | data() { |
57 | 62 | return { |
58 | 63 | title: "操作", |
... | ... | @@ -74,7 +79,7 @@ |
74 | 79 | templateName: "", |
75 | 80 | templateContent: "", |
76 | 81 | receiver: "", |
77 | - msgType: "", | |
82 | + msgType: "system", | |
78 | 83 | testData: "", |
79 | 84 | sendParams: {} |
80 | 85 | } |
... | ... | @@ -89,7 +94,7 @@ |
89 | 94 | }, |
90 | 95 | close() { |
91 | 96 | this.receiver = ""; |
92 | - this.msgType = ""; | |
97 | + this.msgType = "system"; | |
93 | 98 | this.sendParams = {}; |
94 | 99 | this.visible = false; |
95 | 100 | }, |
... | ... |