checkStatistic.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="form-wrap">
  3. <el-form
  4. class="search-box"
  5. ref="form"
  6. :model="form"
  7. :inline="true">
  8. <div class="block-title">
  9. 查询条件
  10. </div>
  11. <el-form-item
  12. label="起始时间"
  13. prop="checkTimeBegin">
  14. <el-date-picker
  15. v-model="form.checkTimeBegin"
  16. type="datetime"
  17. placeholder="选择日期时间">
  18. </el-date-picker>
  19. </el-form-item>
  20. <el-form-item
  21. label="截止时间"
  22. prop="checkTimeEnd">
  23. <el-date-picker
  24. default-time="23:59:59"
  25. v-model="form.checkTimeEnd"
  26. type="datetime"
  27. placeholder="选择日期时间">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item
  31. label="票种"
  32. prop="ticketTypeIdList">
  33. <el-select
  34. v-model="form.ticketTypeIdList"
  35. multiple
  36. clearable>
  37. <el-option
  38. v-for="item in ticketTypeList"
  39. :key="item.id"
  40. :value="item.id"
  41. :label="item.name">
  42. </el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item
  46. label="销售渠道"
  47. prop="sourceList">
  48. <el-select
  49. v-model="form.sourceList"
  50. multiple
  51. clearable>
  52. <el-option
  53. v-for="(item,index) in saleChannels"
  54. :key="index"
  55. :label="item"
  56. :value="item"
  57. >
  58. </el-option>
  59. </el-select>
  60. </el-form-item>
  61. <!-- 新增分组筛选项 -->
  62. <el-form-item
  63. label="分组筛选"
  64. style="width:100%">
  65. <el-checkbox-group
  66. v-model="selectKeys"
  67. :min="0"
  68. :max="4">
  69. <draggable :list="groupKeys">
  70. <el-checkbox
  71. :key="item.value"
  72. :label="item.value"
  73. v-for="(item) in groupKeys"
  74. :disabled="disabled(item)"
  75. >
  76. {{ item.label }}
  77. </el-checkbox>
  78. </draggable>
  79. </el-checkbox-group>
  80. (可拖拽排序)
  81. </el-form-item>
  82. <div
  83. class="btn-wrap"
  84. style="margin-bottom:20px">
  85. <el-button
  86. @click="reset">
  87. 重置
  88. </el-button>
  89. <el-button
  90. :disabled="loading"
  91. type="primary"
  92. @click="getCheckStatistic">
  93. 搜索
  94. </el-button>
  95. <el-button
  96. type="primary"
  97. @click="reportExport">
  98. 导出
  99. </el-button>
  100. </div>
  101. </el-form>
  102. <div class="table-box">
  103. <!-- <div class="block-title">
  104. 统计结果
  105. </div> -->
  106. <el-table
  107. border
  108. stripe
  109. v-loading="loading"
  110. :data="tableData"
  111. :row-class-name="totalRowClassName"
  112. :span-method="objectSpanMethod">
  113. <el-table-column
  114. v-for="(item) in finalGroup"
  115. :key="item.prop"
  116. :prop="item.prop"
  117. :label="item.label">
  118. </el-table-column>
  119. </el-table>
  120. </div>
  121. </div>
  122. </template>
  123. <script>
  124. import { getCheckerVerifyStatistics } from '@/api/queryReport'
  125. import { totalRowClassName } from '@/utils'
  126. import moment from 'moment'
  127. import { getSaleChannelList } from '@/api/order'
  128. // import ReaderInput from '@/components/ReaderInput'
  129. import draggable from 'vuedraggable'
  130. // import moment from 'moment'
  131. export default {
  132. name: 'checkStatistic',
  133. computed: {
  134. scenicName () {
  135. return this.$localStore.get('scenicName') || this.$store.state.user.scenicName
  136. },
  137. saleChannel () {
  138. return this.$store.state.app.saleChannel
  139. },
  140. scenicList () {
  141. return this.$store.state.app.scenicList
  142. },
  143. ticketTypeList () {
  144. return this.$store.state.app.ticketTypeList
  145. },
  146. userScenic () {
  147. return this.$store.state.app.account.managerScenicMatrix ? this.$store.state.app.account.managerScenicMatrix : this.$store.state.app.scenicList
  148. }
  149. },
  150. components: {
  151. draggable
  152. },
  153. data () {
  154. return {
  155. groupKeys: [{ value: 'orderDateDay', label: '统计日期' }],
  156. form: {
  157. checkTimeBegin: new Date(moment().startOf('day').subtract(7, 'day').format('YYYY-MM-DD HH:mm:ss')),
  158. checkTimeEnd: new Date(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')),
  159. ticketTypeIdList: [], //
  160. sourceList: [],
  161. groupByList: [],
  162. pageNum: 1,
  163. pageSize: 10
  164. },
  165. finalGroup: [
  166. { prop: 'otaSourceName', label: '订单渠道' },
  167. { prop: 'ticketTypeName', label: '票种名称' },
  168. { prop: 'unitPrice', label: '单价' },
  169. { prop: 'checkCount', label: '检票数量' },
  170. { prop: 'checkNum', label: '检票人数' },
  171. { prop: 'checkPrice', label: '检票金额' },
  172. { prop: 'orderDateDay', label: '统计日期' }
  173. ],
  174. selectKeys: [], // 默认选中
  175. tableIndex: 1,
  176. OrderIndexArr: [],
  177. tableData: [],
  178. deviceList: [],
  179. saleChannels: [],
  180. // ticketTypeList: [],
  181. loading: false
  182. }
  183. },
  184. created () {
  185. this.getCheckStatistic()
  186. this.getSaleChannelList()
  187. },
  188. mounted () {
  189. },
  190. methods: {
  191. hideClear () {
  192. if (['铭投山庄'].includes(this.scenicName)) {
  193. if (this.form.keyList2.length === 1) {
  194. return 'hideClear'
  195. } else {
  196. return ''
  197. }
  198. } else {
  199. return ''
  200. }
  201. },
  202. disabled (item) {
  203. if (['铭投山庄'].includes(this.scenicName)) {
  204. if (this.form.keyList2.length > 1) {
  205. return false
  206. } else if (this.form.keyList2.length === 1) {
  207. if (this.form.keyList2.includes(item.id)) {
  208. return true
  209. } else {
  210. return false
  211. }
  212. }
  213. } else {
  214. return false
  215. }
  216. },
  217. totalRowClassName,
  218. reset () {
  219. this.$refs.form.resetFields()
  220. },
  221. getSaleChannelList () {
  222. getSaleChannelList({ pageSize: -1, pageNum: 1 }).then((res) => {
  223. this.saleChannels = res?.data || []
  224. })
  225. },
  226. // 获取表格数据
  227. getCheckStatistic () {
  228. this.loading = true
  229. this.tableIndex++
  230. // this.finalGroup = []
  231. // this.finalGroup = this.groupKeys.filter(i => {
  232. // return this.selectKeys.includes(i.value)
  233. // })
  234. if (this.selectKeys.length === 0) {
  235. this.finalGroup = [
  236. { prop: 'otaSourceName', label: '订单渠道' },
  237. { prop: 'ticketTypeName', label: '票种名称' },
  238. { prop: 'unitPrice', label: '单价' },
  239. { prop: 'checkCount', label: '检票数量' },
  240. { prop: 'checkNum', label: '检票人数' },
  241. { prop: 'checkPrice', label: '检票金额' }
  242. ]
  243. } else {
  244. this.finalGroup = [
  245. { prop: 'orderDateDay', label: '统计日期' },
  246. { prop: 'otaSourceName', label: '订单渠道' },
  247. { prop: 'ticketTypeName', label: '票种名称' },
  248. { prop: 'unitPrice', label: '单价' },
  249. { prop: 'checkCount', label: '检票数量' },
  250. { prop: 'checkNum', label: '检票人数' },
  251. { prop: 'checkPrice', label: '检票金额' }
  252. ]
  253. }
  254. if (this.form.checkTimeBegin) {
  255. this.form.checkTimeBegin = moment(this.form.checkTimeBegin).format('YYYY-MM-DD HH:mm:ss')
  256. } else {
  257. this.form.checkTimeBegin = ''
  258. }
  259. if (this.form.checkTimeEnd) {
  260. this.form.checkTimeEnd = moment(this.form.checkTimeEnd).format('YYYY-MM-DD HH:mm:ss')
  261. } else {
  262. this.form.checkTimeEnd = ''
  263. }
  264. if (!this.form.ticketTypeIdList) {
  265. this.form.ticketTypeIdList = []
  266. }
  267. this.form.groupByList = [...this.selectKeys] || []
  268. getCheckerVerifyStatistics(this.form).then(res => {
  269. this.tableData = res.data
  270. }).finally(() => {
  271. this.loading = false
  272. })
  273. },
  274. objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
  275. if (columnIndex < this.finalGroup.length) {
  276. if (!(this.OrderIndexArr[columnIndex] && this.OrderIndexArr[columnIndex].length)) return
  277. for (let i = 0; i < this.OrderIndexArr[columnIndex].length; i++) {
  278. let element = this.OrderIndexArr[columnIndex][i]
  279. for (let j = 0; j < element.length; j++) {
  280. let item = element[j]
  281. if (rowIndex === item) {
  282. if (j === 0) {
  283. return {
  284. rowspan: element.length,
  285. colspan: 1
  286. }
  287. } else if (j !== 0) {
  288. return {
  289. rowspan: 0,
  290. colspan: 0
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. },
  298. reportExport () {
  299. this.$confirm(`是否要导出明细数据`, '确认提示', {
  300. confirmButtonText: '是',
  301. cancelButtonText: '否',
  302. type: 'warning'
  303. }).then(() => {
  304. this.handleExport({
  305. ...this.form,
  306. export: true,
  307. exportDetail: true
  308. })
  309. }).catch(() => {
  310. this.handleExport({
  311. ...this.form,
  312. export: true,
  313. exportDetail: false
  314. })
  315. })
  316. },
  317. handleExport (params) {
  318. getCheckerVerifyStatistics(params).then(() => {
  319. this.$message.success('导出成功。')
  320. this.goToDownload()
  321. }, () => {
  322. this.$message.success('导出失败。')
  323. })
  324. }
  325. }
  326. }
  327. </script>
  328. <style scoped lang="scss">
  329. .hideClear{
  330. ::v-deep .el-tag.el-tag--info .el-tag__close{
  331. display: none;
  332. }
  333. }
  334. </style>