提交 16d5dcb4 authored 作者: 刘旭's avatar 刘旭

修改商品规格

上级 53a25e71
......@@ -37,8 +37,8 @@
<el-form-item label="商品图片">
<el-upload :action="uploadPath" :show-file-list="false" :headers="headers"
:on-success="uploadPicUrl" class="avatar-uploader" accept=".jpg,.jpeg,.png,.gif">
<img v-if="goods.picUrl" :src="goods.picUrl" class="avatar" />
<!-- <img v-if="goods.picUrl" :src="'http://192.168.0.23' + goods.picUrl" class="avatar" /> -->
<!-- <img v-if="goods.picUrl" :src="goods.picUrl" class="avatar" /> -->
<img v-if="goods.picUrl" :src="'http://192.168.0.23' + goods.picUrl" class="avatar" />
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
......@@ -105,7 +105,7 @@
<el-col :span="10">
<el-radio-group v-model="multipleSpec" @change="specChanged">
<!-- <el-radio-button :label="false">默认标准规格</el-radio-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">
......@@ -115,14 +115,14 @@
<el-table :data="specifications">
<el-table-column property="specification" label="规格名" />
<el-table-column property="value" label="规格值">
<el-table-column property="value" label="规格值" align="center">
<template #default="scope">
<el-tag type="primary">
{{ scope.row.value }}
</el-tag>
</template>
</el-table-column>
<el-table-column property="picUrl" label="规格图片">
<el-table-column property="picUrl" label="规格图片" align="center">
<template #default="scope">
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" width="40" />
</template>
......@@ -140,16 +140,28 @@
<el-form ref="specRef" :rules="rules" :model="specForm" status-icon label-position="left"
label-width="100px" style="width: 400px; margin-left: 50px">
<el-form-item label="规格名" prop="specification">
<el-input v-model="specForm.specification" />
<el-select v-model="specForm.specification" class="m-2" placeholder="请选择规格名"
@change="dictChange">
<el-option v-for="item in dictList" :key="item.id" :label="item.dictName"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="规格值" prop="value">
<el-input v-model="specForm.value" />
<el-select v-model="specForm.value" multiple collapse-tags collapse-tags-tooltip
placeholder="请选择规格值" style="width: 240px" @change="dictItemChange">
<el-option v-for="item in dictItemList" :key="item.id" :label="item.itemText"
:value="item.itemText" />
</el-select>
</el-form-item>
<el-form-item label="规格图片" prop="picUrl">
<el-upload :action="uploadPath" :show-file-list="false" :headers="headers"
:on-success="uploadSpecPicUrl" class="avatar-uploader" accept=".jpg,.jpeg,.png,.gif">
<img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar" />
<i v-else class="el-icon-plus avatar-uploader-icon" />
<div v-if="specForm.picUrl">
<img :src="'http://192.168.0.23' + specForm.picUrl" class="avatar" />
</div>
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
</el-upload>
</el-form-item>
</el-form>
......@@ -206,6 +218,7 @@ import { uploadPath } from "@/services/api/storage";
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'
let editDrawer = ref(false)
let newKeywordVisible = ref(false);
......@@ -234,7 +247,7 @@ let goods = ref({
let goodsParts = ref()
let specVisiable = ref(false);
let specForm = ref({ specification: "", value: "", picUrl: "" } as any);
let multipleSpec = ref(false);
let multipleSpec = ref(true);
let specifications = ref([] as any);
let productVisiable = ref(false);
let productForm = ref({
......@@ -429,33 +442,52 @@ let specChanged = (label: any) => {
let uploadSpecPicUrl = (res: any) => {
specForm.value.picUrl = res.data.url;
}
let dictList = ref()
let handleSpecificationShow = () => {
getDictList().then((res: any) => {
if (res.code === 200) {
dictList.value = res.data.records
specForm.value = { specification: "", value: "", picUrl: "" };
specVisiable.value = true;
}
})
}
let handleSpecificationAdd = () => {
let index = specifications.value.length - 1;
for (let i = 0; i < specifications.value.length; i++) {
const v = specifications.value[i];
if (v.specification === specForm.value.specification) {
if (v.value === specForm.value) {
ElMessage({
type: "warning",
message: "已经存在规格值:" + v.value,
});
specForm.value = {};
specVisiable.value = false;
return;
} else {
index = i;
let dictItemList = ref()
let dictName = ref()
let dictValue = ref()
let dictChange = (id: any) => {
getDictItemList({ dictId: id }).then((res: any) => {
if (res.code === 200) {
dictItemList.value = res.data.records
for (let s of dictList.value) {
if (s.id === id) dictName.value = s.dictName
}
}
})
}
let dictItemChange = (val: []) => {
dictValue.value = val
}
let handleSpecificationAdd = () => {
if (!dictName.value) return ElMessage({
type: 'warning',
message: '请选择规格名'
})
if (dictValue.value) {
for (let s of dictValue.value) {
specifications.value.push({
specification: dictName.value,
value: s
})
}
specifications.value.splice(index + 1, 0, specForm);
specVisiable.value = false;
specToProduct();
} else {
ElMessage({
type: 'warning',
message: '请选择规格值'
})
}
}
let handleSpecificationDelete = (row: any) => {
const index = specifications.value.indexOf(row);
......
......@@ -113,12 +113,12 @@
</el-row>
<el-table :data="specifications">
<el-table-column property="specification" label="规格名" />
<el-table-column property="value" label="规格值">
<el-table-column property="specification" label="规格名" align="left" />
<el-table-column property="value" label="规格值" align="center">
<template #default="scope">
<!-- <el-tag type="primary"> -->
<el-tag type="primary">
{{ scope.row.value }}
<!-- </el-tag> -->
</el-tag>
</template>
</el-table-column>
<el-table-column property="picUrl" label="规格图片">
......@@ -139,20 +139,28 @@
<el-form ref="specRef" :rules="rules" :model="specForm" status-icon label-position="left"
label-width="100px" style="width: 400px; margin-left: 50px">
<el-form-item label="规格名" prop="specification">
<el-input v-model="specForm.specification" />
<el-select v-model="specForm.specification" class="m-2" placeholder="请选择规格名"
@change="dictChange">
<el-option v-for="item in dictList" :key="item.id" :label="item.dictName"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="规格值" prop="value">
<el-input v-model="specForm.value" />
<el-select v-model="specForm.value" multiple collapse-tags collapse-tags-tooltip
placeholder="请选择规格值" style="width: 240px" @change="dictItemChange">
<el-option v-for="item in dictItemList" :key="item.id" :label="item.itemText"
:value="item.itemText" />
</el-select>
</el-form-item>
<el-form-item label="规格图片" prop="picUrl">
<el-upload :action="uploadPath" :show-file-list="false" :headers="headers"
:on-success="uploadSpecPicUrl" class="avatar-uploader" accept=".jpg,.jpeg,.png,.gif">
<div v-if="specForm.picUrl">
<!-- <img v-if="specForm.picUrl.split('http').length > 1" :src="specForm.picUrl"
class="avatar" /> -->
<img :src="'http://192.168.0.23' + specForm.picUrl" class="avatar" />
</div>
<i v-else class="el-icon-plus avatar-uploader-icon" />
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
</el-upload>
</el-form-item>
</el-form>
......@@ -209,6 +217,7 @@ import { uploadPath } from "@/services/api/storage";
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'
let shelvesDrawer = ref(false)
let newKeywordVisible = ref(false);
......@@ -402,44 +411,62 @@ let specChanged = (label: any) => {
}
}
let uploadSpecPicUrl = (res: any) => {
specForm.value.picUrl = res.data.url;
console.log('上传成功');
// specForm.value.picUrl = res.data.url;
}
let dictList = ref()
let handleSpecificationShow = () => {
getDictList().then((res: any) => {
if (res.code === 200) {
dictList.value = res.data.records
specForm.value = { specification: "", value: "", picUrl: "" };
specVisiable.value = true;
}
})
}
let handleSpecificationAdd = () => {
console.log(specifications.value);
console.log(specForm.value);
let index = specifications.value.length - 1;
for (let i = 0; i < specifications.value.length; i++) {
const v = specifications.value[i];
if (v.specification === specForm.value.specification) {
if (v.value === specForm.value) {
ElMessage({
type: "warning",
message: "已经存在规格值:" + v.value,
});
specForm.value = { specification: "", value: "", picUrl: "" };
specVisiable.value = false;
return;
} else {
index = i;
}
}
if (!dictName.value) return ElMessage({
type: 'warning',
message: '请选择规格名'
})
if (dictValue.value) {
for (let s of dictValue.value) {
specifications.value.push({
specification: dictName.value,
value: s
})
}
specifications.value.splice(index + 1, 0, specForm.value);
specVisiable.value = false;
specToProduct();
} else {
ElMessage({
type: 'warning',
message: '请选择规格值'
})
}
}
let handleSpecificationDelete = (row: any) => {
const index = specifications.value.indexOf(row);
specifications.value.splice(index, 1);
specToProduct();
}
let dictItemList = ref()
let dictName = ref()
let dictValue = ref()
let dictChange = (id: any) => {
getDictItemList({ dictId: id }).then((res: any) => {
if (res.code === 200) {
dictItemList.value = res.data.records
for (let s of dictList.value) {
if (s.id === id) dictName.value = s.dictName
}
}
})
}
let dictItemChange = (val: []) => {
dictValue.value = val
}
let specToProduct = () => {
if (specifications.value.length === 0) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论