123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <template>
- <a-card :bordered="false" class="shopOrder-table-page-search-wrapper">
- <div class="shopOrder-searchForm">
- <a-form layout="inline" @keyup.enter.native="refresh">
- <a-row :gutter="20">
- <a-col :span="8">
- <a-form-item label="投递时间:" :label-col="{ span: 5 }" :wrapper-col="{ span: 19}">
- <a-range-picker
- id="network-time"
- v-model="time"
- style="width: 100%;"
- :format="dateFormat"
- :showTime="{ format: 'HH'}"
- :placeholder="['开始时间','结束时间']"
- :disabledDate="disabledDate"
- @change="onChange" />
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item label="网点名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
- <a-select
- id="releaseRecordList-stationNo"
- placeholder="请选择网点名称"
- allowClear
- v-model="queryParam.stationNo"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption"
- >
- <a-select-option v-for="item in optionData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-button
- class="serach-btn"
- type="primary"
- id="releaseRecordList-refresh"
- @click="refresh">查询</a-button>
- <a-button class="serach-btn" id="releaseRecordList-handleReset" @click="handleReset">重置</a-button>
- <a-button class="export-btn" id="releaseRecordList-export" v-hasPermission="'B_rubbishSearchTime_export'" :loading="loading" @click="handleExport">导出</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 合计 -->
- <a-alert type="info" showIcon style="margin-bottom:15px">
- <div class="ftext" slot="message">总计<span> {{ totalNum }} </span>条,可回收垃圾总计<span> {{ recyclTotal }} </span>千克,有害垃圾总计<span> {{ harmTotal }} </span>千克</div>
- </a-alert>
- <s-table
- ref="table"
- size="default"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- bordered>
- </s-table>
- </a-card>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import {
- stationList
- } from '@/api/releaseRecord.js'
- import { getPutInTimeList, exportTnTimeForm, getDetailTotal } from '@/api/reportForm.js'
- import moment from 'moment'
- import getDate from '@/libs/getDate.js'
- export default {
- components: { STable, VSelect },
- data () {
- return {
- loading: false,
- form: this.$form.createForm(this),
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 16 }
- },
- // 将默认近七天时间日期回显在时间选择框中
- time: [
- moment(getDate.getRecentday().starttime, 'YYYY-MM-DD HH'),
- moment(getDate.getRecentday().endtime, 'YYYY-MM-DD HH')
- ],
- dateFormat: 'YYYY-MM-DD HH',
- // 查询参数
- queryParam: {
- beginDate: null, // 开始时间
- endDate: null, // 结束时间
- stationNo: undefined // 网点名称
- },
- optionData: [],
- totalNum: 0, // 总条数
- recyclTotal: 0, // 可回收总计
- harmTotal: 0, // 有害垃圾总计
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
- { title: '投递时间', dataIndex: 'putInDate', width: 100, align: 'center' },
- { title: '可回收垃圾投递量(kg)',
- children: [
- { title: '废旧衣物', width: 100, align: 'center', dataIndex: 'clothesWeight', customRender: (text) => { return text || 0 } },
- { title: '废旧纸张', width: 100, align: 'center', dataIndex: 'paperWeight', customRender: (text) => { return text || 0 } },
- { title: '废旧塑料', width: 100, align: 'center', dataIndex: 'plasticWeight', customRender: (text) => { return text || 0 } },
- { title: '废旧金属', width: 100, align: 'center', dataIndex: 'metalWeight', customRender: (text) => { return text || 0 } },
- { title: '废旧金属/塑料', width: 100, align: 'center', dataIndex: 'plasticOrMetalWeight', customRender: (text) => { return text || 0 } },
- { title: '废旧玻璃', width: 100, align: 'center', dataIndex: 'glassWeight', customRender: (text) => { return text || 0 } },
- { title: '可回收物', width: 100, align: 'center', dataIndex: 'recyclingWeight', customRender: (text) => { return text || 0 } }
- ]
- },
- { title: '可回收垃圾小计(kg)', dataIndex: 'recyclTotalWeight', width: 100, align: 'center' },
- { title: '有害垃圾(kg)', dataIndex: 'harmWeight', width: 100, align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- const searchData = Object.assign(parameter, this.queryParam)
- if (this.time && this.time.length) {
- searchData.beginDate = moment(this.time[0])
- searchData.endDate = moment(this.time[1])
- } else {
- searchData.beginDate = ''
- searchData.endDate = ''
- }
- return getPutInTimeList(searchData).then(res => {
- if (res.status == 200) {
- const no = (res.data.pageNo - 1) * res.data.pageSize
- for (let i = 0; i < res.data.list.length; i++) {
- const _item = res.data.list[i]
- _item.no = no + i + 1
- }
- this.totalNum = res.data.count
- this.getListTotal()
- return res.data
- } else {
- this.totalNum = 0
- }
- })
- }
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.time = [
- moment(getDate.getRecentday().starttime, 'YYYY-MM-DD HH'),
- moment(getDate.getRecentday().endtime, 'YYYY-MM-DD HH')
- ]
- vm.queryParam.stationNo = undefined
- vm.getStationList()
- })
- },
- methods: {
- // 不可选日期
- disabledDate (date, dateStrings) {
- return date && date.valueOf() > Date.now()
- },
- // 创建时间change
- onChange (dates, dateStrings) {
- if ((dates, dateStrings)) {
- this.queryParam.beginDate = dateStrings[0]
- this.queryParam.endDate = dateStrings[1]
- }
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 导出
- handleExport () {
- const params = this.queryParam
- if (this.time && this.time.length) {
- params.beginDate = moment(this.time[0])
- params.endDate = moment(this.time[1])
- } else {
- params.beginDate = ''
- params.endDate = ''
- }
- if (!params.beginDate && !params.endDate) {
- this.$message.error('请先选择需要导出的投放时间区间再进行导出!')
- return
- }
- // 判断两个时间段是否相差m个月 第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
- if (moment(params.endDate).diff(moment(params.beginDate), 'months', true) > 3) {
- this.$message.error('单次最多只能导出3个月的数据,请缩小查询区间后再进行导出!')
- return
- }
- this.$confirm({
- title: '提示',
- content: '导出过程可能需要一些时间,且导出期间不能进行其它操作,确定要导出吗?',
- onOk: () => {
- this.loading = true
- exportTnTimeForm(params).then(res => {
- this.loading = false
- this.download(res)
- })
- },
- onCancel () {
- console.log('Cancel')
- }
- })
- },
- download (data) {
- if (!data) { return }
- const url = window.URL.createObjectURL(new Blob([data]))
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- const a = moment(this.queryParam.beginDate).format('LL') + '-' + moment(this.queryParam.endDate).format('LL')
- console.log(a)
- const name = this.queryParam.stationNo ? this.optionData.find(item => item.stationNo == this.queryParam.stationNo).name : ''
- const fname = a + '分时投递统计表' + (name ? '(' + name + ')' : '')
- link.setAttribute('download', fname + '.xlsx')
- document.body.appendChild(link)
- link.click()
- },
- // 查询
- refresh () {
- this.$refs.table.refresh(true)
- },
- // 获取合作商数据
- getStationList () {
- stationList().then(res => {
- if (res.status == 200) {
- this.optionData = res.data || []
- }
- })
- },
- // 合计
- getListTotal () {
- const params = {
- beginDate: this.queryParam.beginDate,
- endDate: this.queryParam.endDate,
- stationNo: this.queryParam.stationNo // 网点名称
- }
- if (this.time && this.time.length) {
- params.beginDate = moment(this.time[0])
- params.endDate = moment(this.time[1])
- } else {
- params.beginDate = ''
- params.endDate = ''
- }
- getDetailTotal(params).then(res => {
- if (res.status == 200) {
- if (res.data) {
- this.recyclTotal = res.data.recyclAll || 0
- this.harmTotal = res.data.harmAll || 0
- } else {
- this.recyclTotal = 0
- this.harmTotal = 0
- }
- }
- })
- },
- // 重置
- handleReset () {
- this.time = [
- moment(getDate.getRecentday().starttime, 'YYYY-MM-DD HH'),
- moment(getDate.getRecentday().endtime, 'YYYY-MM-DD HH')
- ]
- this.queryParam.stationNo = undefined
- this.$refs.table.refresh(true)
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .shopOrder-table-page-search-wrapper{
- .shopOrder-searchForm{
- .ant-form-inline .ant-form-item{
- width: 100%;
- }
- // 搜索框的下间距
- .ant-form-item {
- margin-bottom: 10px;
- }
- // .handle-btn{
- // margin-bottom: 15px;
- // }
- .serach-btn{
- margin-right: 10px;
- margin-top: 4px;
- }
- }
- .export-btn{
- background-color: #ff9900;
- border-color: #ff9900;
- color: #fff;
- }
- .export-btn.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger), .export-btn.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger){
- color: #fff;
- border-color: #ff9900;
- }
- .actionBtn {
- font-size: 20px;
- padding: 0 10px;
- }
- .blue {
- color: #1890FF;
- }
- .green {
- color: #16b50e;
- }
- .red {
- color: red;
- }
- }
- </style>
|