Browse Source

fix短信管理

miaofuhao 1 year ago
parent
commit
290c23cacf

+ 3 - 0
CMS1.0/src/store/commonSelect/common.js

@@ -2,6 +2,7 @@ import { getPageListData } from '@/api/main/system/system'
2 2
 import { addDateRange } from '@/utils/ruoyi'
3 3
 const useSelectStore = defineStore('common', {
4 4
     state: () => ({
5
+        templateListData:[],
5 6
         userListData: [],
6 7
         deptListData: [],
7 8
         orderTypeTree: [],
@@ -21,6 +22,8 @@ const useSelectStore = defineStore('common', {
21 22
     }),
22 23
     actions: {
23 24
         async getSelectData(payload) {
25
+            const templateResult = await getPageListData('/sms/template')    //  /common/user
26
+            this.templateListData = getUserSelcet(templateResult.data, 'templateCode', 'templateId')
24 27
             const deptResult = await getPageListData('/common/dept') // /common/dept
25 28
             this.deptListData = arrayToTree(deptResult.data, 100)   
26 29
             const userResult = await getPageListData('/common/user')    //  /common/user

+ 6 - 5
CMS1.0/src/views/main/msgManagement/msgTemplate/config/content.config.js

@@ -2,11 +2,12 @@ export const contentTableConfig = {
2 2
   title: '短信模板',
3 3
   contentTableHeader: true,
4 4
   propList: [
5
-    { prop: 'postCode', label: '模板编号' },
6
-    { prop: 'postName', label: '模板名称' },
7
-    { prop: 'postSort', label: '模板内容' },
8
-    { prop: 'status', label: '状态'},
9
-    { label: '操作', minWidth: '120', slotName: 'handler' }
5
+    { prop: 'templateCode', label: '模板编号' },
6
+    { prop: 'templateName', label: '模板名称' },
7
+    { prop: 'content', label: '模板内容' },
8
+    { prop: 'status', label: '状态', slotName: 'templateStatus', customSlot: true},
9
+    { prop: 'createTime', label: '创建时间'},
10
+    { label: '操作', minWidth: '120', slotName: 'handlerOperation', customSlot: true }
10 11
   ],
11 12
   showIndexColumn: true,
12 13
   showSelectColumn: false,

+ 12 - 20
CMS1.0/src/views/main/msgManagement/msgTemplate/config/modal.config.js

@@ -1,39 +1,31 @@
1 1
 export const modalConfig = {
2 2
   formItems: [
3 3
     {
4
-      field: 'postCode',
4
+      field: 'templateCode',
5 5
       type: 'input',
6 6
       label: '模板编号',
7 7
       required: true,
8
-      placeholder: '请输入岗位编码'
8
+      placeholder: '请输入模板编号'
9 9
     },
10 10
     {
11
-      field: 'postName',
11
+      field: 'templateName',
12 12
       type: 'input',
13 13
       label: '模板名称',
14 14
       required: true,
15
-      placeholder: '请输入岗位名称'
15
+      placeholder: '请输入模板名称'
16 16
     },
17 17
     {
18
-      field: 'remark',
18
+      field: 'status',
19
+      type: 'switch',
20
+      label: '状态',
21
+      required: true,
22
+    },
23
+    {
24
+      field: 'content',
19 25
       type: 'textarea',
20 26
       label: '模板内容',
21
-      placeholder: '请输入备注'
27
+      placeholder: '请输入模板内容'
22 28
     }
23
-    // {
24
-    //   field: "departmentId",
25
-    //   type: "select",
26
-    //   label: "选择部门",
27
-    //   placeholder: "请选择部门",
28
-    //   options: [],
29
-    // },
30
-    // {
31
-    //   field: "roleId",
32
-    //   type: "select",
33
-    //   label: "选择角色",
34
-    //   placeholder: "请选择角色",
35
-    //   options: [],
36
-    // },
37 29
   ],
38 30
   colLayout: { span: 24 },
39 31
   itemStyle: {}

+ 2 - 2
CMS1.0/src/views/main/msgManagement/msgTemplate/config/search.config.js

@@ -8,13 +8,13 @@ export const searchFormConfig = {
8 8
   },
9 9
   formItems: [
10 10
     {
11
-      field: 'postCode',
11
+      field: 'templateCode',
12 12
       type: 'input',
13 13
       label: '模板编号',
14 14
       placeholder: '请输入模板编号'
15 15
     },
16 16
     {
17
-      field: 'postName',
17
+      field: 'templateName',
18 18
       type: 'input',
19 19
       label: '模板名称',
20 20
       placeholder: '请输入模板名称'

+ 79 - 5
CMS1.0/src/views/main/msgManagement/msgTemplate/msgTemplate.vue

@@ -8,26 +8,56 @@
8 8
     <page-content
9 9
       ref="pageContentRef"
10 10
       :contentTableConfig="contentTableConfig"
11
-      pageName="/system/post"
11
+      pageName="/sms/template"
12 12
       :isExport="false"
13 13
       @newBtnClick="handleNewData"
14 14
       @editBtnClick="handleEditData"
15 15
     >
16
-      <template #postStatus="{ row }">
16
+      <template #templateStatus="{ row }">
17 17
         <el-tag :type="row.status === '0' ? 'error' : 'success'">{{ row.status === '0' ? '禁用' : '启用' }}</el-tag>
18 18
       </template>
19
+      <template #handlerOperation="{ row }">
20
+        <el-button type="primary" v-if="row.status=='1'" link @click="handleEdit(row)">编辑</el-button>
21
+        <el-button type="primary" v-if="row.status=='1'" link @click="handleEnable(row)">禁用</el-button>
22
+        <el-button type="primary" v-if="row.status=='0'" link @click="handleEnable(row)">启用</el-button>
23
+        <el-button type="primary" link @click="handleDelete(row)">删除</el-button>
24
+        <el-button type="primary" link @click="handleTest(row)">测试</el-button>
25
+      </template>
19 26
     </page-content>
20 27
     <page-modal
21 28
       :defaultInfo="defaultInfo"
22 29
       ref="pageModalRef"
23
-      pageName="/system/post"
30
+      pageName="/sms/template"
24 31
       :modalConfig="modalConfigRef"
25 32
     ></page-modal>
33
+    <el-dialog
34
+    v-model="dialogVisible"
35
+    title="测试"
36
+    width="500"
37
+    :before-close="handleClose"
38
+  >
39
+    <el-form label-width="auto">
40
+      <el-form-item label="手机号">
41
+        <el-input v-model="templateForm.tel" />
42
+      </el-form-item>
43
+      <el-form-item label="短信内容">
44
+        <el-input v-model="templateForm.content" type="textarea" />
45
+      </el-form-item>
46
+    </el-form>
47
+    <template #footer>
48
+      <div class="dialog-footer">
49
+        <el-button @click="dialogVisible = false">取消</el-button>
50
+        <el-button type="primary" @click="handleSend">
51
+          确定
52
+        </el-button>
53
+      </div>
54
+    </template>
55
+  </el-dialog>
26 56
   </div>
27 57
 </template>
28 58
 
29 59
 <script>
30
-import { defineComponent } from 'vue'
60
+import { defineComponent,onMounted } from 'vue'
31 61
 
32 62
 import PageSearch from '@/components/page-search'
33 63
 import PageContent from '@/components/page-content'
@@ -40,8 +70,10 @@ import { modalConfig } from './config/modal.config'
40 70
 import { usePageSearch } from '@/hooks/use-page-search'
41 71
 import { usePageModal } from '@/hooks/use-page-modal'
42 72
 
73
+import { editPageData, deletePageData } from '@/api/main/system/system';
74
+
43 75
 export default defineComponent({
44
-  name: 'FollowUpPlan',
76
+  name: 'MsgTemplate',
45 77
   components: {
46 78
     PageSearch,
47 79
     PageContent,
@@ -49,7 +81,41 @@ export default defineComponent({
49 81
   },
50 82
   setup() {
51 83
     const [pageContentRef, handleResetClick, handleQueryClick] = usePageSearch()
84
+    const { proxy } = getCurrentInstance();
85
+    const dialogVisible = ref(false)
86
+    const templateForm = ref({})
87
+    function handleSend() {
88
+      console.log(templateForm.value)
89
+    }
90
+    function handleDelete(data) {
91
+      deletePageData('/sms/template/'+data.templateId).then((data) => {
92
+        proxy.$modal.msgSuccess('删除成功');
93
+        pageContentRef.value.getPageData()
94
+      });
95
+    }
96
+    function handleEdit(data) {
97
+      console.log(data);
98
+      defaultInfo.value = data
99
+      pageModalRef.value.dialogVisible = true
100
+    }
101
+    function handleEnable(data) {
52 102
 
103
+      const params ={
104
+        templateId:data.templateId,
105
+        content:data.content,
106
+        templateCode:data.templateCode,
107
+        templateName:data.templateName,
108
+        status:data.status ==='1'?'0':'1'
109
+      }
110
+      editPageData('/sms/template', params).then((data) => {
111
+          proxy.$modal.msgSuccess(data.status ==='1'?'禁用成功':'启用成功');
112
+          pageContentRef.value.getPageData()
113
+        });
114
+    }
115
+    function handleTest(data) {
116
+      console.log(data)
117
+      dialogVisible.value = true
118
+    }
53 119
     // 1.处理逻辑
54 120
     const newCallback = () => {}
55 121
     const editCallback = () => {
@@ -65,6 +131,14 @@ export default defineComponent({
65 131
     const [pageModalRef, defaultInfo, handleNewData, handleEditData] =
66 132
       usePageModal(newCallback, editCallback)
67 133
     return {
134
+      handleSend,
135
+      templateForm,
136
+      dialogVisible,
137
+      proxy,
138
+      handleDelete,
139
+      handleEdit,
140
+      handleTest,
141
+      handleEnable,
68 142
       searchFormConfig,
69 143
       contentTableConfig,
70 144
       pageContentRef,

+ 7 - 7
CMS1.0/src/views/main/msgManagement/sendRecord/config/content.config.js

@@ -1,13 +1,13 @@
1 1
 export const contentTableConfig = {
2
-  title: '岗位管理',
2
+  title: '发送记录',
3 3
   contentTableHeader: true,
4 4
   propList: [
5
-    { prop: 'postCode', label: '模板编号' },
6
-    { prop: 'postName', label: '手机号' },
7
-    { prop: 'postSort', label: '发送内容' },
8
-    { prop: 'status', label: '方向'},
9
-    { prop: 'status', label: '状态'},
10
-    { prop: 'status', label: '备注'},
5
+    { prop: 'templateCode', label: '模板编号' },
6
+    { prop: 'phoneNumber', label: '手机号' },
7
+    { prop: 'content', label: '发送内容' },
8
+    { prop: 'sendDirection', label: '方向'},
9
+    { prop: 'status', label: '状态', slotName: 'sendStatus', customSlot: true},
10
+    { prop: 'note', label: '备注'},
11 11
     { prop: 'createTime', label: '创建时间' },
12 12
     
13 13
   ],

+ 11 - 7
CMS1.0/src/views/main/msgManagement/sendRecord/config/search.config.js

@@ -1,3 +1,6 @@
1
+import useSelectStore from '@/store/commonSelect/common'
2
+let templateData = useSelectStore().templateListData
3
+
1 4
 export const searchFormConfig = {
2 5
   labelWidth: '120px',
3 6
   itemStyle: {
@@ -8,25 +11,26 @@ export const searchFormConfig = {
8 11
   },
9 12
   formItems: [
10 13
     {
11
-      field: 'postCode',
14
+      field: 'phoneNumber',
12 15
       type: 'input',
13 16
       label: '手机号',
14 17
       placeholder: '请输入手机号'
15 18
     },
16 19
     {
17
-      field: 'postName',
18
-      type: 'input',
20
+      field: 'templateId',
21
+      type: 'select',
19 22
       label: '模版',
20
-      placeholder: '请选择模版'
23
+      placeholder: '请选择模版',
24
+      options: templateData
21 25
     },
22 26
     {
23
-      field: 'status',
27
+      field: 'sendDirection',
24 28
       type: 'select',
25 29
       label: '方向',
26 30
       placeholder: '请选择方向',
27 31
       options: [
28
-        { title: '启用', value: 1 },
29
-        { title: '禁用', value: 0 }
32
+        { title: '发送', value: '发送' },
33
+        { title: '接收', value: '接收' }
30 34
       ]
31 35
     }
32 36
   ]

+ 24 - 9
CMS1.0/src/views/main/msgManagement/sendRecord/sendRecord.vue

@@ -1,20 +1,21 @@
1 1
 <template>
2 2
   <div class="app-container">
3 3
     <page-search
4
-      :searchFormConfig="searchFormConfig"
4
+      :searchFormConfig="searchFormConfigRef"
5 5
       @resetBtnClick="handleResetClick"
6 6
       @queryBtnClick="handleQueryClick"
7 7
     />
8 8
     <page-content
9 9
       ref="pageContentRef"
10 10
       :contentTableConfig="contentTableConfig"
11
-      pageName="/system/post"
11
+      pageName="/sms/record"
12 12
       :isExport="false"
13
+      :isCreate="false"
13 14
       @newBtnClick="handleNewData"
14 15
       @editBtnClick="handleEditData"
15 16
     >
16
-      <template #postStatus="{ row }">
17
-        <el-tag :type="row.status === '0' ? 'error' : 'success'">{{ row.status === '0' ? '禁用' : '启用' }}</el-tag>
17
+      <template #sendStatus="{ row }">
18
+        <el-tag :type="(row.status.indexOf('失败') !== -1) ? 'error' : 'success'">{{ row.status }}</el-tag>
18 19
       </template>
19 20
     </page-content>
20 21
     <page-modal
@@ -27,7 +28,7 @@
27 28
 </template>
28 29
 
29 30
 <script>
30
-import { defineComponent } from 'vue'
31
+import { defineComponent,onMounted } from 'vue'
31 32
 
32 33
 import PageSearch from '@/components/page-search'
33 34
 import PageContent from '@/components/page-content'
@@ -39,9 +40,10 @@ import { modalConfig } from './config/modal.config'
39 40
 
40 41
 import { usePageSearch } from '@/hooks/use-page-search'
41 42
 import { usePageModal } from '@/hooks/use-page-modal'
43
+import { getPageListData } from '@/api/main/system/system';
42 44
 
43 45
 export default defineComponent({
44
-  name: 'FollowUpPlan',
46
+  name: 'SendRecord',
45 47
   components: {
46 48
     PageSearch,
47 49
     PageContent,
@@ -49,7 +51,14 @@ export default defineComponent({
49 51
   },
50 52
   setup() {
51 53
     const [pageContentRef, handleResetClick, handleQueryClick] = usePageSearch()
52
-
54
+    onMounted(()=>{
55
+      getList()
56
+    })
57
+    function getList(data) {
58
+      getPageListData('/sms/template',{}).then((data) => {
59
+        console.log(data)
60
+      });
61
+    }
53 62
     // 1.处理逻辑
54 63
     const newCallback = () => {}
55 64
     const editCallback = () => {
@@ -58,19 +67,25 @@ export default defineComponent({
58 67
 
59 68
     // 2.动态添加部门和角色列表
60 69
     const modalConfigRef = computed(() => {
70
+      console.log(modalConfig.formItems);
61 71
       return modalConfig
62 72
     })
63
-
73
+    const searchFormConfigRef = computed(() => {
74
+      return searchFormConfig
75
+    })
76
+    
64 77
     // 3.调用hook获取公共变量和函数
65 78
     const [pageModalRef, defaultInfo, handleNewData, handleEditData] =
66 79
       usePageModal(newCallback, editCallback)
67 80
     return {
68
-      searchFormConfig,
81
+      getList,
69 82
       contentTableConfig,
70 83
       pageContentRef,
71 84
       handleResetClick,
72 85
       handleQueryClick,
73 86
       modalConfigRef,
87
+      searchFormConfigRef,
88
+      searchFormConfig,
74 89
       pageModalRef,
75 90
       defaultInfo,
76 91
       handleNewData,