interior-statistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <!-- 订单内部统计表-->
  3. <div id="interiorStatistics">
  4. <!-- 查询区域 -->
  5. <a-card :bordered="false">
  6. <div class="table-page-search-wrapper">
  7. <a-form layout="inline" @keyup.enter.native="searchQuery">
  8. <a-row :gutter="24">
  9. <a-col :md="6" :sm="8">
  10. <a-form-item label="起始年月">
  11. <a-range-picker
  12. style="width: 100%"
  13. :placeholder="['开始年月', '结束年月']"
  14. format="YYYY-MM"
  15. :mode="mode2"
  16. :value="value"
  17. @panelChange="handlePanelChange"
  18. @change="monthChange"
  19. required
  20. />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="8">
  24. <a-form-item label="部门">
  25. <a-input placeholder="请输入部门" v-model="queryParam.department" required></a-input>
  26. <!-- <a-select placeholder="请选择部门" v-model="queryParam.">
  27. <a-select-option :value="''">请选择</a-select-option>
  28. <a-select-option :value="0">业务一部</a-select-option>
  29. <a-select-option :value="1">业务二部</a-select-option>
  30. </a-select> -->
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="8">
  34. <a-form-item label="客户">
  35. <a-input placeholder="请输入客户" v-model="queryParam.customer"></a-input>
  36. </a-form-item>
  37. </a-col>
  38. <template v-if="toggleSearchStatus"></template>
  39. <a-col :md="6" :sm="8">
  40. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  41. <a-button type="primary" @click="searchQuery" :disabled="isDisabled" icon="search">查询</a-button>
  42. <a-button
  43. type="primary"
  44. @click="searchReset"
  45. :disabled="isDisabled"
  46. icon="reload"
  47. style="margin-left: 8px"
  48. >重置</a-button
  49. >
  50. <a @click="handleToggleSearch" style="margin-left: 8px">
  51. {{ toggleSearchStatus ? '收起' : '展开' }}
  52. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  53. </a>
  54. </span>
  55. </a-col>
  56. </a-row>
  57. </a-form>
  58. </div>
  59. </a-card>
  60. <!-- 引入 echarts -->
  61. <a-card :bordered="false" style="marginTop:10px;">
  62. <div class="chart">
  63. <!-- 部门 -->
  64. <div class="depChartStyle" style="background:rgba(255, 165, 0,.09);">
  65. <departmentChart ref="departmentChart" />
  66. </div>
  67. <!-- 客户 -->
  68. <div class="cusChartStyle" style="background:rgba(134, 151, 201,.08);">
  69. <customerChart ref="customerChart" />
  70. </div>
  71. </div>
  72. </a-card>
  73. <!-- table -->
  74. <a-card :bordered="false" style="marginTop:10px;">
  75. <a-table
  76. v-if="data"
  77. bordered
  78. rowKey="index"
  79. :columns="columns"
  80. :data-source="data"
  81. :loading="loading"
  82. :pagination="pagination"
  83. @change="handleTableChange"
  84. >
  85. </a-table>
  86. </a-card>
  87. </div>
  88. </template>
  89. <script>
  90. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  91. import JEllipsis from '@/components/jeecg/JEllipsis'
  92. import moment from 'moment'
  93. import departmentChart from '@views/reportForms/order-statistics/chart/interior/departmentChart'
  94. import customerChart from '@views/reportForms/order-statistics/chart/interior/customerChart.vue'
  95. import { externalList } from '@api/reportForms/order-statistics.js'
  96. export default {
  97. name: 'InteriorStatistics', // 订单内部统计表
  98. mixins: [JeecgListMixin],
  99. components: { JEllipsis, moment, departmentChart, customerChart },
  100. data() {
  101. // let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  102. return {
  103. description: '订单内部统计表',
  104. columns: [
  105. {
  106. title: '序号',
  107. width: 90,
  108. dataIndex: 'index',
  109. key: 'index',
  110. customRender: (text, record, index) => `${index + 1}`,
  111. className: 'replacecolor'
  112. },
  113. {
  114. title: '部门',
  115. width: 140,
  116. dataIndex: 'cdepName',
  117. className: 'replacecolor'
  118. },
  119. {
  120. title: '供应商分类',
  121. width: 120,
  122. dataIndex: 'ccusCode',
  123. className: 'replacecolor'
  124. // customRender: function(text) {
  125. // if (text == '1') {
  126. // return '销售类型1'
  127. // }
  128. // if (text == '2') {
  129. // return '销售类型2'
  130. // }
  131. // if (text == '3') {
  132. // return '销售类型3'
  133. // }
  134. // if (text == '4') {
  135. // return '销售类型4'
  136. // }
  137. // }
  138. },
  139. {
  140. title: '供应商',
  141. width: 140,
  142. dataIndex: 'cvenAbbName',
  143. className: 'replacecolor'
  144. },
  145. {
  146. title: '计划到货月份',
  147. width: 120,
  148. dataIndex: 'yearMonth',
  149. customRender: text => {
  150. return moment(text).format('YYYY-MM')
  151. },
  152. className: 'replacecolor'
  153. },
  154. { title: '含税单价', width: 120, dataIndex: 'inatUnitPrice', className: 'replacecolor' },
  155. {
  156. title: '实际数量',
  157. width: 120,
  158. dataIndex: 'iquantity',
  159. className: 'replacecolor'
  160. },
  161. { title: '本币金额', width: 150, dataIndex: 'inatMoney', className: 'replacecolor' }
  162. ],
  163. data: [],
  164. loading: false, // 表格加载
  165. // 查询条件
  166. queryParam: {
  167. vendorType: '内部'
  168. // pageNo: '',
  169. // startYearMonth: '',
  170. // endYearMonth: '',
  171. // department: '',
  172. // customer: ''
  173. },
  174. pagination: {
  175. // total: '', //总条数
  176. // current: '', //当前页
  177. // pageSize: '' //一页多少
  178. },
  179. mode2: ['month', 'month'],
  180. value: [], //起始月份
  181. isDisabled: false, //按钮禁止
  182. monthFormat: 'YYYY-MM'
  183. // dateFormat: 'YYYY-MM-DD'
  184. }
  185. },
  186. mounted() {},
  187. created() {
  188. // 初次加载当月数据
  189. this.getThisMonthData()
  190. },
  191. methods: {
  192. // 初次加载当月数据(列表、图)
  193. getThisMonthData() {
  194. this.$nextTick(() => {
  195. let nowDate = new Date()
  196. let date = {
  197. year: nowDate.getFullYear(),
  198. month: nowDate.getMonth() + 1
  199. }
  200. if (date.month >= 1 && date.month <= 9) {
  201. date.month = '0' + date.month
  202. }
  203. var time = date.year + '-' + date.month
  204. this.queryParam.startYearMonth = time
  205. this.queryParam.endYearMonth = time
  206. this.queryParam.vendorType = '内部'
  207. externalList(this.queryParam).then(res => {
  208. // 参数给 chart
  209. this.$refs.departmentChart.queryParam = this.queryParam
  210. this.$refs.customerChart.queryParam = this.queryParam
  211. // console.log('????', this.$refs.departmentChart.queryParam)
  212. if (res.success) {
  213. this.data = res.result.records
  214. console.log('订单内部列表', this.data)
  215. this.pagination = {
  216. total: res.result.total,
  217. current: res.result.current,
  218. pageSize: res.result.size
  219. }
  220. }
  221. })
  222. })
  223. },
  224. // 查询订单统计
  225. getExternalData() {
  226. this.$nextTick(() => {
  227. this.queryParam.vendorType = '内部'
  228. externalList(this.queryParam).then(res => {
  229. // 参数给 chart
  230. this.$refs.departmentChart.queryParam = this.queryParam
  231. this.$refs.customerChart.queryParam = this.queryParam
  232. if (res.success) {
  233. this.data = res.result.records
  234. console.log('订单内部列表', this.data)
  235. this.pagination = {
  236. total: res.result.total,
  237. current: res.result.current,
  238. pageSize: res.result.size
  239. }
  240. }
  241. })
  242. })
  243. },
  244. searchQuery() {
  245. this.queryParam.pageNo = ''
  246. if (this.queryParam) {
  247. // 清空部门chart数据
  248. this.$refs.departmentChart.cdepNameArr = []
  249. this.$refs.departmentChart.iquantityArr = []
  250. this.$refs.departmentChart.inatMoneyArr = []
  251. // 清空客户chart数据
  252. this.$refs.customerChart.ccusNameArr = []
  253. this.$refs.customerChart.iquantityArr = []
  254. this.$refs.customerChart.inatMoneyArr = []
  255. this.getExternalData()
  256. //查询条件 传给 部门chart + 渲染
  257. this.$refs.departmentChart.queryParam = this.queryParam
  258. this.$refs.departmentChart.getDepChartData()
  259. //查询条件 传给 客户chart + 渲染
  260. this.$refs.customerChart.queryParam = this.queryParam
  261. this.$refs.customerChart.getCusChartData()
  262. }
  263. this.isDisabled = true
  264. setTimeout(() => {
  265. let that = this
  266. that.isDisabled = false
  267. }, 3000)
  268. },
  269. searchReset() {
  270. this.queryParam = {}
  271. this.value = [] //起始年月重置
  272. this.queryParam.startYearMonth = []
  273. this.queryParam.endYearMonth = []
  274. // 清空部门chart数据 + 查询条件 + 重新渲染
  275. this.$refs.departmentChart.cdepNameArr = []
  276. this.$refs.departmentChart.iquantityArr = []
  277. this.$refs.departmentChart.inatMoneyArr = []
  278. this.$refs.departmentChart.queryParam = {}
  279. this.$refs.departmentChart.getDepChartData()
  280. // 清空客户chart数据 + 查询条件 + 重新渲染
  281. this.$refs.customerChart.ccusNameArr = []
  282. this.$refs.customerChart.iquantityArr = []
  283. this.$refs.customerChart.inatMoneyArr = []
  284. this.$refs.customerChart.queryParam = {}
  285. this.$refs.customerChart.getCusChartData()
  286. // 重新渲染列表数据
  287. this.getExternalData()
  288. // 按钮置灰
  289. this.isDisabled = true
  290. setTimeout(() => {
  291. let that = this
  292. that.isDisabled = false
  293. }, 3000)
  294. },
  295. // 日期面板变化时的回调
  296. handlePanelChange(value, mode) {
  297. this.value = value
  298. this.mode2 = [mode[0] === 'date' ? 'month' : mode[0], mode[1] === 'date' ? 'month' : mode[1]]
  299. this.queryParam.startYearMonth = value[0].format('YYYY-MM')
  300. this.queryParam.endYearMonth = value[1].format('YYYY-MM')
  301. // console.log('开始年月:', this.queryParam.startYearMonth)
  302. // console.log('结束年月:', this.queryParam.endYearMonth)
  303. },
  304. // 时间发生变化的回调,发生在用户选择时间时
  305. monthChange(value) {
  306. this.value = value
  307. },
  308. handleTableChange(pagination, filters, sorter) {
  309. this.queryParam.pageNo = pagination.current
  310. this.getExternalData()
  311. }
  312. }
  313. }
  314. </script>
  315. <style lang="less" scoped>
  316. @import '~@assets/less/common.less';
  317. @import '~@assets/less/overwriter.less';
  318. /deep/ .ant-table-thead > tr > th {
  319. text-align: center;
  320. // font-weight: 700;
  321. }
  322. /deep/ .ant-table-tbody {
  323. text-align: center;
  324. }
  325. // /deep/ th.replacecolor {
  326. // background-color: #ccc;
  327. // }
  328. .depChartStyle,
  329. .cusChartStyle {
  330. // width: 100%;
  331. // height: 600px;
  332. text-align: center;
  333. padding-top: 10px;
  334. }
  335. .depChartStyle {
  336. margin-bottom: 20px;
  337. }
  338. </style>