Просмотр исходного кода

采购的日期和时间可以了

shish 4 лет назад
Родитель
Сommit
7a1fe99127

+ 8 - 45
ghsApp/src/admin/statistics/cgStat.vue

@@ -6,12 +6,10 @@
 			<AppSearchModule placeholder="输英文字母搜索" @input="searchFn"/>
 		</view>
 		</view>
-
 		<view class="top-bar">
-			<DateSelect class="bar" :menuObj="menuTimeObj" :selectItemId.sync="selectTimeId" top="0" @selectSussess="selectDateFn" />
-			<ShopSelect class="bar" :menuObj.sync="menuObj" :selectItemId.sync="shopId" top="0" @selectSussess="selectShopFn" />
+			<DateSelect class="bar" top="0" @selectDateFn="selectDateFn" />
+			<ShopSelect class="bar" top="0" @selectShopFn="selectShopFn" />
 		</view>
-
 		<view class="main-view">
 			<view class="space-view ex-table">
 				<block>
@@ -37,27 +35,23 @@
 </view>
 </template>
 <script>
-const Month = (new Date().getMonth()+1)<10?'0'+(new Date().getMonth()+1):new Date().getMonth()+1
-const time = `${new Date().getFullYear()}-${Month}-${new Date().getDate()}`;
 import AppWrapperEmpty from "@/components/app-wrapper-empty";
 import SelectList from "@/components/plugin/selectList";
 import { getStatCgGhsProfile } from "@/api/statistics/index";
-import { list,selectShop } from "@/mixins";
+import { list } from "@/mixins";
 import ShopSelect from "@/components/module/shopSelect";
 import DateSelect from "@/components/module/dateSelect";
 import AppSearchModule from "@/components/module/app-search";
 import {mapActions, mapGetters} from "vuex";
 export default {
 	components: { SelectList, AppWrapperEmpty,ShopSelect,AppSearchModule,DateSelect },
-	mixins: [list,selectShop],
+	mixins: [list],
 	computed: {		...mapGetters(["getDictionariesInfo","getLoginInfo"])	},
 	data() {
 		return {
 			isShow:false,
 			customizationTime:[],
-			menuTimeObj:'',//时间分类-类型
 			menuShopObj:'',//门店分类-类型
-			selectTimeId:'',//选择时间id
 			shopId:'',//选择分店id
 			itemId:'',
 			selectListData: [
@@ -89,14 +83,6 @@ export default {
 	onLoad(e) {
 		this.itemId = e.id;
 		this.params.itemId = e.id;
-		let dateDefaultOption = [];
-		let list = this.getDictionariesInfo.dateDefaultOption;
-		if(!this.$util.isEmpty(list)){
-			for (let i=0;i<list.length;i++){
-				dateDefaultOption.push({name:list[i].name,id:list[i].value})
-			}
-		}
-		this.menuTimeObj = {title:'今天',titleChild:'时间',list: dateDefaultOption};
 		this.shopId = this.getLoginInfo.shopId;
 	},
 	methods: {
@@ -121,38 +107,15 @@ export default {
 				that.profile = that.storageData
 			}
 		},
-		// 选择分店
+		//选择分店
 		selectShopFn(val){
-			this.params.shopId = val.selectItem.id;
+			this.params.shopId = val.id;
 			this.init();
 		},
 		//选择时间
 		selectDateFn(val) {
-			this.params.selectTime = this.selectTimeId;
-			if(val.custom==1){
-				this.isShow = false;
-				this.params.startTime = val.start
-				this.params.endTime = val.end
-				this.init();
-			}else{
-				this.init();
-			}
-		},
-		//选择时间-时间段
-		selectTime(){
-			this.customizationTime = [time,time],
-				this.isShow = true;
-		},
-		//选择时间段确定
-		timeChange(e){
-			this.isShow = false;
-			this.params.startTime = e[0]
-			this.params.endTime = e[1]
-			this.init();
-		},
-		//选择时间段取消
-		timeCancel(e){
-			this.isShow = false
+			this.params = {...this.params,...val}
+			this.init();			
 		},
 		async init() {
 			this.getList();

+ 17 - 71
ghsApp/src/components/module/dateSelect.vue

@@ -1,7 +1,7 @@
 <template>
     <view class="select-bg_bx">
         <view v-if="isShowTit" @click="switchCut" :class="['select-title',dropdownShow?'select_corlor':'']">
-            <text>{{selectItemId?menuObjActive:menuObj.title}}</text>
+            <text>{{currentDateName}}</text>
             <text v-if="placeholder" style="color: #ccc;">{{placeholder}}</text>
             <i v-if="isShowMore" class="iconfont iconsanjiao_xia"></i>
         </view>
@@ -12,12 +12,12 @@
         <view v-if="dropdownShow" :style="{top}" class="select-fixed_bx">
             <slot>
                 <view class="select-item-box">
-                    <view class="title">{{menuObj.titleChild}}</view>
+                    <view class="title">时间</view>
                     <view class="item-child_box">
                         <button
-                            v-for="(item,index) in menuObj.list"
+                            v-for="(item,index) in getDictionariesInfo.dateDefaultOption"
                             :key="index"
-                            @click="changeItem(item)"
+                            @click="changeDateOption(item)"
                             :class="['admin-button-com','mini-btn',selectItemId === item.id?'blue':'default']">
                             {{item.name}}
                         </button>
@@ -28,7 +28,7 @@
                     <view class="item-child_box" >
                         <view class="admin-button-com mini-btn default custom" @click="showDatePicker(0)">{{startDate || '选择开始日期'}}</view>
                         <view class="admin-button-com mini-btn default custom" @click="showDatePicker(1)">{{endDate || '选择结束日期'}}</view>
-                        <view class="admin-button-com mini-btn blue custom" @click="setDateConfirm()">确认</view>
+                        <view class="admin-button-com mini-btn blue custom" @click="customDateConfirm()">确认</view>
                     </view>
                 </view>
             </slot>
@@ -36,7 +36,6 @@
         <mx-date-picker :show="showPicker" format="yyyy-mm-dd" type="date" :value="defaultPickerDate" :show-tips="true" @confirm="confirmPicker" @cancel="cancelPicker" />
     </view>
 </template>
-
 <script>
 import DropdownList from "@/components/plugin/dropdown-list";
 import MxDatePicker from '@/components/mx-datepicker/mx-datepicker.vue';
@@ -47,14 +46,6 @@ export default {
         DropdownList,MxDatePicker
     },
     props:{
-        menuObj:{
-            type: Object,
-            default: ()=>({
-                title:'时间',
-                titleChild:'时间',
-                list: [{name:'昨天',id:'0'},{name:'今天',id:'1'},{name:'本月',id:'2'},{name:'上月',id:'3'},{name:'今年',id:'4'}]
-            })
-        },
         top:{
             type: String,
             default: 'auto'
@@ -78,32 +69,23 @@ export default {
     },
     data(){
         return {
-            defaultPickerDate:'2019-01-01',
+            defaultPickerDate:'',
             showPicker: false,
             dropdownShow: false,
             selectItem:'',
-            menuObjActive:'',
+            currentDateName:'今天',
             startDate:'',
             endDate:'',
             dateIndex:0
         }
     },
     computed:{
-        ...mapGetters(["getMyShopInfo"]),
-        formatSelect(){
-            if(!this.$util.isEmpty(this.selectItemId)&&
-            this.$util.isString(this.selectItemId)&&
-            this.selectItemId.split('-').length>1){
-                return true
-            }else{
-                return false
-            }
-        },
+        ...mapGetters(["getDictionariesInfo"])
     },
     mounted(){
         let nowDate = new Date();
-		let end = nowDate.Format("yyyy-MM-dd")
-        this.defaultPickerDate = end
+		let currentDate = nowDate.Format("yyyy-MM-dd")
+        this.defaultPickerDate = currentDate
     },
     onLoad(){
     },
@@ -120,7 +102,7 @@ export default {
              }
              this.showPicker = false;
         },
-        setDateConfirm() {
+        customDateConfirm() {
             if(this.$util.isEmpty(this.startDate)){
                 this.$msg('请选择开始日期')
                 return false
@@ -129,60 +111,24 @@ export default {
                 this.$msg('请选择开始日期')
                 return false
             }
-            this.$emit('update:selectItemId','custom')            
-            this.$emit('selectSussess',{
-                custom:1,start:this.startDate,end:this.endDate
-            })
-            this.menuObjActive = '时间段';
             this.dropdownShow = false
+            this.currentDateName = '时间段'
+            this.$emit('selectDateFn',{selectTime:'custom',start:this.startDate,end:this.endDate})
         },
-        cancelPicker(e){//取消
+        cancelPicker(){
             this.showPicker = false;
         },
         switchCut(){
             this.dropdownShow = !this.dropdownShow
         },
-        changeItem(val){
-            if(val.id== this.selectItemId&&val.name!='时间段'){
-                return false
-            }
-            this.$emit('update:selectItemId',val.id)
-
-            this.dropdownShow = false;
-
-            this.$emit('update:menuObj',{
-                ...this.menuObj,
-                title:val.name
-            })
-            this.menuObjActive = val.name;
-
-            this.$emit('selectSussess',{
-                select: this.$util.isString(val)?val:val.name,
-                selectItem: val
-            })
-        },
-        endTimeFn(e){
-
-            this.selectItemId = e.detail.value;
-
+        changeDateOption(val){
             this.dropdownShow = false;
-
-            this.$emit('update:selectItemId',val.id)
-
-            this.$emit('update:menuObj',{
-                ...this.menuObj,
-                title:e.detail.value
-            })
-
-            this.$emit('selectSussess',{
-                select: e.detail.value,
-                selectItem: val
-            })
+            this.currentDateName = val.name;
+            this.$emit('selectDateFn',{selectTime:val.value})
         }
     }
 }
 </script>
-
 <style lang="scss" scoped>
 .select-bg_bx {
     .select-title {

+ 24 - 21
ghsApp/src/components/module/shopSelect.vue

@@ -1,7 +1,7 @@
 <template>
     <view class="select-bg_bx">
         <view v-if="isShowTit" @click="switchCut" :class="['select-title',dropdownShow?'select_corlor':'']">
-            <text>{{menuObjActive?menuObjActive:getMyShopInfo.shopName}}</text>
+            <text>{{showShopName!=''?showShopName:getMyShopInfo.shopName}}</text>
             <text v-if="placeholder" style="color: #ccc;">{{placeholder}}</text>
             <i v-if="isShowMore" class="iconfont iconsanjiao_xia"></i>
         </view>
@@ -12,10 +12,10 @@
         <view v-if="dropdownShow" :style="{top}" class="select-fixed_bx">
             <slot>
                 <view class="select-item-box">
-                    <view class="title">{{menuObj.titleChild}}</view>
+                    <view class="title">门店</view>
                     <view class="item-child_box">
-                        <button v-for="(item,index) in menuObj.list" :key="index" @click="changeItem(item)" 
-                        :class="['admin-button-com','mini-btn',selectItemId === item.id?'blue':'default']"> {{item.name}} </button>
+                        <button v-for="(item,index) in shopList" :key="index" @click="changeItem(item)" 
+                        :class="['admin-button-com','mini-btn','default']"> {{item.name}} </button>
                     </view>
                 </view>
             </slot>
@@ -24,25 +24,17 @@
 </template>
 <script>
 import DropdownList from "@/components/plugin/dropdown-list";
-import {mapGetters} from "vuex";
+import {mapGetters,mapState} from "vuex";
 export default {
     name:'DorpdownSelect',
     components:{
         DropdownList
     },
     props:{
-        menuObj:{
-            type: Object,
-            default: ()=>({ title:'门店', titleChild:'门店', list: [] })
-        },
         top:{
             type: String,
             default: 'auto'
         },
-        selectItemId:{
-            type:[String,Number],
-            default:''
-        },
         isShowTit:{
             type: Boolean,
             default: true
@@ -62,28 +54,39 @@ export default {
     },
     data(){
         return {
-            defaultPickerDate:['2019-01-01','2019-01-06'],
-            showPicker: false,
             dropdownShow: false,
             selectItem:'',
-            menuObjActive:'',
+            showShopName:'',
+            shopList:[]
         }
     },
     computed:{
-		...mapGetters(["getMyShopInfo"])
+		...mapGetters(["getMyShopInfo"]),
+        ...mapState({
+			userShopAll:state=>state.user.userShopAll
+        }),
     },
     mounted(){
+        this.shopList = this.userShopAll.map(i=>({...i,name:i.shopName}))
     },
+	watch:{
+        userShopAll (val) {
+			if(!this.$util.isEmpty(val)) {
+				this.shopList = val.map(i=>({
+					...i,
+					name:i.shopName
+				}));
+			}
+		}
+	},
     methods:{
         switchCut(){
             this.dropdownShow = !this.dropdownShow
         },
         changeItem(val){
-            this.$emit('update:selectItemId',val.id)
             this.dropdownShow = false;
-            this.$emit('update:menuObj',{ ...this.menuObj, title:val.name })
-            this.menuObjActive = val.name;
-            this.$emit('selectSussess',{ select: this.$util.isString(val)?val:val.name, selectItem: val })
+            this.showShopName = val.name;
+            this.$emit('selectShopFn',val)
         }
     }
 }