CheckJobReportWeek.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="page-header-index-wide">
  3. <a-card title="保养任务周工作负荷统计报表" :loading="loading" v-show="visible" :bordered="false" :body-style="{padding: '0'}">
  4. <div class="salesCard">
  5. <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
  6. <div class="extra-wrapper" slot="tabBarExtraContent">
  7. <a-button type="primary" icon="printer" @click="handlePrint()">打印</a-button>
  8. <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
  9. <a-select style="margin-left: 8px" @change="changeYear" v-model="queryParam.year" placeholder="请选择">
  10. <a-select-option
  11. v-for="item in years"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value">{{ item.label }}
  15. </a-select-option>
  16. </a-select>
  17. <a-select style="margin-left: 8px" @change="changeLevel" v-model="queryParam.standardLevel" placeholder="请选择">
  18. <a-select-option
  19. v-for="(label,value) in levelMap"
  20. :key="value"
  21. :label="label"
  22. :value="parseInt(value)">{{ label }}
  23. </a-select-option>
  24. </a-select>
  25. </div>
  26. <a-tab-pane loading="true" tab="图形统计" key="1">
  27. <a-row>
  28. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  29. <div style="padding: 10px">
  30. <div id="container"></div>
  31. </div>
  32. </a-col>
  33. </a-row>
  34. </a-tab-pane>
  35. <a-tab-pane loading="true" tab="表格统计" key="2">
  36. <a-row>
  37. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  38. <div style="padding: 10px">
  39. <a-table
  40. bordered
  41. :data-source="chartsData"
  42. :columns="columns"
  43. tableLayout="auto"
  44. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  45. rowKey="month">
  46. </a-table>
  47. </div>
  48. </a-col>
  49. </a-row>
  50. </a-tab-pane>
  51. </a-tabs>
  52. </div>
  53. </a-card>
  54. <print-in-check-job-report-week ref="basePrintModal" @ok="handleOk"/>
  55. </div>
  56. </template>
  57. <script>
  58. import { getWeekReport, exportWeekReport } from '@/api/report/check-job'
  59. import { Chart } from '@antv/g2'
  60. import PrintInCheckJobReportWeek from '@/views/dashboard/modules/PrintInCheckJobReportWeek'
  61. export default {
  62. name: 'Analysis',
  63. components: {
  64. PrintInCheckJobReportWeek,
  65. Chart
  66. },
  67. data () {
  68. return {
  69. loading: false,
  70. serverData: [],
  71. queryParam: {
  72. year: 2021,
  73. standardLevel: 2
  74. },
  75. years: [],
  76. levelMap: {},
  77. visible: true,
  78. chart: null, // 创建一个chart变量
  79. chartsData: [],
  80. // 表头
  81. columns: [
  82. {
  83. title: '周',
  84. width: 180,
  85. dataIndex: 'week'
  86. },
  87. {
  88. title: '保养标准工时',
  89. width: 120,
  90. dataIndex: 'totalHours'
  91. }
  92. ]
  93. }
  94. },
  95. created () {
  96. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  97. this.initSelectYear()
  98. },
  99. mounted () {
  100. this.changeYear(this.queryParam.year)
  101. },
  102. methods: {
  103. initSelectYear () {
  104. var myDate = new Date()
  105. this.queryParam.year = myDate.getFullYear()// 获取当前年
  106. this.years = []
  107. for (let i = 0; i < 5; i++) {
  108. this.years.push({ value: (this.queryParam.year - i), label: (this.queryParam.year - i) + '年' })
  109. }
  110. },
  111. changeYear (value) {
  112. this.queryParam.year = value
  113. getWeekReport(this.queryParam)
  114. .then(res => {
  115. this.chartsData = res.data
  116. // 需要将数据分组:总数,完成数
  117. /* const groupData = []
  118. this.chartsData.forEach(function (data) {
  119. groupData.push({ name: '总数', month: data.month, num: data.totalNum })
  120. groupData.push({ name: '完成数', month: data.month, num: data.totalFinishNum })
  121. }) */
  122. this.getCharts('container', this.chartsData)// 调用统计图
  123. })
  124. },
  125. changeLevel (value) {
  126. this.queryParam.standardLevel = value
  127. getWeekReport(this.queryParam)
  128. .then(res => {
  129. this.chartsData = res.data
  130. this.getCharts('container', this.chartsData)// 调用统计图
  131. })
  132. },
  133. getCharts (id, data) {
  134. this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
  135. this.chart = new Chart({
  136. container: 'container',
  137. autoFit: true,
  138. height: 400
  139. })
  140. this.chart.data(data)
  141. this.chart.scale('totalHours', {
  142. nice: true
  143. })
  144. this.chart.tooltip({
  145. showMarkers: false,
  146. shared: true
  147. })
  148. this.chart.interval().position('week*totalHours')
  149. this.chart.interaction('active-region')
  150. this.chart.legend({
  151. position: 'bottom'
  152. })
  153. this.chart.render()
  154. },
  155. doExport () {
  156. const parameter = {
  157. ...this.queryParam
  158. }
  159. exportWeekReport(parameter).then(file => {
  160. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  161. })
  162. },
  163. handlePrint (record) {
  164. const modal = this.$refs.basePrintModal
  165. this.visible = false
  166. modal.base({ year: this.queryParam.year, data: this.chartsData })
  167. },
  168. handleOk () {
  169. this.visible = true
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="less" scoped>
  175. .extra-wrapper {
  176. line-height: 55px;
  177. padding-right: 24px;
  178. .extra-item {
  179. display: inline-block;
  180. margin-right: 24px;
  181. a {
  182. margin-left: 24px;
  183. }
  184. }
  185. }
  186. .antd-pro-pages-dashboard-analysis-twoColLayout {
  187. position: relative;
  188. display: flex;
  189. display: block;
  190. flex-flow: row wrap;
  191. }
  192. .antd-pro-pages-dashboard-analysis-salesCard {
  193. height: calc(100% - 24px);
  194. /deep/ .ant-card-head {
  195. position: relative;
  196. }
  197. }
  198. .dashboard-analysis-iconGroup {
  199. i {
  200. margin-left: 16px;
  201. color: rgba(0,0,0,.45);
  202. cursor: pointer;
  203. transition: color .32s;
  204. color: black;
  205. }
  206. }
  207. .analysis-salesTypeRadio {
  208. position: absolute;
  209. right: 54px;
  210. bottom: 12px;
  211. }
  212. </style>