|
|
@@ -9,7 +9,7 @@ const storeId = Number(router.currentRoute.value.params.storeId)
|
|
|
const name = ref('')
|
|
|
const category = ref()
|
|
|
const price = ref()
|
|
|
-const photoUrlList = ref([''])
|
|
|
+const photoUrlList = ref<string[]>([])
|
|
|
|
|
|
const imageFileList = ref([])
|
|
|
|
|
|
@@ -29,7 +29,7 @@ function handleCreateProduct() {
|
|
|
category: category.value,
|
|
|
price: price.value,
|
|
|
photoUrlList: photoUrlList.value
|
|
|
- };
|
|
|
+ }
|
|
|
createProduct(payload).then(res => {
|
|
|
if (res.data.code === '000') {
|
|
|
ElMessage({
|
|
|
@@ -37,11 +37,11 @@ function handleCreateProduct() {
|
|
|
type: 'success',
|
|
|
center: true,
|
|
|
})
|
|
|
- name.value = '';
|
|
|
- category.value = '';
|
|
|
- price.value = '';
|
|
|
- photoUrlList.value = [];
|
|
|
- imageFileList.value = [];
|
|
|
+ name.value = ''
|
|
|
+ category.value = ''
|
|
|
+ price.value = ''
|
|
|
+ photoUrlList.value = []
|
|
|
+ imageFileList.value = []
|
|
|
} else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.data.msg,
|
|
|
@@ -54,10 +54,11 @@ function handleCreateProduct() {
|
|
|
|
|
|
function handleChange(file: any, fileList: any) {
|
|
|
imageFileList.value = fileList
|
|
|
- let formData = new FormData();
|
|
|
- formData.append('file', file.raw);
|
|
|
+ let formData = new FormData()
|
|
|
+ formData.append('file', file.raw)
|
|
|
uploadImage(formData).then(res => {
|
|
|
- photoUrlList.value.push(res.data.result);
|
|
|
+ console.log(res.data.result)
|
|
|
+ photoUrlList.value.push(res.data.result)
|
|
|
});
|
|
|
}
|
|
|
|