| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <template>
- <div class="div-box-new-margin">
- <div class="div-border-box" id="uninvoiceAmountFull">
- <div class="out">
- <div>
- <div class="div-line div-line-right"></div>
- <div class="title" style="min-width: 264px;">{{$t(`近12月出货未开票金额趋势分析`)}}</div>
- </div>
- <div class="in">
- <div class="inline-16 mt-10">
- <departmentSalesperson ref="departmentSalesperson" @depSelect="depSelect" @personSelect="personSelect" :isFull="isFull" :is-new-dep="true"></departmentSalesperson>
- </div>
- <div class="mt-10 inline-16">
- <p class="search__label">{{$t('状态')}}:</p>
- <el-select v-model="param.content.where.isleave" clearable style="margin-right:10px" size="small" :placeholder="$t('请选择状态')" @change="queryModel(param.content.dataid,param.content.where.isleave,'状态')" >
- <el-option :label="$t('在职')" value="1"></el-option>
- <el-option :label="$t('离职')" value="2"></el-option>
- </el-select>
- </div>
- <div class="mt-10 inline-15">
- <span class="search__label inline-16">{{$t('分析日期')}}:</span>
- <el-date-picker
- :append-to-body="!isFull"
- v-model="endDate"
- type="date"
- :clearable="false"
- @change="changeDate"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- size="small"
- :range-separator="$t('至')"
- :start-placeholder="$t('开始月份')"
- :end-placeholder="$t('结束月份')">
- </el-date-picker>
- </div>
- <fullScreen domId="uninvoiceAmountFull" @onFull="onFull" @backFull="backFull"></fullScreen>
- </div>
- </div>
- <div class="chart">
- <div id="uninvoiceAmountChart" :style="{height: heightChart}"></div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
- import fullScreen from "@/views/salesData/components/fullScreen";
- import { Line } from '@antv/g2plot';
- const seriesKey = 'series';
- const valueKey = 'value';
- const meta = {
- date: {
- alias: '日期',
- },
- zerotothree: {
- alias: '0-3月出货未开票金额(万元)',
- },
- threetosix: {
- alias: '3-6月出货未开票金额(万元)',
- },
- sixtotwelve:{
- alias: '6-12月出货未开票金额(万元)'
- },
- twelveup:{
- alias: '一年以上出货未开票金额(万元)'
- },
- };
- export default {
- name: "uninvoiceAmountAnalysis",
- props:['dataid','scrollHeight','windowWidth'],
- components:{departmentSalesperson,fullScreen},
- data(){
- return {
- chartLine:null,
- param:{
- "id": 20231016122504,
- "content": {
- "type": 0,
- "dataid": '',
- "enddate": "2023-09-21",
- "where":{
- "isleave":"1"
- }
- }
- },
- list:[],
- endDate:new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
- heightChart:'98%',
- isFull:false
- }
- },
- methods:{
- async listData(val){
- this.renderPie(val)
- },
- processData(data, yFields, meta) {
- const result = [];
- data.forEach((d) => {
- yFields.forEach((yField) => {
- const name = this.$t(meta?.[yField]?.alias || yField);
- result.push({ ...d, date: d.date, [seriesKey]: name, [valueKey]: d[yField] });
- });
- });
- return result;
- },
- /*图表更新*/
- async queryModel(val,isleave,state){
- if (state == '状态'){
- this.$refs.departmentSalesperson.person = ''
- this.param.content.type = 1
- this.param.content.dataid = this.$refs.departmentSalesperson.depmentid ? this.$refs.departmentSalesperson.depmentid : -1
- }else {
- this.param.content.dataid = val?val : this.dataid
- }
- this.param.content.enddate = this.endDate
- this.param.content.where.isleave = isleave
- const res = await this.$api.requested(this.param)
- this.list = res.data.map(item=>{
- let zerotothree = this.tool.unitConversion(item.zerotothree,10000)
- let threetosix = this.tool.unitConversion(item.threetosix,10000)
- let sixtotwelve = this.tool.unitConversion(item.sixtotwelve,10000)
- let twelveup = this.tool.unitConversion(item.twelveup,10000)
- return {
- "zerotothree":zerotothree,
- "threetosix":threetosix,
- "date":item.date,
- "sixtotwelve":sixtotwelve,
- "twelveup":twelveup,
- }
- })
- this.chartLine.changeData(this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup'], meta))
- state == '状态' ? this.personData(this.$refs.departmentSalesperson.depmentid ) : ''
- },
- renderPie(val){
- this.chartLine = new Line('uninvoiceAmountChart',{
- data:this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup',], meta),
- xField: 'date',
- yField: valueKey,
- seriesField: seriesKey,
- label:{
- layout: [],
- formatter: (datum) =>{
- return '¥' + this.tool.formatAmount(datum.value,2)
- }
- },
- smooth: true,
- tooltip: {
- formatter: (datum) => {
- return {
- name:datum.series,
- value:'¥'+this.tool.formatAmount(datum.value,2)
- }
- }
- }
- });
- this.chartLine.render();
- this.queryModel(val,this.param.content.where.isleave)
- },
- changeDate(){
- this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
- },
- /*选择部门*/
- depSelect(val){
- this.param.content.type = 1
- this.param.content.dataid = val?val:-1
- this.personData(this.param.content.dataid)
- this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
- },
- /*选择业务员*/
- personSelect(val){
- if (val || this.$refs.departmentSalesperson.depmentid){
- this.param.content.type = val?0:1
- this.param.content.dataid = val?val:this.$refs.departmentSalesperson.depmentid
- }else {
- this.param.content.type = 1
- this.param.content.dataid = -1
- }
- this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
- },
- /*获取新的业务员列表*/
- async personData(depid){
- let param = {
- id: 20230620102004,
- content: {
- isleave:this.param.content.where.isleave,
- depid:depid
- },
- }
- const res = await this.$api.requested(param)
- this.$refs.departmentSalesperson.personnelList = res.data.hr
- },
- /*全屏*/
- onFull(){
- this.heightChart = this.windowWidth > 1180 ?'calc(100vh - 85px)':'calc(100vh - 124px)'
- this.isFull = true
- },
- /*退出全屏*/
- backFull(val){
- this.heightChart = '98%'
- this.isFull = false
- this.$emit('backFull',val)
- }
- }
- }
- </script>
- <style scoped>
- </style>
|