waybillManager.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /** // author:jiana // time:2025-04-23 // desc:运单管理 */
  2. <template>
  3. <div class="waybillManager">
  4. <Card>
  5. <!-- 筛选 -->
  6. <Row :gutter="8">
  7. <Col span="10">
  8. 运单号 <Input v-model="filtInfoData.waybillNum" placeholder="请输入运单号" style="width: 80%" />
  9. </Col>
  10. <Col span="2">
  11. <Button type="primary" @click="getData">查询</Button>
  12. </Col>
  13. <Col span="2">
  14. <Button @click="resetData">重置</Button>
  15. </Col>
  16. <Col span="2">
  17. <Button type="primary" @click="exportModal = true">导出</Button>
  18. </Col>
  19. </Row>
  20. </Card>
  21. <Card style="margin-top: 20px">
  22. <Row>
  23. <Col span="12"> 运单列表 </Col>
  24. <Col span="12" style="text-align: right">
  25. <!-- <Button @click="batchOperation">批量操作</Button> -->
  26. </Col>
  27. </Row>
  28. <!-- 表格部分 -->
  29. <el-table
  30. v-loading="loading"
  31. :data="TabData.data"
  32. border
  33. style="width: 100%; margin-top: 20px"
  34. @selection-change="handleSelectionChange"
  35. >
  36. <!-- <el-table-column type="selection" align="center" width="50"/> -->
  37. <el-table-column label="运单号" width="180" prop="waybillNum" align="center" />
  38. <el-table-column label="运输起始地" width="100" prop="transportOrigin" align="center"></el-table-column>
  39. <el-table-column label="运输目的地" width="120" prop="transportDestination" align="center"></el-table-column>
  40. <el-table-column label="司机姓名" prop="driverName" width="120" align="center"></el-table-column>
  41. <el-table-column label="司机手机号" prop="driverPhone" width="120" align="center"></el-table-column>
  42. <el-table-column label="车牌" prop="plateNumber" width="120" align="center"></el-table-column>
  43. <el-table-column label="车牌颜色" align="center" prop="plateColor" width="100"> </el-table-column>
  44. <el-table-column label="状态" align="center" width="100">
  45. <template #default="scope">
  46. <span>{{ wayBillStatus(scope.row.status) }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="运输发货时间" width="160" align="center">
  50. <template #default="scope">
  51. {{ moment(scope.row.startTime).format('yyyy-MM-DD hh:mm:ss') || '暂无' }}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="运输到货时间" width="160" align="center">
  55. <template #default="scope">
  56. {{ moment(scope.row.endTime).format('yyyy-MM-DD hh:mm:ss') || '暂无' }}
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="订单号" prop="orderInfo.orderNum" width="220" align="center"></el-table-column>
  60. <el-table-column label="物料名称" prop="orderInfo.name" width="150" align="center"></el-table-column>
  61. <el-table-column label="供应商名称" prop="orderInfo.company" width="180" align="center"></el-table-column>
  62. <el-table-column label="牧场名称" prop="orderInfo.orgName" width="180" align="center"></el-table-column>
  63. <el-table-column label="操作" width="130" fixed="right" align="center">
  64. <template #default="scope">
  65. <Button class="opt_btn" size="small" type="primary" ghost @click="lookTrack(scope.row)">查看轨迹</Button>
  66. <!-- <Button class="opt_btn" size="small" type="warning" @click="deleteInfo(scope.row.id)">删除</Button> -->
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <!-- 分页 -->
  71. <div class="page_style">
  72. <Page :total="TabData.total" :model-value="currentPage" show-elevator show-total @on-change="changePage" />
  73. </div>
  74. </Card>
  75. <Modal v-model="showModal" width="75%" title="查看轨迹">
  76. <mapTrack :waybillNum="waybillNum" :waybill="waybill" v-if="showModal"></mapTrack>
  77. </Modal>
  78. <!-- 运单状态选择弹框 -->
  79. <Modal v-model="exportModal" width="30%" @on-ok="exportData" ok-text="确认导出" title="导出运单状态选择">
  80. <div>
  81. <div class="modal-content">
  82. <div class="modal-header">
  83. <h3>运单状态选择</h3>
  84. </div>
  85. <div class="modal-body">
  86. <el-select v-model="waybillStatus" placeholder="全部">
  87. <el-option label="全部" value=""></el-option>
  88. <el-option label="未开始" value="CREATED"></el-option>
  89. <el-option label="运输中" value="IN_TRANSIT"></el-option>
  90. <el-option label="运单结束" value="FINISHED"></el-option>
  91. </el-select>
  92. </div>
  93. </div>
  94. </div>
  95. </Modal>
  96. </div>
  97. </template>
  98. <script>
  99. import { defineComponent, ref, reactive, onMounted } from 'vue'
  100. import { tms } from '@/request/api'
  101. import { Message, Modal, Spin, Input } from 'view-ui-plus'
  102. import moment from 'moment'
  103. import { useRouter, useRoute } from 'vue-router'
  104. import AMapLoader from '@amap/amap-jsapi-loader'
  105. import mapTrack from './mapTrack.vue'
  106. import api from '@/request/apiConfig'
  107. import { wayBillStatus, plateColorFilter } from '@/utils/system/filters'
  108. import axios from 'axios'
  109. export default defineComponent({
  110. components: {
  111. mapTrack,
  112. },
  113. setup() {
  114. const router = useRouter()
  115. const route = useRoute()
  116. const exportModal = ref(false)
  117. let filtInfoData = reactive({
  118. // 搜索
  119. limit: 10,
  120. offset: 0,
  121. waybillNum: '',
  122. })
  123. let TabData = ref([]) // 列表数据
  124. let loading = ref(false)
  125. //获取列表内容
  126. async function getData() {
  127. loading.value = true
  128. await tms.queryWaybillByCondition(filtInfoData).then(res => {
  129. if (res.code == 0) {
  130. TabData.value = res
  131. }
  132. })
  133. loading.value = false
  134. }
  135. //重置
  136. function resetData() {
  137. filtInfoData.offset = 0
  138. filtInfoData.limit = 10
  139. filtInfoData.waybillNum = ''
  140. getData()
  141. }
  142. let currentPage = ref(1)
  143. //更改页码
  144. function changePage(page) {
  145. if (TabData.value.limit) {
  146. filtInfoData.offset = (page - 1) * TabData.value.limit //更新偏移量
  147. currentPage = page //切换当前页码
  148. getData()
  149. }
  150. }
  151. //删除
  152. function deleteInfo(id) {
  153. this.$Modal.confirm({
  154. title: '提示',
  155. content: '<p>确定删除该信息吗?</p>',
  156. onOk: async () => {
  157. const params = {
  158. id: id,
  159. reason: offSafeValue.value,
  160. }
  161. await cow.cattleDealoffSale(params).then(res => {
  162. if (res.code === 101) {
  163. Message.success('删除成功!')
  164. getData()
  165. }
  166. })
  167. },
  168. onCancel: () => {
  169. this.$Message.info('Clicked cancel')
  170. },
  171. })
  172. }
  173. //批量操作
  174. function batchOperation() {}
  175. const showModal = ref(false)
  176. let waybillNum = ref('')
  177. let waybill = ref({}) // 运单数据
  178. // 查看详情
  179. function lookTrack(data) {
  180. waybill.value = data
  181. waybillNum.value = data.waybillNum
  182. showModal.value = true
  183. }
  184. // 选择监听器
  185. const handleSelectionChange = val => {
  186. context.emit('selection-change', val)
  187. }
  188. const waybillStatus = ref('')
  189. // 导出
  190. const exportData = () => {
  191. console.log(api, 'api');
  192. axios({
  193. method: 'get',
  194. url: api.apiTms + '/waybills/wayBillListExport',
  195. // headers里面设置token
  196. headers: {
  197. 'Content-Type': 'application/json',
  198. 'X-AIYANGNIU-SIGNATURE': localStorage.aynUserToken,
  199. },
  200. params: {
  201. status: waybillStatus.value,
  202. },
  203. dataType: 'json',
  204. // 二进制流文件,一定要设置成blob,默认是json
  205. responseType: 'blob',
  206. }).then(res => {
  207. const filename = '运单报表'
  208. const link = document.createElement('a')
  209. const blob = new Blob([res.data], { type: 'application/zip;charset=utf-8' })
  210. if ('download' in document.createElement('a')) {
  211. // 非IE下载
  212. const elink = document.createElement('a')
  213. elink.download = filename + '.xls'
  214. elink.style.display = 'none'
  215. elink.href = URL.createObjectURL(blob)
  216. document.body.appendChild(elink)
  217. elink.click()
  218. URL.revokeObjectURL(elink.href) // 释放URL 对象
  219. document.body.removeChild(elink)
  220. } else {
  221. // IE10+下载
  222. navigator.msSaveBlob(blob, fileName)
  223. }
  224. })
  225. }
  226. onMounted(() => {
  227. getData()
  228. })
  229. return {
  230. handleSelectionChange,
  231. getData,
  232. changePage,
  233. moment,
  234. deleteInfo,
  235. TabData,
  236. filtInfoData,
  237. loading,
  238. batchOperation,
  239. resetData,
  240. lookTrack,
  241. showModal,
  242. wayBillStatus,
  243. plateColorFilter,
  244. waybillNum,
  245. waybill,
  246. exportData,
  247. exportModal,
  248. waybillStatus
  249. }
  250. },
  251. })
  252. </script>
  253. <style lang="scss" scoped>
  254. .waybillManager {
  255. padding: 1em;
  256. .opt_btn {
  257. margin-bottom: 3px;
  258. margin-right: 3px;
  259. }
  260. .page_style {
  261. text-align: right;
  262. margin-top: 1em;
  263. // background-color: var(--system-container-background);
  264. }
  265. }
  266. </style>