许成详 6 anos atrás
pai
commit
17d5d4ea5a

+ 54
- 15
src/pages/system/channelManager/channelList/add.vue Ver arquivo

@@ -3,24 +3,27 @@
3 3
     <form class="mainForm">
4 4
       <ul>
5 5
         <li class="flex-h">
6
-          <span>渠道名:</span>
6
+          <span>选择案场:</span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%">
9
-              <el-input
10
-                placeholder="请输入渠道名"
11
-                v-model="postData.channelName"
12
-                clearable>
13
-              </el-input>
9
+              <el-select v-model="CaseId" placeholder="请选择">
10
+                <el-option
11
+                  v-for="item in cases"
12
+                  :key="item.CaseId"
13
+                  :label="item.CaseName"
14
+                  :value="item.CaseId">
15
+                </el-option>
16
+              </el-select>
14 17
             </div>
15 18
           </div>
16 19
         </li>
17 20
         <li class="flex-h">
18
-          <span>渠道code:</span>
21
+          <span>渠道:</span>
19 22
           <div class="flex-item">
20 23
             <div style="width:50%">
21 24
               <el-input
22
-                placeholder="请输入渠道code"
23
-                v-model="postData.channelCode"
25
+                placeholder="请输入渠道"
26
+                v-model="postData.ChannelName"
24 27
                 clearable>
25 28
               </el-input>
26 29
             </div>
@@ -36,26 +39,62 @@
36 39
 </template>
37 40
 
38 41
 <script>
42
+import { mapState } from 'vuex'
39 43
 export default {
40 44
   name: '',
41 45
   data () {
42 46
     return {
43 47
       postData: {
44
-        channelName: '',
45
-        channelCode: ''
48
+        ChannelId: '', // 渠道id
49
+        ChannelName: '', // 渠道名称
50
+        CaseId: '', // 案场id
51
+        OrgId: '', // 机构id
52
+      }
53
+    }
54
+  },
55
+  computed: {
56
+    ...mapState({
57
+      cases: x => x.app.cases.list,
58
+      defaultCaseId: x => x.app.cases.default,
59
+      OrgId: x => x.app.user.OrgId,
60
+    }),
61
+    CaseId: {
62
+      get () {
63
+        return this.postData.CaseId === '' ? this.defaultCaseId || '' : this.postData.CaseId
64
+      },
65
+      set (val) {
66
+        this.postData.CaseId = val
46 67
       }
47 68
     }
48 69
   },
49 70
   components: {},
50 71
   methods: {
51
-    submit () {
52
-      console.log(this.postData)
72
+    submit () { // 提交数据
73
+      if (this.postData.ChannelName === '') {
74
+        this.$message({
75
+          type: 'error',
76
+          message: '渠道名称不能为空'
77
+        })
78
+        return false
79
+      }
80
+      this.postData.OrgId = this.OrgId
81
+      if (this.postData.CaseId === '') this.postData.CaseId = this.CaseId
82
+      this.$ajax(this.$api.channelManager.addChannel.url, {
83
+        method: this.$api.channelManager.addChannel.method,
84
+        data: this.postData
85
+      }).then(res => {
86
+        this.$message({
87
+          type: 'success',
88
+          message: '操作成功'
89
+        })
90
+        this.$router.push({ name: 'channelList' })
91
+      })
53 92
     },
54 93
     cancel () {
55
-      this.$router.go(-1)
94
+      this.$router.push({ name: 'channelList' })
56 95
     }
57 96
   },
58
-  mounted () {}
97
+  mounted () { }
59 98
 }
60 99
 </script>
61 100
 

+ 65
- 15
src/pages/system/channelManager/channelList/edit.vue Ver arquivo

@@ -3,24 +3,27 @@
3 3
     <form class="mainForm">
4 4
       <ul>
5 5
         <li class="flex-h">
6
-          <span>渠道名:</span>
6
+          <span>选择案场:</span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%">
9
-              <el-input
10
-                placeholder="请输入渠道名"
11
-                v-model="postData.channelName"
12
-                clearable>
13
-              </el-input>
9
+              <el-select v-model="CaseId" placeholder="请选择">
10
+                <el-option
11
+                  v-for="item in cases"
12
+                  :key="item.CaseId"
13
+                  :label="item.CaseName"
14
+                  :value="item.CaseId">
15
+                </el-option>
16
+              </el-select>
14 17
             </div>
15 18
           </div>
16 19
         </li>
17 20
         <li class="flex-h">
18
-          <span>渠道code:</span>
21
+          <span>渠道:</span>
19 22
           <div class="flex-item">
20 23
             <div style="width:50%">
21 24
               <el-input
22
-                placeholder="请输入渠道code"
23
-                v-model="postData.channelCode"
25
+                placeholder="请输入渠道"
26
+                v-model="postData.ChannelName"
24 27
                 clearable>
25 28
               </el-input>
26 29
             </div>
@@ -36,26 +39,73 @@
36 39
 </template>
37 40
 
38 41
 <script>
42
+import { mapState } from 'vuex'
39 43
 export default {
40 44
   name: '',
41 45
   data () {
42 46
     return {
43 47
       postData: {
44
-        channelName: '',
45
-        channelCode: ''
48
+        ChannelId: '', // 渠道id
49
+        ChannelName: '', // 渠道名称
50
+        CaseId: '', // 案场id
51
+        OrgId: '', // 机构id
46 52
       }
47 53
     }
48 54
   },
55
+  computed: {
56
+    ...mapState({
57
+      cases: x => x.app.cases.list,
58
+      defaultCaseId: x => x.app.cases.default,
59
+      OrgId: x => x.app.user.OrgId,
60
+    }),
61
+    CaseId: {
62
+      get () {
63
+        return this.postData.CaseId === '' ? this.defaultCaseId || '' : this.postData.CaseId
64
+      },
65
+      set (val) {
66
+        this.postData.CaseId = val
67
+      }
68
+    }
69
+  },
70
+  created () {
71
+    this.getChannelInfo()
72
+  },
49 73
   components: {},
50 74
   methods: {
51
-    submit () {
52
-      console.log(this.postData)
75
+    getChannelInfo () {
76
+      this.$ajax(this.$api.channelManager.getChannelInfo.url, {
77
+        method: this.$api.channelManager.getChannelInfo.method,
78
+        urlData: { channelId: this.$route.query.id }
79
+      }).then(res => {
80
+        this.postData = res
81
+      })
82
+    },
83
+    submit () { // 提交数据
84
+      if (this.postData.ChannelName === '') {
85
+        this.$message({
86
+          type: 'error',
87
+          message: '渠道名称不能为空'
88
+        })
89
+        return false
90
+      }
91
+      this.postData.OrgId = this.OrgId
92
+      if (this.postData.CaseId === '') this.postData.CaseId = this.CaseId
93
+      this.$ajax(this.$api.channelManager.editChannel.url, {
94
+        method: this.$api.channelManager.editChannel.method,
95
+        data: this.postData
96
+      }).then(res => {
97
+        this.$message({
98
+          type: 'success',
99
+          message: '操作成功'
100
+        })
101
+        this.$router.push({ name: 'channelList' })
102
+      })
53 103
     },
54 104
     cancel () {
55
-      this.$router.go(-1)
105
+      this.$router.push({ name: 'channelList' })
56 106
     }
57 107
   },
58
-  mounted () {}
108
+  mounted () { }
59 109
 }
60 110
 </script>
61 111
 

+ 12
- 15
src/pages/system/channelManager/channelList/index.vue Ver arquivo

@@ -26,16 +26,16 @@
26 26
     </div>
27 27
     <div class="system-table-box">
28 28
       <el-table
29
-        :data="tableData"
29
+        :data="currentList"
30 30
         stripe
31 31
         style="width: 100%">
32 32
         <el-table-column
33
-          prop="channelName"
34
-          label="渠道名">
33
+          prop="CaseName"
34
+          label="案场">
35 35
         </el-table-column>
36 36
         <el-table-column
37
-          prop="channelCode"
38
-          label="渠道code">
37
+          prop="ChannelName"
38
+          label="渠道名称">
39 39
         </el-table-column>
40 40
         <el-table-column label="操作">
41 41
           <template slot-scope="scope">
@@ -70,7 +70,7 @@ export default {
70 70
     return {
71 71
       total: 0,
72 72
       postData: { // 表格搜索条件
73
-        CaseId: '', // 案场id
73
+        caseid: '', // 案场id
74 74
         page: 1, // 当前页码
75 75
         pagesize: 10, // 请求数据量
76 76
       },
@@ -87,10 +87,10 @@ export default {
87 87
     }),
88 88
     CaseId: {
89 89
       get () {
90
-        return this.postData.CaseId || this.defaultCaseId
90
+        return this.postData.caseid || this.defaultCaseId
91 91
       },
92 92
       set (val) {
93
-        this.postData.CaseId = val
93
+        this.postData.caseid = val
94 94
       }
95 95
     }
96 96
   },
@@ -101,13 +101,10 @@ export default {
101 101
       this.getList()
102 102
     },
103 103
     getList () { // 获取列表
104
-      this.$ajax(this.$api.goodsManager.getGoodsTypeList.url, {
105
-        method: this.$api.goodsManager.getGoodsTypeList.method,
106
-        data: { ...this.postData, CaseId: this.CaseId }
104
+      this.$ajax(this.$api.channelManager.getChannelList.url, {
105
+        method: this.$api.channelManager.getChannelList.method,
106
+        queryData: { ...this.postData, caseid: this.CaseId }
107 107
       }).then(res => {
108
-        for (var n = 0; n < res.list.length; n++) {
109
-          res.list[n].CaseName = this.cases.filter(x => x.CaseId === res.list[n].CaseId)[0].CaseName
110
-        }
111 108
         this.currentList = res.list
112 109
         this.postData.page = res.page
113 110
         this.total = res.pagenum
@@ -117,7 +114,7 @@ export default {
117 114
       this.getList()
118 115
     },
119 116
     handleEdit (index, row) { // 编辑
120
-      this.$router.push({ name: 'editGoodsType', query: { id: row.TypeId } })
117
+      this.$router.push({ name: 'editChannel', query: { id: row.ChannelId } })
121 118
     },
122 119
     handleDelete (index, row) { // 删除
123 120
       let name = '确认删除规格“' + row.TypeName + '”?'

+ 13
- 1
src/util/api.js Ver arquivo

@@ -48,7 +48,19 @@ const $api = {
48 48
   channelManager: {
49 49
     getChannelList: { // 渠道列表
50 50
       method: 'get',
51
-      url: `${baseUrl}${common}/`
51
+      url: `${baseUrl}${common}/channel`
52
+    },
53
+    getChannelInfo: { // 获取渠道信息
54
+      method: 'get',
55
+      url: `${baseUrl}${common}/channel/:channelId`
56
+    },
57
+    addChannel: { // 新增渠道
58
+      method: 'post',
59
+      url: `${baseUrl}${common}/channel`
60
+    },
61
+    editChannel: { // 更新渠道
62
+      method: 'put',
63
+      url: `${baseUrl}${common}/channel`
52 64
     },
53 65
   },
54 66
   caseManager: {