cleanDetail.vue 11 KB

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