Browse Source

花材销量

shish 2 years ago
parent
commit
795a52623b

+ 2 - 0
ghs/src/cool/request/index.js

@@ -35,6 +35,7 @@ import product from '@/service/product/index';
 import ptItemClass from '@/service/pt-item-class/index';
 import ghsItemClass from '@/service/ghs-item-class/index';
 import statBook from '@/service/stat-book/index';
+import statItem from '@/service/stat-item/index';
 import stat from '@/service/stat/index';
 import ghs from '@/service/ghs/index';
 import cg from '@/service/cg/index';
@@ -48,6 +49,7 @@ export function SET_SERVICE({ store }) {
 	// const ignore = ['./request.js'];
 
 	let modules = {
+		statItem,
 		modify,
 		customBalanceChange,
 		purchaseOrderItem,

+ 2 - 1
ghs/src/mock/userInfo.js

@@ -187,7 +187,8 @@ let menu = {
 		{id: '1201',parentId: '12',name: '收入明细',type: 1,icon: 'icondingdanguanli',orderNum: 12,router: '/assets/list',viewPath: 'views/assets/list.vue',keepAlive: 1},
 		{id: '1202',parentId: '12',name: '支出明细',type: 1,icon: 'icondingdanguanli',orderNum: 12,router: '/assets/expendList',viewPath: 'views/assets/expendList.vue',keepAlive: 1},
 		{id: '1203',parentId: '12',name: '收支分类',type: 1,icon: 'icondingdanguanli',orderNum: 12,router: '/assets/incomeClass',viewPath: 'views/assets/incomeClass.vue',keepAlive: 1},
-		
+		{id: '1205',parentId: '12',name: '花材销量',type: 1,icon: 'icondingdanguanli',orderNum: 12,router: '/assets/itemSale',viewPath: 'views/assets/itemSale.vue',keepAlive: 1},
+
 		{id: '13',parentId: null,name: '设置',type: 0,icon: 'iconshezhi',orderNum: 12,router: '/goods/list',viewPath: 'views/goods/goods-list.vue',keepAlive: 1},
 		{id: '1301',parentId: '13',name: '密码设置',type: 1,icon: 'iconkehuguanli',orderNum: 12,router: '/setting/set-password',viewPath: 'views/setting/set-password.vue',keepAlive: 1}
 	]

+ 13 - 0
ghs/src/service/stat-item/index.js

@@ -0,0 +1,13 @@
+import { BaseService, Service } from '@/cool';
+@Service('stat-item')
+export class StatItemService extends BaseService {
+
+	getShow(data) {
+		return this.request({
+			url: '/show',
+			params: data
+		});
+	}
+
+}
+export default new StatItemService();

+ 157 - 0
ghs/src/views/assets/itemSale.vue

@@ -0,0 +1,157 @@
+<template>
+	<div class="shop-list">
+		<x-crud @load="onLoad">
+			<template #slot-date-select>
+                <el-date-picker v-model="currentDateList" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" @change="getDate" value-format="yyyy-MM-dd"
+                end-placeholder="结束日期" :picker-options="pickerOptions" size="mini"> </el-date-picker>
+			</template>
+			<template #slot-export-due>
+				<el-button type="primary" size="mini" style="margin-left:60px;" @click="exportData()">导出数据</el-button>
+			</template>
+
+            <template #slot-total-amount>
+				<span style="font-size:15px;font-weight:bold;">{{totalNum}} 笔 ¥{{ totalAmount }} 总毛利 {{ totalMl }}</span>
+			</template>
+
+			<template #table-column-mll="{scope}">
+				<span>{{ scope.row.mll }}%</span>
+        	</template>
+			
+		</x-crud>
+	</div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+export default {
+	data() {
+		return {
+			crud: null,
+            pickerOptions: {
+				shortcuts: [{
+					text: '最近一周',
+					onClick(picker) {
+					const end = new Date();
+					const start = new Date();
+					start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+					picker.$emit('pick', [start, end]);
+					}
+				}, {
+					text: '最近一个月',
+					onClick(picker) {
+					const end = new Date();
+					const start = new Date();
+					start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+					picker.$emit('pick', [start, end]);
+					}
+				}, {
+					text: '最近三个月',
+					onClick(picker) {
+					const end = new Date();
+					const start = new Date();
+					start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+					picker.$emit('pick', [start, end]);
+					}
+				}]
+            },
+            currentDateList:'',
+            startTime:'',
+            endTime:'',
+            searchTime:'',
+            totalAmount:0,
+			totalNum:0,
+			totalMl:0
+		}
+	},
+	computed: {
+		...mapGetters(['shopInfo']),
+	},
+	methods: {
+		exportData(){
+			this.$service.statItem.getShow({searchTime:this.searchTime,startTime:this.startTime,endTime:this.endTime,export:1}).then(res => {
+				if(res.file){
+					window.location.href = res.file
+				}
+			})
+		},
+		onLoad({ ctx, app }) {
+                this.app = app;
+                ctx.service({
+                    page: () => {
+                        return this.$service.statItem.getShow({searchTime:this.searchTime,startTime:this.startTime,endTime:this.endTime}).then((res) => {
+							this.totalAmount = res.totalAmount||0
+							this.totalMl = res.totalMl||0
+							this.totalNum = res.totalNum||0
+							let list = [...res.list]
+                            return {
+                                list: list
+                            };
+                        });
+                    }
+                })
+				.set('table', {
+					columns: [
+						{
+							label: '名称',
+							prop: 'name',
+							align: 'center',
+						},
+						{
+							label: '总数量',
+							prop: 'num',
+							align: 'center',
+						},
+						{
+							label: '总金额',
+							prop: 'amount',
+							align: 'center',
+						},
+						{
+							label: '毛利',
+							prop: 'gross',
+							align: 'center',
+						},
+						{
+							label: '毛利率',
+							prop: 'mll',
+							align: 'center',
+						}
+					],
+					op: {
+						visible: true,
+						props: {
+							width: 250,
+							align: 'center',
+							fixed: 'right',
+							label: '操作'
+						},
+						layout: []
+					}
+				})
+				.set('layout', [
+					[   'slot-date-select',
+                        'slot-order-debt',
+						'flex1',
+                        'slot-export-due',
+						'refresh-btn',
+					],
+					[ 'data-table' ],
+                    ['slot-total-amount','flex1']
+				])
+				.done();
+			    app.refresh();
+		},
+        getDate(){
+            this.searchTime = 'custom'
+            this.startTime = this.currentDateList[0]
+            this.endTime = this.currentDateList[1]
+            this.app.refresh({searchTime:this.searchTime,startTime:this.startTime,endTime:this.endTime});
+        }
+	},
+};
+</script>
+
+<style lang="stylus" scoped>
+.shop-list {
+  height: 100%;
+}
+</style>