cleanDetail.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. <!-- <a-button type="primary" @click="handleDetail(record)" >查看清运明细</a-button> -->
  78. </span>
  79. </s-table>
  80. <!-- 详情弹窗 -->
  81. <cleanDetailModal :deviceNo="itemDeviceNo" :cleanTime="itemCleanTime" :visible="isOpenModal" @close="isOpenModal=false"></cleanDetailModal>
  82. </a-card>
  83. </template>
  84. <script>
  85. import { STable, VSelect } from '@/components'
  86. import { stationList } from '@/api/releaseRecord.js'
  87. import cleanDetailModal from './cleanDetailModal.vue'
  88. import { cleanDetailsList, getCleanDetailsTotal, cleanUserList } from '@/api/cleanManage.js'
  89. import moment from 'moment'
  90. export default {
  91. components: { STable, VSelect, cleanDetailModal },
  92. data () {
  93. return {
  94. formItemLayout: {
  95. labelCol: {
  96. span: 7
  97. },
  98. wrapperCol: {
  99. span: 17
  100. }
  101. },
  102. isOpenModal: false, // 默认弹窗关闭
  103. itemDeviceNo: '', // 每行设备编号
  104. itemCleanTime: '', // 每行清运时间
  105. // 查询参数
  106. queryParam: {
  107. operatorUserId: undefined, // 网点编号
  108. deviceNo: null, // 设备编号
  109. loginFlag: '',
  110. beginDate: null, // 开始时间
  111. endDate: null // 结束时间
  112. },
  113. optionData: [], // 网点名称数据
  114. cleanUserData: [], // 操作人数据
  115. // 将默认当天时间日期回显在时间选择框中
  116. time: [],
  117. dateFormat: 'YYYY-MM-DD', // 日期格式
  118. totalNum: 0, // 总条数
  119. cleanWeightTotal: 0, // 可回收物清运量总计
  120. columns: [{ title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  121. { title: '清运时间', dataIndex: 'cleanTime', width: 100, align: 'center' },
  122. { title: '网点名称', dataIndex: 'stationName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  123. { title: '设备编号', dataIndex: 'deviceNo', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  124. { title: '可回收物清运量(kg)', dataIndex: 'cleanWeight', width: 100, align: 'center', sorter: true, customRender: (text) => { return text || 0 } },
  125. { title: '清运司机', dataIndex: 'driverName', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  126. { title: '操作人', dataIndex: 'operatorName', width: 100, align: 'center' },
  127. { title: '备注', dataIndex: 'remarks', width: 100, align: 'center', customRender: (text) => { return text || '--' } },
  128. { title: '操作', dataIndex: 'action', width: 100, align: 'center', scopedSlots: { customRender: 'action' } }],
  129. // 加载数据方法 必须为 Promise 对象
  130. loadData: parameter => {
  131. const searchData = Object.assign(parameter, this.queryParam)
  132. if (this.time && this.time.length) {
  133. searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  134. searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  135. } else {
  136. searchData.beginDate = null
  137. searchData.endDate = null
  138. }
  139. return cleanDetailsList(searchData).then(res => {
  140. if (res.status == 200) {
  141. const no = (res.data.pageNo - 1) * res.data.pageSize
  142. for (let i = 0; i < res.data.list.length; i++) {
  143. const _item = res.data.list[i]
  144. _item.no = no + i + 1
  145. if (_item.cleanWeight != null || 0) {
  146. _item.cleanWeight = (_item.cleanWeight / 1000).toFixed(2)
  147. }
  148. }
  149. this.totalNum = res.data.count
  150. return res.data
  151. } else {
  152. this.totalNum = 0
  153. }
  154. })
  155. }
  156. }
  157. },
  158. mounted () {
  159. this.getStationList()
  160. this.getTotal()
  161. this.getCleanUserList()
  162. },
  163. methods: {
  164. // 不可选日期
  165. disabledDate (date, dateStrings) {
  166. return date && date.valueOf() > Date.now()
  167. },
  168. // 创建时间change
  169. onChange (dates, dateStrings) {
  170. if ((dates, dateStrings)) {
  171. this.queryParam.beginDate = dateStrings[0]
  172. this.queryParam.endDate = dateStrings[1]
  173. }
  174. },
  175. filterOption (input, option) {
  176. return (
  177. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  178. )
  179. },
  180. // 获取操作人数据
  181. getCleanUserList () {
  182. cleanUserList().then(res => {
  183. if (res.status == 200) {
  184. this.cleanUserData = res.data || []
  185. console.log(this.cleanUserData)
  186. }
  187. })
  188. },
  189. // 获取合作商数据
  190. getStationList () {
  191. stationList().then(res => {
  192. if (res.status == 200) {
  193. this.optionData = res.data || []
  194. }
  195. })
  196. },
  197. // 合计
  198. getTotal () {
  199. const params = this.queryParam
  200. if (this.time && this.time.length) {
  201. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD 00:00:00')
  202. params.endDate = moment(this.time[1]).format('YYYY-MM-DD 23:59:59')
  203. } else {
  204. params.beginDate = null
  205. params.endDate = null
  206. }
  207. getCleanDetailsTotal(params).then(res => {
  208. if (res.status == 200) {
  209. if (res.data != 0 || null) {
  210. this.cleanWeightTotal = (res.data.cleanWeight / 1000).toFixed(2)
  211. }
  212. } else {
  213. this.cleanWeightTotal = 0
  214. }
  215. })
  216. },
  217. // 查询
  218. refresh () {
  219. this.$refs.table.refresh(true)
  220. this.getTotal()
  221. },
  222. // 重置
  223. reset () {
  224. this.queryParam = {
  225. operatorUserId: undefined, // 网点编号
  226. deviceNo: null, // 设备编号
  227. loginFlag: '',
  228. beginDate: null, // 开始时间
  229. endDate: null // 结束时间
  230. }
  231. this.time = []
  232. this.refresh()
  233. },
  234. // 查看清运详情
  235. handleDetail (record) {
  236. this.itemDeviceNo = record.deviceNo
  237. this.itemCleanTime = record.cleanTime
  238. this.isOpenModal = true
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang='less' scoped>
  244. .cleanDetail-container {
  245. .cleanDetail-container-searchForm {
  246. .ant-form-inline .ant-form-item {
  247. width: 100%;
  248. margin-bottom: 15px;
  249. }
  250. }
  251. }
  252. </style>