cleanDetail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. :disabledDate="disabledDate"
  16. v-model="time"
  17. id="cleanDetail-time"
  18. :format="dateFormat"
  19. :placeholder="['开始时间', '结束时间']" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  23. <a-form-model-item label="网点名称" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  24. <a-select
  25. id="cleanDetail-stationNo"
  26. placeholder="请选择网点名称"
  27. allowClear
  28. v-model="queryParam.stationNo"
  29. showSearch
  30. option-filter-prop="children"
  31. :filter-option="filterOption">
  32. <a-select-option v-for="item in optionData" :key="item.stationNo" :value="item.stationNo">{{ 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 label="设备编号" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  38. <a-input allowClear placeholder="请输入设备编号" v-model.trim="queryParam.deviceNo" id="cleanDetail-queryOrderDate" />
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  42. <a-form-model-item label="清运司机" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  43. <a-select
  44. id="cleanDetail-operatorUserId"
  45. placeholder="请选择清运司机"
  46. allowClear
  47. v-model="queryParam.operatorUserId"
  48. showSearch
  49. option-filter-prop="children"
  50. :filter-option="filterOption">
  51. <a-select-option v-for="item in cleanUserData" :key="item.id" :value="item.id">{{ 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="refresh" style="margin: 4px 10px 0 20px" id="cleanDetail-refresh">查询</a-button>
  57. <a-button type="" @click="reset" style="margin-top: 4px" id="cleanDetail-reset">重置</a-button>
  58. </a-col>
  59. </a-row>
  60. </a-form-model>
  61. </div>
  62. <!-- 合计 -->
  63. <a-alert type="info" showIcon style="margin-bottom:15px">
  64. <div class="ftext" slot="message">总计<span> {{ totalNum }} </span>条,可回收物清运量总计<span> {{ cleanWeightTotal }} </span>kg</div>
  65. </a-alert>
  66. <!-- 列表 -->
  67. <s-table
  68. ref="table"
  69. :rowKey="(record) => record.id"
  70. :columns="columns"
  71. :data="loadData"
  72. bordered
  73. >
  74. <span slot="action" slot-scope="text,record">
  75. <a-button type="primary" @click="handleDetail(record)" v-hasPermission="'B_cleanDetail'" id="cleanDetail-handleDetail">查看清运明细</a-button>
  76. <span v-if="!$hasPermissions('B_cleanDetail')">--</span>
  77. </span>
  78. </s-table>
  79. <!-- 详情弹窗 -->
  80. <cleanDetailModal :deviceNo="itemDeviceNo" :cleanTime="itemCleanTime" :visible="isOpenModal" @close="isOpenModal=false"></cleanDetailModal>
  81. </a-card>
  82. </template>
  83. <script>
  84. import { STable, VSelect } from '@/components'
  85. import { stationList } from '@/api/releaseRecord.js'
  86. import cleanDetailModal from './cleanDetailModal.vue'
  87. import { cleanDetailsList, getCleanDetailsTotal, cleanUserList } from '@/api/cleanManage.js'
  88. import moment from 'moment'
  89. export default {
  90. components: { STable, VSelect, cleanDetailModal },
  91. data () {
  92. return {
  93. formItemLayout: {
  94. labelCol: {
  95. span: 7
  96. },
  97. wrapperCol: {
  98. span: 17
  99. }
  100. },
  101. isOpenModal: false, // 默认弹窗关闭
  102. itemDeviceNo: '', // 每行设备编号
  103. itemCleanTime: '', // 每行清运时间
  104. // 查询参数
  105. queryParam: {
  106. operatorUserId: undefined, // 操作人id
  107. stationNo: undefined, // 网点编号
  108. deviceNo: null, // 设备编号
  109. beginDate: null, // 开始时间
  110. endDate: null // 结束时间
  111. },
  112. optionData: [], // 网点名称数据
  113. cleanUserData: [], // 操作人数据
  114. // 将默认当天时间日期回显在时间选择框中
  115. time: [],
  116. dateFormat: 'YYYY-MM-DD', // 日期格式
  117. totalNum: 0, // 总条数
  118. cleanWeightTotal: 0, // 可回收物清运量总计
  119. columns: [{ title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  120. { title: '清运时间', dataIndex: 'cleanTime', width: 100, align: 'center' },
  121. { title: '网点名称', dataIndex: 'stationName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  122. { title: '设备编号', dataIndex: 'srcDeviceCode', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  123. { title: '可回收物清运量(kg)', dataIndex: 'cleanWeight', width: 100, align: 'center', sorter: true, customRender: (text) => { return text || 0 } },
  124. { title: '清运司机', dataIndex: 'driverName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  125. { title: '操作人', dataIndex: 'operatorName', width: 100, align: 'center' },
  126. { title: '备注', dataIndex: 'remarks', width: 100, align: 'center', ellipsis: true, 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 cleanDetailsList(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.getCleanUserList()
  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. getCleanUserList () {
  181. cleanUserList().then(res => {
  182. if (res.status == 200) {
  183. this.cleanUserData = 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. getTotal () {
  197. const params = this.queryParam
  198. if (this.time && this.time.length) {
  199. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  200. params.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  201. } else {
  202. params.beginDate = null
  203. params.endDate = null
  204. }
  205. getCleanDetailsTotal(params).then(res => {
  206. if (res.status == 200) {
  207. if (res.data != 0 || null) {
  208. this.cleanWeightTotal = (res.data.cleanWeight / 1000).toFixed(3)
  209. }
  210. } else {
  211. this.cleanWeightTotal = 0
  212. }
  213. })
  214. },
  215. // 查询
  216. refresh () {
  217. this.$refs.table.refresh(true)
  218. this.getTotal()
  219. },
  220. // 重置
  221. reset () {
  222. this.queryParam = {
  223. operatorUserId: undefined, // 操作人id
  224. stationNo: undefined, // 网点编号
  225. deviceNo: null, // 设备编号
  226. beginDate: null, // 开始时间
  227. endDate: null // 结束时间
  228. }
  229. this.time = []
  230. this.refresh()
  231. },
  232. // 查看清运详情
  233. handleDetail (record) {
  234. this.itemDeviceNo = record.deviceNo
  235. this.itemCleanTime = record.cleanTime
  236. this.isOpenModal = true
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang='less' scoped>
  242. .cleanDetail-container {
  243. .cleanDetail-container-searchForm {
  244. .ant-form-inline .ant-form-item {
  245. width: 100%;
  246. margin-bottom: 15px;
  247. }
  248. }
  249. }
  250. </style>