external-statistics.vue 11 KB

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