Commit aff2bef7 authored by xieyishang's avatar xieyishang

11~

parent 1105c868
.shuttlemain{
padding: 30upx 30upx;
}
.shuttlecell{
background-color: #fff;
border: 1px solid #e6e6e6;
width: 300upx;
border-radius: 10upx;
}
.shuttle_head{
height: 88upx;
line-height: 88upx;
padding: 0 15upx;
}
.shuttle_items{
margin-bottom: 16upx;
}
.shuttle_body{
padding: 20upx;
border-top: 1px solid #e6e6e6;
}
.changesicon{
margin: 100upx 20upx;
}
.changesicon .arrowicon{
background-color: #FBFBFB;
width: 100upx;
height: 100upx;
line-height: 100upx;
text-align: center;
color: #ff6900;
font-size: 40upx;
margin-top: 30upx;
}
.changesicon .submitsss{
font-size: 30upx;
}
<template>
<!-- 导商品 -->
<!-- 穿梭框 -->
<view class="guidegoods">
<view class="shuttlemain flex ">
<!-- 一级 -->
<view class="shuttlecell">
<view class="shuttle_head">
<label @tap="taggleAllChecked">
<checkbox color="#ff6900" value="cb" :checked="cateAllChecked" />分类
</label>
</view>
<view class="shuttle_body">
<checkbox-group @change="changegroup">
<label class="flex shuttle_items" v-for="(item,index) in categorylist" :key="index">
<checkbox color="#ff6900" :value="item.cate_id" :checked="item.checked" />
<view class="shuttle_items_tit">{{item.cate_name}}</view>
</label>
</checkbox-group>
</view>
</view>
<view class="changesicon">
<view class="arrowicon" @tap="AntiElection"></view>
<view class="arrowicon" @tap="eleProductListfun"></view>
<view class="arrowicon submitsss" @tap="submitfuns">提交</view>
</view> <!-- 二级 -->
<view class="shuttlecell">
<view class="shuttle_head">
<label @tap="taggleAllCheckedTwo">
<checkbox color="#ff6900" value="cb" :checked="ProAllChecked" />产品
</label>
</view>
<view class="shuttle_body">
<checkbox-group @change="changegrouptwo">
<label class="flex shuttle_items" v-for="(item,index) in projuctList" :key="index">
<checkbox color="#ff6900" :value="item.product_id" :checked="item.checked" />
<view class="shuttle_items_tit">{{item.product_name}}</view>
</label>
</checkbox-group>
</view>
</view>
</view>
</view>
</template>
<script>
import {shop_class,eleProductList,CopyList} from "@/utils/api/goods.js";
export default {
data() {
return {
cateAllChecked:false,//分类是否全选
cateVal:[],//分类选中的值
categorylist: [], //分类
ProAllChecked:false,
ProVal:[],//产品选中的值
projuctList:[],//分类下面的产品
};
},
onLoad() {
this.shop_classfun();//获取分类
this.getCopyList();//获取之前选中的数据
},
computed:{
},
methods:{
//获取之前选中的数据
async getCopyList(){
let res = await CopyList({
});
if(res.code==0){
let list = res.data;
list = list.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
item.product_id = String(item.product_id);//默认字符串类型
item.cate_id = String(item.cate_id);//默认字符串类型
return item;
})
this.projuctList = list;
this.clearChecked();
}else{
//获取之前的默认数据失败
}
},
//获取分类
async shop_classfun(){
let res = await shop_class({});
if(res.code==0){
let list = res.data;
list = list.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
item.cate_id = String(item.cate_id);//默认字符串类型
return item;
})
this.categorylist = list;
}else{
//获取分类失败
}
},
//获取指定分类下面的产品
async eleProductListfun(){
if(this.cateVal.length==0){
return false;
}
let class_id = this.cateVal.join(",");
let res = await eleProductList({
class_id:class_id,
});
if(res.code==0){
let list = res.data;
list = list.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
item.product_id = String(item.product_id);//默认字符串类型
item.cate_id = String(item.cate_id);//默认字符串类型
return item;
})
this.projuctList = list;
this.clearChecked();
}else{
this.projuctList = [];//失败了要清除
//获取指定分类下的产品失败了
}
},
//--------------------------------------requist end--------------------------------
//监听菜品勾选的改版
changegroup(e){
this.cateVal = e.detail.value;//选中的值
//修改对应的状态
this.categorylist = this.categorylist.map((item,index)=>{
if(this.cateVal.indexOf(item.cate_id)!=-1){
item.checked = true;
}else{
item.checked = false;
}
return item;
})
this.testingAllChecked();
},
//检测分类是否全选hian
testingAllChecked(){
let bool = this.categorylist.every((item,index)=>{
return item.checked ==true;
})
this.cateAllChecked = bool;
},
//分类的全选反选
taggleAllChecked(){
this.cateAllChecked = !this.cateAllChecked;
if(this.cateAllChecked){
//全部选中
let cateVal =[];
this.categorylist = this.categorylist.map((item,index)=>{
item.checked = true;//选中状态 默认没有选中
cateVal.push(item.cate_id)
return item;
})
this.cateVal = cateVal;
}else{
//全部去除勾选
this.cateVal =[];
this.categorylist = this.categorylist.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
return item;
})
}
},
///---------------------------分类逻辑end--------------------------
//产品选中
changegrouptwo(e){
this.ProVal = e.detail.value;//选中的值
//修改对应的状态
this.projuctList = this.projuctList.map((item,index)=>{
if(this.ProVal.indexOf(item.product_id)!=-1){
item.checked = true;
}else{
item.checked = false;
}
return item;
})
this.testingAllCheckedTwo();
},
//检测是否全选
testingAllCheckedTwo(){
let bool = this.projuctList.every((item,index)=>{
return item.checked ==true;
})
this.ProAllChecked = bool;
},
//菜品的全选反选
taggleAllCheckedTwo(){
this.ProAllChecked = !this.ProAllChecked;
if(this.ProAllChecked){
//全部选中
let ProVal =[];
this.projuctList = this.projuctList.map((item,index)=>{
item.checked = true;//选中状态 默认没有选中
ProVal.push(item.product_id)
return item;
})
this.ProVal = ProVal;
}else{
//全部去除勾选
this.ProVal =[];
this.projuctList = this.projuctList.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
return item;
})
}
},
//取消全部选中
clearChecked(){
//取消分类的选中
//取消 之前产品的选中
this.cateAllChecked=false;
this.cateVal=[];
this.ProAllChecked=false;
this.ProVal=[];
this.categorylist = this.categorylist.map((item,index)=>{
item.checked = false;//选中状态 默认没有选中
return item;
})
},
//反选 通过去除选中的产品 回选出对应的分类
AntiElection(){
//获取选中的分类id
let Provalcate = [];
let projuctList = [];
this.projuctList.forEach((item,index)=>{
if(item.checked){
Provalcate.push(String(item.cate_id))
}else{
projuctList.push(item)
}
})
this.projuctList =projuctList;
console.info("Provalcate",Provalcate);
if(Provalcate.length!=0){
this.ProAllChecked = false;
}
let cateVal =[];
this.categorylist = this.categorylist.map((item,index)=>{
if(Provalcate.indexOf(item.cate_id)!=-1){
console.info("符合~",index);
item.checked = true;//选中状态 默认没有选中
cateVal.push(item.cate_id)
}
return item;
})
this.cateVal = cateVal;
},
//提交商品
submitfuns(){
if(this.ProVal.length==0){
this.$api.msg("请勾选产品");
return false;
}
let checkedProList = [];
this.projuctList.forEach((item,index)=>{
if(item.checked){
checkedProList.push(item);
}
})
uni.setStorageSync("checkedProList",checkedProList);
uni.navigateTo({
url:"/pages/guidegoodstwo/guidegoodstwo"
})
}
}
}
</script>
<style lang="scss">
@import "./guidegoods.scss";
</style>
<template>
<!-- 快递导入 第二步 -->
<view class="guidegoodstwo">
<view class="prolist">
<view class="proitems" v-for="(item,index) in checkedProList" :key="index">
<view class="cellspro">标题:{{item.product_name}}</view>
<view class="cellspro flex ali-c">
<text>价格:</text>
<input class="inputs" type="text" value="" v-model="item.price" />
</view>
</view>
</view>
<view class="fixed_btns flex ali-c jus-c">
<view class="submitbtnss" @tap="submitfun">提交</view>
</view>
</view>
</template>
<script>
import {CopyAdd} from "@/utils/api/goods.js";
export default {
data() {
return {
checkedProList:[],
}
},
onLoad() {
this.checkedProList = uni.getStorageSync("checkedProList");
},
methods: {
//提交修改的内容
submitfun(){
let checkedProList = this.checkedProList.map((item,index)=>{
return {product_id:item.product_id,price:item.price}
})
CopyAdd({
list:checkedProList,
}).then((res)=>{
if(res.code==0){
this.$api.msg("提交成功!");
setTimeout(()=>{
uni.navigateBack({
})
},800)
}else{
this.$api.msg(res.msg);
}
})
}
}
}
</script>
<style lang="scss">
.guidegoodstwo{
padding-bottom: 100upx;
}
.prolist{
padding: 30upx;
}
.proitems{
margin-bottom: 15upx;
padding: 20upx 15upx;
background-color: #FFFFFF;
border-radius: 14upx;
}
.proitems .cellspro{
color: #757575;
font-size: 30upx;
margin-top: 20upx;
}
.proitems .cellspro .inputs{
height: 50upx;
line-height: 50upx;
border:1px solid #ccc;
font-size: 30upx;
box-sizing: border-box;
padding: 0 20upx;
}
.fixed_btns{
height: 120upx;
width: 100%;
background-color: #fff;
position: fixed;
left: 0;
bottom: 0;
padding: 0 40upx;
box-sizing: border-box;
}
.fixed_btns .submitbtnss{
width: 100%;
background: #ff6900;
color: #FFFFFF;
font-size: 32upx;
border-radius: 12upx;
height: 88upx;
line-height: 88upx;
text-align: center;
}
</style>
// 2021年1月16日14:13:40 新增
//商品快速导入接口
import request from "./../request.js";
/**
* 请求接口封装
*
* noAuth false 是需要鉴权的 true 是不用鉴权的
*
* 商家助手的接口封装
*
*/
//获取商品分类 菜品库的分类
export function shop_class(data)
{
return request.post("CopyProduct/shop_class",data,{ noAuth : false});
}
//获取菜品库下面的商品
export function eleProductList(data)
{
return request.post("CopyProduct/eleProductList",data,{ noAuth : false});
}
//提交 CopyAdd 修改后的产品
export function CopyAdd(data)
{
return request.post("CopyProduct/CopyAdd",data,{ noAuth : false});
}
//获取之前 提交成功的产品
export function CopyList(data)
{
return request.post("CopyProduct/CopyList",data,{ noAuth : false});
}
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