unRecyclableRubbishTotal.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <a-card :bordered="false" class="unRecyclableRubbishTotal-container">
  3. <!-- 搜索条件 -->
  4. <div class="unRecyclableRubbishTotal-container-searchForm">
  5. <a-form-model
  6. ref="queryParam"
  7. :model="queryParam"
  8. layout="inline"
  9. @keyup.enter.native="$refs.table.refresh(true)"
  10. >
  11. <a-row :gutter="24">
  12. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  13. <a-form-model-item label="采集时间区间" :label-col="{ span:8 }" :wrapper-col="{ span:16}">
  14. <a-range-picker
  15. id="unRecyclableRubbishTotal-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 prop="provinceCode" label="所属区域:" :label-col="{ span:8 }" :wrapper-col="{ span:16}">
  26. <a-select
  27. id="unRecyclableRubbishTotal-provinceCode"
  28. allowClear
  29. v-model="queryParam.provinceCode"
  30. @change="getCityList"
  31. placeholder="请选择省">
  32. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  33. </a-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  37. <a-form-model-item prop="cityCode" label=" " :colon="false" :label-col="{ span:4 }" :wrapper-col="{ span:16}">
  38. <a-select
  39. allowClear
  40. id="unRecyclableRubbishTotal-cityCode"
  41. v-model="queryParam.cityCode"
  42. @change="getAreaList"
  43. placeholder="请选择市">
  44. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  45. </a-select>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  49. <a-form-model-item prop="districtCode" label=" " :colon="false" :label-col="{ span:0}" :wrapper-col="{ span:16}">
  50. <a-select allowClear id="unRecyclableRubbishTotal-districtCode" v-model="queryParam.districtCode" placeholder="请选择区/县">
  51. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  52. </a-select>
  53. </a-form-model-item>
  54. </a-col>
  55. <a-col :xs="24" :sm="12" :md="6" :lg="4">
  56. <a-button type="primary" @click="$refs.table.refresh(true)" id="unRecyclableRubbishTotal-refresh" style="margin: 4px 10px 0 0">查询</a-button>
  57. <a-button type="" @click="reset" id="unRecyclableRubbishTotal-reset" style="margin-top: 4px">重置</a-button>
  58. </a-col>
  59. </a-row>
  60. <a-row :gutter="24">
  61. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  62. <a-form-model-item label="网点名称" :label-col="{ span:8}" :wrapper-col="{ span:16}">
  63. <a-select
  64. style="max-height: 50px;overflow: auto;"
  65. id="unRecyclableRubbishTotal-stationNo"
  66. placeholder="请选择网点名称"
  67. allowClear
  68. v-model="queryParam.stationNo"
  69. :showSearch="true"
  70. option-filter-prop="children"
  71. :filter-option="filterOption">
  72. <a-select-option v-for="item in optionData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  73. </a-select>
  74. </a-form-model-item>
  75. </a-col>
  76. </a-row>
  77. </a-form-model>
  78. </div>
  79. <!-- 合计 -->
  80. <a-alert type="info" showIcon style="margin-bottom:15px">
  81. <div class="ftext" slot="message">总计<span> {{ orderTotal }} </span>条,<span> {{ total }} </span>kg。
  82. 其中,可回收物总计<span>{{ huishouTotal}} </span>kg,有害垃圾总计<span>{{harmTotal }} </span>kg,厨余垃圾总计<span>{{ chuyuTotal }} </span>kg,其他垃圾总计<span> {{ otherTotal }} </span>kg,建筑垃圾总计<span> {{ jianzhuTotal }} </span>kg
  83. </div>
  84. </a-alert>
  85. <!-- 列表 -->
  86. <s-table ref="table" :rowKey="(record) => record.id" :columns="columns" :data="loadData" bordered>
  87. <!-- 可回收物小计 -->
  88. <template slot="totalWeight" slot-scope="text,record">
  89. <span >{{ record.totalWeight ? (record.totalWeight/1000).toFixed(3)/1 : '0' }}</span>
  90. </template>
  91. <!-- 操作 -->
  92. </s-table>
  93. </a-card>
  94. </template>
  95. <script>
  96. import { STable, VSelect } from '@/components'
  97. import { stationList } from '@/api/releaseRecord.js'
  98. import { getRubbishList, getRubbishTotal } from '@/api/reportForm.js'
  99. import { getProvince, getCityByPro, getDistrictByCity } from '@/api/station'
  100. import moment from 'moment'
  101. import getDate from '@/libs/getDate.js'
  102. export default {
  103. components: {
  104. STable,
  105. VSelect
  106. },
  107. data () {
  108. return {
  109. orderTotal: 0, // 总计条数
  110. total: 0, // 可回收垃圾总计
  111. huishouTotal:0, // 可回收物
  112. harmTotal:0, // 有害垃圾
  113. otherTotal: 0, // 其他垃圾总计
  114. jianzhuTotal: 0, // 建筑垃圾总计
  115. chuyuTotal: 0, // 厨余垃圾总计
  116. queryParam: {
  117. stationNo: undefined, // 网点名称
  118. findRubbishDataBeginDate: null, // 开始时间
  119. findRubbishDataEndDate: null, // 结束时间
  120. provinceCode: undefined, // 省
  121. cityCode: undefined, // 市
  122. districtCode: undefined // 区
  123. },
  124. optionData: [], // 网点列表数据
  125. addrProvinceList: [], // 省下拉
  126. addrCityList: [], // 市下拉
  127. addrDistrictList: [], // 区下拉
  128. // 将默认当天时间日期回显在时间选择框中
  129. time: [
  130. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD'),
  131. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD')
  132. ],
  133. dateFormat: 'YYYY-MM-DD', // 日期格式
  134. columns: [
  135. { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  136. { title: '网点名称', dataIndex: 'stationName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  137. { title: '可回收物(kg)', dataIndex: 'GATHER_RECYCLING', width: 100, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  138. { title: '有害垃圾(kg)', dataIndex: 'GATHER_HARM', width: 100, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  139. { title: '厨余垃圾(kg)', dataIndex: 'GATHER_KITCHEN', width: 100, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  140. { title: '其他垃圾(kg)', dataIndex: 'GATHER_OTHER', width: 100, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  141. { title: '总计(kg)', dataIndex: 'GATHER_TOTAL', width: 100, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } }
  142. ],
  143. // 加载数据方法 必须为 Promise 对象
  144. loadData: parameter => {
  145. const searchData = Object.assign(parameter, this.queryParam)
  146. if (this.time && this.time.length) {
  147. searchData.findRubbishDataBeginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  148. searchData.findRubbishDataEndDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  149. } else {
  150. searchData.findRubbishDataBeginDate = null
  151. searchData.findRubbishDataEndDate = null
  152. }
  153. return getRubbishList(searchData).then(res => {
  154. if (res.status == 200) {
  155. const no = (res.data.pageNo - 1) * res.data.pageSize
  156. for (let i = 0; i < res.data.list.length; i++) {
  157. const _item = res.data.list[i]
  158. _item.no = no + i + 1
  159. }
  160. this.orderTotal = res.data.count || 0
  161. this.getTotal()
  162. return res.data
  163. } else {
  164. this.orderTotal = 0
  165. }
  166. })
  167. }
  168. }
  169. },
  170. mounted () {
  171. this.getStationList()
  172. this.getProvinceList()
  173. },
  174. methods: {
  175. // 不可选日期
  176. disabledDate (date, dateStrings) {
  177. return date && date.valueOf() > Date.now()
  178. },
  179. // 创建时间change
  180. onChange (dates, dateStrings) {
  181. if ((dates, dateStrings)) {
  182. this.queryParam.findRubbishDataBeginDate = dateStrings[0]
  183. this.queryParam.findRubbishDataEndDate = dateStrings[1]
  184. }
  185. },
  186. filterOption (input, option) {
  187. return (
  188. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  189. )
  190. },
  191. // 获取网点数据
  192. getStationList () {
  193. stationList().then(res => {
  194. if (res.status == 200) {
  195. this.optionData = res.data || []
  196. } else {
  197. this.optionData = []
  198. }
  199. })
  200. },
  201. // 获取省列表
  202. getProvinceList () {
  203. getProvince().then(res => {
  204. if (res.status == 200) {
  205. this.addrProvinceList = res.data || []
  206. } else {
  207. this.addrProvinceList = []
  208. }
  209. })
  210. },
  211. // 获取城市列表
  212. getCityList (val) {
  213. this.addrCityList = []
  214. this.addrDistrictList = []
  215. this.queryParam.cityCode = undefined
  216. this.queryParam.districtCode = undefined
  217. this.getCityListRequest(val)
  218. },
  219. getCityListRequest (val) {
  220. getCityByPro({
  221. id: val
  222. }).then(res => {
  223. if (res.status == 200) {
  224. this.addrCityList = res.data || []
  225. } else {
  226. this.addrCityList = []
  227. }
  228. })
  229. },
  230. // 获取区县列表
  231. getAreaList (val) {
  232. this.addrDistrictList = []
  233. this.queryParam.districtCode = undefined
  234. this.getAreaListRequest(val)
  235. },
  236. getAreaListRequest (val) {
  237. getDistrictByCity({
  238. id: val
  239. }).then(res => {
  240. if (res.status == 200) {
  241. this.addrDistrictList = res.data || []
  242. } else {
  243. this.addrDistrictList = []
  244. }
  245. })
  246. },
  247. // 总计
  248. getTotal () {
  249. const params = this.queryParam
  250. if (this.time && this.time.length) {
  251. params.findRubbishDataBeginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  252. params.findRubbishDataEndDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  253. } else {
  254. params.findRubbishDataBeginDate = null
  255. params.findRubbishDataEndDate = null
  256. }
  257. getRubbishTotal(params).then(res => {
  258. if (res.status == 200) {
  259. if (res.data) {
  260. this.otherTotal = res.data.GATHER_OTHER ? (res.data.GATHER_OTHER / 1000).toFixed(3) / 1 : '0'
  261. this.jianzhuTotal = res.data.GATHER_BUILDING ? (res.data.GATHER_BUILDING / 1000).toFixed(3) / 1 : '0'
  262. this.chuyuTotal = res.data.GATHER_KITCHEN ? (res.data.GATHER_KITCHEN / 1000).toFixed(3) / 1 : '0'
  263. this.huishouTotal = res.data.GATHER_RECYCLING ? (res.data.GATHER_RECYCLING / 1000).toFixed(3) / 1 : '0'
  264. this.harmTotal = res.data.GATHER_HARM ? (res.data.GATHER_HARM / 1000).toFixed(3) / 1 : '0'
  265. this.total = res.data.GATHER_TOTAL ? (res.data.GATHER_TOTAL / 1000).toFixed(3) / 1 : '0'
  266. }
  267. }
  268. })
  269. },
  270. // 重置
  271. reset () {
  272. this.queryParam.stationNo = undefined
  273. this.queryParam.findRubbishDataBeginDate = null
  274. this.queryParam.findRubbishDataEndDate = null
  275. this.queryParam.provinceCode = undefined
  276. this.queryParam.cityCode = undefined
  277. this.queryParam.districtCode = undefined
  278. this.addrCityList = [] // 市下拉
  279. this.addrDistrictList = [] // 区下拉
  280. this.time = [
  281. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD'),
  282. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD')
  283. ]
  284. this.$refs.table.refresh(true)
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang='less' scoped>
  290. .unRecyclableRubbishTotal-container {
  291. .unRecyclableRubbishTotal-container-searchForm {
  292. .ant-form-inline .ant-form-item {
  293. width: 100%;
  294. margin-bottom: 15px;
  295. }
  296. }
  297. }
  298. </style>