Commit 1e6fd284 by lixiaomin

轮播图

parent ef1f4477
import request from "@/utils/request";
// 查询列表
export function getBannerList(pageNum,pageSize,data) {
return request({
url: "/system/banner/list?pageNum=" + pageNum+ "&pageSize="+pageSize,
method: "post",
data: data,
});
}
// 新增轮播图
export function addBanner(data) {
return request({
url: "/system/banner/create",
method: "post",
data: data,
});
}
// 修改轮播图
export function updateBanner(data) {
return request({
url: "/system/banner/update",
method: "post",
data: data,
});
}
// 删除轮播图
export function delBanner(id) {
return request({
url: "/system/banner/delete?bannerId="+id,
method: "get"
});
}
// 修改上下线状态轮播图
export function upStateBanner(id,state) {
return request({
url: "/system/banner/state/update?bannerId="+id+"&state="+state,
method: "get"
});
}
/** 组装省市区门店数据,供回显使用 */
function buildPS(pdata){
let province= pdata.province;
let ps_ary = new Array();
if(province && province[0]==0){
ps_ary.push(["0"]);
}else{
//如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
let t_shopIds = pdata.shopIds;
let t_area = pdata.area;
let t_city = pdata.city;
let t_province = pdata.province;
let child_ary = new Array();
//找到对应的节点
if(t_shopIds ){
getChildNodeData(t_shopIds,child_ary);
}
if(t_area ){
getChildNodeData(t_area,child_ary);
}
if(t_city ){
getChildNodeData(t_city,child_ary);
}
if(t_province ){
getChildNodeData(t_province,child_ary);
}
//循环所有最底层子节点找到parent,生成数组;
for(let i=0;i<child_ary.length;i++){
let cdata_ary = new Array();
cdata_ary.push(child_ary[i].value);
getNodeData(child_ary[i],cdata_ary);
cdata_ary.unshift("1");
ps_ary.push(cdata_ary)
}
}
return ps_ary;
}
let list=[];
function getChildNodeData(pval,child_ary){
for(let i=0;i<pval.length;i++){
//找到指定值对应的节点
let tobj = cascadTreeData(list[1],pval[i]);
//找到所有的最底层子节点
getNodeList(tobj,child_ary);
}
}
//填充所有父节点的值
function getNodeData(child,pary){
if(child.parentObj){
pary.unshift(child.parentObj.value);
getNodeData(child.parentObj,pary);
}
}
//找到当前的值对应的节点,
function cascadTreeData(tdata,pval){
if(!pval || pval==null ) return null;
if(tdata && tdata.value && tdata.value==pval){
return tdata;
}else{
let tchild = tdata.children;
if(tchild){
for(let i=0;i<tchild.length;i++){
let titem = tchild[i];
if(titem.value==pval){
return titem;
}else{
let tobj = cascadTreeData(titem,pval);
if(tobj) return tobj;
}
}
}
}
}
//找到指定节点所有的子节点
function getNodeList(pnode,pary){
if(pnode==null) return ;
if(pnode.children){
for(let i=0;i<pnode.children.length;i++){
let titem = pnode.children[i];
if(titem.children){
getNodeList(titem,pary);
}else{
pary.push(titem);
}
}
}else{
pary.push(pnode);
}
}
function getList(dataList){
list=dataList
}
export default{
buildPS,
getList
}
\ No newline at end of file
...@@ -213,6 +213,7 @@ import {listClass} from "@/api/system/category"; ...@@ -213,6 +213,7 @@ import {listClass} from "@/api/system/category";
import {listSpu} from "@/api/system/goods"; import {listSpu} from "@/api/system/goods";
import {listShop,getShopAreaTree} from "@/api/system/shop"; import {listShop,getShopAreaTree} from "@/api/system/shop";
import piovince from '@/utils/piovince' import piovince from '@/utils/piovince'
import area from '@/utils/area'
export default { export default {
components: { GiveCoupon}, components: { GiveCoupon},
data() { data() {
...@@ -582,109 +583,111 @@ export default { ...@@ -582,109 +583,111 @@ export default {
this.shopRange=sh_ary; this.shopRange=sh_ary;
} }
//省市区门店 //省市区门店
let ps_ary = this.buildPS(response.data); area.getList(this.shopAreaTreeList);
let ps_ary=area.buildPS(response.data);
//let ps_ary = this.buildPS(response.data);
this.storesRange = ps_ary; this.storesRange = ps_ary;
} }
}); });
} }
}).catch(() => {}); }).catch(() => {});
}, },
/** 组装省市区门店数据,供回显使用 */ // /** 组装省市区门店数据,供回显使用 */
buildPS(pdata){ // buildPS(pdata){
//this.storesRange=[[1,"110000","110000","110105","48"]]; // //this.storesRange=[[1,"110000","110000","110105","48"]];
//0,1 // //0,1
//province: "110000" // //province: "110000"
//city: "110000" // //city: "110000"
// area // // area
//shopIds // //shopIds
let province= pdata.province; // let province= pdata.province;
let ps_ary = new Array(); // let ps_ary = new Array();
if(province && province[0]==0){ // if(province && province[0]==0){
ps_ary.push(["0"]); // ps_ary.push(["0"]);
}else{ // }else{
//如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点 // //如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
let t_shopIds = pdata.shopIds; // let t_shopIds = pdata.shopIds;
let t_area = pdata.area; // let t_area = pdata.area;
let t_city = pdata.city; // let t_city = pdata.city;
let t_province = pdata.province; // let t_province = pdata.province;
let child_ary = new Array(); // let child_ary = new Array();
//找到对应的节点 // //找到对应的节点
if(t_shopIds ){ // if(t_shopIds ){
this.getChildNodeData(t_shopIds,child_ary); // this.getChildNodeData(t_shopIds,child_ary);
} // }
if(t_area ){ // if(t_area ){
this.getChildNodeData(t_area,child_ary); // this.getChildNodeData(t_area,child_ary);
} // }
if(t_city ){ // if(t_city ){
this.getChildNodeData(t_city,child_ary); // this.getChildNodeData(t_city,child_ary);
} // }
if(t_province ){ // if(t_province ){
this.getChildNodeData(t_province,child_ary); // this.getChildNodeData(t_province,child_ary);
} // }
//循环所有最底层子节点找到parent,生成数组; // //循环所有最底层子节点找到parent,生成数组;
for(let i=0;i<child_ary.length;i++){ // for(let i=0;i<child_ary.length;i++){
let cdata_ary = new Array(); // let cdata_ary = new Array();
cdata_ary.push(child_ary[i].value); // cdata_ary.push(child_ary[i].value);
this.getNodeData(child_ary[i],cdata_ary); // this.getNodeData(child_ary[i],cdata_ary);
cdata_ary.unshift("1"); // cdata_ary.unshift("1");
ps_ary.push(cdata_ary) // ps_ary.push(cdata_ary)
} // }
} // }
return ps_ary; // return ps_ary;
}, // },
getChildNodeData(pval,child_ary){ // getChildNodeData(pval,child_ary){
for(let i=0;i<pval.length;i++){ // for(let i=0;i<pval.length;i++){
//找到指定值对应的节点 // //找到指定值对应的节点
let tobj = this.cascadTreeData(this.shopAreaTreeList[1],pval[i]); // let tobj = this.cascadTreeData(this.shopAreaTreeList[1],pval[i]);
console.log("tobj ",tobj); // console.log("tobj ",tobj);
//找到所有的最底层子节点 // //找到所有的最底层子节点
this.getNodeList(tobj,child_ary); // this.getNodeList(tobj,child_ary);
} // }
}, // },
//填充所有父节点的值 // //填充所有父节点的值
getNodeData(child,pary){ // getNodeData(child,pary){
if(child.parentObj){ // if(child.parentObj){
pary.unshift(child.parentObj.value); // pary.unshift(child.parentObj.value);
this.getNodeData(child.parentObj,pary); // this.getNodeData(child.parentObj,pary);
} // }
}, // },
//找到当前的值对应的节点, // //找到当前的值对应的节点,
cascadTreeData(tdata,pval){ // cascadTreeData(tdata,pval){
if(!pval || pval==null ) return null; // if(!pval || pval==null ) return null;
if(tdata && tdata.value && tdata.value==pval){ // if(tdata && tdata.value && tdata.value==pval){
return tdata; // return tdata;
}else{ // }else{
let tchild = tdata.children; // let tchild = tdata.children;
if(tchild){ // if(tchild){
for(let i=0;i<tchild.length;i++){ // for(let i=0;i<tchild.length;i++){
let titem = tchild[i]; // let titem = tchild[i];
if(titem.value==pval){ // if(titem.value==pval){
return titem; // return titem;
}else{ // }else{
let tobj = this.cascadTreeData(titem,pval); // let tobj = this.cascadTreeData(titem,pval);
if(tobj) return tobj; // if(tobj) return tobj;
} // }
} // }
} // }
} // }
}, // },
//找到指定节点所有的子节点 // //找到指定节点所有的子节点
getNodeList(pnode,pary){ // getNodeList(pnode,pary){
if(pnode==null) return ; // if(pnode==null) return ;
if(pnode.children){ // if(pnode.children){
for(let i=0;i<pnode.children.length;i++){ // for(let i=0;i<pnode.children.length;i++){
let titem = pnode.children[i]; // let titem = pnode.children[i];
if(titem.children){ // if(titem.children){
this.getNodeList(titem,pary); // this.getNodeList(titem,pary);
}else{ // }else{
pary.push(titem); // pary.push(titem);
} // }
} // }
}else{ // }else{
pary.push(pnode); // pary.push(pnode);
} // }
}, // },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
......
...@@ -132,9 +132,7 @@ export default { ...@@ -132,9 +132,7 @@ export default {
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10
name: null,
state: null
}, },
// 表单参数 // 表单参数
form: {}, form: {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment