netWorkCleanRecord.vue 9.4 KB

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