unRecyclableRubbishDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <a-card :bordered="false" class="unRecyclableRubbishDetails-container">
  3. <!-- 搜索条件 -->
  4. <div class="unRecyclableRubbishDetails-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="unRecyclableRubbishDetails-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="{ span:8}" :wrapper-col="{ span:16}">
  26. <a-input
  27. id="unRecyclableRubbishDetails-queryWord"
  28. allowClear
  29. :maxLength="30"
  30. v-model="queryParam.queryWord"
  31. placeholder="请输入姓名/手机号码"
  32. autocomplete="off"/>
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  36. <a-form-model-item label="网点名称" :label-col="{ span:8}" :wrapper-col="{ span:16}">
  37. <a-select
  38. style="max-height: 50px;overflow: auto;margin-top: 3px;"
  39. id="unRecyclableRubbishDetails-stationNo"
  40. placeholder="请选择网点名称"
  41. allowClear
  42. v-model="queryParam.stationNo"
  43. :showSearch="true"
  44. option-filter-prop="children"
  45. :filter-option="filterOption">
  46. <a-select-option v-for="item in optionData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  47. </a-select>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  51. <a-button type="primary" @click="$refs.table.refresh(true)" id="unRecyclableRubbishDetails-refresh" style="margin-top: 4px">查询</a-button>
  52. <a-button type="" @click="reset" id="unRecyclableRubbishDetails-reset" style="margin: 4px 0 0 10px">重置</a-button>
  53. </a-col>
  54. </a-row>
  55. </a-form-model>
  56. </div>
  57. <!-- 合计 -->
  58. <a-alert type="info" showIcon style="margin-bottom:15px">
  59. <div class="ftext" slot="message">总计<span> {{ orderTotal }} </span>条,<span> {{ total }} </span>kg。
  60. 其中,可回收物总计<span>{{ huishouTotal }} </span>kg,有害垃圾总计<span>{{ harmTotal }} </span>kg,厨余垃圾总计<span>{{ chuyuTotal }} </span>kg,其他垃圾总计<span> {{ otherTotal }} </span>kg,建筑垃圾总计<span> {{ jianzhuTotal }} </span>kg
  61. </div>
  62. </a-alert>
  63. <!-- 列表 -->
  64. <s-table ref="table" :rowKey="record => record.id" :columns="columns" :data="loadData" bordered>
  65. <!-- 图片 -->
  66. <template slot="img" slot-scope="text,record">
  67. <viewer :images="record.imageUrlList? record.imageUrlList:[]" class="viewer" ref="viewer" @inited="inited" rebuild>
  68. <img v-for="src in record.imageUrlList" :src="src" :key="src" class="image">
  69. </viewer>
  70. <P style="margin-bottom: 0;">{{ record.imageUrlList ? record.imageUrlList.length+' 张' :'0 张' }}</P>
  71. </template>
  72. </s-table>
  73. </s-table>
  74. </a-card>
  75. </template>
  76. <script>
  77. import { STable, VSelect } from '@/components'
  78. import { stationList } from '@/api/releaseRecord.js'
  79. import { getRubbishDetailList, getRubbishDetailTotal } from '@/api/reportForm.js'
  80. import moment from 'moment'
  81. import getDate from '@/libs/getDate.js'
  82. export default {
  83. components: {
  84. STable,
  85. VSelect
  86. },
  87. data () {
  88. return {
  89. orderTotal: 0, // 总计条数
  90. total: 0, // 可回收垃圾总计
  91. huishouTotal: 0, // 可回收物
  92. harmTotal: 0, // 有害垃圾
  93. otherTotal: 0, // 其他垃圾总计
  94. jianzhuTotal: 0, // 建筑垃圾总计
  95. chuyuTotal: 0, // 厨余垃圾总计
  96. queryParam: {
  97. stationNo: undefined, // 网点名称
  98. beginDate: null, // 开始时间
  99. endDate: null, // 结束时间
  100. queryWord: ''
  101. },
  102. optionData: [], // 网点列表数据
  103. // 将默认当天时间日期回显在时间选择框中
  104. time: [
  105. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD'),
  106. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD')
  107. ],
  108. dateFormat: 'YYYY-MM-DD', // 日期格式
  109. columns: [
  110. { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  111. { title: '创建时间', dataIndex: 'createDate', width: 150, align: 'center' },
  112. { title: '网点名称', dataIndex: 'stationName', width: 120, align: 'center', customRender: (text) => { return text || '--' } },
  113. { title: '采集员姓名', dataIndex: 'gatherName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  114. { title: '采集员手机', dataIndex: 'gatherPhone', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  115. { title: '可回收物(kg)', dataIndex: 'gatherRecycling', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  116. { title: '有害垃圾(kg)', dataIndex: 'gatherHarm', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  117. { title: '厨余垃圾(kg)', dataIndex: 'gatherKitchen', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  118. { title: '其他垃圾(kg)', dataIndex: 'gatherOther', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  119. { title: '建筑垃圾(kg)', dataIndex: 'gatherBuilding', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  120. { title: '总计(kg)', dataIndex: 'gatherTotal', width: 80, align: 'center', customRender: (text) => { return text ? (text / 1000).toFixed(3) / 1 : '0' } },
  121. { title: '备注', dataIndex: 'remarks', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  122. { title: '图片', width: 100, align: 'center', scopedSlots: { customRender: 'img' } }
  123. ],
  124. // 图片
  125. images: [],
  126. // 加载数据方法 必须为 Promise 对象
  127. loadData: parameter => {
  128. const searchData = Object.assign(parameter, this.queryParam)
  129. if (this.time && this.time.length) {
  130. searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  131. searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  132. } else {
  133. searchData.beginDate = null
  134. searchData.endDate = null
  135. }
  136. return getRubbishDetailList(searchData).then(res => {
  137. if (res.status == 200) {
  138. const no = (res.data.pageNo - 1) * res.data.pageSize
  139. for (let i = 0; i < res.data.list.length; i++) {
  140. const _item = res.data.list[i]
  141. _item.no = no + i + 1
  142. }
  143. this.orderTotal = res.data.count || 0
  144. this.getTotal()
  145. return res.data
  146. } else {
  147. this.orderTotal = 0
  148. }
  149. })
  150. }
  151. }
  152. },
  153. mounted () {
  154. this.getStationList()
  155. },
  156. methods: {
  157. // 不可选日期
  158. disabledDate (date, dateStrings) {
  159. return date && date.valueOf() > Date.now()
  160. },
  161. // 创建时间change
  162. onChange (dates, dateStrings) {
  163. if ((dates, dateStrings)) {
  164. this.queryParam.beginDate = dateStrings[0]
  165. this.queryParam.endDate = dateStrings[1]
  166. }
  167. },
  168. filterOption (input, option) {
  169. return (
  170. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  171. )
  172. },
  173. // 获取网点数据
  174. getStationList () {
  175. stationList().then(res => {
  176. if (res.status == 200) {
  177. this.optionData = res.data || []
  178. } else {
  179. this.optionData = []
  180. }
  181. })
  182. },
  183. // 总计
  184. getTotal () {
  185. const params = this.queryParam
  186. if (this.time && this.time.length) {
  187. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  188. params.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  189. } else {
  190. params.beginDate = null
  191. params.endDate = null
  192. }
  193. getRubbishDetailTotal(params).then(res => {
  194. if (res.status == 200) {
  195. if (res.data) {
  196. this.otherTotal = res.data.GATHER_OTHER ? (res.data.GATHER_OTHER / 1000).toFixed(3) / 1 : '0'
  197. this.jianzhuTotal = res.data.GATHER_BUILDING ? (res.data.GATHER_BUILDING / 1000).toFixed(3) / 1 : '0'
  198. this.chuyuTotal = res.data.GATHER_KITCHEN ? (res.data.GATHER_KITCHEN / 1000).toFixed(3) / 1 : '0'
  199. this.total = res.data.GATHER_TOTAL ? (res.data.GATHER_TOTAL / 1000).toFixed(3) / 1 : '0'
  200. this.harmTotal = res.data.GATHER_HARM ? (res.data.GATHER_HARM / 1000).toFixed(3) / 1 : '0'
  201. this.huishouTotal = res.data.GATHER_RECYCLING ? (res.data.GATHER_RECYCLING / 1000).toFixed(3) / 1 : '0'
  202. }
  203. }
  204. })
  205. },
  206. // 重置
  207. reset () {
  208. this.queryParam.stationNo = undefined
  209. this.queryParam.beginDate = null
  210. this.queryParam.endDate = null
  211. this.queryParam.queryWord = ''
  212. this.time = [
  213. moment(getDate.getRecentday().starttime, 'YYYY-MM-DD'),
  214. moment(getDate.getRecentday().endtime, 'YYYY-MM-DD')
  215. ]
  216. this.$refs.table.refresh(true)
  217. },
  218. inited (viewer) {
  219. this.$viewer = viewer
  220. },
  221. isShow () {
  222. this.$viewer.update()
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang='less' scoped>
  228. .unRecyclableRubbishDetails-container {
  229. .unRecyclableRubbishDetails-container-searchForm {
  230. .ant-form-inline .ant-form-item {
  231. width: 100%;
  232. margin-bottom: 15px;
  233. }
  234. }
  235. .image {
  236. width:25px;
  237. height: 25px;
  238. cursor: pointer;
  239. margin: 5px;
  240. display: inline-block;
  241. }
  242. .image:not(:first-child){
  243. display: none;
  244. }
  245. }
  246. </style>