Commit 6f256411 by 匡雅琴

饼图接口联调

1 parent 165aee7c
......@@ -50,6 +50,11 @@ const getUsedWarehousing = params => {
return window.$HTTP.get('solarfilm/getUsedWarehousing', params)
}
// 总体----获取商品采购进度占比
const getBugProgress = params => {
return window.$HTTP.get('solarfilm/getBugProgress', params)
}
export default {
getAllGoodsRatio,
getAllOpenBuyTrend,
......@@ -59,5 +64,6 @@ export default {
getMerchantGoodsRatio,
getMerchantPurchase,
getMerchantPurchaseTrend,
getUsedWarehousing
getUsedWarehousing,
getBugProgress
}
......@@ -11,7 +11,9 @@
<template v-else>
<div class="flex item-content">
<div v-show="itm.hasIcon">{{ itm.hasIcon }}</div>
<div>{{ itm.type == 'number' ? numAddSymbol(item[itm.name]) : item[itm.name] }}</div>
<div v-if="itm.type == 'number'">{{numAddSymbol(item[itm.name])}}</div>
<div v-else-if="itm.type == 'decimal'">{{toPercent(item[itm.name])}}</div>
<div v-else>{{ item[itm.name] }}</div>
</div>
</template>
</div>
......
......@@ -29,7 +29,7 @@ Date.prototype.format = function (fmt) {
const throttle = (fn, delay = 1000) => {
// 距离上一次的执行时间
let lastTime = 0
return function() {
return function () {
const _this = this
const _arguments = arguments
const now = new Date().getTime()
......@@ -134,6 +134,12 @@ const deepClone = obj => {
}
throw new Error("Unable to clone obj! Its type isn't supported.")
}
// 数字转百分数
const toPercent = num => {
let str = Number(num).toFixed(0)
str += '%'
return str
}
const utils = {
getParams,
getQuery,
......@@ -146,7 +152,8 @@ const utils = {
getNMonth,
debounce,
setChartFontSize,
deepClone
deepClone,
toPercent
}
Object.keys(utils).map(key => {
......
......@@ -47,6 +47,7 @@ export default {
this.openMessage('获取所有门店入库失败')
return
}
this.listData = res.data.dataList || []
})
}
}
......
......@@ -7,9 +7,10 @@
<script>
import RightViewContent from './RightViewContent.vue'
import { changeMixin } from '@/mixins'
export default {
name: 'PurchaseProgress',
mixins: [changeMixin],
components: {
RightViewContent
},
......@@ -19,37 +20,22 @@ export default {
// 采购进度饼图结构
progressChart: {
id: 'progress',
keys: ['isDelivery', 'price'],
keys: ['progress', 'purchaseamount'],
height: '15.34vh',
colors: ['#4FA0FF', '#7CFFB2', '#FDF006']
},
// 采购进度数据
progressData: [
{
isDelivery: '已发货',
per: 0.36,
price: 4568
},
{
isDelivery: '未发货',
per: 0.25,
price: 4568
},
{
isDelivery: '已入库',
per: 0.44,
price: 4568
}
],
progressData: [],
progressLegend: [
{
name: 'isDelivery'
name: 'progress'
},
{
name: 'per'
name: 'rate',
type: 'decimal'
},
{
name: 'price',
name: 'purchaseamount',
hasIcon: '¥',
type: 'number'
}
......@@ -61,9 +47,19 @@ export default {
methods: {
init() {
this.getBugProgress()
},
// 获取商品采购进度占比
getBugProgress() {
this.api.solar.getBugProgress({ year: 2023 }).then(res => {
console.log(res, '000')
if (!res.code === '0') {
this.openMessage('获取采购进度占比失败')
return
}
this.progressData = res.data.dataList || []
})
}
}
}
</script>
......
<template>
<div class="purchase-propertion-box">
<box-title title="商城采购额商品占比"></box-title>
<RightViewContent class="content-box" :chart="propertionChart" :listData="propertionData" :legentList="propertionLegend" :legendColors="propertionLegendColors"></RightViewContent>
<RightViewContent class="content-box" :chart="propertionChart" :listData="propertionData" :legentList="propertionLegend" :legendColors="propertionChart.colors"></RightViewContent>
</div>
</template>
<script>
import RightViewContent from './RightViewContent.vue'
import { changeMixin } from '@/mixins'
export default {
name: 'PurchasePropertion',
mixins: [changeMixin],
components: {
RightViewContent
},
......@@ -19,74 +20,51 @@ export default {
// 采购占比饼图结构
propertionChart: {
id: 'propertion',
keys: ['name', 'per'],
keys: ['goodsname', 'purchaseamount'],
height: '15.34vh',
colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001']
},
// 采购占比数据
propertionData: [
{
name: '商品1',
per: 0.36,
price: 4568,
averagePrice: 668
},
{
name: '商品2',
per: 0.2,
price: 4568,
averagePrice: 668
},
{
name: '商品3',
per: 0.16,
price: 4568,
averagePrice: 668
},
{
name: '品1发货',
per: 0.1,
price: 4568,
averagePrice: 668
},
{
name: '商品5',
per: 0.09,
price: 4568,
averagePrice: 668
},
{
name: '商品6',
per: 0.09,
price: 4568,
averagePrice: 668
}
],
propertionData: [],
propertionLegend: [
{
name: 'name'
name: 'goodsname'
},
{
name: 'per'
},
{
name: 'price',
name: 'purchaseamount',
hasIcon: '¥',
type: 'number'
},
{
name: 'averagePrice',
name: 'averprice',
hasIcon: '均价¥',
type: 'number'
}
],
propertionLegendColors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001']
}
},
mounted() {},
methods: {}
methods: {
init() {
this.getAllGoodsRatio()
},
// 获取商品采购占比
getAllGoodsRatio() {
this.api.solar.getAllGoodsRatio({ year: 2023 }).then(res => {
console.log(res, '000')
if (!res.code === '0') {
this.openMessage('获取商品采购占比失败')
return
}
this.propertionData = res.data.dataList[0].shopgoodsRatioList || []
})
}
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!