许成详 hace 6 años
padre
commit
aa4255cbc5

+ 86
- 34
src/pages/system/caseManager/caseInfo/addCase/index.vue Ver fichero

@@ -3,12 +3,12 @@
3 3
     <form class="mainForm">
4 4
       <ul>
5 5
         <li class="flex-h">
6
-          <span>案场名称:</span>
6
+          <span>案场名称:<em>*</em></span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%">
9 9
               <el-input
10
-                placeholder="请输入内容"
11
-                v-model="postData.name"
10
+                placeholder="请输入名称"
11
+                v-model="postData.CaseName"
12 12
                 clearable>
13 13
               </el-input>
14 14
             </div>
@@ -22,54 +22,62 @@
22 22
                 type="textarea"
23 23
                 :autosize="{ minRows: 3, maxRows: 5}"
24 24
                 placeholder="请填写详细地址"
25
-                v-model="postData.address">
25
+                v-model="postData.CaseAddress">
26 26
               </el-input>
27 27
             </div>
28 28
           </div>
29 29
         </li>
30 30
         <li class="flex-h">
31
-          <span>案场头像:</span>
31
+          <span>案场描述:</span>
32 32
           <div class="flex-item">
33 33
             <div>
34
-              <a class="formImg">
35
-                <img src="" class="centerLabel contain" alt="">
36
-                <i class="iconfont icon-quxiao"></i>
37
-              </a>
38
-              <el-button type="success" size="mini">上传图片</el-button>
34
+              <el-input
35
+                type="textarea"
36
+                :autosize="{ minRows: 3, maxRows: 5}"
37
+                placeholder="请填写详细描述"
38
+                v-model="postData.CaseDesc">
39
+              </el-input>
39 40
             </div>
40 41
           </div>
41 42
         </li>
42 43
         <li class="flex-h">
43
-          <span>案场负责人:</span>
44
+          <span>案场电话:</span>
44 45
           <div class="flex-item">
45 46
             <div style="width:50%">
46 47
               <el-input
47
-                placeholder="真实姓名,可包含汉字、英文"
48
-                v-model="postData.leaderName"
48
+                placeholder="限中国地区有效号码"
49
+                v-model="postData.CaseTel"
49 50
                 clearable>
50 51
               </el-input>
51 52
             </div>
52 53
           </div>
53 54
         </li>
54 55
         <li class="flex-h">
55
-          <span>负责人手机号:</span>
56
+          <span>案场头像:</span>
56 57
           <div class="flex-item">
57
-            <div style="width:50%">
58
-              <el-input
59
-                placeholder="限中国地区有效手机号"
60
-                v-model="postData.leaderPhone"
61
-                clearable>
62
-              </el-input>
58
+            <div>
59
+              <!-- <a class="formImg">
60
+                <img :src="postData.CaseIcon" class="centerLabel contain" alt="">
61
+                <i class="iconfont icon-quxiao"></i>
62
+              </a> -->
63
+              <el-upload
64
+                class="avatar-uploader"
65
+                :action='$api.file.image.url'
66
+                :show-file-list="false"
67
+                :on-success="handleAvatarSuccess">
68
+                <img v-if="postData.CaseIcon" :src="postData.CaseIcon" class="avatar">
69
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
70
+              </el-upload>
63 71
             </div>
64 72
           </div>
65 73
         </li>
66 74
         <li class="flex-h">
67
-          <span>左击地图获取经纬度:</span>
68
-          <div class="flex-item">
75
+          <span>左击地图获取经纬度:<em>*</em></span>
76
+          <div class="flex-item" style="margin-left: 10px;">
69 77
             <div style="width:50%">
70 78
               <el-input
71 79
                 placeholder=""
72
-                v-model="postData.atitudeAndLongitude"
80
+                v-model="postData.Coordinate"
73 81
                 clearable>
74 82
               </el-input>
75 83
             </div>
@@ -97,6 +105,7 @@
97 105
 </template>
98 106
 
99 107
 <script>
108
+import { mapState, mapActions } from 'vuex'
100 109
 
101 110
 export default {
102 111
   name: '',
@@ -104,11 +113,17 @@ export default {
104 113
     var _self = this
105 114
     return {
106 115
       postData: {
107
-        name: '', // 案场名称
108
-        address: '', // 案场地址
109
-        leaderName: '', // 负责人
110
-        leaderPhone: '', // 负责人手机号
111
-        atitudeAndLongitude: '',
116
+        OrgId: '', // 机构id
117
+        CaseId: '', // 案场id
118
+        CaseName: '', // 案场名称
119
+        CaseDesc: '', // 案场描述
120
+        CaseIcon: '', // 案场图标
121
+        CaseAddress: '', // 案场地址
122
+        CaseTel: '', // 案场电话
123
+        Coordinate: '', // 经纬度
124
+        Status: '', // 状态
125
+        CreatDate: '', // 创建日期
126
+        CreatUser: '', // 创建人
112 127
       },
113 128
       markers: [],
114 129
       searchOption: {
@@ -118,14 +133,25 @@ export default {
118 133
       mapCenter: [118.789509, 32.019989],
119 134
       events: {
120 135
         click: (e) => {
121
-          _self.postData.atitudeAndLongitude = e.lnglat.lat + ',' + e.lnglat.lng
136
+          _self.postData.Coordinate = e.lnglat.lat + ',' + e.lnglat.lng
122 137
         }
123 138
       },
124 139
     }
125 140
   },
141
+  computed: {
142
+    ...mapState({
143
+      OrgId: x => x.app.user.OrgId,
144
+    }),
145
+  },
126 146
   components: {},
127 147
   methods: {
128
-    onSearchResult (pois) {
148
+    ...mapActions([
149
+      'updateSystemInfo'
150
+    ]),
151
+    handleAvatarSuccess (res, file) {
152
+      this.postData.CaseIcon = res.result.url
153
+    },
154
+    onSearchResult (pois) { // 搜索地图
129 155
       let latSum = 0
130 156
       let lngSum = 0
131 157
       if (pois.length > 0) {
@@ -142,11 +168,37 @@ export default {
142 168
         this.mapCenter = [center.lng, center.lat]
143 169
       }
144 170
     },
145
-    submit () {
146
-      console.log(this.postData)
171
+    submit () { // 提交数据
172
+      if (this.postData.CaseName === '') {
173
+        this.$message({
174
+          type: 'error',
175
+          message: '案场名称不能为空'
176
+        })
177
+        return false
178
+      }
179
+      if (this.postData.Coordinate === '') {
180
+        this.$message({
181
+          type: 'error',
182
+          message: '案场经纬度不能为空'
183
+        })
184
+        return false
185
+      }
186
+      this.postData.OrgId = this.OrgId
187
+      this.$ajax(this.$api.caseManager.addCase.url, {
188
+        method: this.$api.caseManager.addCase.method,
189
+        data: this.postData
190
+      }).then(res => {
191
+        this.$message({
192
+          type: 'success',
193
+          message: '操作成功'
194
+        })
195
+        this.updateSystemInfo().then(() => {
196
+          this.$router.push({ name: 'caseInfo' })
197
+        })
198
+      })
147 199
     },
148
-    cancel () {
149
-      this.$router.go(-1)
200
+    cancel () { // 取消
201
+      this.$router.push({ name: 'caseInfo' })
150 202
     }
151 203
   }
152 204
 }

+ 5
- 1
src/pages/system/caseManager/caseInfo/addCase/page.scss Ver fichero

@@ -1,4 +1,8 @@
1
-
1
+span{
2
+  em{
3
+    color: red;
4
+  }
5
+}
2 6
 .map{
3 7
   height: 500px;
4 8
   background: #eee;

+ 97
- 34
src/pages/system/caseManager/caseInfo/editCase/index.vue Ver fichero

@@ -3,12 +3,12 @@
3 3
     <form class="mainForm">
4 4
       <ul>
5 5
         <li class="flex-h">
6
-          <span>案场名称:</span>
6
+          <span>案场名称:<em>*</em></span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%">
9 9
               <el-input
10
-                placeholder="请输入内容"
11
-                v-model="postData.name"
10
+                placeholder="请输入名称"
11
+                v-model="postData.CaseName"
12 12
                 clearable>
13 13
               </el-input>
14 14
             </div>
@@ -22,54 +22,62 @@
22 22
                 type="textarea"
23 23
                 :autosize="{ minRows: 3, maxRows: 5}"
24 24
                 placeholder="请填写详细地址"
25
-                v-model="postData.address">
25
+                v-model="postData.CaseAddress">
26 26
               </el-input>
27 27
             </div>
28 28
           </div>
29 29
         </li>
30 30
         <li class="flex-h">
31
-          <span>案场头像:</span>
31
+          <span>案场描述:</span>
32 32
           <div class="flex-item">
33 33
             <div>
34
-              <a class="formImg">
35
-                <img src="" class="centerLabel contain" alt="">
36
-                <i class="iconfont icon-quxiao"></i>
37
-              </a>
38
-              <el-button type="success" size="mini">上传图片</el-button>
34
+              <el-input
35
+                type="textarea"
36
+                :autosize="{ minRows: 3, maxRows: 5}"
37
+                placeholder="请填写详细描述"
38
+                v-model="postData.CaseDesc">
39
+              </el-input>
39 40
             </div>
40 41
           </div>
41 42
         </li>
42 43
         <li class="flex-h">
43
-          <span>案场负责人:</span>
44
+          <span>案场电话:</span>
44 45
           <div class="flex-item">
45 46
             <div style="width:50%">
46 47
               <el-input
47
-                placeholder="真实姓名,可包含汉字、英文"
48
-                v-model="postData.leaderName"
48
+                placeholder="限中国地区有效号码"
49
+                v-model="postData.CaseTel"
49 50
                 clearable>
50 51
               </el-input>
51 52
             </div>
52 53
           </div>
53 54
         </li>
54 55
         <li class="flex-h">
55
-          <span>负责人手机号:</span>
56
+          <span>案场头像:</span>
56 57
           <div class="flex-item">
57
-            <div style="width:50%">
58
-              <el-input
59
-                placeholder="限中国地区有效手机号"
60
-                v-model="postData.leaderPhone"
61
-                clearable>
62
-              </el-input>
58
+            <div>
59
+              <!-- <a class="formImg">
60
+                <img :src="postData.CaseIcon" class="centerLabel contain" alt="">
61
+                <i class="iconfont icon-quxiao"></i>
62
+              </a> -->
63
+              <el-upload
64
+                class="avatar-uploader"
65
+                :action='$api.file.image.url'
66
+                :show-file-list="false"
67
+                :on-success="handleAvatarSuccess">
68
+                <img v-if="postData.CaseIcon" :src="postData.CaseIcon" class="avatar">
69
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
70
+              </el-upload>
63 71
             </div>
64 72
           </div>
65 73
         </li>
66 74
         <li class="flex-h">
67
-          <span>左击地图获取经纬度:</span>
68
-          <div class="flex-item">
75
+          <span>左击地图获取经纬度:<em>*</em></span>
76
+          <div class="flex-item" style="margin-left: 10px;">
69 77
             <div style="width:50%">
70 78
               <el-input
71 79
                 placeholder=""
72
-                v-model="postData.atitudeAndLongitude"
80
+                v-model="postData.Coordinate"
73 81
                 clearable>
74 82
               </el-input>
75 83
             </div>
@@ -97,6 +105,7 @@
97 105
 </template>
98 106
 
99 107
 <script>
108
+import { mapState, mapActions } from 'vuex'
100 109
 
101 110
 export default {
102 111
   name: '',
@@ -104,11 +113,17 @@ export default {
104 113
     var _self = this
105 114
     return {
106 115
       postData: {
107
-        name: '', // 案场名称
108
-        address: '', // 案场地址
109
-        leaderName: '', // 负责人
110
-        leaderPhone: '', // 负责人手机号
111
-        atitudeAndLongitude: '',
116
+        OrgId: '', // 机构id
117
+        CaseId: '', // 案场id
118
+        CaseName: '', // 案场名称
119
+        CaseDesc: '', // 案场描述
120
+        CaseIcon: '', // 案场图标
121
+        CaseAddress: '', // 案场地址
122
+        CaseTel: '', // 案场电话
123
+        Coordinate: '', // 经纬度
124
+        Status: '', // 状态
125
+        CreatDate: '', // 创建日期
126
+        CreatUser: '', // 创建人
112 127
       },
113 128
       markers: [],
114 129
       searchOption: {
@@ -118,14 +133,36 @@ export default {
118 133
       mapCenter: [118.789509, 32.019989],
119 134
       events: {
120 135
         click: (e) => {
121
-          _self.postData.atitudeAndLongitude = e.lnglat.lat + ',' + e.lnglat.lng
136
+          _self.postData.Coordinate = e.lnglat.lat + ',' + e.lnglat.lng
122 137
         }
123 138
       },
124 139
     }
125 140
   },
141
+  computed: {
142
+    ...mapState({
143
+      OrgId: x => x.app.user.OrgId,
144
+    }),
145
+  },
146
+  created () {
147
+    this.getCaseInfoById()
148
+  },
126 149
   components: {},
127 150
   methods: {
128
-    onSearchResult (pois) {
151
+    ...mapActions([
152
+      'updateSystemInfo'
153
+    ]),
154
+    getCaseInfoById () { // 获取案场信息
155
+      this.$ajax(this.$api.caseManager.getCaseInfo.url, {
156
+        method: this.$api.caseManager.getCaseInfo.method,
157
+        urlData: { id: this.$route.query.id }
158
+      }).then(res => {
159
+        this.postData = res
160
+      })
161
+    },
162
+    handleAvatarSuccess (res, file) {
163
+      this.postData.CaseIcon = res.result.url
164
+    },
165
+    onSearchResult (pois) { // 搜索地图
129 166
       let latSum = 0
130 167
       let lngSum = 0
131 168
       if (pois.length > 0) {
@@ -142,11 +179,37 @@ export default {
142 179
         this.mapCenter = [center.lng, center.lat]
143 180
       }
144 181
     },
145
-    submit () {
146
-      console.log(this.postData)
182
+    submit () { // 提交数据
183
+      if (this.postData.CaseName === '') {
184
+        this.$message({
185
+          type: 'error',
186
+          message: '案场名称不能为空'
187
+        })
188
+        return false
189
+      }
190
+      if (this.postData.Coordinate === '') {
191
+        this.$message({
192
+          type: 'error',
193
+          message: '案场经纬度不能为空'
194
+        })
195
+        return false
196
+      }
197
+      this.postData.OrgId = this.OrgId
198
+      this.$ajax(this.$api.caseManager.addCase.url, {
199
+        method: this.$api.caseManager.addCase.method,
200
+        data: this.postData
201
+      }).then(res => {
202
+        this.$message({
203
+          type: 'success',
204
+          message: '操作成功'
205
+        })
206
+        this.updateSystemInfo().then(() => {
207
+          this.$router.push({ name: 'caseInfo' })
208
+        })
209
+      })
147 210
     },
148
-    cancel () {
149
-      this.$router.go(-1)
211
+    cancel () { // 取消
212
+      this.$router.push({ name: 'caseInfo' })
150 213
     }
151 214
   }
152 215
 }

+ 5
- 1
src/pages/system/caseManager/caseInfo/editCase/page.scss Ver fichero

@@ -1,4 +1,8 @@
1
-
1
+span{
2
+  em{
3
+    color: red;
4
+  }
5
+}
2 6
 .map{
3 7
   height: 500px;
4 8
   background: #eee;

+ 2
- 2
src/pages/system/caseManager/caseInfo/index.vue Ver fichero

@@ -3,7 +3,7 @@
3 3
     <div class="system-table-search">
4 4
       <div class="flex-h">
5 5
         <div class="flex-item flex-h">
6
-          <el-button size="mini" type="success" @click="redirection('addIndexCase')">新增案场</el-button>
6
+          <el-button size="mini" type="success" @click="redirection('addCase')">新增案场</el-button>
7 7
         </div>
8 8
         <tableSearch value="请输入案场名称" @exportSearchKey="searchList"></tableSearch>
9 9
       </div>
@@ -94,7 +94,7 @@ export default {
94 94
     },
95 95
     editItem (index, row) { // 修改
96 96
       // console.log(index, row)
97
-      this.$router.push({ name: 'editIndexCase', query: { id: row.id } })
97
+      this.$router.push({ name: 'editCase', query: { id: row.CaseId } })
98 98
     },
99 99
     keyManager (index, row) { // 钥匙管理
100 100
       console.log(index, row)

+ 7
- 4
src/store/app.js Ver fichero

@@ -87,10 +87,13 @@ export default {
87 87
   },
88 88
   actions: {
89 89
     updateSystemInfo (context) { // 这里的context和我们使用的$store拥有相同的对象和方法
90
-      this.$ajax(this.$api.system.init.url, {
91
-        method: this.$api.system.init.method
92
-      }).then(res => {
93
-        context.commit('init', res)
90
+      return new Promise((resolve) => {
91
+        this.$ajax(this.$api.system.init.url, {
92
+          method: this.$api.system.init.method
93
+        }).then(res => {
94
+          context.commit('init', res)
95
+          resolve()
96
+        })
94 97
       })
95 98
     }
96 99
   }

+ 12
- 0
src/util/api.js Ver fichero

@@ -23,6 +23,18 @@ const $api = {
23 23
       method: 'get',
24 24
       url: `${baseUrl}/common/case/info`
25 25
     },
26
+    addCase: { // 新增案场
27
+      method: 'post',
28
+      url: `${baseUrl}/common/case/info`
29
+    },
30
+    getCaseInfo: { // 查询案场
31
+      method: 'get',
32
+      url: `${baseUrl}/common/case/info/:id`
33
+    },
34
+    editCase: { // 编辑案场
35
+      method: 'put',
36
+      url: `${baseUrl}/common/case/info/:id`
37
+    },
26 38
   },
27 39
   goodsManager: {
28 40
     getGoodsSpecList: { // 商品规格列表