netWorkCleanRecord.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <a-card :bordered="false" class="cleanDetail-container">
  3. <!-- 搜索条件 -->
  4. <div class="cleanDetail-container-searchForm">
  5. <a-form-model
  6. ref="queryParam"
  7. :model="queryParam"
  8. layout="inline"
  9. @keyup.enter.native="refresh"
  10. v-bind="formItemLayout">
  11. <a-row :gutter="24">
  12. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  13. <a-form-model-item label="创建时间" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  14. <a-range-picker
  15. id="netWorkCleanRecord-time"
  16. v-model="time"
  17. style="width: 100%;"
  18. :format="dateFormat"
  19. :placeholder="['开始时间','结束时间']"
  20. :disabledDate="disabledDate"
  21. @change="onChange" />
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  25. <a-form-model-item label="网点名称" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  26. <a-select
  27. id="netWorkCleanRecord-stationNo"
  28. placeholder="请选择网点名称"
  29. allowClear
  30. v-model="queryParam.stationNo"
  31. :showSearch="true"
  32. option-filter-prop="children"
  33. :filter-option="filterOption">
  34. <a-select-option v-for="item in optionData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  35. </a-select>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  39. <a-button type="primary" @click="refreshSearch" id="netWorkCleanRecord-refresh" style="margin: 4px 10px 0 20px">查询</a-button>
  40. <a-button type="" @click="reset" id="netWorkCleanRecord-reset" style="margin-top: 4px">重置</a-button>
  41. </a-col>
  42. </a-row>
  43. </a-form-model>
  44. </div>
  45. <!-- 合计 -->
  46. <a-alert type="info" showIcon style="margin-bottom:15px">
  47. <div class="ftext" slot="message">总计<span> {{ totalNum }} </span>条,可回收物清运量总计<span> {{ cleanWeightTotal }} </span>kg</div>
  48. </a-alert>
  49. <!-- 列表 -->
  50. <s-table
  51. ref="table"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. bordered
  56. >
  57. <span slot="action" slot-scope="text,record">
  58. <!-- <a-button type="primary" @click="handleDetail(record)" id="netWorkCleanRecord-handleDetail">查看详情</a-button> -->
  59. <a-button type="primary" @click="handleDetail(record)" v-hasPermission="'B_netWorkCleanRecord_detail'" id="netWorkCleanRecord-handleDetail">查看详情</a-button>
  60. <span v-if="!$hasPermissions('B_netWorkCleanRecord_detail')">--</span>
  61. </span>
  62. </s-table>
  63. <!-- 详情弹窗 -->
  64. <netWorkCleanModal :stationNo="itemStationNo" :searchDate="time" :visible="isOpenModal" @close="isOpenModal=false"></netWorkCleanModal>
  65. </a-card>
  66. </template>
  67. <script>
  68. import { STable, VSelect } from '@/components'
  69. import { stationList } from '@/api/releaseRecord.js'
  70. import { cleanRecordList, getCleanStationTotal } from '@/api/cleanManage.js'
  71. import netWorkCleanModal from './netWorkCleanModal.vue'
  72. import moment from 'moment'
  73. import getDate from '@/libs/getDate.js'
  74. export default {
  75. components: { STable, VSelect, netWorkCleanModal },
  76. data () {
  77. return {
  78. formItemLayout: {
  79. labelCol: {
  80. span: 7
  81. },
  82. wrapperCol: {
  83. span: 17
  84. }
  85. },
  86. isOpenModal: false, // 默认弹窗关闭
  87. itemStationNo: '', // 每行网点编号
  88. // 查询参数
  89. queryParam: {
  90. beginDate: null, // 开始时间
  91. endDate: null, // 结束时间
  92. stationNo: undefined // 网点编号
  93. },
  94. totalNum: 0, // 总条数
  95. cleanWeightTotal: 0, // 回收物总计
  96. optionData: [], // 网点名称数据
  97. // 将默认近一周时间日期回显在时间选择框中
  98. time: [
  99. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD'),
  100. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD')
  101. ],
  102. dateFormat: 'YYYY-MM-DD',
  103. columns: [{ title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  104. { title: '网点名称', dataIndex: 'stationName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  105. { title: '清运次数', dataIndex: 'cleanTimes', width: 100, align: 'center', sorter: true },
  106. { title: '清运重量(kg)', dataIndex: 'cleanWeight', width: 100, align: 'center', sorter: true, customRender: (text) => { return text || 0 } },
  107. { title: '最后清运时间', dataIndex: 'cleanTime', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  108. { title: '操作', dataIndex: 'action', width: 100, align: 'center', scopedSlots: { customRender: 'action' } }],
  109. // 加载数据方法 必须为 Promise 对象
  110. loadData: parameter => {
  111. const searchData = Object.assign(parameter, this.queryParam)
  112. if (this.time && this.time.length) {
  113. searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  114. searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  115. } else {
  116. searchData.beginDate = null
  117. searchData.endDate = null
  118. }
  119. return cleanRecordList(searchData).then(res => {
  120. if (res.status == 200) {
  121. const no = (res.data.pageNo - 1) * res.data.pageSize
  122. for (let i = 0; i < res.data.list.length; i++) {
  123. const _item = res.data.list[i]
  124. _item.no = no + i + 1
  125. if (_item.cleanWeight != null || 0) {
  126. _item.cleanWeight = (_item.cleanWeight / 1000).toFixed(2)
  127. }
  128. }
  129. this.totalNum = res.data.count
  130. return res.data
  131. } else {
  132. this.totalNum = 0
  133. }
  134. })
  135. }
  136. }
  137. },
  138. mounted () {
  139. this.getStationList()
  140. this.getTotal()
  141. },
  142. methods: {
  143. // 不可选日期
  144. disabledDate (date, dateStrings) {
  145. return date && date.valueOf() > Date.now()
  146. },
  147. // 创建时间change
  148. onChange (dates, dateStrings) {
  149. if ((dates, dateStrings)) {
  150. this.queryParam.beginDate = dateStrings[0]
  151. this.queryParam.endDate = dateStrings[1]
  152. }
  153. },
  154. filterOption (input, option) {
  155. return (
  156. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  157. )
  158. },
  159. // 获取网点名称数据
  160. getStationList () {
  161. stationList().then(res => {
  162. if (res.status == 200) {
  163. this.optionData = res.data || []
  164. }
  165. })
  166. },
  167. // 总计
  168. getTotal () {
  169. const params = this.queryParam
  170. if (this.time && this.time.length) {
  171. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  172. params.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  173. } else {
  174. params.beginDate = null
  175. params.endDate = null
  176. }
  177. getCleanStationTotal(params).then(res => {
  178. if (res.status == 200) {
  179. if (res.data != 0 || null) {
  180. this.cleanWeightTotal = (res.data.cleanWeight / 1000).toFixed(2)
  181. }
  182. } else {
  183. this.cleanWeightTotal = 0
  184. }
  185. })
  186. },
  187. // 查询
  188. refreshSearch () {
  189. this.$refs.table.refresh(true)
  190. this.getTotal()
  191. },
  192. // 刷新列表
  193. // refreshTable () {
  194. // if (this.itemStationNo && this.time) {
  195. // this.$refs.table.refresh()
  196. // } else {
  197. // this.$refs.table.refresh(true)
  198. // }
  199. // },
  200. // 重置
  201. reset () {
  202. this.queryParam = {
  203. stationNo: undefined,
  204. beginDate: null,
  205. endDate: null
  206. }
  207. this.time = [
  208. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD 00:00:00'),
  209. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD 23:59:59')
  210. ]
  211. this.refreshSearch()
  212. },
  213. // 查看清运详情
  214. handleDetail (record) {
  215. this.itemStationNo = record.stationNo
  216. this.searchDate = this.time
  217. this.isOpenModal = true
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang='less' scoped>
  223. .cleanDetail-container {
  224. .cleanDetail-container-searchForm {
  225. .ant-form-inline .ant-form-item {
  226. width: 100%;
  227. margin-bottom: 15px;
  228. }
  229. }
  230. }
  231. </style>