StoreReport1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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-month-picker
  8. style="margin-left: 8px"
  9. :default-value="moment(defaultStartMonth, monthFormat)"
  10. :format="monthFormat"
  11. v-model="queryParam.startMonth"
  12. placeholder="开始月份"
  13. @change="onStartChange" />
  14. <a-month-picker
  15. style="margin-left: 8px"
  16. :default-value="moment(defaultEndMonth, monthFormat)"
  17. :format="monthFormat"
  18. v-model="queryParam.endMonth"
  19. placeholder="结束月份"
  20. @change="onEndChange" />
  21. <!-- <a-tree-select
  22. style="margin-left: 8px;width: 100%"
  23. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  24. :treeData="storeTreeData"
  25. :treeNodeFilterProp="'name'"
  26. :showSearch="true"
  27. v-decorator="['storeId']"
  28. v-model="queryParam.storeId"
  29. placeholder="仓库类型"
  30. >
  31. </a-tree-select>-->
  32. <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
  33. <a-button style="margin-left: 8px" type="primary" @click="handlePrint()">打印</a-button>
  34. <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
  35. </div>
  36. <a-tab-pane loading="true" tab="图形统计" key="1">
  37. <a-row>
  38. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  39. <div style="padding: 10px">
  40. <div id="container"></div>
  41. </div>
  42. </a-col>
  43. </a-row>
  44. </a-tab-pane>
  45. <a-tab-pane loading="true" tab="表格统计" key="2">
  46. <a-row>
  47. <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  48. <div style="padding: 10px">
  49. <a-table
  50. bordered
  51. :data-source="chartsData"
  52. :columns="columns"
  53. tableLayout="auto"
  54. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  55. rowKey="month">
  56. <span slot="action" slot-scope="record">
  57. <template>
  58. <a @click="handleView(record,1)">入库明细</a>
  59. <a-divider type="vertical" />
  60. <a @click="handleView(record,2)">出库明细</a>
  61. <a-divider type="vertical" />
  62. <a @click="doExportDetail(record,1)">导出入库明细</a>
  63. <a-divider type="vertical" />
  64. <a @click="doExportDetail(record,2)">导出出库明细</a>
  65. </template>
  66. </span>
  67. </a-table>
  68. </div>
  69. </a-col>
  70. </a-row>
  71. </a-tab-pane>
  72. </a-tabs>
  73. </div>
  74. </a-card>
  75. <print-in-store ref="basePrintModal" @ok="handleOk"/>
  76. <detail-in-store-report ref="inStoreModal" @ok="handleOk"/>
  77. <detail-out-store-report ref="outStoreModal" @ok="handleOk"/>
  78. </div>
  79. </template>
  80. <script>
  81. import { getStoreMonthReport, exportMonthReport1, exportMonthReportMonth1 } from '@/api/report/check-job'
  82. import { Chart } from '@antv/g2'
  83. import PrintInStore from '@/views/dashboard/modules/PrintInStoreInAndOutReport'
  84. import DetailCheckJobReport from '@/views/dashboard/modules/DetailCheckJobReport'
  85. import DetailInStoreReport from '@/views/dashboard/modules/DetailInStoreReport'
  86. import DetailOutStoreReport from '@/views/dashboard/modules/DetailOutStoreReport'
  87. import moment from 'moment'
  88. import { fetchStoreTree } from '@/api/store/store'
  89. export default {
  90. name: 'Analysis',
  91. components: {
  92. DetailOutStoreReport,
  93. DetailInStoreReport,
  94. PrintInStore,
  95. Chart,
  96. DetailCheckJobReport
  97. },
  98. props: {
  99. title: {
  100. type: String,
  101. default: '仓库出库入库数据月统计报表'
  102. }
  103. },
  104. data () {
  105. return {
  106. storeTreeData: [],
  107. queryParam: {
  108. startMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
  109. endMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-12-01',
  110. storeId: null,
  111. searchStartTime: null,
  112. searchEndTime: null,
  113. filter: this.filter
  114. },
  115. loading: false,
  116. serverData: [],
  117. sbLevelMap: {},
  118. treeData: [],
  119. monthFormat: 'YYYY-MM',
  120. defaultStartMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-01',
  121. defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR) + '-12',
  122. years: [],
  123. levelMap: {},
  124. visible: true,
  125. chart: null, // 创建一个chart变量
  126. chartsData: [],
  127. // 表头
  128. columns: [
  129. {
  130. title: '月份',
  131. width: 180,
  132. dataIndex: 'month'
  133. },
  134. {
  135. title: '入库数量',
  136. width: 120,
  137. dataIndex: 'inStoreNum'
  138. },
  139. {
  140. title: '出库数量',
  141. width: 120,
  142. dataIndex: 'outStoreNum'
  143. },
  144. {
  145. title: '入库金额',
  146. width: 120,
  147. dataIndex: 'inStorePrice',
  148. customRender: (text, record, index) => {
  149. return this.BaseTool.Amount.formatter(text)
  150. }
  151. },
  152. {
  153. title: '出库金额',
  154. width: 120,
  155. dataIndex: 'outStorePrice',
  156. customRender: (text, record, index) => {
  157. return this.BaseTool.Amount.formatter(text)
  158. }
  159. },
  160. {
  161. title: '操作',
  162. key: 'action',
  163. width: '200px',
  164. align: 'center',
  165. scopedSlots: { customRender: 'action' }
  166. }
  167. ]
  168. }
  169. },
  170. created () {
  171. this.tableOption()
  172. this.setTree()
  173. },
  174. mounted () {
  175. this.$nextTick(function () {
  176. this.getData()
  177. })
  178. },
  179. methods: {
  180. tableOption () {
  181. if (!this.optionAlertShow) {
  182. this.options = {
  183. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  184. rowSelection: {
  185. selectedRowKeys: this.selectedRowKeys,
  186. onChange: this.onSelectChange,
  187. getCheckboxProps: record => ({
  188. props: {
  189. disabled: true,
  190. name: record.id
  191. }
  192. })
  193. }
  194. }
  195. this.optionAlertShow = true
  196. } else {
  197. this.options = {
  198. alert: false,
  199. rowSelection: null
  200. }
  201. this.optionAlertShow = false
  202. }
  203. },
  204. setTree () {
  205. fetchStoreTree().then(res => {
  206. this.storeTreeData = res.data
  207. })
  208. },
  209. moment,
  210. changeLevel (value) {
  211. this.queryParam.standardLevel = value
  212. this.getData()
  213. },
  214. onStartChange (date, dateString) {
  215. this.$nextTick(() => {
  216. this.queryParam.startMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  217. })
  218. },
  219. onEndChange (date, dateString) {
  220. this.queryParam.endMonth = this.BaseTool.Date.formatter(dateString + '-01', this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  221. },
  222. getData () {
  223. if (this.queryParam.startMonth == null) {
  224. this.$message.error('请选择起始月份')
  225. return
  226. }
  227. if (this.queryParam.endMonth == null) {
  228. this.$message.error('请选择结束月份')
  229. return
  230. }
  231. for (var i = 0; i < this.storeTreeData.length; i++) {
  232. if (this.queryParam.storeId === this.storeTreeData[i].id) {
  233. alert('立体仓和货架没有数据')
  234. return
  235. }
  236. }
  237. getStoreMonthReport(this.queryParam)
  238. .then(res => {
  239. this.chartsData = res.data
  240. // 需要将数据分组:总数,完成数
  241. const groupData = []
  242. this.chartsData.forEach(function (data) {
  243. groupData.push({ name: '入库数量', month: data.month + '', num: data.inStoreNum })
  244. groupData.push({ name: '出库数量', month: data.month + '', num: data.outStoreNum })
  245. })
  246. this.getCharts('container', groupData)// 调用统计图
  247. })
  248. },
  249. getCharts (id, data) {
  250. this.chart && this.chart.destroy()// 防止点击搜索按钮新增一个
  251. this.chart = new Chart({
  252. container: 'container',
  253. autoFit: true,
  254. height: 400
  255. })
  256. this.chart.data(data)
  257. this.chart.scale('num', {
  258. nice: true
  259. })
  260. this.chart.tooltip({
  261. showMarkers: false,
  262. shared: true
  263. })
  264. this.chart.interval().position('month*num').color('name').adjust([
  265. {
  266. type: 'dodge',
  267. marginRatio: 0
  268. }
  269. ])
  270. this.chart.interaction('active-region')
  271. this.chart.legend({
  272. position: 'bottom'
  273. })
  274. this.chart.render()
  275. },
  276. doExport () {
  277. const parameter = {
  278. ...this.queryParam
  279. }
  280. exportMonthReport1(parameter).then(file => {
  281. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  282. })
  283. },
  284. doExportDetail (record, number) {
  285. const parameter = {
  286. ...this.queryParam,
  287. month: record.month,
  288. year: record.year,
  289. number: number
  290. }
  291. exportMonthReportMonth1(parameter).then(file => {
  292. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  293. })
  294. },
  295. handlePrint (record) {
  296. const modal = this.$refs.basePrintModal
  297. this.visible = false
  298. modal.base({ startMonth: this.queryParam.startMonth, endMonth: this.queryParam.endMonth, title: this.title, data: this.chartsData })
  299. },
  300. handleView (record, number) {
  301. let modal
  302. if (number === 1) {
  303. modal = this.$refs.inStoreModal
  304. } else {
  305. modal = this.$refs.outStoreModal
  306. }
  307. console.log(record)
  308. modal.base(record)
  309. },
  310. handleOk () {
  311. this.visible = true
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="less" scoped>
  317. .extra-wrapper {
  318. line-height: 55px;
  319. padding-right: 24px;
  320. .extra-item {
  321. display: inline-block;
  322. margin-right: 24px;
  323. a {
  324. margin-left: 24px;
  325. }
  326. }
  327. }
  328. .antd-pro-pages-dashboard-analysis-twoColLayout {
  329. position: relative;
  330. display: flex;
  331. display: block;
  332. flex-flow: row wrap;
  333. }
  334. .antd-pro-pages-dashboard-analysis-salesCard {
  335. height: calc(100% - 24px);
  336. /deep/ .ant-card-head {
  337. position: relative;
  338. }
  339. }
  340. .dashboard-analysis-iconGroup {
  341. i {
  342. margin-left: 16px;
  343. color: rgba(0,0,0,.45);
  344. cursor: pointer;
  345. transition: color .32s;
  346. color: black;
  347. }
  348. }
  349. .analysis-salesTypeRadio {
  350. position: absolute;
  351. right: 54px;
  352. bottom: 12px;
  353. }
  354. </style>