提交 9d4def11 authored 作者: 刘旭's avatar 刘旭

修改bug

上级 883d4bbb
......@@ -4,4 +4,4 @@ VITE_APP_PORT = 3003
# 请求接口
VITE_APP_BASE_URL = "/admin"
VITE_APP_BASE_IMG = "/wx/storage/fetch/"
\ No newline at end of file
VITE_APP_BASE_IMG = ""
\ No newline at end of file
......@@ -4,4 +4,4 @@ VITE_APP_PORT = 3002
# 请求接口
VITE_APP_BASE_URL = "/admin"
VITE_APP_BASE_IMG = "/wx/storage/fetch/"
\ No newline at end of file
VITE_APP_BASE_IMG = ""
\ No newline at end of file
......@@ -9,7 +9,7 @@
<script setup lang="ts">
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue'
import { onBeforeUnmount, ref, shallowRef, computed } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
const props = defineProps({
......@@ -19,6 +19,11 @@ const props = defineProps({
}
})
const valueHtml = computed({
get: () => props.valueHtml,
set: (value) => emits("htmlChange", value),
})
const mode = ref('mode')
const emits = defineEmits(['htmlChange'])
......
......@@ -46,8 +46,8 @@
</el-form-item>
<el-form-item label="宣传画廊">
<el-upload :action="uploadPath" :limit="5" :headers="headers" :on-exceed="uploadOverrun"
:on-success="handleGalleryUrl" :on-remove="handleRemove" multiple
<el-upload v-model:file-list="fileList" :action="uploadPath" :limit="5" :headers="headers"
:on-exceed="uploadOverrun" :on-success="handleGalleryUrl" :on-remove="handleRemove" multiple
accept=".jpg,.jpeg,.png,.gif" list-type="picture-card">
<el-icon class="avatar-uploader-icon">
<Plus />
......@@ -232,6 +232,7 @@ let galleryFileList = ref([] as any);
let categoryIds = ref([] as any);
let categoryList = ref([] as any);
let brandList = ref([] as any);
let fileList = ref([] as any)
let goods = ref({
goodsSn: "",
name: "",
......@@ -244,7 +245,7 @@ let goods = ref({
unit: "",
brandId: "",
brief: "",
detail: '<p>你好啊!!</p>',
detail: '<p></p>',
categoryId: undefined,
keywords: undefined
} as any);
......@@ -284,39 +285,50 @@ let initList = () => {
initList()
let init = (id: number) => {
detailGoods(id).then((res) => {
goods.value = res.data.goods;
for (let s in res.data.parts) {
goodsParts.value.push(res.data.parts[s].partGoodsId)
}
detailGoods(id).then((res: any) => {
if (res.code === 200) {
res.data.goods.gallery.map((item: any) => {
fileList.value.push({
url: item,
name: item.split('/')[item.split('/').length - 1]
})
})
goods.value = res.data.goods;
for (let s in res.data.parts) {
goodsParts.value.push(res.data.parts[s].partGoodsId)
}
// 稍微调整一下前后端不一致
if (goods.value?.brandId === 0) {
goods.value!.brandId = null;
}
if (goods.value?.keywords === "") {
goods.value!.keywords = null;
}
specifications.value = res.data.specifications;
products.value = res.data.products;
attributes.value = res.data.attributes;
selectSpecRef.value.setAttributes(res.data.products)
categoryIds.value = res.data.categoryIds;
galleryFileList.value = [];
for (var i = 0; i < goods.value?.gallery.length; i++) {
galleryFileList.value.push({
url: goods.value?.gallery[i],
});
}
const keyword: any = res.data.goods.keywords;
if (keyword !== null) {
keywords.value = keyword.split(",");
// 稍微调整一下前后端不一致
if (goods.value?.brandId === 0) {
goods.value!.brandId = null;
}
if (goods.value?.keywords === "") {
goods.value!.keywords = null;
}
specifications.value = res.data.specifications;
products.value = res.data.products;
attributes.value = res.data.attributes;
selectSpecRef.value.setAttributes(res.data.products)
categoryIds.value = res.data.categoryIds;
galleryFileList.value = [];
for (var i = 0; i < goods.value?.gallery.length; i++) {
galleryFileList.value.push({
url: goods.value?.gallery[i],
});
}
const keyword: any = res.data.goods.keywords;
if (keyword !== null) {
keywords.value = keyword.split(",");
}
}
});
listCatAndBrand().then((res: any) => {
categoryList.value = res.data.categoryList;
brandList.value = res.data.brandList;
if (res.code === 200) {
categoryList.value = res.data.categoryList;
brandList.value = res.data.brandList;
}
});
}
......@@ -350,6 +362,7 @@ let handleCancel = () => {
products.value = []
goodsParts.value = []
attributes.value = []
fileList.value = []
editDrawer.value = false
}
let handleEdit = () => {
......@@ -406,11 +419,11 @@ let uploadOverrun = () => {
});
}
let handleGalleryUrl = (res: any, file: any, fileList: any) => {
// if (res.errno === 0) {
goods.value.gallery.push(res.data.url);
// }
fileList.value.push(fileList)
}
let handleRemove = (file: any, fileList: any) => {
fileList.value = fileList
for (let i = 0; i < goods.value.gallery.length; i++) {
// 这里存在两种情况
// 1. 如果所删除图片是刚刚上传的图片,那么图片地址是file.res.data.url
......
......@@ -57,8 +57,8 @@
</el-form-item>
<el-form-item label="宣传画廊">
<el-upload :action="uploadPath" :limit="5" :headers="headers" :on-exceed="uploadOverrun"
:on-success="handleGalleryUrl" :on-remove="handleRemove" multiple
<el-upload v-model:file-list="goods.gallery" :action="uploadPath" :limit="5" :headers="headers"
:on-exceed="uploadOverrun" :on-success="handleGalleryUrl" :on-remove="handleRemove" multiple
accept=".jpg,.jpeg,.png,.gif" list-type="picture-card">
<el-icon class="avatar-uploader-icon">
<Plus />
......@@ -236,6 +236,7 @@ let newKeyword = ref("");
let keywords = ref([] as any);
let categoryList = ref([] as any);
let brandList = ref([] as any);
let fileList = ref([])
let goods = ref({
goodsSn: "",
name: "",
......
......@@ -89,11 +89,11 @@ export default ({ command, mode }) => {
// '/foo': '',
// 选项写法
"/admin": {
target: "http://192.168.0.9:8089/",
target: "http://192.168.0.23/",
// rewrite: (path) => path.replace(/^\/api/, '')
},
"/wx": {
target: "http://192.168.0.9:8089/",
target: "http://192.168.0.23/",
// rewrite: (path) => path.replace(/^\/api/, '')
},
// 正则表达式写法
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论