Compare commits
No commits in common. 'main' and 'liran_branch' have entirely different histories.
main
...
liran_bran
@ -1,3 +0,0 @@
|
||||
export { default as Navbar } from './Navbar'
|
||||
export { default as Sidebar } from './Sidebar'
|
||||
export { default as AppMain } from './AppMain'
|
||||
@ -1,41 +0,0 @@
|
||||
import store from '@/store'
|
||||
|
||||
const { body } = document
|
||||
const WIDTH = 1024
|
||||
const RATIO = 3
|
||||
|
||||
export default {
|
||||
watch: {
|
||||
$route(route) {
|
||||
if (this.device === 'mobile' && this.sidebar.opened) {
|
||||
store.dispatch('CloseSideBar', { withoutAnimation: false })
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
window.addEventListener('resize', this.resizeHandler)
|
||||
},
|
||||
mounted() {
|
||||
const isMobile = this.isMobile()
|
||||
if (isMobile) {
|
||||
store.dispatch('ToggleDevice', 'mobile')
|
||||
store.dispatch('CloseSideBar', { withoutAnimation: true })
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isMobile() {
|
||||
const rect = body.getBoundingClientRect()
|
||||
return rect.width - RATIO < WIDTH
|
||||
},
|
||||
resizeHandler() {
|
||||
if (!document.hidden) {
|
||||
const isMobile = this.isMobile()
|
||||
store.dispatch('ToggleDevice', isMobile ? 'mobile' : 'desktop')
|
||||
|
||||
if (isMobile) {
|
||||
store.dispatch('CloseSideBar', { withoutAnimation: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,185 +0,0 @@
|
||||
<template>
|
||||
<el-card class="form-container" shadow="never">
|
||||
<el-form :model="productAttr" :rules="rules" ref="productAttrFrom" label-width="150px">
|
||||
<el-form-item label="属性名称:" prop="name">
|
||||
<el-input v-model="productAttr.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品类型:">
|
||||
<el-select v-model="productAttr.productAttributeCategoryId" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in productAttrCateList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类筛选样式:">
|
||||
<el-radio-group v-model="productAttr.filterType">
|
||||
<el-radio :label="0">普通</el-radio>
|
||||
<el-radio :label="1">颜色</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="能否进行检索:">
|
||||
<el-radio-group v-model="productAttr.searchType">
|
||||
<el-radio :label="0">不需要检索</el-radio>
|
||||
<el-radio :label="1">关键字检索</el-radio>
|
||||
<el-radio :label="2">范围检索</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品属性关联:">
|
||||
<el-radio-group v-model="productAttr.relatedStatus">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="属性是否可选:">
|
||||
<el-radio-group v-model="productAttr.selectType">
|
||||
<el-radio :label="0">唯一</el-radio>
|
||||
<el-radio :label="1">单选</el-radio>
|
||||
<el-radio :label="2">复选</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="属性值的录入方式:">
|
||||
<el-radio-group v-model="productAttr.inputType">
|
||||
<el-radio :label="0">手工录入</el-radio>
|
||||
<el-radio :label="1">从下面列表中选择</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="属性值可选值列表:">
|
||||
<el-input :autosize="true" type="textarea" v-model="inputListFormat"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否支持手动新增:">
|
||||
<el-radio-group v-model="productAttr.handAddStatus">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序属性:">
|
||||
<el-input v-model="productAttr.sort"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit('productAttrFrom')">提交</el-button>
|
||||
<el-button v-if="!isEdit" @click="resetForm('productAttrFrom')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchList} from '@/api/productAttrCate'
|
||||
import {createProductAttr,getProductAttr,updateProductAttr} from '@/api/productAttr'
|
||||
|
||||
const defaultProductAttr = {
|
||||
filterType: 0,
|
||||
handAddStatus: 0,
|
||||
inputList: '',
|
||||
inputType: 0,
|
||||
name: '',
|
||||
productAttributeCategoryId: 0,
|
||||
relatedStatus: 0,
|
||||
searchType: 0,
|
||||
selectType: 0,
|
||||
sort: 0,
|
||||
type: 0
|
||||
};
|
||||
export default {
|
||||
name: "ProductAttrDetail",
|
||||
props: {
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
productAttr: Object.assign({}, defaultProductAttr),
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: '请输入属性名称', trigger: 'blur'},
|
||||
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
|
||||
]
|
||||
},
|
||||
productAttrCateList: null,
|
||||
inputListFormat:null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.isEdit){
|
||||
getProductAttr(this.$route.query.id).then(response => {
|
||||
this.productAttr = response.data;
|
||||
this.inputListFormat = this.productAttr.inputList.replace(/,/g,'\n');
|
||||
});
|
||||
}else{
|
||||
this.resetProductAttr();
|
||||
}
|
||||
this.getCateList();
|
||||
},
|
||||
watch:{
|
||||
inputListFormat: function (newValue, oldValue) {
|
||||
newValue = newValue.replace(/\n/g,',');
|
||||
this.productAttr.inputList = newValue;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCateList() {
|
||||
let listQuery = {pageNum: 1, pageSize: 100};
|
||||
fetchList(listQuery).then(response => {
|
||||
this.productAttrCateList = response.data.list;
|
||||
});
|
||||
},
|
||||
resetProductAttr() {
|
||||
this.productAttr = Object.assign({}, defaultProductAttr);
|
||||
this.productAttr.productAttributeCategoryId = Number(this.$route.query.cid);
|
||||
this.productAttr.type = Number(this.$route.query.type);
|
||||
},
|
||||
onSubmit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$confirm('是否提交数据', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if(this.isEdit){
|
||||
updateProductAttr(this.$route.query.id,this.productAttr).then(response=>{
|
||||
this.$message({
|
||||
message: '修改成功',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.$router.back();
|
||||
});
|
||||
}else{
|
||||
createProductAttr(this.productAttr).then(response=>{
|
||||
this.$message({
|
||||
message: '提交成功',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.resetForm('productAttrFrom');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
this.$message({
|
||||
message: '验证失败',
|
||||
type: 'error',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
this.resetProductAttr();
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -1,264 +0,0 @@
|
||||
<template>
|
||||
<el-card class="form-container" shadow="never">
|
||||
<el-form :model="productCate"
|
||||
:rules="rules"
|
||||
ref="productCateFrom"
|
||||
label-width="150px">
|
||||
<el-form-item label="分类名称:" prop="name">
|
||||
<el-input v-model="productCate.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="上级分类:">
|
||||
<el-select v-model="productCate.parentId"
|
||||
placeholder="请选择分类">
|
||||
<el-option
|
||||
v-for="item in selectProductCateList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量单位:">
|
||||
<el-input v-model="productCate.productUnit"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序:">
|
||||
<el-input v-model="productCate.sort"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否显示:">
|
||||
<el-radio-group v-model="productCate.showStatus">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否显示在导航栏:">
|
||||
<el-radio-group v-model="productCate.navStatus">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类图标:">
|
||||
<single-upload v-model="productCate.icon"></single-upload>
|
||||
</el-form-item>
|
||||
<el-form-item v-for="(filterProductAttr, index) in filterProductAttrList"
|
||||
:label="index | filterLabelFilter"
|
||||
:key="filterProductAttr.key"
|
||||
>
|
||||
<el-cascader
|
||||
clearable
|
||||
v-model="filterProductAttr.value"
|
||||
:options="filterAttrs">
|
||||
</el-cascader>
|
||||
<el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="small" type="primary" @click="handleAddFilterAttr()">新增</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键词:">
|
||||
<el-input v-model="productCate.keywords"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类描述:">
|
||||
<el-input type="textarea" :autosize="true" v-model="productCate.description"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit('productCateFrom')">提交</el-button>
|
||||
<el-button v-if="!isEdit" @click="resetForm('productCateFrom')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate';
|
||||
import {fetchListWithAttr} from '@/api/productAttrCate';
|
||||
import {getProductAttrInfo} from '@/api/productAttr';
|
||||
import SingleUpload from '@/components/Upload/singleUpload';
|
||||
|
||||
const defaultProductCate = {
|
||||
description: '',
|
||||
icon: '',
|
||||
keywords: '',
|
||||
name: '',
|
||||
navStatus: 0,
|
||||
parentId: 0,
|
||||
productUnit: '',
|
||||
showStatus: 0,
|
||||
sort: 0,
|
||||
productAttributeIdList: []
|
||||
};
|
||||
export default {
|
||||
name: "ProductCateDetail",
|
||||
components: {SingleUpload},
|
||||
props: {
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
productCate: Object.assign({}, defaultProductCate),
|
||||
selectProductCateList: [],
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: '请输入品牌名称', trigger: 'blur'},
|
||||
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
|
||||
]
|
||||
},
|
||||
filterAttrs: [],
|
||||
filterProductAttrList: [{
|
||||
value: []
|
||||
}]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.isEdit) {
|
||||
getProductCate(this.$route.query.id).then(response => {
|
||||
this.productCate = response.data;
|
||||
});
|
||||
getProductAttrInfo(this.$route.query.id).then(response => {
|
||||
if (response.data != null && response.data.length > 0) {
|
||||
this.filterProductAttrList = [];
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
this.filterProductAttrList.push({
|
||||
key: Date.now() + i,
|
||||
value: [response.data[i].attributeCategoryId, response.data[i].attributeId]
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.productCate = Object.assign({}, defaultProductCate);
|
||||
}
|
||||
this.getSelectProductCateList();
|
||||
this.getProductAttrCateList();
|
||||
},
|
||||
methods: {
|
||||
getSelectProductCateList() {
|
||||
fetchList(0, {pageSize: 100, pageNum: 1}).then(response => {
|
||||
this.selectProductCateList = response.data.list;
|
||||
this.selectProductCateList.unshift({id: 0, name: '无上级分类'});
|
||||
});
|
||||
},
|
||||
getProductAttrCateList() {
|
||||
fetchListWithAttr().then(response => {
|
||||
let list = response.data;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let productAttrCate = list[i];
|
||||
let children = [];
|
||||
if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList.length > 0) {
|
||||
for (let j = 0; j < productAttrCate.productAttributeList.length; j++) {
|
||||
children.push({
|
||||
label: productAttrCate.productAttributeList[j].name,
|
||||
value: productAttrCate.productAttributeList[j].id
|
||||
})
|
||||
}
|
||||
}
|
||||
this.filterAttrs.push({label: productAttrCate.name, value: productAttrCate.id, children: children});
|
||||
}
|
||||
});
|
||||
},
|
||||
getProductAttributeIdList() {
|
||||
//获取选中的筛选商品属性
|
||||
let productAttributeIdList = [];
|
||||
for (let i = 0; i < this.filterProductAttrList.length; i++) {
|
||||
let item = this.filterProductAttrList[i];
|
||||
if (item.value !== null && item.value.length === 2) {
|
||||
productAttributeIdList.push(item.value[1]);
|
||||
}
|
||||
}
|
||||
return productAttributeIdList;
|
||||
},
|
||||
onSubmit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$confirm('是否提交数据', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if (this.isEdit) {
|
||||
this.productCate.productAttributeIdList = this.getProductAttributeIdList();
|
||||
updateProductCate(this.$route.query.id, this.productCate).then(response => {
|
||||
this.$message({
|
||||
message: '修改成功',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.$router.back();
|
||||
});
|
||||
} else {
|
||||
this.productCate.productAttributeIdList = this.getProductAttributeIdList();
|
||||
createProductCate(this.productCate).then(response => {
|
||||
this.$refs[formName].resetFields();
|
||||
this.resetForm(formName);
|
||||
this.$message({
|
||||
message: '提交成功',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
this.$message({
|
||||
message: '验证失败',
|
||||
type: 'error',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
this.productCate = Object.assign({}, defaultProductCate);
|
||||
this.getSelectProductCateList();
|
||||
this.filterProductAttrList = [{
|
||||
value: []
|
||||
}];
|
||||
},
|
||||
removeFilterAttr(productAttributeId) {
|
||||
if (this.filterProductAttrList.length === 1) {
|
||||
this.$message({
|
||||
message: '至少要留一个',
|
||||
type: 'warning',
|
||||
duration: 1000
|
||||
});
|
||||
return;
|
||||
}
|
||||
var index = this.filterProductAttrList.indexOf(productAttributeId);
|
||||
if (index !== -1) {
|
||||
this.filterProductAttrList.splice(index, 1)
|
||||
}
|
||||
},
|
||||
handleAddFilterAttr() {
|
||||
if (this.filterProductAttrList.length === 3) {
|
||||
this.$message({
|
||||
message: '最多添加三个',
|
||||
type: 'warning',
|
||||
duration: 1000
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.filterProductAttrList.push({
|
||||
value: null,
|
||||
key: Date.now()
|
||||
});
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
filterLabelFilter(index) {
|
||||
if (index === 0) {
|
||||
return '筛选属性:';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue