uninvoiceAmountAnalysis.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="div-box-new-margin">
  3. <div class="div-border-box" id="uninvoiceAmountFull">
  4. <div class="out">
  5. <div>
  6. <div class="div-line div-line-right"></div>
  7. <div class="title" style="min-width: 264px;">{{$t(`近12月出货未开票金额趋势分析`)}}</div>
  8. </div>
  9. <div class="in">
  10. <div class="inline-16 mt-10">
  11. <departmentSalesperson ref="departmentSalesperson" @depSelect="depSelect" @personSelect="personSelect" :isFull="isFull" :is-new-dep="true"></departmentSalesperson>
  12. </div>
  13. <div class="mt-10 inline-16">
  14. <p class="search__label">{{$t('状态')}}:</p>
  15. <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,'状态')" >
  16. <el-option :label="$t('在职')" value="1"></el-option>
  17. <el-option :label="$t('离职')" value="2"></el-option>
  18. </el-select>
  19. </div>
  20. <div class="mt-10 inline-15">
  21. <span class="search__label inline-16">{{$t('分析日期')}}:</span>
  22. <el-date-picker
  23. :append-to-body="!isFull"
  24. v-model="endDate"
  25. type="date"
  26. :clearable="false"
  27. @change="changeDate"
  28. format="yyyy-MM-dd"
  29. value-format="yyyy-MM-dd"
  30. size="small"
  31. :range-separator="$t('至')"
  32. :start-placeholder="$t('开始月份')"
  33. :end-placeholder="$t('结束月份')">
  34. </el-date-picker>
  35. </div>
  36. <fullScreen domId="uninvoiceAmountFull" @onFull="onFull" @backFull="backFull"></fullScreen>
  37. </div>
  38. </div>
  39. <div class="chart">
  40. <div id="uninvoiceAmountChart" :style="{height: heightChart}"></div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
  47. import fullScreen from "@/views/salesData/components/fullScreen";
  48. import { Line } from '@antv/g2plot';
  49. const seriesKey = 'series';
  50. const valueKey = 'value';
  51. const meta = {
  52. date: {
  53. alias: '日期',
  54. },
  55. zerotothree: {
  56. alias: '0-3月出货未开票金额(万元)',
  57. },
  58. threetosix: {
  59. alias: '3-6月出货未开票金额(万元)',
  60. },
  61. sixtotwelve:{
  62. alias: '6-12月出货未开票金额(万元)'
  63. },
  64. twelveup:{
  65. alias: '一年以上出货未开票金额(万元)'
  66. },
  67. };
  68. export default {
  69. name: "uninvoiceAmountAnalysis",
  70. props:['dataid','scrollHeight','windowWidth'],
  71. components:{departmentSalesperson,fullScreen},
  72. data(){
  73. return {
  74. chartLine:null,
  75. param:{
  76. "id": 20231016122504,
  77. "content": {
  78. "type": 0,
  79. "dataid": '',
  80. "enddate": "2023-09-21",
  81. "where":{
  82. "isleave":"1"
  83. }
  84. }
  85. },
  86. list:[],
  87. endDate:new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
  88. heightChart:'98%',
  89. isFull:false
  90. }
  91. },
  92. methods:{
  93. async listData(val){
  94. this.renderPie(val)
  95. },
  96. processData(data, yFields, meta) {
  97. const result = [];
  98. data.forEach((d) => {
  99. yFields.forEach((yField) => {
  100. const name = this.$t(meta?.[yField]?.alias || yField);
  101. result.push({ ...d, date: d.date, [seriesKey]: name, [valueKey]: d[yField] });
  102. });
  103. });
  104. return result;
  105. },
  106. /*图表更新*/
  107. async queryModel(val,isleave,state){
  108. if (state == '状态'){
  109. this.$refs.departmentSalesperson.person = ''
  110. this.param.content.type = 1
  111. this.param.content.dataid = this.$refs.departmentSalesperson.depmentid ? this.$refs.departmentSalesperson.depmentid : -1
  112. }else {
  113. this.param.content.dataid = val?val : this.dataid
  114. }
  115. this.param.content.enddate = this.endDate
  116. this.param.content.where.isleave = isleave
  117. const res = await this.$api.requested(this.param)
  118. this.list = res.data.map(item=>{
  119. let zerotothree = this.tool.unitConversion(item.zerotothree,10000)
  120. let threetosix = this.tool.unitConversion(item.threetosix,10000)
  121. let sixtotwelve = this.tool.unitConversion(item.sixtotwelve,10000)
  122. let twelveup = this.tool.unitConversion(item.twelveup,10000)
  123. return {
  124. "zerotothree":zerotothree,
  125. "threetosix":threetosix,
  126. "date":item.date,
  127. "sixtotwelve":sixtotwelve,
  128. "twelveup":twelveup,
  129. }
  130. })
  131. this.chartLine.changeData(this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup'], meta))
  132. state == '状态' ? this.personData(this.$refs.departmentSalesperson.depmentid ) : ''
  133. },
  134. renderPie(val){
  135. this.chartLine = new Line('uninvoiceAmountChart',{
  136. data:this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup',], meta),
  137. xField: 'date',
  138. yField: valueKey,
  139. seriesField: seriesKey,
  140. label:{
  141. layout: [],
  142. formatter: (datum) =>{
  143. return '¥' + this.tool.formatAmount(datum.value,2)
  144. }
  145. },
  146. smooth: true,
  147. tooltip: {
  148. formatter: (datum) => {
  149. return {
  150. name:datum.series,
  151. value:'¥'+this.tool.formatAmount(datum.value,2)
  152. }
  153. }
  154. }
  155. });
  156. this.chartLine.render();
  157. this.queryModel(val,this.param.content.where.isleave)
  158. },
  159. changeDate(){
  160. this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
  161. },
  162. /*选择部门*/
  163. depSelect(val){
  164. this.param.content.type = 1
  165. this.param.content.dataid = val?val:-1
  166. this.personData(this.param.content.dataid)
  167. this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
  168. },
  169. /*选择业务员*/
  170. personSelect(val){
  171. if (val || this.$refs.departmentSalesperson.depmentid){
  172. this.param.content.type = val?0:1
  173. this.param.content.dataid = val?val:this.$refs.departmentSalesperson.depmentid
  174. }else {
  175. this.param.content.type = 1
  176. this.param.content.dataid = -1
  177. }
  178. this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
  179. },
  180. /*获取新的业务员列表*/
  181. async personData(depid){
  182. let param = {
  183. id: 20230620102004,
  184. content: {
  185. isleave:this.param.content.where.isleave,
  186. depid:depid
  187. },
  188. }
  189. const res = await this.$api.requested(param)
  190. this.$refs.departmentSalesperson.personnelList = res.data.hr
  191. },
  192. /*全屏*/
  193. onFull(){
  194. this.heightChart = this.windowWidth > 1180 ?'calc(100vh - 85px)':'calc(100vh - 124px)'
  195. this.isFull = true
  196. },
  197. /*退出全屏*/
  198. backFull(val){
  199. this.heightChart = '98%'
  200. this.isFull = false
  201. this.$emit('backFull',val)
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped>
  207. </style>