Browse Source

2023-3-15

master
guoxing 2 years ago
parent
commit
3bdf7cff71
  1. 152
      mallplusui-web-admin/src/views/build/community/components/CommunityDetail.vue
  2. 2
      mallplusui-web-admin/src/views/build/community/index.vue
  3. 520
      mallplusui-web-admin/src/views/pms/productCate/components/ProductCateDetail.vue
  4. 18
      mallplusui-web-admin/src/views/pms/productCate/index.vue

152
mallplusui-web-admin/src/views/build/community/components/CommunityDetail.vue

@ -2,15 +2,15 @@
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<el-form :model="community" :rules="rules" ref="communityFrom" label-width="130px"> <el-form :model="community" :rules="rules" ref="communityFrom" label-width="130px">
<el-form-item label="社区名称:" > <el-form-item label="社区名称:">
<span>{{name}}</span> <span>{{name}}</span>
</el-form-item> </el-form-item>
<el-form-item label="取货点名称:" prop="name"> <el-form-item label="取货点名称:" prop="name">
<el-input v-model="community.name"></el-input> <el-input v-model="community.name"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="取货点电话:" prop="counts"> <el-form-item label="取货点电话:" prop="phone">
<el-input v-model="community.counts"></el-input> <el-input v-model="community.phone" maxlength="11"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="取货点地址:" prop="details"> <el-form-item label="取货点地址:" prop="details">
<el-input v-model="community.details"></el-input> <el-input v-model="community.details"></el-input>
@ -61,12 +61,12 @@
</el-card> </el-card>
</template> </template>
<script> <script>
import BaiduMap from 'vue-baidu-map/components/map/Map.vue' // import BaiduMap from 'vue-baidu-map/components/map/Map.vue'
import BmLocalSearch from 'vue-baidu-map/components/search/LocalSearch'; // import BmLocalSearch from 'vue-baidu-map/components/search/LocalSearch';
import BmCityList from 'vue-baidu-map/components/controls/CityList'; // import BmCityList from 'vue-baidu-map/components/controls/CityList';
import BmCopyright from 'vue-baidu-map/components/controls/Copyright'; // import BmCopyright from 'vue-baidu-map/components/controls/Copyright';
import BmView from 'vue-baidu-map/components/map/MapView'; // import BmView from 'vue-baidu-map/components/map/MapView';
import BmMarker from 'vue-baidu-map/components/overlays/Marker' // import BmMarker from 'vue-baidu-map/components/overlays/Marker'
import { import {
createCommunity, createCommunity,
getCommunity, getCommunity,
@ -81,15 +81,15 @@
}; };
export default { export default {
name: 'CommunityDetail', name: 'CommunityDetail',
components: { // components: {
SingleUpload, // SingleUpload,
BaiduMap, // BaiduMap,
BmLocalSearch, // BmLocalSearch,
BmCityList, // BmCityList,
BmView, // BmView,
BmCopyright, // BmCopyright,
BmMarker // BmMarker
}, // },
props: { props: {
isEdit: { isEdit: {
type: Boolean, type: Boolean,
@ -97,6 +97,21 @@
} }
}, },
data() { data() {
var checkSubmit = (rule, value, callback) => {
const Submit =
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
if (value) {
if (!Submit.test(value)) {
callback(new Error('手机号格式不正确'))
}
callback()
}
callback()
// if (Submit.test(value)) {
// return callback()
// }
// callback(new Error(''))
}
return { return {
name: "", name: "",
community: Object.assign({}, defaultCommunity), community: Object.assign({}, defaultCommunity),
@ -112,15 +127,20 @@
message: '长度在 2 到 140 个字符', message: '长度在 2 到 140 个字符',
trigger: 'blur' trigger: 'blur'
} }
] ],
phone: [{
required: true,
validator: checkSubmit,
trigger: 'blur'
}]
}, },
location: '北京', // location: '',
keyword: '百度', // keyword: '',
center: { // center: {
lng: 116.404, // lng: 116.404,
lat: 39.915 // lat: 39.915
}, // },
zoom: 15 // zoom: 15
} }
}, },
mounted() { mounted() {
@ -129,21 +149,21 @@
// window.addEventListener('mousewheel',this.handleScroll,false) // window.addEventListener('mousewheel',this.handleScroll,false)
}, },
created() { created() {
console.log("query>>>",this.$route.query) console.log("query>>>", this.$route.query)
this.name = this.$route.query.cname this.name = this.$route.query.cname
if (this.isEdit) { if (this.isEdit) {
getCommunity(this.$route.query.id).then(response => { getCommunity(this.$route.query.id).then(response => {
this.community = response.data; this.community = response.data;
if (this.community.latitude) { // if (this.community.latitude) {
this.center.lat = this.community.latitude; // this.center.lat = this.community.latitude;
} // }
if (this.community.longitude) { // if (this.community.longitude) {
this.center.lng = this.community.longitude; // this.center.lng = this.community.longitude;
} // }
if (this.community.city) { // if (this.community.city) {
this.location = this.community.city; // this.location = this.community.city;
} // }
}); });
} else { } else {
this.community = Object.assign({}, defaultCommunity); this.community = Object.assign({}, defaultCommunity);
@ -151,24 +171,42 @@
}, },
methods: { methods: {
changeAfters(e) { // changeAfters(e) {
console.log('123') // console.log('123')
console.log(e) // console.log(e)
}, // },
handleScroll(e) { // handleScroll(e) {
//body100%hover // //body100%hover
document.body.scrollTop = 0 // document.body.scrollTop = 0
document.documentElement.scrollTop = 0 // document.documentElement.scrollTop = 0
}, // },
syncCenterAndZoom(e) { // syncCenterAndZoom(e) {
const { // const {
lng, // lng,
lat // lat
} = e.target.getCenter() // } = e.target.getCenter()
this.center.lng = lng // this.center.lng = lng
this.center.lat = lat // this.center.lat = lat
this.zoom = e.target.getZoom() // this.zoom = e.target.getZoom()
// },
UpNumber(val, limit = 2) {
val = val.replace(/[^\d]/g, '') //
val = val.replace(/^00/, '0.') // 0
val = val.replace(/^\./g, '0.') // 0.
val = val.replace(/\.{2,}/g, '.') //
val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); //
/^0\d+/.test(val) ? val = val.slice(1) : '' // 0
const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
const reg = new RegExp(str)
if (limit === 0) {
//
val = val.replace(reg, '$1')
} else {
//
val = val.replace(reg, '$1.$2')
}
return val
}, },
onSubmit(formName) { onSubmit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
@ -179,8 +217,8 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.community.companyId = this.$route.query.cid this.community.companyId = this.$route.query.cid
this.community.latitude = this.center.lat; // this.community.latitude = this.center.lat;
this.community.longitude = this.center.lng; // this.community.longitude = this.center.lng;
if (this.isEdit) { if (this.isEdit) {
updateCommunity(this.$route.query.id, this.community).then(response => { updateCommunity(this.$route.query.id, this.community).then(response => {
if (response.code == 200) { if (response.code == 200) {
@ -190,7 +228,7 @@
type: 'success', type: 'success',
duration: 1000 duration: 1000
}); });
this.$router.back(); this.$router.go(-1);
} else { } else {
this.$message({ this.$message({
message: response.msg, message: response.msg,
@ -210,7 +248,7 @@
type: 'success', type: 'success',
duration: 1000 duration: 1000
}); });
this.$router.back(); this.$router.go(-1);
} else { } else {
this.$message({ this.$message({
message: response.msg, message: response.msg,

2
mallplusui-web-admin/src/views/build/community/index.vue

@ -55,7 +55,7 @@
<template slot-scope="scope">{{scope.row.phone}}</template> <template slot-scope="scope">{{scope.row.phone}}</template>
</el-table-column> </el-table-column>
<el-table-column label="取货点地址" align="center"> <el-table-column label="取货点地址" align="center">
<template slot-scope="scope">{{scope.row.address}}</template> <template slot-scope="scope">{{scope.row.details}}</template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间" width="200" align="center"> <el-table-column label="创建时间" width="200" align="center">

520
mallplusui-web-admin/src/views/pms/productCate/components/ProductCateDetail.vue

@ -1,269 +1,287 @@
<template> <template>
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<el-form :model="productCate" <el-form :model="productCate" :rules="rules" ref="productCateFrom" label-width="150px">
:rules="rules" <el-form-item label="分类名称:" prop="name">
ref="productCateFrom" <el-input v-model="productCate.name"></el-input>
label-width="150px"> </el-form-item>
<el-form-item label="分类名称:" prop="name"> <el-form-item label="上级分类:">
<el-input v-model="productCate.name"></el-input> <el-select v-model="productCate.parentId" placeholder="请选择分类">
</el-form-item> <el-option v-for="item in selectProductCateList" :key="item.id" :label="item.name" :value="item.id">
<el-form-item label="上级分类:"> </el-option>
<el-select v-model="productCate.parentId" </el-select>
placeholder="请选择分类"> </el-form-item>
<el-option <el-form-item label="数量单位:">
v-for="item in selectProductCateList" <el-input v-model="productCate.productUnit"></el-input>
:key="item.id" </el-form-item>
:label="item.name" <el-form-item label="排序:">
:value="item.id"> <el-input v-model="productCate.sort"></el-input>
</el-option> </el-form-item>
</el-select> <el-form-item label="是否显示:">
</el-form-item> <el-radio-group v-model="productCate.showStatus">
<el-form-item label="数量单位:"> <el-radio :label="1"></el-radio>
<el-input v-model="productCate.productUnit"></el-input> <el-radio :label="0"></el-radio>
</el-form-item> </el-radio-group>
<el-form-item label="排序:"> </el-form-item>
<el-input v-model="productCate.sort"></el-input> <!-- <el-form-item label="是否显示在导航栏:">
</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-group v-model="productCate.navStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item> -->
<!-- <el-form-item label="是否显示在首页:"> <!-- <el-form-item label="是否显示在首页:">
<el-radio-group v-model="productCate.indexStatus"> <el-radio-group v-model="productCate.indexStatus">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> --> </el-form-item> -->
<el-form-item label="分类图标:"> <el-form-item label="分类图标:">
<single-upload v-model="productCate.icon"></single-upload> <single-upload v-model="productCate.icon"></single-upload>
</el-form-item> </el-form-item>
<el-form-item v-for="(filterProductAttr, index) in filterProductAttrList" <el-form-item v-for="(filterProductAttr, index) in filterProductAttrList" :label="index | filterLabelFilter"
:label="index | filterLabelFilter" :key="filterProductAttr.key">
:key="filterProductAttr.key" <el-cascader clearable v-model="filterProductAttr.value" :options="filterAttrs">
> </el-cascader>
<el-cascader <el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button>
clearable </el-form-item>
v-model="filterProductAttr.value" <el-form-item>
:options="filterAttrs"> <el-button size="small" type="primary" @click="handleAddFilterAttr()">新增</el-button>
</el-cascader> </el-form-item>
<el-button style="margin-left: 20px" @click.prevent="removeFilterAttr(filterProductAttr)">删除</el-button> <el-form-item label="关键词:">
</el-form-item> <el-input v-model="productCate.keywords"></el-input>
<el-form-item> </el-form-item>
<el-button size="small" type="primary" @click="handleAddFilterAttr()">新增</el-button> <el-form-item label="分类描述:">
</el-form-item> <el-input type="textarea" :autosize="true" v-model="productCate.description"></el-input>
<el-form-item label="关键词:"> </el-form-item>
<el-input v-model="productCate.keywords"></el-input> <el-form-item>
</el-form-item> <el-button type="primary" @click="onSubmit('productCateFrom')">提交</el-button>
<el-form-item label="分类描述:"> <el-button v-if="!isEdit" @click="resetForm('productCateFrom')">重置</el-button>
<el-input type="textarea" :autosize="true" v-model="productCate.description"></el-input> </el-form-item>
</el-form-item> </el-form>
<el-form-item> </el-card>
<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> </template>
<script> <script>
import {fetchList, createProductCate, updateProductCate, getProductCate} from '@/api/productCate'; import {
import {fetchListWithAttr} from '@/api/productAttrCate'; fetchList,
import {getProductAttrInfo} from '@/api/productAttr'; createProductCate,
import SingleUpload from '@/components/Upload/singleUpload'; updateProductCate,
getProductCate
} from '@/api/productCate';
import {
fetchListWithAttr
} from '@/api/productAttrCate';
import {
getProductAttrInfo
} from '@/api/productAttr';
import SingleUpload from '@/components/Upload/singleUpload';
const defaultProductCate = { const defaultProductCate = {
description: '', description: '',
icon: '', icon: '',
keywords: '', keywords: '',
name: '', name: '',
navStatus: 0, navStatus: 1,
parentId: 0, parentId: 0,
productUnit: '', productUnit: '',
showStatus: 1, showStatus: 0,
indexStatus:1, indexStatus: 1,
sort: 0, sort: 0,
productAttributeIdList: [] productAttributeIdList: []
}; };
export default { export default {
name: "ProductCateDetail", name: "ProductCateDetail",
components: {SingleUpload}, components: {
props: { SingleUpload
isEdit: { },
type: Boolean, props: {
default: false isEdit: {
} type: Boolean,
}, default: false
data() { }
return { },
productCate: Object.assign({}, defaultProductCate), data() {
selectProductCateList: [], return {
rules: { productCate: Object.assign({}, defaultProductCate),
name: [ selectProductCateList: [],
{required: true, message: '请输入品牌名称', trigger: 'blur'}, rules: {
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'} name: [{
] required: true,
}, message: '请输入品牌名称',
filterAttrs: [], trigger: 'blur'
filterProductAttrList: [{ },
value: [] {
}] min: 2,
} max: 140,
}, message: '长度在 2 到 140 个字符',
created() { trigger: 'blur'
if (this.isEdit) { }
getProductCate(this.$route.query.id).then(response => { ]
this.productCate = response.data; },
}); filterAttrs: [],
getProductAttrInfo(this.$route.query.id).then(response => { filterProductAttrList: [{
if (response.data != null && response.data.length > 0) { value: []
this.filterProductAttrList = []; }]
for (let i = 0; i < response.data.length; i++) { }
this.filterProductAttrList.push({ },
key: Date.now() + i, created() {
value: [response.data[i].attributeCategoryId, response.data[i].attributeId] if (this.isEdit) {
}) getProductCate(this.$route.query.id).then(response => {
} this.productCate = response.data;
} });
}); getProductAttrInfo(this.$route.query.id).then(response => {
} else { if (response.data != null && response.data.length > 0) {
this.productCate = Object.assign({}, defaultProductCate); this.filterProductAttrList = [];
} for (let i = 0; i < response.data.length; i++) {
this.getSelectProductCateList(); this.filterProductAttrList.push({
this.getProductAttrCateList(); key: Date.now() + i,
}, value: [response.data[i].attributeCategoryId, response.data[i].attributeId]
methods: { })
getSelectProductCateList() { }
fetchList(0, {pageSize: 100, pageNum: 1}).then(response => { }
this.selectProductCateList = response.data.records; });
this.selectProductCateList.unshift({id: 0, name: '无上级分类'}); } else {
}); this.productCate = Object.assign({}, defaultProductCate);
}, }
getProductAttrCateList() { this.getSelectProductCateList();
fetchListWithAttr().then(response => { this.getProductAttrCateList();
let list = response.data; },
for (let i = 0; i < list.length; i++) { methods: {
let productAttrCate = list[i]; getSelectProductCateList() {
let children = []; fetchList(0, {
if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList.length > 0) { pageSize: 100,
for (let j = 0; j < productAttrCate.productAttributeList.length; j++) { pageNum: 1
children.push({ }).then(response => {
label: productAttrCate.productAttributeList[j].name, this.selectProductCateList = response.data.records;
value: productAttrCate.productAttributeList[j].id this.selectProductCateList.unshift({
}) id: 0,
} name: '无上级分类'
} });
this.filterAttrs.push({label: productAttrCate.name, value: productAttrCate.id, children: children}); });
} },
}); getProductAttrCateList() {
}, fetchListWithAttr().then(response => {
getProductAttributeIdList() { let list = response.data;
// for (let i = 0; i < list.length; i++) {
let productAttributeIdList = []; let productAttrCate = list[i];
for (let i = 0; i < this.filterProductAttrList.length; i++) { let children = [];
let item = this.filterProductAttrList[i]; if (productAttrCate.productAttributeList != null && productAttrCate.productAttributeList
if (item.value !== null && item.value.length === 2) { .length > 0) {
productAttributeIdList.push(item.value[1]); for (let j = 0; j < productAttrCate.productAttributeList.length; j++) {
} children.push({
} label: productAttrCate.productAttributeList[j].name,
return productAttributeIdList; value: productAttrCate.productAttributeList[j].id
}, })
onSubmit(formName) { }
this.$refs[formName].validate((valid) => { }
if (valid) { this.filterAttrs.push({
this.$confirm('是否提交数据', '提示', { label: productAttrCate.name,
confirmButtonText: '确定', value: productAttrCate.id,
cancelButtonText: '取消', children: children
type: 'warning' });
}).then(() => { }
if (this.isEdit) { });
this.productCate.productAttributeIdList = this.getProductAttributeIdList(); },
updateProductCate(this.$route.query.id, this.productCate).then(response => { getProductAttributeIdList() {
this.$message({ //
message: '修改成功', let productAttributeIdList = [];
type: 'success', for (let i = 0; i < this.filterProductAttrList.length; i++) {
duration: 1000 let item = this.filterProductAttrList[i];
}); if (item.value !== null && item.value.length === 2) {
this.$router.back(); productAttributeIdList.push(item.value[1]);
}); }
} else { }
this.productCate.productAttributeIdList = this.getProductAttributeIdList(); return productAttributeIdList;
createProductCate(this.productCate).then(response => { },
this.$refs[formName].resetFields(); onSubmit(formName) {
this.resetForm(formName); this.$refs[formName].validate((valid) => {
this.$message({ if (valid) {
message: '提交成功', this.$confirm('是否提交数据', '提示', {
type: 'success', confirmButtonText: '确定',
duration: 1000 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 { } else {
this.$message({ this.$message({
message: '验证失败', message: '验证失败',
type: 'error', type: 'error',
duration: 1000 duration: 1000
}); });
return false; return false;
} }
}); });
}, },
resetForm(formName) { resetForm(formName) {
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
this.productCate = Object.assign({}, defaultProductCate); this.productCate = Object.assign({}, defaultProductCate);
this.getSelectProductCateList(); this.getSelectProductCateList();
this.filterProductAttrList = [{ this.filterProductAttrList = [{
value: [] value: []
}]; }];
}, },
removeFilterAttr(productAttributeId) { removeFilterAttr(productAttributeId) {
if (this.filterProductAttrList.length === 1) { if (this.filterProductAttrList.length === 1) {
this.$message({ this.$message({
message: '至少要留一个', message: '至少要留一个',
type: 'warning', type: 'warning',
duration: 1000 duration: 1000
}); });
return; return;
} }
var index = this.filterProductAttrList.indexOf(productAttributeId); var index = this.filterProductAttrList.indexOf(productAttributeId);
if (index !== -1) { if (index !== -1) {
this.filterProductAttrList.splice(index, 1) this.filterProductAttrList.splice(index, 1)
} }
}, },
handleAddFilterAttr() { handleAddFilterAttr() {
if (this.filterProductAttrList.length === 3) { if (this.filterProductAttrList.length === 3) {
this.$message({ this.$message({
message: '最多添加三个', message: '最多添加三个',
type: 'warning', type: 'warning',
duration: 1000 duration: 1000
}); });
return; return;
} }
this.filterProductAttrList.push({ this.filterProductAttrList.push({
value: null, value: null,
key: Date.now() key: Date.now()
}); });
} }
}, },
filters: { filters: {
filterLabelFilter(index) { filterLabelFilter(index) {
if (index === 0) { if (index === 0) {
return '筛选属性:'; return '筛选属性:';
} else { } else {
return ''; return '';
} }
} }
} }
} }
</script> </script>
<style scoped> <style scoped>

18
mallplusui-web-admin/src/views/pms/productCate/index.vue

@ -119,6 +119,7 @@
}, },
methods: { methods: {
resetParentId() { resetParentId() {
console.log('parentId>>>', this.$route.query.parentId);
if (this.$route.query.parentId != null) { if (this.$route.query.parentId != null) {
this.parentId = this.$route.query.parentId; this.parentId = this.$route.query.parentId;
} else { } else {
@ -130,8 +131,11 @@
}, },
getList() { getList() {
this.listLoading = true; this.listLoading = true;
console.log('parentId>>>', this.parentId);
console.log('listQuery>>>', this.listQuery);
fetchList(this.parentId, this.listQuery).then(response => { fetchList(this.parentId, this.listQuery).then(response => {
this.listLoading = false; this.listLoading = false;
console.log('list>>>', response.data.records);
this.list = response.data.records; this.list = response.data.records;
this.total = response.data.total; this.total = response.data.total;
}); });
@ -188,12 +192,16 @@
}); });
}, },
handleShowNextLevel(index, row) { handleShowNextLevel(index, row) {
this.$router.push({ this.listQuery = {
path: '/pms/productCate', pageNum: 1,
query: { pageSize: 5
parentId: row.id
} }
}) this.$router.push({
path: '/pms/productCate',
query: {
parentId: row.id
}
})
}, },
handleTransferProduct(index, row) { handleTransferProduct(index, row) {
console.log('handleAddProductCate'); console.log('handleAddProductCate');

Loading…
Cancel
Save