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

补全修改

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