123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <a-card size="small" :bordered="false" class="chainStockIncomeReportList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form-model
- id="chainStockIncomeReportList-form"
- ref="ruleForm"
- class="form-model-con"
- layout="inline"
- :model="queryParam"
- :rules="rules"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- @keyup.enter.native="handelSearch" >
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="连锁店" prop="tenantId">
- <a-select
- placeholder="请选择连锁店"
- id="chainStockIncomeReportList-tenantId"
- allowClear
- v-model="queryParam.tenantId"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption">
- <a-select-option v-for="item in linkageGroupData" :id="item.dealerSn" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="入库完成时间" prop="time">
- <rangeDate id="chainStockIncomeReportList-time" ref="rangeDate" :value="queryParam.time" @change="dateChange" />
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="handelSearch" id="chainStockIncomeReportList-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" id="chainStockIncomeReportList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 列表 -->
- <a-row :gutter="15" style="margin-top: 50px;">
- <a-col :md="12" :sm="24">
- <div class="chart-box">
- <div class="chart-hj">
- 库存总入数量:{{ (totalData&&totalData.totalQty) ? toThousands(totalData.totalQty,0) : '--' }}
-
- 总成本:{{ (totalData&&totalData.totalCost) ? toThousands(totalData.totalCost) : '--' }}
- </div>
- <div id="con1" class="chart"></div>
- </div>
- </a-col>
- <a-col :md="12" :sm="24" style="margin-top: 30px;">
- <a-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.dataBizTypeDictValue"
- :columns="columns"
- :dataSource="tableData"
- :loading="listLoading"
- :pagination="false"
- bordered>
- </a-table>
- </a-col>
- </a-row>
- </a-spin>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import rangeDate from '@/views/common/rangeDate.vue'
- import echarts from 'echarts'
- import { reportStockPutList } from '@/api/reportStock'
- import { linkageGroupList } from '@/api/reportData'
- import { on, off } from '@/libs/tools'
- export default {
- components: { rangeDate },
- mixins: [commonMixin],
- data () {
- const _this = this
- return {
- spinning: false,
- queryParam: { // 查询条件
- time: [],
- beginDate: '',
- endDate: '',
- tenantId: undefined
- },
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- rules: {
- 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
- 'time': [{ required: true, message: '请选择入库完成时间', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- columns: [
- { title: '明细项', dataIndex: 'dataBizTypeDictValue', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '数量(件)', dataIndex: 'productQty', width: '25%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '成本(元)', dataIndex: 'productCost', width: '25%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '售价(元)', dataIndex: 'productPrice', width: '25%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
- ],
- // 统计图
- pieData: [],
- pieColor: ['#00aaff', '#ffaa00', '#00aa00', '#ff55ff', '#1dc5d4', '#8465c7', '#00ffff'],
- tableData: [], // 含总计数据
- loadData: [], // 不含总计数据
- listLoading: false, // loading
- chart1: null, // 图表对象
- totalData: null, // 统计
- linkageGroupData: [] // 连锁店下拉
- }
- },
- methods: {
- // 初始化饼图 title: 标题 data:数据 bit:单位
- initPie (chart, title, data, bit) {
- const legend = []
- if (bit) {
- data.map(item => {
- const p = `${item.name}: ${item.value}${bit}`
- legend.push(p)
- })
- }
- const option = {
- color: this.pieColor,
- title: {
- text: title,
- top: 20,
- left: 20,
- textStyle: {
- color: '#abd7ff'
- },
- textAlingn: 'left'
- },
- tooltip: {
- trigger: 'item',
- formatter: `{b} : {d}%`
- },
- legend: {
- orient: 'horizontal',
- left: 'center',
- bottom: '5',
- padding: 5,
- textStyle: {
- color: '#abd7ff',
- fontSize: 10
- },
- show: !!bit,
- formatter: function (name) {
- if (bit) {
- const p = data.find(item => item.name == name)
- return name + (p ? (':' + p.value + bit) : '')
- }
- }
- },
- series: [{
- type: 'pie',
- radius: ['50%', '70%'],
- startAngle: 75,
- top: 50,
- avoidLabelOverlap: true, // 在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠
- label: {
- normal: {
- formatter: params => {
- return (
- '{name|' + params.name + '}{value|' + params.percent + '%' + '}'
- )
- },
- padding: [0, -70, 25, -70],
- rich: {
- name: {
- fontSize: 12,
- padding: [0, 4, 0, 4],
- color: '#999'
- },
- value: {
- fontSize: 12,
- color: '#999'
- }
- }
- }
- },
- labelLine: {
- normal: {
- length: 20,
- length2: 70,
- lineStyle: {
- color: '#e6e6e6'
- }
- }
- },
- data: data,
- insideLabel: {
- show: true
- }
- }]
- }
- return option
- },
- // 时间 change
- dateChange (date) {
- this.queryParam.time = date
- this.queryParam.beginDate = date[0] || ''
- this.queryParam.endDate = date[1] || ''
- },
- // 查询
- handelSearch () {
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- this.getList()
- } else {
- return false
- }
- })
- },
- // 查询列表
- getList () {
- const params = {
- beginDate: this.queryParam.beginDate,
- endDate: this.queryParam.endDate,
- tenantId: this.queryParam.tenantId
- }
- // 开始查询
- this.listLoading = true
- this.spinning = true
- reportStockPutList(params).then(res => {
- this.listLoading = false
- if (res.status == 200 && res.data) {
- const reportStockPutVOList = (res.data && res.data.reportStockPutVOList) ? res.data.reportStockPutVOList : []
- const totalQty = (res.data && (res.data.totalQty || res.data.totalQty == 0)) ? res.data.totalQty : '--'
- const totalPrice = (res.data && (res.data.totalPrice || res.data.totalPrice == 0)) ? res.data.totalPrice : '--'
- const totalCost = (res.data && (res.data.totalCost || res.data.totalCost == 0)) ? res.data.totalCost : '--'
- this.totalData = {
- totalQty: totalQty,
- totalPrice: totalPrice,
- totalCost: totalCost
- }
- if (reportStockPutVOList) {
- this.loadData = res.data.reportStockPutVOList
- this.tableData = res.data.reportStockPutVOList
- const total = [{ dataBizTypeDictValue: '总入', productQty: totalQty, productCost: totalCost, productPrice: totalPrice }]
- this.tableData = [...this.tableData, ...total]
- } else {
- this.loadData = []
- this.tableData = []
- }
- this.chartInit()
- } else {
- this.loadData = []
- this.tableData = []
- this.totalData = null
- this.chartInit()
- }
- this.spinning = false
- })
- },
- // 图表初始化
- chartInit () {
- this.pieData = []
- if (this.loadData.length < 1) {
- this.pieData = [{ name: '总成本', value: 0 }]
- } else {
- this.loadData.map((item, index) => {
- if (index != this.loadData.length) {
- this.pieData.push({
- name: item.dataBizTypeDictValue + '总成本',
- value: item.productCost
- })
- }
- })
- }
- const con1 = document.getElementById('con1')
- const chart1 = echarts.init(con1)
- const option = this.initPie(chart1, '', this.pieData)
- chart1.setOption(option)
- this.chart1 = chart1
- this.chart1.resize()
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate.resetDate()
- this.queryParam.time = []
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.tenantId = undefined
- this.loadData = []
- this.tableData = []
- this.totalData = null
- this.chartInit()
- },
- // 连锁店筛选
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 连锁店
- getLinkageGroup () {
- linkageGroupList({}).then(res => {
- if (res.status == 200) {
- const data = res.data || []
- if (data.length > 0) {
- this.linkageGroupData = data
- } else {
- this.linkageGroupData = []
- }
- } else {
- this.linkageGroupData = []
- }
- })
- },
- chartResize () {
- this.chart1.resize()
- },
- pageInit () {
- this.getLinkageGroup()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- on(window, 'resize', this.chartResize)
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- },
- deactivated () {
- off(window, 'resize', this.chartResize)
- },
- beforeDestroy () {
- off(window, 'resize', this.chartResize)
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .chainStockIncomeReportList-wrap{
- min-height: 700px;
- .chart-box{
- height: 400px;
- .chart-hj{
- font-size: 22px;
- text-align: center;
- }
- .chart{
- width: 100%;
- height: 450px;
- overflow: auto;
- }
- }
- }
- </style>
|