提交 e940bf3f authored 作者: 刘旭's avatar 刘旭

补全修改

上级 5edc9119
...@@ -79,8 +79,12 @@ ...@@ -79,8 +79,12 @@
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader v-model="categoryIds" :options="categoryList" expand-trigger="hover" clearable <!-- <el-cascader v-model="categoryIds" :options="categoryList" expand-trigger="hover" clearable
@change="handleCategoryChange" /> @change="handleCategoryChange" /> -->
<el-select v-model="goods.categoryId" placeholder="请选择" @change="handleCategoryChange">
<el-option v-for="item in categoryList" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
...@@ -105,13 +109,7 @@ ...@@ -105,13 +109,7 @@
<h3>商品规格</h3> <h3>商品规格</h3>
<el-row :gutter="20" type="flex" align="middle" style="padding: 20px 0"> <el-row :gutter="20" type="flex" align="middle" style="padding: 20px 0">
<el-col :span="10"> <el-col :span="10">
<el-radio-group v-model="multipleSpec" @change="specChanged"> <el-button type="primary" @click="handleSpecificationShow">添加</el-button>
<!-- <el-radio-button :label="false">默认标准规格</el-radio-button> -->
<el-radio-button :label="true">多规格支持</el-radio-button>
</el-radio-group>
</el-col>
<el-col v-if="multipleSpec" :span="10">
<el-button :plain="true" type="primary" @click="handleSpecificationShow">添加</el-button>
</el-col> </el-col>
</el-row> </el-row>
...@@ -174,6 +172,9 @@ ...@@ -174,6 +172,9 @@
</el-dialog> </el-dialog>
</el-card> </el-card>
<selectSpec ref="selectSpecRef" :specData="specifications" :products="products"
@productsData="productsData" />
<el-card class="box-card"> <el-card class="box-card">
<h3>商品参数</h3> <h3>商品参数</h3>
<el-button type="primary" @click="handleAttributeShow">添加</el-button> <el-button type="primary" @click="handleAttributeShow">添加</el-button>
...@@ -221,6 +222,7 @@ import { ElMessageBox, ElMessage, ElNotification } from "element-plus"; ...@@ -221,6 +222,7 @@ import { ElMessageBox, ElMessage, ElNotification } from "element-plus";
import richTextEditor from '@/components/richTextEditor.vue' import richTextEditor from '@/components/richTextEditor.vue'
import { listGoods } from "@/services/api/commodityManage/list"; import { listGoods } from "@/services/api/commodityManage/list";
import { getDictList, getDictItemList } from '@/services/api/market/auxiliary' import { getDictList, getDictItemList } from '@/services/api/market/auxiliary'
import selectSpec from './selectSpec.vue'
let editDrawer = ref(false) let editDrawer = ref(false)
let newKeywordVisible = ref(false); let newKeywordVisible = ref(false);
...@@ -251,17 +253,9 @@ let specVisiable = ref(false); ...@@ -251,17 +253,9 @@ let specVisiable = ref(false);
let specForm = ref({ specification: "", value: "", picUrl: "" } as any); let specForm = ref({ specification: "", value: "", picUrl: "" } as any);
let multipleSpec = ref(true); let multipleSpec = ref(true);
let specifications = ref([] as any); let specifications = ref([] as any);
let productVisiable = ref(false);
let productForm = ref({ let products = ref([]);
id: 0, let selectSpecRef = ref();
specifications: [],
price: 0.0,
number: 0,
url: "",
});
let products = ref([
{ id: 0, specifications: ["标准"], price: 0.0, number: 0, url: "" },
]);
let attributeVisiable = ref(false); let attributeVisiable = ref(false);
let attributeForm = ref({ attribute: "", value: "" } as any); let attributeForm = ref({ attribute: "", value: "" } as any);
let attributes = ref([] as any); let attributes = ref([] as any);
...@@ -295,9 +289,6 @@ let init = (id: number) => { ...@@ -295,9 +289,6 @@ let init = (id: number) => {
for (let s in res.data.parts) { for (let s in res.data.parts) {
goodsParts.value.push(res.data.parts[s].partGoodsId) goodsParts.value.push(res.data.parts[s].partGoodsId)
} }
// partsList.value = res.data.parts
console.log(res.data);
// 稍微调整一下前后端不一致 // 稍微调整一下前后端不一致
if (goods.value?.brandId === 0) { if (goods.value?.brandId === 0) {
...@@ -309,8 +300,8 @@ let init = (id: number) => { ...@@ -309,8 +300,8 @@ let init = (id: number) => {
specifications.value = res.data.specifications; specifications.value = res.data.specifications;
products.value = res.data.products; products.value = res.data.products;
attributes.value = res.data.attributes; attributes.value = res.data.attributes;
selectSpecRef.value.setAttributes(res.data.products)
categoryIds.value = res.data.categoryIds; categoryIds.value = res.data.categoryIds;
galleryFileList.value = []; galleryFileList.value = [];
for (var i = 0; i < goods.value?.gallery.length; i++) { for (var i = 0; i < goods.value?.gallery.length; i++) {
galleryFileList.value.push({ galleryFileList.value.push({
...@@ -331,9 +322,12 @@ let init = (id: number) => { ...@@ -331,9 +322,12 @@ let init = (id: number) => {
let htmlChange = (value: any) => goods.value.detail = value let htmlChange = (value: any) => goods.value.detail = value
let productsData = (data: any) => {
products.value = data
}
let handleCategoryChange = (value: any) => { let handleCategoryChange = (value: any) => {
goods.value.categoryId = value[value.length - 1]; // goods.value.categoryId = value[value.length - 1];
} }
let handleCancel = () => { let handleCancel = () => {
goods.value = { goods.value = {
...@@ -353,7 +347,7 @@ let handleCancel = () => { ...@@ -353,7 +347,7 @@ let handleCancel = () => {
keywords: undefined, keywords: undefined,
} }
specifications.value = [] specifications.value = []
products.value = [{ id: 0, specifications: ["标准"], price: 0.0, number: 0, url: "" },] products.value = []
goodsParts.value = [] goodsParts.value = []
attributes.value = [] attributes.value = []
editDrawer.value = false editDrawer.value = false
...@@ -434,19 +428,7 @@ let handleRemove = (file: any, fileList: any) => { ...@@ -434,19 +428,7 @@ let handleRemove = (file: any, fileList: any) => {
} }
} }
} }
let specChanged = (label: any) => {
if (label === false) {
specifications.value = [
{ specification: "规格", value: "标准", picUrl: "" },
];
products.value = [
{ id: 0, specifications: ["标准"], price: 0.0, number: 0, url: "" },
];
} else {
specifications.value = [];
products.value = [];
}
}
let uploadSpecPicUrl = (res: any) => { let uploadSpecPicUrl = (res: any) => {
specForm.value.picUrl = res.data.url; specForm.value.picUrl = res.data.url;
} }
...@@ -573,23 +555,7 @@ let specToProduct = () => { ...@@ -573,23 +555,7 @@ let specToProduct = () => {
products = products; products = products;
} }
let handleProductShow = (row: any) => {
productForm = Object.assign({}, row);
productVisiable.value = true;
}
let uploadProductUrl = (res: any) => {
productForm.value.url = res.data.url;
}
let handleProductEdit = () => {
for (let i = 0; i < products.value.length; i++) {
const v = products.value[i];
if (v.id === productForm.value.id) {
products.value.splice(i, 1, productForm.value);
break;
}
}
productVisiable.value = false;
}
let handleAttributeShow = () => { let handleAttributeShow = () => {
attributeForm.value = {}; attributeForm.value = {};
attributeVisiable.value = true; attributeVisiable.value = true;
......
...@@ -49,6 +49,10 @@ let props = defineProps({ ...@@ -49,6 +49,10 @@ let props = defineProps({
specData: { specData: {
type: Object, type: Object,
default: [] default: []
},
products: {
type: Object,
default: []
} }
}) })
...@@ -66,6 +70,7 @@ let data = computed(() => { ...@@ -66,6 +70,7 @@ let data = computed(() => {
let specList = ref([] as any) let specList = ref([] as any)
let attributes = ref([] as any) let attributes = ref([] as any)
var specData = ref([] as any) //符合条件的数据 var specData = ref([] as any) //符合条件的数据
watch(specData.value, (newVlaue: any) => { watch(specData.value, (newVlaue: any) => {
...@@ -75,8 +80,13 @@ watch(specData.value, (newVlaue: any) => { ...@@ -75,8 +80,13 @@ watch(specData.value, (newVlaue: any) => {
} }
}) })
let setAttributes = (data: any) => {
if(data) attributes.value = data
}
// 每组只可以取一个
let radioChange = (e: any, item: any) => { let radioChange = (e: any, item: any) => {
console.log(e, item); // console.log(e, item);
item.values.forEach((res: any) => { item.values.forEach((res: any) => {
if (specList.value.indexOf(res.value) != -1) { if (specList.value.indexOf(res.value) != -1) {
let s = specList.value.indexOf(res.value) let s = specList.value.indexOf(res.value)
...@@ -86,6 +96,8 @@ let radioChange = (e: any, item: any) => { ...@@ -86,6 +96,8 @@ let radioChange = (e: any, item: any) => {
} }
}) })
if (specList.value.indexOf(e) == -1) specList.value.push(e) if (specList.value.indexOf(e) == -1) specList.value.push(e)
console.log(specList.value, 'specList');
} }
let clickAdd = () => { let clickAdd = () => {
...@@ -173,6 +185,10 @@ let group = (data: any) => { ...@@ -173,6 +185,10 @@ let group = (data: any) => {
if (test1.length === 0) return poty.value = [...specData.value] if (test1.length === 0) return poty.value = [...specData.value]
else group(test1) else group(test1)
} }
defineExpose({
setAttributes
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -77,8 +77,12 @@ ...@@ -77,8 +77,12 @@
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader :options="categoryList" expand-trigger="hover" clearable <!-- <el-cascader :options="categoryList" expand-trigger="hover" clearable
@change="handleCategoryChange" /> @change="handleCategoryChange" /> -->
<el-select v-model="goods.categoryId" placeholder="请选择" @change="handleCategoryChange">
<el-option v-for="item in categoryList" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
...@@ -164,7 +168,7 @@ ...@@ -164,7 +168,7 @@
</el-dialog> </el-dialog>
</el-card> </el-card>
<selectSpec :specData="specifications" @productsData="productsData"/> <selectSpec :specData="specifications" @productsData="productsData" />
<el-card class="box-card"> <el-card class="box-card">
<h3>商品参数</h3> <h3>商品参数</h3>
...@@ -237,18 +241,12 @@ let goods = ref({ ...@@ -237,18 +241,12 @@ let goods = ref({
categoryId: undefined, categoryId: undefined,
keywords: undefined, keywords: undefined,
}); });
let cateId = ref('') //分类值
let goodsParts = ref() let goodsParts = ref()
let specVisiable = ref(false); let specVisiable = ref(false);
let specForm = ref({ specification: "", value: "", picUrl: "" }); let specForm = ref({ specification: "", value: "", picUrl: "" });
let specifications = ref([] as any); let specifications = ref([] as any);
let productVisiable = ref(false);
let productForm = ref({
id: 0,
specifications: [],
price: 0.0,
number: 0,
url: "",
});
let headers = ref({ 'Authorization': sessionStorage.getItem("token") }) let headers = ref({ 'Authorization': sessionStorage.getItem("token") })
let products = ref([]); let products = ref([]);
...@@ -289,7 +287,8 @@ initList() ...@@ -289,7 +287,8 @@ initList()
let htmlChange = (value: any) => goods.value.detail = value let htmlChange = (value: any) => goods.value.detail = value
let handleCategoryChange = (value: any) => { let handleCategoryChange = (value: any) => {
goods.value.categoryId = value[value.length - 1]; // console.log(goods.value.categoryId);
// goods.value.categoryId = value[value.length - 1];
} }
let handleCancel = () => { let handleCancel = () => {
goods.value = { goods.value = {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论