index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <style scoped lang="scss">
  2. .system-container {
  3. :deep(.el-card__body) {
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: space-between;
  7. flex: 1;
  8. overflow: auto;
  9. .el-table {
  10. flex: 1;
  11. }
  12. }
  13. }
  14. .page-content {
  15. margin-bottom: 20px;
  16. }
  17. .page-pager {
  18. background-color: #fff;
  19. height: 24px;
  20. }
  21. </style>
  22. <template>
  23. <div class="system-container layout-padding">
  24. <el-card shadow="hover" class="layout-padding-auto">
  25. <el-form
  26. :model="state.formQuery"
  27. ref="queryRef"
  28. size="default" label-width="0px" class="mt5 mb5">
  29. <el-input
  30. v-model="state.formQuery.mobilePhone"
  31. placeholder="用户手机号"
  32. clearable
  33. @blur="loadData(true)"
  34. class="wd150 mr10">
  35. </el-input>
  36. <ext-select
  37. v-model="state.formQuery.stationIds"
  38. placeholder="站点"
  39. clearable
  40. url="station/listStation"
  41. urlMethod="get"
  42. data-key=""
  43. label-key="stationName"
  44. value-key="stationId"
  45. @on-change="loadData(true)"
  46. class="wd150 mr10">
  47. </ext-select>
  48. <el-input
  49. v-model="state.formQuery.startChargeSeq"
  50. placeholder="充电订单号"
  51. clearable
  52. @blur="loadData(true)"
  53. class="wd150 mr10">
  54. </el-input>
  55. <el-input
  56. v-model="state.formQuery.connectorId"
  57. placeholder="充电设备接口编码"
  58. clearable
  59. @blur="loadData(true)"
  60. class="wd150 mr10">
  61. </el-input>
  62. <el-date-picker
  63. v-model="state.formQuery.startDate"
  64. placeholder="开始时间"
  65. type="date"
  66. value-format="YYYY-MM-DD"
  67. @on-change="loadData(true)"
  68. class="wd150 mr10">
  69. </el-date-picker>
  70. <el-date-picker
  71. v-model="state.formQuery.endDate"
  72. placeholder="结束时间"
  73. type="date"
  74. value-format="YYYY-MM-DD"
  75. @on-change="loadData(true)"
  76. class="wd150 mr10">
  77. </el-date-picker>
  78. <ext-d-select
  79. v-model="state.formQuery.orderStatus"
  80. type="ChargeOrder.orderStatus"
  81. placeholder="订单状态"
  82. clearable
  83. @on-change="loadData(true)"
  84. class="wd150 mr10">
  85. </ext-d-select>
  86. <ext-d-select
  87. v-model="state.formQuery.chargeStatus"
  88. placeholder="充电状态"
  89. clearable
  90. type="ChargeOrder.chargeStatus"
  91. @on-change="loadData(true)"
  92. class="wd150 mr10">
  93. </ext-d-select>
  94. <!-- <ext-d-select-->
  95. <!-- v-model="state.formQuery.stopReason"-->
  96. <!-- placeholder="充电停止原因"-->
  97. <!-- clearable-->
  98. <!-- type="ChargeOrder.stopReason"-->
  99. <!-- @blur="loadData(true)"-->
  100. <!-- class="wd150 mr10">-->
  101. <!-- </ext-d-select>-->
  102. <ext-d-select
  103. v-model="state.formQuery.invoiceStatus"
  104. placeholder="发票状态"
  105. clearable
  106. type="ChargeOrder.invoiceStatus"
  107. @on-change="loadData(true)"
  108. class="wd150 mr10">
  109. </ext-d-select>
  110. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  111. <SvgIcon name="ele-Search"/>
  112. 查询
  113. </el-button>
  114. </el-form>
  115. <el-card class="w100">
  116. <div class="order-summary">
  117. <span>订单笔数:</span>
  118. <el-tag type="success">{{ state.extraData.totalOrders }} 笔</el-tag>
  119. <span class="ml5">电量:</span>
  120. <el-tag type="success">{{ state.extraData.totalPower }} 度</el-tag>
  121. <span class="ml5">订单金额:</span>
  122. <el-tag type="success">{{ u.fmt.fmtMoney(state.extraData.totalMoney) }} 元</el-tag>
  123. <span class="ml5"> 电费:</span>
  124. <el-tag type="success">{{ u.fmt.fmtMoney(state.extraData.elecMoney) }} 元</el-tag>
  125. <span class="ml5">服务费:</span>
  126. <el-tag type="success">{{ u.fmt.fmtMoney(state.extraData.serviceMoney) }} 元</el-tag>
  127. <span class="ml5">服务费优惠:</span>
  128. <el-tag type="success">{{ u.fmt.fmtMoney(state.extraData.serviceMoneyDiscount) }} 元</el-tag>
  129. <span class="ml5">实付服务费:</span>
  130. <el-tag type="success">{{ u.fmt.fmtMoney(state.extraData.payServiceAmount) }} 元</el-tag>
  131. </div>
  132. </el-card>
  133. <el-table
  134. border
  135. stripe="stripe"
  136. :height="state.tableData.height"
  137. highlight-current-row
  138. current-row-key="id"
  139. row-key="id"
  140. :data="state.tableData.data"
  141. v-loading="state.tableData.loading"
  142. @selection-change="handleTableSelectionChange"
  143. @sort-change="handleTableSortChange">
  144. <template #empty>
  145. <el-empty></el-empty>
  146. </template>
  147. <el-table-column
  148. v-for="field in state.tableData.columns"
  149. :key="field.prop"
  150. :label="field.label"
  151. :align="field.align||'left'"
  152. :column-key="field.prop"
  153. :width="field.width"
  154. :min-width="field.minWidth"
  155. :fixed="field.fixed"
  156. :sortable="field.sortable"
  157. :show-overflow-tooltip="!field.fixed&&field.width>150"
  158. >
  159. <template #default="{row}">
  160. <template v-if="field.prop==='expand'">
  161. <p style="padding-left: 2em;" v-html="row[field.prop]"></p>
  162. </template>
  163. <template v-else-if="'totalMoney'===field.prop">
  164. {{ u.fmt.fmtMoney(row[field.prop]) }}
  165. </template>
  166. <template v-else-if="'elecMoney'===field.prop">
  167. {{ u.fmt.fmtMoney(row[field.prop]) }}
  168. </template>
  169. <template v-else-if="'serviceMoney'===field.prop">
  170. {{ u.fmt.fmtMoney(row[field.prop]) }}
  171. </template>
  172. <template v-else-if="'payAmount'===field.prop">
  173. {{ u.fmt.fmtMoney(row[field.prop]) }}
  174. </template>
  175. <template v-else-if="'discountAmount'===field.prop">
  176. {{ u.fmt.fmtMoney(row[field.prop]) }}
  177. </template>
  178. <template v-else-if="'serviceMoneyDiscount'===field.prop">
  179. {{ u.fmt.fmtMoney(row[field.prop]) }}
  180. </template>
  181. <template v-else-if="'payServiceAmount'===field.prop">
  182. {{ u.fmt.fmtMoney(row[field.prop]) }}
  183. </template>
  184. <template v-else-if="'orderStatus'===field.prop">
  185. <ext-d-label type="ChargeOrder.orderStatus" v-model="row[field.prop]"/>
  186. </template>
  187. <template v-else-if="'chargeStatus'===field.prop">
  188. <ext-d-label type="ChargeOrder.chargeStatus" v-model="row[field.prop]"/>
  189. </template>
  190. <template v-else-if="'stopReason'===field.prop">
  191. <ext-d-label type="ChargeOrder.stopReason" v-model="row[field.prop]"/>
  192. </template>
  193. <template v-else-if="'invoiceStatus'===field.prop">
  194. <ext-d-label type="ChargeOrder.invoiceStatus" v-model="row[field.prop]"/>
  195. </template>
  196. <template v-else-if="'startTime'===field.prop">
  197. <div title="充电开始时间">
  198. {{ (row.startTime) }}
  199. </div>
  200. <hr>
  201. <div title="充电结束时间">
  202. {{ (row.endTime) }}
  203. </div>
  204. </template>
  205. <template v-else-if="'stationId'===field.prop">
  206. <div >
  207. {{ (row.stationId) }}
  208. </div>
  209. <hr v-if="row.stationName">
  210. <div >
  211. {{ (row.stationName) }}
  212. </div>
  213. </template>
  214. <template v-else>
  215. <div>{{ row[field.prop] }}</div>
  216. </template>
  217. </template>
  218. </el-table-column>
  219. </el-table>
  220. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  221. </el-card>
  222. </div>
  223. <!-- <ChargeOrderDialog ref="chargeOrderDialogRef" @refresh="loadData(true)"/>-->
  224. </template>
  225. <script setup lang="ts" name="ChargeOrderList">
  226. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  227. import {$body, $get} from "/@/utils/request";
  228. import {Msg} from "/@/utils/message";
  229. import u from "/@/utils/u"
  230. import {useRoute} from "vue-router";
  231. const route = useRoute();
  232. import ExtPage from '/@/components/form/ExtPage.vue'
  233. import mittBus from '/@/utils/mitt';
  234. import ExtDatePicker from "/@/components/form/ExtDatePicker.vue";
  235. import ExtDSelect from "/@/components/form/ExtDSelect.vue";
  236. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  237. import ExtSelect from "/@/components/form/ExtSelect.vue";
  238. // const ChargeOrderDialog = defineAsyncComponent(() => import("/@/views/page/ChargeOrderDialog.vue"));
  239. //定义引用
  240. const queryRef = ref();
  241. const chargeOrderDialogRef = ref();
  242. //定义变量
  243. const state = reactive({
  244. formQuery: {},
  245. pageQuery: {
  246. pageNum: 1,
  247. pageSize: 10,
  248. total: 0
  249. },
  250. tableData: {
  251. height: 500,
  252. data: [] as Array<any>,
  253. loading: false,
  254. columns: [
  255. {label: '站点ID/名称', prop: 'stationId', width: 130,align:'center', resizable: true, fixed: 'left'},
  256. {label: '用户手机号', prop: 'mobilePhone', width: 120, resizable: true, fixed: 'left'},
  257. // {label: '站点ID', prop: 'stationId',width:100, resizable: true, fixed: 'left'},
  258. // {label: '站点', prop: 'stationName', width: 150, resizable: true, fixed: 'left'},
  259. {label: '充电订单号', prop: 'startChargeSeq', width: 170, resizable: true, fixed: 'left'},
  260. {label: '设备编号', prop: 'shortId', width: 90, resizable: true},
  261. {label: '充电设备接口编码', prop: 'connectorId', width: 160, resizable: true},
  262. {label: '充电开始/结束时间', prop: 'startTime', sortable: 'custom', width: 175, resizable: true},
  263. // {label: '充电结束时间', prop: 'endTime', sortable: 'custom', width: 160, resizable: true},
  264. {label: '充电量/度', prop: 'totalPower', width: 95, resizable: true},
  265. {label: '订单总金额', prop: 'totalMoney', width: 105, resizable: true},
  266. {label: '服务费优惠', prop: 'serviceMoneyDiscount', width: 105, resizable: true},
  267. {label: '实付金额', prop: 'payAmount', width: 90, resizable: true},
  268. {label: '总电费', prop: 'elecMoney', width: 80, resizable: true},
  269. {label: '总服务费', prop: 'serviceMoney', width: 90, resizable: true},
  270. {label: '实付服务费', prop: 'payServiceAmount', width: 105, resizable: true},
  271. // {label: '时段数:0~32', prop: 'sumPeriod', width:150, resizable: true},
  272. // {label: '充电明细信息', prop: 'chargeDetail', width:150, resizable: true},
  273. {label: '订单状态', prop: 'orderStatus', width: 90, resizable: true},
  274. {label: '充电状态', prop: 'chargeStatus', width: 90, resizable: true},
  275. {label: '充电停止原因', prop: 'stopReason', width: 120, resizable: true},
  276. {label: '发票状态', prop: 'invoiceStatus', width: 90, resizable: true},
  277. // {label: '创建时间', prop: 'createTime', sortable: 'custom', width:150, resizable: true},
  278. // {label: '更新时间', prop: 'updateTime', sortable: 'custom',width:150, resizable: true},
  279. // {
  280. // label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
  281. // }
  282. ],
  283. },
  284. extraData: {
  285. totalOrders: 0,
  286. totalPower: 0,
  287. elecMoney: 0,
  288. serviceMoney: 0,
  289. totalMoney: 0,
  290. }
  291. })
  292. // 监听双向绑定 modelValue 的变化
  293. // watch(
  294. // () => state.pageIndex,
  295. // () => {
  296. //
  297. // }
  298. // );
  299. //生命周期钩子
  300. onBeforeMount(() => {
  301. })
  302. onMounted(() => {
  303. var query = route.query;
  304. console.log(route.params, route.query)
  305. if (query.connectorId) {
  306. state.formQuery.connectorId = query.connectorId;
  307. }
  308. if (query.mobilePhone) {
  309. state.formQuery.mobilePhone = query.mobilePhone;
  310. }
  311. loadData();
  312. nextTick(() => {
  313. let bodyHeight = document.body.clientHeight;
  314. let queryHeight = queryRef.value.$el.clientHeight;
  315. state.tableData.height = bodyHeight - queryHeight - 320
  316. // state.tableData.height =300
  317. })
  318. mittBus.on("chargeOrder.refresh", () => {
  319. loadData();
  320. })
  321. });
  322. onBeforeUnmount(() => {
  323. mittBus.off("chargeOrder.refresh")
  324. })
  325. //region 方法区
  326. // 初始化表格数据
  327. const loadData = (refresh: boolean = false) => {
  328. if (refresh) {
  329. state.pageQuery.pageNum = 1;
  330. }
  331. state.tableData.loading = true;
  332. $get(`/custom/listChargeOrders`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  333. let {list, total, extraData} = res;
  334. state.extraData = extraData;
  335. state.tableData.data = list;
  336. state.pageQuery.total = total;
  337. state.tableData.loading = false;
  338. }).catch(e => {
  339. console.error(e)
  340. state.tableData.loading = false;
  341. })
  342. };
  343. // 打开修改用户弹窗
  344. const onRowClick = (type: string, row: any) => {
  345. chargeOrderDialogRef.value.open(type, row);
  346. };
  347. // 删除用户
  348. const onRowDel = (row: any) => {
  349. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  350. $get(`/chargeOrder/delete/${row.id}`).then(() => {
  351. Msg.message("删除成功", 'success')
  352. }).catch(() => {
  353. Msg.message("删除失败", 'error')
  354. })
  355. });
  356. };
  357. const handleTableSelectionChange = (selection: any) => {
  358. console.log("handleTableSelectionChange>>", selection)
  359. // emit("on-check-change", selection)
  360. }
  361. const handleTableSortChange = (column, prop, order) => {
  362. console.log("handleTableSortChange>>", column, prop, order)
  363. // emit("on-sort-change", column)
  364. }
  365. //endregion
  366. // 暴露变量
  367. // defineExpose({
  368. // loadData,
  369. // });
  370. </script>