|
@@ -2,16 +2,24 @@
|
2
|
2
|
<div>
|
3
|
3
|
<div class="form-wrapper">
|
4
|
4
|
<el-form label-width="100px" :model="detail">
|
|
5
|
+ <el-form-item label="项目">
|
|
6
|
+ <el-select v-model="detail.buildingId" placeholder="请选择">
|
|
7
|
+ <el-option
|
|
8
|
+ v-for="item in buildingList"
|
|
9
|
+ :key="item.buildingId"
|
|
10
|
+ :label="item.buildingName"
|
|
11
|
+ :value="item.buildingId">
|
|
12
|
+ </el-option>
|
|
13
|
+ </el-select>
|
|
14
|
+ </el-form-item>
|
5
|
15
|
<el-form-item label="商品图片:">
|
6
|
16
|
<el-upload
|
7
|
|
- class="avatar-uploader"
|
8
|
|
- :action="upFileUrl"
|
9
|
|
- name='file'
|
10
|
|
- :show-file-list="false"
|
11
|
|
- :before-upload="beforeImgUpload"
|
12
|
|
- :on-success="handleAvatarSuccess">
|
13
|
|
- <img v-if="detail.imgUrl" :src="detail.imgUrl" class="avatar">
|
14
|
|
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
17
|
+ :headers="uploadHeaders"
|
|
18
|
+ :action="upFileUrl"
|
|
19
|
+ :show-file-list="false"
|
|
20
|
+ :on-success="handleAvatarSuccess">
|
|
21
|
+ <img v-if="detail.imgUrl" :src="detail.imgUrl" class="avatar">
|
|
22
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
15
|
23
|
</el-upload>
|
16
|
24
|
</el-form-item>
|
17
|
25
|
<el-form-item label="商品名称:">
|
|
@@ -26,22 +34,21 @@
|
26
|
34
|
<el-form-item label="剩余数量:">
|
27
|
35
|
<el-input v-model="detail.inventory"></el-input>
|
28
|
36
|
</el-form-item>
|
29
|
|
- <el-form-item label="授权项目:">
|
30
|
|
- <el-select v-model="detail.buildings" placeholder="请选择">
|
31
|
|
- <el-option v-for="(build,i) in buildings.list || []" :key="i" :label="build.buildingName" :value="build.buildingId"></el-option>
|
32
|
|
- </el-select>
|
33
|
|
- </el-form-item>
|
34
|
37
|
<el-form-item label="商品详情:">
|
35
|
38
|
<div id="websiteEditorElem" style="height: 400px"></div>
|
36
|
39
|
</el-form-item>
|
37
|
40
|
<el-form-item label="状态:">
|
38
|
|
- <el-radio-group v-model="detail.status">
|
39
|
|
- <el-radio-button :label="0">禁用</el-radio-button>
|
40
|
|
- <el-radio-button :label="1">启用</el-radio-button>
|
41
|
|
- </el-radio-group>
|
|
41
|
+ <el-select v-model="detail.status" clearable placeholder="请选择">
|
|
42
|
+ <el-option
|
|
43
|
+ v-for="item in options"
|
|
44
|
+ :key="item.value"
|
|
45
|
+ :label="item.label"
|
|
46
|
+ :value="item.value">
|
|
47
|
+ </el-option>
|
|
48
|
+ </el-select>
|
42
|
49
|
</el-form-item>
|
43
|
50
|
<el-form-item label="领取地址:">
|
44
|
|
- <el-input v-model="detail.tel"></el-input>
|
|
51
|
+ <el-input v-model="detail.address"></el-input>
|
45
|
52
|
</el-form-item>
|
46
|
53
|
<el-form-item>
|
47
|
54
|
<el-button type="primary" @click="submitForm">保存</el-button>
|
|
@@ -67,7 +74,25 @@ export default {
|
67
|
74
|
data() {
|
68
|
75
|
return {
|
69
|
76
|
upFileUrl: apis.file.upload.url,
|
70
|
|
- detail: {}
|
|
77
|
+ detail: {
|
|
78
|
+ buildingId: '',
|
|
79
|
+ imgUrl: '',
|
|
80
|
+ goodsName: '',
|
|
81
|
+ pointPrice: '',
|
|
82
|
+ totalNum: '',
|
|
83
|
+ inventory: '',
|
|
84
|
+ status: '',
|
|
85
|
+ address: '',
|
|
86
|
+ goodsId: '',
|
|
87
|
+ },
|
|
88
|
+ options: [{
|
|
89
|
+ value: '1',
|
|
90
|
+ label: '已上架'
|
|
91
|
+ }, {
|
|
92
|
+ value: '0',
|
|
93
|
+ label: '已下架'
|
|
94
|
+ }],
|
|
95
|
+ buildingList: [],
|
71
|
96
|
};
|
72
|
97
|
},
|
73
|
98
|
created() {
|
|
@@ -76,15 +101,30 @@ export default {
|
76
|
101
|
computed: {
|
77
|
102
|
...mapBuildingState({
|
78
|
103
|
buildings: x => x.buildings
|
79
|
|
- })
|
|
104
|
+ }),
|
|
105
|
+ uploadHeaders () {
|
|
106
|
+ const token = localStorage.getItem('x-token') || ''
|
|
107
|
+ return {
|
|
108
|
+ Authorization: `Bearer ${token}`
|
|
109
|
+ }
|
|
110
|
+ }
|
80
|
111
|
},
|
81
|
112
|
methods: {
|
82
|
113
|
...mapBuildingActions(["getBuildings"]),
|
83
|
|
- ...mapGoodsActions(["getGoodsDetail", "editConsultant"]),
|
|
114
|
+ ...mapGoodsActions(["getGoodsDetail", "editGoods", "addGoods"]),
|
84
|
115
|
init() {
|
85
|
|
- if (this.$route.params.id) {
|
|
116
|
+ this.detail.goodsId = this.$route.params.id
|
|
117
|
+ if (this.detail.goodsId !== undefined) {
|
86
|
118
|
this.getGoodsDetail({ id: this.$route.params.id }).then(data => {
|
87
|
|
- this.detail = data;
|
|
119
|
+ this.detail.buildingId = data.buildingId
|
|
120
|
+ this.detail.imgUrl = data.imgUrl
|
|
121
|
+ this.detail.goodsName = data.goodsName
|
|
122
|
+ this.detail.pointPrice = data.pointPrice
|
|
123
|
+ this.detail.totalNum = data.totalNum
|
|
124
|
+ this.detail.inventory = data.inventory
|
|
125
|
+ this.detail.status = data.status
|
|
126
|
+ this.detail.address = data.address
|
|
127
|
+ this.detail.goodsId = data.goodsId
|
88
|
128
|
});
|
89
|
129
|
}
|
90
|
130
|
},
|
|
@@ -98,21 +138,33 @@ export default {
|
98
|
138
|
return true;
|
99
|
139
|
},
|
100
|
140
|
|
101
|
|
- handleAvatarSuccess(res) {
|
102
|
|
- this.detail.photo = res.data;
|
103
|
|
- this.hideLoadding();
|
|
141
|
+ handleAvatarSuccess(res, file) {
|
|
142
|
+ this.imageUrl = URL.createObjectURL(file.raw);
|
|
143
|
+ // console.log(res)
|
|
144
|
+ this.detail.imgUrl = res.data
|
104
|
145
|
},
|
105
|
146
|
|
106
|
147
|
submitForm() {
|
107
|
148
|
this.showLoadding("保存中...");
|
108
|
|
- this.editConsultant(this.detail)
|
|
149
|
+ if (this.detail.goodsId === '' || this.detail.goodsId === undefined) {
|
|
150
|
+ console.log('添加')
|
|
151
|
+ this.addGoods(this.detail)
|
|
152
|
+ .then(res => {
|
|
153
|
+ this.hideLoadding();
|
|
154
|
+ this.$notify.info("保存成功");
|
|
155
|
+ this.$router.go(-1)
|
|
156
|
+ })
|
|
157
|
+ .catch(err => {
|
|
158
|
+ this.hideLoadding();
|
|
159
|
+ this.$notify.error(err.message);
|
|
160
|
+ });
|
|
161
|
+ return;
|
|
162
|
+ }
|
|
163
|
+ this.editGoods(this.detail)
|
109
|
164
|
.then(res => {
|
110
|
|
- if (res.personId) {
|
111
|
|
- this.detail = res;
|
112
|
|
- }
|
113
|
|
-
|
114
|
165
|
this.hideLoadding();
|
115
|
166
|
this.$notify.info("保存成功");
|
|
167
|
+ this.$router.go(-1)
|
116
|
168
|
})
|
117
|
169
|
.catch(err => {
|
118
|
170
|
this.hideLoadding();
|
|
@@ -162,16 +214,12 @@ export default {
|
162
|
214
|
];
|
163
|
215
|
phoneEditor.create()
|
164
|
216
|
|
165
|
|
- // this.getBuildings({
|
166
|
|
- // pageNum: 1,
|
167
|
|
- // pageSize: 100
|
168
|
|
- // }).then(() => {
|
169
|
|
- // if ((this.$route.query.id || "") !== "") {
|
170
|
|
- // this.getDetail({ id: this.$route.query.id }).then(data => {
|
171
|
|
- // phoneEditor.txt.html(data.url);
|
172
|
|
- // });
|
173
|
|
- // }
|
174
|
|
- // });
|
|
217
|
+ this.getBuildings({
|
|
218
|
+ pageNum: 1,
|
|
219
|
+ pageSize: 100
|
|
220
|
+ }).then((data) => {
|
|
221
|
+ this.buildingList = data.records;
|
|
222
|
+ });
|
175
|
223
|
}
|
176
|
224
|
};
|
177
|
225
|
</script>
|