Просмотр исходного кода

Merge branch 'master' of http://git.shengws.com/zhangbj/scrm-vue

zhengchengwu 5 лет назад
Родитель
Сommit
05dceecc89

+ 1 - 0
config/index.js Просмотреть файл

@@ -19,6 +19,7 @@ module.exports = {
19 19
 
20 20
     host: 'test1.sgjyun.com',
21 21
     port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
22
+    host: 'test1.sgjyun.com',
22 23
     autoOpenBrowser: true,
23 24
     errorOverlay: true,
24 25
     notifyOnErrors: false,

+ 21 - 0
src/api/activity/activity.js Просмотреть файл

@@ -11,4 +11,25 @@ export function fetchActivities(page, keyword, status) {
11 11
     method: 'get',
12 12
     params: params,
13 13
   })
14
+}
15
+
16
+export function fetchActivity(id) {
17
+  return request({
18
+    url: "/api/activity",
19
+    method: "get",
20
+    params: {
21
+      id: id,
22
+    }
23
+  })
24
+}
25
+
26
+export function submitActivity(publish, activity) {
27
+  return request({
28
+    url: "/api/activity/submit",
29
+    method: "post",
30
+    params: {
31
+      publish: publish,
32
+    },
33
+    data: activity,
34
+  })
14 35
 }

+ 2 - 1
src/lang/en.js Просмотреть файл

@@ -114,7 +114,8 @@ export default {
114 114
     marketingTool: "marketing tools",
115 115
     activityList: "activity list",
116 116
     activityPublish: "publish activity",
117
-    systemsetting:'Systemsetting'
117
+    activityModify: "edit activity",
118
+    systemsetting:'Systemsetting',
118 119
   },
119 120
   navbar: {
120 121
     logOut: 'Log Out',

+ 2 - 1
src/lang/zh.js Просмотреть файл

@@ -162,8 +162,9 @@ export default {
162 162
     marketingTool: "营销工具",
163 163
     activityList: "活动列表",
164 164
     activityPublish: "发布活动",
165
+    activityModify: "编辑活动",
165 166
     systemsetting:'系统设置',
166
-    staffmanagement:'员工管理'
167
+    staffmanagement:'员工管理',
167 168
   },
168 169
   navbar: {
169 170
     logOut: '退出登录',

+ 11 - 0
src/router/modules/marketing_tool.js Просмотреть файл

@@ -28,5 +28,16 @@ export default {
28 28
         noCache: true
29 29
       }
30 30
     },
31
+    {
32
+      path: '/activity/modify',
33
+      hidden: true,
34
+      is_menu: false,
35
+      component: () => import('@/scrm_pages/marketing_tool/activity_publish'),
36
+      name: 'activityModify',
37
+      meta: {
38
+        title: 'activityModify',
39
+        noCache: true
40
+      }
41
+    },
31 42
   ]
32 43
 }

+ 36 - 1
src/scrm_pages/marketing_tool/activity_publish.vue Просмотреть файл

@@ -9,7 +9,7 @@
9 9
                     <preview-form :activity="activity" :paragraph="activity_paragraph"></preview-form>
10 10
                 </div>
11 11
                 <div class="edit-panel">
12
-                    <edit-form :activity="activity" :paragraph="activity_paragraph"></edit-form>
12
+                    <edit-form ref="edit_form" :activity="activity" :paragraph="activity_paragraph"></edit-form>
13 13
                 </div>
14 14
             </div>
15 15
         </div>
@@ -20,6 +20,7 @@
20 20
 import BreadCrumb from "@/scrm_pages/components/bread-crumb";
21 21
 import PreviewForm from "@/scrm_pages/marketing_tool/components/edit_activity_preview_form"
22 22
 import EditForm from "@/scrm_pages/marketing_tool/components/edit_activity_edit_form"
23
+import { fetchActivity } from "@/api/activity/activity"
23 24
 
24 25
 export default {
25 26
     name: "ActivityPublish",
@@ -53,6 +54,40 @@ export default {
53 54
             }
54 55
         }
55 56
     },
57
+    created() {
58
+        var id = this.$route.query.id
59
+        if (id != undefined) {
60
+            fetchActivity(id).then(rs => {
61
+                var resp = rs.data
62
+                if (resp.state == 1) {
63
+                    // console.log(resp.data)
64
+                    var activity = resp.data.activity
65
+                    this.activity.id = activity.id
66
+                    this.activity.poster_photo = activity.poster_photo
67
+                    this.activity.title = activity.title
68
+                    this.activity.subtitle = activity.subtitle
69
+                    this.activity.address = activity.address
70
+                    this.activity.limit_num = activity.limit_num
71
+                    this.activity.sign_up_deadline = activity.sign_up_deadline * 1000
72
+                    this.activity.start_time = activity.start_time * 1000
73
+                    this.activity.phone_number = activity.phone_number
74
+                    this.activity.sign_up_notice = activity.sign_up_notice
75
+
76
+                    var paragraph = resp.data.paragraph
77
+                    this.activity_paragraph.title = paragraph.title
78
+                    this.activity_paragraph.content = paragraph.content
79
+
80
+                    this.$refs.edit_form.initForms()
81
+
82
+                } else {
83
+                    this.$message.error(resp.msg)
84
+                }
85
+
86
+            }).catch(err => {
87
+                this.$message.error(err)
88
+            })
89
+        }
90
+    },
56 91
 }
57 92
 </script>
58 93
 

+ 1 - 1
src/scrm_pages/marketing_tool/components/drafts_cell.vue Просмотреть файл

@@ -10,7 +10,7 @@
10 10
                 <a href="/">{{ activity.title }}</a>
11 11
             </h3>
12 12
             <div class="operation">
13
-                <el-button type="primary" size="small" icon="el-icon-edit-outline">编辑</el-button>
13
+                <el-button type="primary" size="small" icon="el-icon-edit-outline" @click="$router.push({ path: '/activity/modify', query: {id: activity.id} })">编辑</el-button>
14 14
                 <el-button type="danger" size="small" icon="el-icon-delete">删除</el-button>
15 15
             </div>
16 16
         </div>

+ 111 - 11
src/scrm_pages/marketing_tool/components/edit_activity_edit_form.vue Просмотреть файл

@@ -11,7 +11,7 @@
11 11
                     基本信息
12 12
                 </p>
13 13
                 <div class="module-item">
14
-                    <label class="item-title">主图</label>
14
+                    <label class="item-title">海报</label>
15 15
                     <div class="poster-photo-panel">
16 16
                         <el-input v-model="poster_photo_file_name" :readonly="true" class="input"></el-input>
17 17
                         <el-upload 
@@ -22,7 +22,7 @@
22 22
                         :on-success="posterPhotoUploadSuccess"
23 23
                         :before-upload="beforePosterPhotoUpload"
24 24
                         >
25
-                            <el-button type="primary" style="margin-left: 10px;" v-loading="uploading_poster_photo">上传图片</el-button>
25
+                            <el-button type="primary" style="margin-left: 10px;" :loading="uploading_poster_photo">上传图片</el-button>
26 26
                         </el-upload>
27 27
                     </div>
28 28
                 </div>
@@ -93,9 +93,9 @@
93 93
             </div>
94 94
 
95 95
             <div class="submit-button-panel">
96
-                <el-button style="padding: 10px 30px;" type="primary">发 布</el-button>
97
-                <el-button style="color: #409eff; border-color: #409eff; padding: 10px 30px;">保存草稿</el-button>
98
-                <el-button style="color: #409eff; border-color: #409eff; padding: 10px 30px;">预 览</el-button>
96
+                <el-button style="padding: 10px 30px;" type="primary" @click="publishAction" :loading="publishing_activity" :disabled="saving_activity || saving_before_preview_activity">发 布</el-button>
97
+                <el-button style="color: #409eff; border-color: #409eff; padding: 10px 30px;" @click="saveAction" :loading="saving_activity" :disabled="publishing_activity || saving_before_preview_activity">保存草稿</el-button>
98
+                <el-button style="color: #409eff; border-color: #409eff; padding: 10px 30px;" :loading="saving_before_preview_activity" :disabled="publishing_activity || saving_activity">预 览</el-button>
99 99
             </div>
100 100
         </div>
101 101
     </div>
@@ -105,6 +105,8 @@
105 105
 import Neditor from '@/components/Neditor'
106 106
 import { getToken } from "@/api/qiniu"
107 107
 import { getFileExtension } from "@/utils/tools"
108
+import { parseTime } from "@/utils"
109
+import { submitActivity } from "@/api/activity/activity"
108 110
 
109 111
 export default {
110 112
     name: "EditActivityEditForm",
@@ -123,6 +125,10 @@ export default {
123 125
     },
124 126
     data() {
125 127
         return {
128
+            saving_activity: false,
129
+            publishing_activity: false,
130
+            saving_before_preview_activity: false,
131
+
126 132
             uploading_poster_photo: false,
127 133
             qntoken: "",
128 134
             poster_photo_file_key: "",
@@ -153,14 +159,19 @@ export default {
153 159
             }
154 160
         },
155 161
         activity_time: function(new_val) {
156
-            this.activity.start_time = new_val
162
+            this.activity.start_time = parseInt(new_val / 1000)
157 163
         },
158 164
         sign_up_deadline: function(new_val) {
159
-            this.activity.sign_up_deadline = new_val  
165
+            this.activity.sign_up_deadline = parseInt(new_val / 1000)
160 166
         },
161 167
     },
162 168
     methods: {
163
-        initParagraphContent: function(content) {
169
+        initForms: function() {
170
+            this.poster_photo_file_name = this.activity.poster_photo
171
+            this.limit_num = this.activity.limit_num > 0 ? this.activity.limit_num : ""
172
+            this.activity_time = this.activity.start_time
173
+            this.sign_up_deadline = this.activity.sign_up_deadline
174
+
164 175
             this.paragraph_init_content = this.paragraph.content
165 176
         },
166 177
         paragraphContentChanged: function(content) {
@@ -172,14 +183,11 @@ export default {
172 183
             this.$message.error(err)
173 184
         },
174 185
         posterPhotoUploadSuccess: function(res, file) {
175
-            console.log(res)
176
-            console.log(file)
177 186
             this.poster_photo_file_name = file.name
178 187
             this.uploading_poster_photo = false
179 188
             this.activity.poster_photo = "https://images.shengws.com/" + res.url
180 189
         },
181 190
         beforePosterPhotoUpload: function(file) {
182
-            console.log(file)
183 191
             var is_image = file.type.indexOf("image") > -1
184 192
             var mb = file.size / 1024 / 1024
185 193
 
@@ -211,6 +219,98 @@ export default {
211 219
                 })
212 220
             })
213 221
         },
222
+
223
+        saveAction: function() {
224
+            this.saving_activity = true
225
+            this.submitActivity(false)
226
+        },
227
+        publishAction: function() {
228
+            this.publishing_activity = true
229
+            this.submitActivity(true, function() {
230
+                // 前往活动详情页
231
+            })
232
+        },
233
+        previewAction: function() {
234
+            this.saving_before_preview_activity = true
235
+            this.submitActivity(false, function() {
236
+                // 前往活动预览页
237
+            })
238
+        },
239
+        submitActivity: function(is_publish, successCallBack) {
240
+            this.validActivityInfo().then(() => {
241
+                var activity = {
242
+                    id: this.activity.id,
243
+                    poster_photo: this.activity.poster_photo,
244
+                    title: this.activity.title,
245
+                    subtitle: this.activity.subtitle,
246
+                    address: this.activity.address,
247
+                    limit_num: this.activity.limit_num,
248
+                    sign_up_deadline: parseTime(this.activity.sign_up_deadline, "{y}-{m}-{d} {h}:{i}"),
249
+                    start_time: parseTime(this.activity.start_time, "{y}-{m}-{d} {h}:{i}"),
250
+                    phone_number: this.activity.phone_number,
251
+                    sign_up_notice: this.activity.sign_up_notice,
252
+
253
+                    paragraph: {
254
+                        title: this.paragraph.title,
255
+                        content: this.paragraph.content,
256
+                    }
257
+                }
258
+                submitActivity(is_publish, activity).then(rs => {
259
+                    var resp = rs.data
260
+                    if (resp.state == 1) {
261
+                        this.activity.id = resp.data.activity_id
262
+                    } else {
263
+                        this.$message.error(resp.msg)
264
+                    }
265
+
266
+                    if (successCallBack != null || successCallBack != undefined) {
267
+                        successCallBack()
268
+                    }
269
+
270
+                    this.saving_activity = false
271
+                    this.publishing_activity = false
272
+                    this.saving_before_preview_activity = false
273
+
274
+                }).catch(err => {
275
+                    this.$message.error(err)
276
+                    this.saving_activity = false
277
+                    this.publishing_activity = false
278
+                    this.saving_before_preview_activity = false
279
+                })
280
+
281
+            }).catch(err => {
282
+                this.$message.error(err)
283
+                this.saving_activity = false
284
+                this.publishing_activity = false
285
+                this.saving_before_preview_activity = false
286
+            })
287
+            
288
+        },
289
+        validActivityInfo: function() {
290
+            return new Promise((resolve, reject) => {
291
+                if (this.activity.poster_photo.length == 0) {
292
+                    reject("海报不能为空")
293
+                } else if (this.activity.title.length == 0) {
294
+                    reject("标题不能为空")
295
+                } else if (this.activity.subtitle.length == 0) {
296
+                    reject("副标题不能为空")
297
+                } else if (this.activity.address.length == 0) {
298
+                    reject("活动地址不能为空")
299
+                } else if (this.activity.sign_up_deadline == 0) {
300
+                    reject("活动报名时间不能为空")
301
+                } else if (this.activity.start == 0) {
302
+                    reject("活动时间不能为空")
303
+                } else {
304
+                    if (this.activity.phone_number.length > 0) {
305
+                        if (/^1\d{10}$/.test(this.activity.phone_number) == false && /^(0\d{2,3}-?\d{7,8}$)/.test(this.activity.phone_number) == false) {
306
+                            reject("联系方式格式错误")
307
+                            return
308
+                        }
309
+                    }
310
+                }
311
+                resolve()
312
+            })
313
+        },
214 314
     },
215 315
 }
216 316
 </script>

+ 2 - 0
src/scrm_pages/marketing_tool/components/edit_activity_preview_form.vue Просмотреть файл

@@ -197,6 +197,8 @@ export default {
197 197
                     width: 40px;
198 198
                     height: 40px;
199 199
                     border-radius: 20px;
200
+                    object-fit: cover;
201
+                    object-position: center;
200 202
                 }
201 203
             }
202 204
             .text-info {

+ 1 - 1
src/scrm_pages/marketing_tool/components/unapproved_cell.vue Просмотреть файл

@@ -13,7 +13,7 @@
13 13
                 审核未通过:{{ activity.reason }}
14 14
             </div>
15 15
             <div class="operation">
16
-                <el-button type="primary" size="small" icon="el-icon-edit-outline">编辑</el-button>
16
+                <el-button type="primary" size="small" icon="el-icon-edit-outline" @click="$router.push({ path: '/activity/modify', query: {id: activity.id} })">编辑</el-button>
17 17
                 <el-button type="danger" size="small" icon="el-icon-delete">删除</el-button>
18 18
             </div>
19 19
         </div>