|
1 | 1 | <template>
|
2 | 2 | <div class="container">
|
| 3 | + <!-- TODO 样式优化:表单宽度、表单项对齐、hr 粗细; --> |
3 | 4 | <el-tabs v-model="activeName" class="tabs">
|
4 | 5 | <!-- 基础设置 -->
|
| 6 | + <!-- TODO @luowenfeng:基础设置,分成商品类型、基础信息、配送信息 --> |
| 7 | + <!-- TODO @luowenfeng:base=》basic 会更好哈 --> |
5 | 8 | <el-tab-pane label="基础设置" name="base">
|
6 | 9 | <el-form ref="base" :model="baseForm" :rules="rules" label-width="100px" style="width: 95%">
|
7 | 10 | <el-form-item label="商品名称" prop="name">
|
8 |
| - <el-input v-model="baseForm.name" placeholder="请输入商品名称"/> |
| 11 | + <el-input v-model="baseForm.name" placeholder="请输入商品名称" /> |
9 | 12 | </el-form-item>
|
10 | 13 | <el-form-item label="促销语">
|
11 | 14 | <el-input type="textarea" v-model="baseForm.sellPoint" placeholder="请输入促销语"/>
|
|
16 | 19 | <el-form-item label="商品视频" prop="videoUrl">
|
17 | 20 | <VideoUpload v-model="baseForm.videoUrl" :value="baseForm.videoUrl"/>
|
18 | 21 | </el-form-item>
|
19 |
| - |
20 | 22 | <el-form-item label="商品品牌" prop="brandId">
|
21 | 23 | <el-select v-model="baseForm.brandId" placeholder="请选择商品品牌">
|
22 | 24 | <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id"/>
|
|
28 | 30 | </el-form-item>
|
29 | 31 | <el-form-item label="是否上架" prop="status">
|
30 | 32 | <el-radio-group v-model="baseForm.status">
|
31 |
| - <el-radio :label="0">立即上架</el-radio> |
32 |
| - <el-radio :label="1">放入仓库</el-radio> |
| 33 | + <el-radio :label="1">立即上架</el-radio> |
| 34 | + <el-radio :label="0">放入仓库</el-radio> |
33 | 35 | </el-radio-group>
|
34 | 36 | </el-form-item>
|
35 | 37 | </el-form>
|
36 | 38 | </el-tab-pane>
|
37 | 39 |
|
38 | 40 | <!-- 价格库存 -->
|
| 41 | + <!-- TODO @luowenfeng:rates=》priceStack 会更好哈 --> |
39 | 42 | <el-tab-pane label="价格库存" name="rates" class="rates">
|
40 | 43 | <el-form ref="rates" :model="ratesForm" :rules="rules">
|
41 | 44 | <el-form-item label="启用多规格">
|
42 |
| - <el-switch v-model="specSwitch" @change="changeSpecSwitch"></el-switch> |
| 45 | + <el-switch v-model="specSwitch" @change="changeSpecSwitch"/> |
43 | 46 | </el-form-item>
|
44 |
| - |
45 | 47 | <!-- 动态添加规格属性 -->
|
46 | 48 | <div v-show="ratesForm.spec === 2">
|
47 | 49 | <div v-for="(specs, index) in dynamicSpec" :key="index" class="dynamic-spec">
|
|
59 | 61 | </template>
|
60 | 62 | </div>
|
61 | 63 | </div>
|
62 |
| - <el-button type="primary" @click="dynamicSpec.push({specValue: []}); ratesForm.rates = []">添加规格项目 |
63 |
| - </el-button> |
| 64 | + <el-button type="primary" @click="dynamicSpec.push({specValue: []}); ratesForm.rates = []">添加规格项目</el-button> |
64 | 65 | </div>
|
65 | 66 |
|
66 | 67 | <!-- 规格明细 -->
|
|
76 | 77 | </template>
|
77 | 78 | <el-table-column label="规格图片" width="120px" :render-header="addRedStar" key="90">
|
78 | 79 | <template slot-scope="scope">
|
79 |
| - <ImageUpload v-model="scope.row.picUrl" :limit="1" :isShowTip="false" |
80 |
| - style="width: 100px; height: 50px"/> |
| 80 | + <ImageUpload v-model="scope.row.picUrl" :limit="1" :isShowTip="false" style="width: 100px; height: 50px"/> |
81 | 81 | </template>
|
82 | 82 | </el-table-column>
|
83 | 83 | <template v-if="this.specSwitch">
|
84 | 84 | <el-table-column label="sku名称" :render-header="addRedStar" key="91">
|
85 | 85 | <template slot-scope="scope">
|
86 |
| - <el-form-item :prop="'rates.'+ scope.$index + '.name'" |
87 |
| - :rules="[{required: true, trigger: 'change'}]"> |
| 86 | + <el-form-item :prop="'rates.'+ scope.$index + '.name'" :rules="[{required: true, trigger: 'change'}]"> |
88 | 87 | <el-input v-model="scope.row.name"/>
|
89 | 88 | </el-form-item>
|
90 | 89 | </template>
|
91 | 90 | </el-table-column>
|
92 | 91 | </template>
|
93 | 92 | <el-table-column label="市场价(元)" :render-header="addRedStar" key="92">
|
94 | 93 | <template slot-scope="scope">
|
95 |
| - <el-form-item :prop="'rates.'+ scope.$index + '.marketPrice'" |
96 |
| - :rules="[{required: true, trigger: 'change'}]"> |
| 94 | + <el-form-item :prop="'rates.'+ scope.$index + '.marketPrice'" :rules="[{required: true, trigger: 'change'}]"> |
97 | 95 | <el-input v-model="scope.row.marketPrice"
|
98 | 96 | oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"/>
|
99 | 97 | </el-form-item>
|
|
104 | 102 | <el-form-item :prop="'rates.'+ scope.$index + '.price'"
|
105 | 103 | :rules="[{required: true, trigger: 'change'}]">
|
106 | 104 | <el-input v-model="scope.row.price"
|
107 |
| - oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"></el-input> |
| 105 | + oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> |
108 | 106 | </el-form-item>
|
109 | 107 | </template>
|
110 | 108 | </el-table-column>
|
111 | 109 | <el-table-column label="成本价" :render-header="addRedStar" key="94">
|
112 | 110 | <template slot-scope="scope">
|
113 | 111 | <el-form-item :prop="'rates.'+ scope.$index + '.costPrice'"
|
114 | 112 | :rules="[{required: true, trigger: 'change'}]">
|
115 |
| - <el-input |
116 |
| - v-model="scope.row.costPrice" |
117 |
| - oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''" |
118 |
| - ></el-input> |
| 113 | + <el-input v-model="scope.row.costPrice" |
| 114 | + oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''" /> |
119 | 115 | </el-form-item>
|
120 | 116 | </template>
|
121 | 117 | </el-table-column>
|
122 | 118 | <el-table-column label="库存" :render-header="addRedStar" key="95">
|
123 | 119 | <template slot-scope="scope">
|
124 |
| - <el-form-item :prop="'rates.'+ scope.$index + '.stock'" |
125 |
| - :rules="[{required: true, trigger: 'change'}]"> |
| 120 | + <el-form-item :prop="'rates.'+ scope.$index + '.stock'" :rules="[{required: true, trigger: 'change'}]"> |
126 | 121 | <el-input v-model="scope.row.stock" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"></el-input>
|
127 | 122 | </el-form-item>
|
128 | 123 | </template>
|
|
134 | 129 | </el-table-column>
|
135 | 130 | <el-table-column label="体积" key="97">
|
136 | 131 | <template slot-scope="scope">
|
137 |
| - <el-input v-model="scope.row.volume"></el-input> |
| 132 | + <el-input v-model="scope.row.volume" /> |
138 | 133 | </template>
|
139 | 134 | </el-table-column>
|
140 | 135 | <el-table-column label="重量" key="98">
|
141 | 136 | <template slot-scope="scope">
|
142 |
| - <el-input v-model="scope.row.weight"></el-input> |
| 137 | + <el-input v-model="scope.row.weight" /> |
143 | 138 | </template>
|
144 | 139 | </el-table-column>
|
145 | 140 | <el-table-column label="条码" key="99">
|
146 | 141 | <template slot-scope="scope">
|
147 |
| - <el-input v-model="scope.row.barCode"></el-input> |
| 142 | + <el-input v-model="scope.row.barCode" /> |
148 | 143 | </template>
|
149 | 144 | </el-table-column>
|
150 | 145 | <template v-if="this.specSwitch">
|
|
169 | 164 | </el-tab-pane>
|
170 | 165 |
|
171 | 166 | <!-- 商品详情 -->
|
| 167 | + <!-- TODO @luowenfeng:third=》detail 会更好哈 --> |
172 | 168 | <el-tab-pane label="商品详情" name="third">
|
173 | 169 | <el-form ref="third" :model="baseForm" :rules="rules">
|
174 | 170 | <el-form-item prop="description">
|
|
178 | 174 | </el-tab-pane>
|
179 | 175 |
|
180 | 176 | <!-- 销售设置 -->
|
| 177 | + <!-- TODO @luowenfeng:fourth=》senior 会更好哈 --> |
181 | 178 | <el-tab-pane label="高级设置" name="fourth">
|
182 | 179 | <el-form ref="fourth" :model="baseForm" :rules="rules" label-width="100px" style="width: 95%">
|
183 | 180 | <el-form-item label="排序字段">
|
@@ -421,15 +418,13 @@ export default {
|
421 | 418 | if (form.id == null) {
|
422 | 419 | createSpu(form).then(() => {
|
423 | 420 | this.$modal.msgSuccess("新增成功");
|
424 |
| - }) |
425 |
| - .then(()=>{ |
| 421 | + }).then(()=>{ |
426 | 422 | this.cancel();
|
427 | 423 | })
|
428 | 424 | } else {
|
429 | 425 | updateSpu(form).then(() => {
|
430 | 426 | this.$modal.msgSuccess("修改成功");
|
431 |
| - }) |
432 |
| - .then(()=>{ |
| 427 | + }).then(()=>{ |
433 | 428 | this.cancel();
|
434 | 429 | })
|
435 | 430 | }
|
|
0 commit comments