40
40
<UploadImg v-model =" formData.picUrl" height =" 80px" />
41
41
</el-form-item >
42
42
</el-col >
43
- <!-- TODO @puhui999:浏览次数,不能修改 -->
44
43
<el-col :span =" 12" >
45
44
<el-form-item label =" 排序" prop =" sort" >
46
45
<el-input-number v-model =" formData.sort" :min =" 0" clearable controls-position =" right" />
59
58
</el-radio-group >
60
59
</el-form-item >
61
60
</el-col >
62
- <!-- TODO @puhui999:可以使用 SpuTableSelect -->
63
- <el-col :span =" 12" >
64
- <el-form-item label =" 商品关联" prop =" spuId" >
65
- <el-select v-model =" formData.spuId" placeholder =" 请选择" >
66
- <el-option
67
- v-for =" item in spuList"
68
- :key =" item.id"
69
- :label =" item.name"
70
- :value =" item.id"
71
- />
72
- </el-select >
73
- </el-form-item >
74
- </el-col >
75
61
<el-col :span =" 12" >
76
62
<el-form-item label =" 是否热门" prop =" recommendHot" >
77
63
<el-radio-group v-model =" formData.recommendHot" >
98
84
</el-radio-group >
99
85
</el-form-item >
100
86
</el-col >
87
+ <el-col :span =" 24" >
88
+ <el-form-item label =" 商品关联" prop =" spuId" >
89
+ <el-tag v-if =" formData.spuId" class =" mr-10px" >
90
+ {{ spuList.find((item) => item.id === formData.spuId)?.name }}
91
+ </el-tag >
92
+ <el-button @click =" spuSelectRef?.open()" >选择商品</el-button >
93
+ </el-form-item >
94
+ </el-col >
101
95
<el-col :span =" 24" >
102
96
<el-form-item label =" 文章内容" >
103
97
<Editor v-model =" formData.content" height =" 150px" />
110
104
<el-button @click =" dialogVisible = false" >取 消</el-button >
111
105
</template >
112
106
</Dialog >
107
+ <SpuSelect ref =" spuSelectRef" @confirm =" selectSpu" />
113
108
</template >
114
109
<script lang="ts" setup>
115
110
import { DICT_TYPE , getBoolDictOptions , getIntDictOptions } from ' @/utils/dict'
116
111
import * as ArticleApi from ' @/api/mall/promotion/article'
117
112
import * as ArticleCategoryApi from ' @/api/mall/promotion/articleCategory'
118
113
import * as ProductSpuApi from ' @/api/mall/product/spu'
114
+ import { SpuSelect } from ' @/views/mall/promotion/components'
119
115
120
116
defineOptions ({ name: ' PromotionArticleForm' })
121
117
@@ -135,7 +131,7 @@ const formData = ref({
135
131
introduction: undefined ,
136
132
sort: 0 ,
137
133
status: 0 ,
138
- spuId: undefined ,
134
+ spuId: 0 ,
139
135
recommendHot: false ,
140
136
recommendBanner: false ,
141
137
content: undefined
@@ -152,7 +148,10 @@ const formRules = reactive({
152
148
content: [{ required: true , message: ' 文章内容不能为空' , trigger: ' blur' }]
153
149
})
154
150
const formRef = ref () // 表单 Ref
155
-
151
+ const spuSelectRef = ref () // 商品和属性选择 Ref
152
+ const selectSpu = (spuId : number ) => {
153
+ formData .value .spuId = spuId
154
+ }
156
155
/** 打开弹窗 */
157
156
const open = async (type : string , id ? : number ) => {
158
157
dialogVisible .value = true
@@ -208,7 +207,7 @@ const resetForm = () => {
208
207
introduction: undefined ,
209
208
sort: 0 ,
210
209
status: 0 ,
211
- spuId: undefined ,
210
+ spuId: 0 ,
212
211
recommendHot: false ,
213
212
recommendBanner: false ,
214
213
content: undefined
0 commit comments