| | |
| | | multipleSlots: true // 在组件定义时的选项中启用多slot支持
|
| | | },
|
| | | properties: {
|
| | | sellerList:{
|
| | | storeList:{
|
| | | type: Array,
|
| | | value: []
|
| | | },
|
| | |
| | | * 组件的初始数据
|
| | | */
|
| | | data: {
|
| | | selectedSellerList:[
|
| | | // {DocItem: 10, SellerId: 1, SellerName: "好几十", Telephone: "15555555555", isDefaultSellerName: false},
|
| | | // {DocItem: 10, SellerId: 2, SellerName: "好", Telephone: "15588555555", isDefaultSellerName: false},
|
| | | // {DocItem: 10, SellerId: 3, SellerName: "555", Telephone: "18888555555", isDefaultSellerName: false},
|
| | | selectedStoreList:[
|
| | | // {DocItem: 10, StoreId: 1, StoreName: "好几十", Telephone: "15555555555", isDefaultStoreName: false},
|
| | | // {DocItem: 10, StoreId: 2, StoreName: "好", Telephone: "15588555555", isDefaultStoreName: false},
|
| | | // {DocItem: 10, StoreId: 3, StoreName: "555", Telephone: "18888555555", isDefaultStoreName: false},
|
| | | ] as any,
|
| | | selectedSeller:'',
|
| | | selectedSellerIdList:[] as any,
|
| | | selectedStore:'',
|
| | | selectedStoreIdList:[] as any,
|
| | | index: -1
|
| | | },
|
| | |
|
| | |
| | | },
|
| | | pageLifetimes:{
|
| | | show(){
|
| | | let {selectedSellerIdList,selectedSeller} = this.data;
|
| | | let newSelectedSellerList = [] as any;
|
| | | console.log('>>>>>>>>>>>>>>组件页面show开始>>>>>>>>>>>>>>');
|
| | | console.log('页面show时 新建活动页当前的selectedSellerIdList',selectedSellerIdList);
|
| | | if (selectedSellerIdList.length>0){
|
| | | let selectedSellerList = this.getSelectedSellerList();
|
| | | console.log('页面show时 新建活动页当前的selectedSellerList',selectedSellerList);
|
| | | let {selectedStoreIdList,selectedStore} = this.data;
|
| | | let newSelectedStoreList = [] as any;
|
| | | console.log('>>>>>>>>>>>>>>门店组件页面show开始>>>>>>>>>>>>>>');
|
| | | console.log('页面show时 新建活动页当前的selectedStoreIdList',selectedStoreIdList);
|
| | | if (selectedStoreIdList.length>0){
|
| | | let selectedStoreList = this.getSelectedStoreList();
|
| | | console.log('页面show时 新建活动页当前的selectedStoreList',selectedStoreList);
|
| | |
|
| | | if (selectedSellerIdList.length != selectedSellerList.length) {
|
| | | selectedSellerIdList.forEach((idItem:any)=>{
|
| | | selectedSellerList.forEach((item:any)=>{
|
| | | if (item.sellerId == idItem) {
|
| | | newSelectedSellerList.push(item)
|
| | | if (selectedStoreIdList.length != selectedStoreList.length) {
|
| | | selectedStoreIdList.forEach((idItem:any)=>{
|
| | | selectedStoreList.forEach((item:any)=>{
|
| | | if (item.docCode == idItem) {
|
| | | newSelectedStoreList.push(item)
|
| | | }
|
| | | })
|
| | | })
|
| | | selectedSellerList = newSelectedSellerList;
|
| | | selectedStoreList = newSelectedStoreList;
|
| | |
|
| | | console.log('营销人员被删除,selectedSellerList数据更新后',newSelectedSellerList);
|
| | | console.log('门店被删除,selectedStoreList数据更新后',newSelectedStoreList);
|
| | | this.setData({
|
| | | selectedSellerList
|
| | | selectedStoreList
|
| | | })
|
| | | }
|
| | | console.log('selectedSellerIdList是否包含selectedSeller',selectedSellerIdList.includes(selectedSeller.toString() as never),selectedSellerIdList,selectedSeller.toString());
|
| | | if (!selectedSellerIdList.includes(selectedSeller.toString() as never)) {
|
| | | console.log('selectedStoreIdList是否包含selectedStore',selectedStoreIdList.includes(selectedStore.toString() as never),selectedStoreIdList,selectedStore.toString());
|
| | | if (!selectedStoreIdList.includes(selectedStore.toString() as never)) {
|
| | | this.setData({
|
| | | selectedSeller: selectedSellerList[0].sellerId,
|
| | | selectedStore: selectedStoreList[0].docCode,
|
| | | index: 0
|
| | | })
|
| | |
|
| | | }
|
| | | console.log('页面show时 新建活动页当前的selectedSeller',this.data.selectedSeller,this.data.index);
|
| | | console.log('页面show时 新建活动页当前的selectedStore',this.data.selectedStore,this.data.index);
|
| | | }
|
| | | console.log('<<<<<<<<<<<<<<<组件页面show结束<<<<<<<<<<<<<<<');
|
| | | console.log('<<<<<<<<<<<<<<<门店组件页面show结束<<<<<<<<<<<<<<<');
|
| | | }
|
| | | },
|
| | | observers: {
|
| | | 'sellerList': function(val) {
|
| | | console.log('监听sellers',val,this.data.sellerList)
|
| | | 'storeList': function(val) {
|
| | | console.log('监听stores',val,this.data.storeList)
|
| | | if (val.length > 0) {
|
| | | let selectedSellerList = val;
|
| | | let selectedSellerIdList = [] as any;
|
| | | console.log('营销人员列表sellers。。。与id、、、',selectedSellerList,selectedSellerIdList);
|
| | | selectedSellerList.forEach((item:any,index:number)=>{
|
| | | selectedSellerIdList.push(item&&item.sellerId&&item.sellerId.toString());
|
| | | if (item.isDefaultSellerName){
|
| | | let selectedStoreList = val;
|
| | | let selectedStoreIdList = [] as any;
|
| | | console.log('门店列表stores。。。与id、、、',selectedStoreList,selectedStoreIdList);
|
| | | selectedStoreList.forEach((item:any,index:number)=>{
|
| | | selectedStoreIdList.push(item&&item.docCode&&item.docCode.toString());
|
| | | if (item.isDefaultStoreName){
|
| | | this.setData({
|
| | | selectedSeller: item.sellerId,
|
| | | selectedStore: item.docCode,
|
| | | index
|
| | | })
|
| | | }
|
| | | })
|
| | | this.setData({selectedSellerList,selectedSellerIdList});
|
| | | this.setData({selectedStoreList,selectedStoreIdList});
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * 组件的方法列表
|
| | | */
|
| | | methods: {
|
| | | selectSeller(event:any) {
|
| | | console.log(event)
|
| | | this.setData({
|
| | | selectedSeller: event.detail
|
| | | });
|
| | | },
|
| | | onSelect(event:any) {
|
| | | const { name, index } = event.currentTarget.dataset;
|
| | | this.setData({
|
| | | selectedSeller: name,
|
| | | index
|
| | | });
|
| | | console.log('选中的默认营销人员',name ,index);
|
| | | },
|
| | | toggle2(event:any){
|
| | | console.log(event);
|
| | | },
|
| | | getSelectedSellerList(){
|
| | | let {selectedSellerIdList} = this.data;
|
| | | let selectedSellerList = [] as any;
|
| | | let sellerList = wx.globalData.sellerList;
|
| | | selectedSellerIdList.forEach((id:any)=>{
|
| | | sellerList.forEach((item:any)=>{
|
| | | if (item.sellerId == Number(id)) {
|
| | | selectedSellerList.push(item)
|
| | | getSelectedStoreList(){
|
| | | let {selectedStoreIdList} = this.data;
|
| | | let selectedStoreList = [] as any;
|
| | | let storeList = wx.globalData.storeList;
|
| | | selectedStoreIdList.forEach((id:any)=>{
|
| | | storeList.forEach((item:any)=>{
|
| | | if (item.docCode == id) {
|
| | | selectedStoreList.push(item)
|
| | | }
|
| | | })
|
| | | })
|
| | | this.setData({
|
| | | selectedSellerList
|
| | | selectedStoreList
|
| | | })
|
| | | return selectedSellerList;
|
| | | return selectedStoreList;
|
| | | },
|
| | |
|
| | | // 父组件获取待提交的营销人员数据
|
| | | getSellerList(){
|
| | | let { selectedSellerList, index} = this.data;
|
| | | selectedSellerList.forEach((item:any)=>{
|
| | | item.isDefaultSellerName = false;
|
| | | getStoreList(){
|
| | | let { selectedStoreList, index} = this.data;
|
| | | selectedStoreList.forEach((item:any)=>{
|
| | | item.isDefaultStoreName = false;
|
| | | })
|
| | | if (index >=0&&selectedSellerList.length>0){
|
| | | selectedSellerList[index].isDefaultSellerName = true;
|
| | | if (index >=0&&selectedStoreList.length>0){
|
| | | selectedStoreList[index].isDefaultStoreName = true;
|
| | | }
|
| | | console.log('待提交的营销人员数据',selectedSellerList);
|
| | | return selectedSellerList;
|
| | | console.log('待提交的门店数据',selectedStoreList);
|
| | | return selectedStoreList;
|
| | | },
|
| | | checkDefaultSeller(){
|
| | | let { selectedSellerList } = this.data;
|
| | | return !(selectedSellerList.every((currentValue:any)=>{
|
| | | return currentValue.isDefaultSellerName == false;
|
| | | }))
|
| | | },
|
| | | addSeller(){
|
| | | addStore(){
|
| | | wx.navigateTo({
|
| | | url: `/pages/sellerList/sellerList`,
|
| | | url: `/pages/storeList/storeList`,
|
| | | success: (res)=> {
|
| | | let selectedSellerIdList = this.data.selectedSellerIdList;
|
| | | console.log('新建活动页当前的selectedSellerIdList',selectedSellerIdList);
|
| | | let selectedStoreIdList = this.data.selectedStoreIdList;
|
| | | console.log('新建活动页当前的selectedStoreIdList',selectedStoreIdList);
|
| | | // 通过eventChannel向被打开页面传送数据
|
| | | res.eventChannel.emit('getSellerListFromPromotionsPage', {
|
| | | selectedSellerIdList
|
| | | res.eventChannel.emit('getStoreListFromPromotionsPage', {
|
| | | selectedStoreIdList
|
| | | })
|
| | | },
|
| | | events: {
|
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
|
| | | getSelectedSellerList: (data: any)=> {
|
| | | console.log('获取营销人员选择页选中的data',data)
|
| | | getSelectedStoreList: (data: any)=> {
|
| | | console.log('获取门店选择页选中的data',data)
|
| | | this.setData({
|
| | | selectedSellerIdList:data.selectedSellerIdList,
|
| | | // selectedSellerList:data.selectedSellerList
|
| | | selectedStoreIdList:data.selectedStoreIdList,
|
| | | // selectedStoreList:data.selectedStoreList
|
| | | })
|
| | | },
|
| | | }
|