index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. .order-detail {
  22. margin-left: 20px;
  23. }
  24. .el-table {
  25. &:deep(.el-table__body-wrapper) {
  26. width: 100% !important;
  27. height: calc(100% - 108px) !important; // 表格高度减去表头的高度
  28. .el-scrollbar__bar.is-horizontal {
  29. height: 10px;
  30. left: 2px;
  31. }
  32. }
  33. }
  34. </style>
  35. <template>
  36. <div class="system-container layout-padding">
  37. <el-card shadow="hover" class="layout-padding-auto">
  38. <ext-query-form
  39. class="page-search"
  40. ref="queryRef"
  41. v-model="state.formQuery"
  42. :columns="state.columns"
  43. :import-config="state.importConfig"
  44. :export-config="state.exportConfig"
  45. @on-change="loadData(true)"
  46. @imported="loadData(true)">
  47. <!-- <template #extraQuery></template>
  48. <template #extraLeft></template>
  49. <template #extraRight></template>-->
  50. </ext-query-form>
  51. <el-table
  52. border
  53. stripe="stripe"
  54. :height="state.tableData.height"
  55. highlight-current-row
  56. current-row-key="id"
  57. row-key="id"
  58. @on-row-click="handleRowClick('view',$event)"
  59. :data="state.tableData.data"
  60. v-loading="state.tableData.loading">
  61. <template #empty>
  62. <el-empty></el-empty>
  63. </template>
  64. <el-table-column
  65. v-for="field in state.columns"
  66. :key="field.prop"
  67. :type="field.type"
  68. :label="field.label"
  69. :column-key="field.prop"
  70. :width="field.width"
  71. :min-width="field.minWidth"
  72. :fixed="field.fixed"
  73. :sortable="field.sortable"
  74. :show-overflow-tooltip="!field.fixed&&field.width>150">
  75. <template #default="{row}">
  76. <template v-if="field.type==='expand'">
  77. <div class="order-detail">
  78. <el-table
  79. border
  80. :data="row.detail"
  81. stripe="stripe">
  82. <el-table-column width="120" label="服务项目" prop="name"></el-table-column>
  83. <el-table-column width="120" label="服务时长" prop="seconds"></el-table-column>
  84. <el-table-column width="120" label="服务单价" prop="price"></el-table-column>
  85. <el-table-column width="120" label="小计金额" prop="amount"></el-table-column>
  86. </el-table>
  87. </div>
  88. </template>
  89. <template v-else-if="'stationId'===field.prop">
  90. <div class="flex-align-items-center text-align-center">
  91. <div>
  92. {{ row.stationId }}
  93. </div>
  94. <hr/>
  95. <div>
  96. {{ row.stationName }}
  97. </div>
  98. </div>
  99. </template>
  100. <template v-else-if="field.prop==='discountType'">
  101. <ext-d-label type="Activity.discountType" :model-value="row[field.prop]"></ext-d-label>
  102. </template>
  103. <template v-else-if="field.prop==='cardType'">
  104. <ext-d-label type="OrderCard.type" :model-value="row[field.prop]"></ext-d-label>
  105. </template>
  106. <template v-else-if="field.prop==='invoiceStatus'">
  107. <ext-d-label type="Invoice.status" :model-value="row[field.prop]"></ext-d-label>
  108. </template>
  109. <template v-else-if="field.prop==='openType'">
  110. <ext-d-label type="Order.openType" :model-value="row[field.prop]"></ext-d-label>
  111. </template>
  112. <template v-else-if="field.prop==='orderStatus'">
  113. <ext-d-label type="Order.status" :model-value="row[field.prop]"></ext-d-label>
  114. </template>
  115. <template v-else-if="field.prop==='payStatus'">
  116. <ext-d-label type="Order.pay" :model-value="row[field.prop]"></ext-d-label>
  117. </template>
  118. <template v-else-if="field.prop==='closeType'">
  119. <ext-d-label type="Order.closeType" :model-value="row[field.prop]"></ext-d-label>
  120. </template>
  121. <template v-else-if="['prepayMoney','amount','amountReceivable','amountReceived','cardBalance','coinMoney','discountAmount','discountMoney'].includes(field.prop)">
  122. {{ u.fmt.fmtMoney(row[field.prop]) }}
  123. </template>
  124. <template v-else-if="field.prop==='idleRemainTime'||field.prop==='operationRemainTime'">
  125. {{ u.fmt.fmtDuration(row[field.prop]) }}
  126. </template>
  127. <template v-else-if="field.prop==='createTime'">
  128. {{ u.fmt.fmtDateTime(row[field.prop]) }}
  129. </template>
  130. <template v-else-if="field.prop==='updateTime'">
  131. {{ u.fmt.fmtDateTime(row[field.prop]) }}
  132. </template>
  133. <template v-else>
  134. <div>{{ row[field.prop] }}</div>
  135. </template>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  140. </el-card>
  141. </div>
  142. </template>
  143. <script lang="ts">
  144. export default {
  145. name: 'adminOrdering'
  146. }
  147. </script>
  148. <script setup lang="ts" name="adminOrdering">
  149. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  150. import {$body, $get} from "/@/utils/request";
  151. import u from '/@/utils/u'
  152. import {Msg} from "/@/utils/message";
  153. import {Session} from "/@/utils/storage";
  154. const {proxy}: any = getCurrentInstance();
  155. import ExtPage from '/@/components/form/ExtPage.vue'
  156. import ExtQueryForm from "/@/components/form/ExtQueryForm.vue";
  157. import mittBus from '/@/utils/mitt';
  158. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  159. //定义引用
  160. const queryRef = ref();
  161. const washOrderDialogRef = ref();
  162. //定义变量
  163. const state = reactive({
  164. formQuery: {},
  165. pageQuery: {
  166. pageNum: 1,
  167. pageSize: 10,
  168. total: 0
  169. },
  170. tableData: {
  171. height: 500,
  172. data: [] as Array<any>,
  173. loading: false
  174. },
  175. importConfig: {},
  176. exportConfig: {},
  177. columns: [
  178. {type: 'expand', width: 60, align: 'center', fixed: 'left'},
  179. {label: '站点', prop: 'stationId', width: 140,query: true, type: 'select', resizable: true,conf:{url:'washStation/list',labelKey:'stationName',valueKey:'stationId',dataKey:'list'}},
  180. {width: 220, label: '订单号', prop: 'orderId', query: true, type: 'text', resizable: true, fixed: 'left'},
  181. {width: 120, label: '用户手机号', prop: 'mobilePhone', query: true, type: 'text', fixed: 'left'},
  182. {width: 100, label: '设备编号', prop: 'shortId', query: false, type: 'text', resizable: true},
  183. {width: 160, label: '开始时间', prop: 'startTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDate(val)}},
  184. {width: 160, label: '结束时间', prop: 'endTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
  185. {width: 100, label: '消费总额', prop: 'amount', query: false, resizable: true},
  186. {width: 100, label: '应收金额', prop: 'amountReceivable', query: false, type: '', resizable: true},
  187. {width: 100, label: '实收金额', prop: 'amountReceived', query: false, type: 'text', resizable: true},
  188. // {width: 160, label: '卡内余额', prop: 'cardBalance', query: false, type: 'text', resizable: true},
  189. // {
  190. // width: 160, label: '卡过期时间',
  191. // prop: 'cardExpired',
  192. // query: false,
  193. // sortable: 'custom',
  194. // type: 'datetime',
  195. // resizable: true,
  196. // conf: {format: (val: any) => u.fmt.fmtDateTime(val)}
  197. // },
  198. // {width: 160, label: '卡内码', prop: 'cardId', query: false, type: 'text', resizable: true},
  199. // {width: 160, label: '卡串号', prop: 'cardSn', query: false, type: 'text', resizable: true},
  200. // {width: 160, label: '卡类型', prop: 'cardType', query: false, type: '', resizable: true},
  201. {
  202. width: 120, label: '关机方式',
  203. prop: 'closeType',
  204. query: false,
  205. type: 'dict',
  206. conf: {dict: 'Order.closeType'},
  207. resizable: true
  208. },
  209. // {width: 160, label: '投币的累计金额', prop: 'coinMoney', query: false, type: 'text', resizable: true},
  210. // {width: 160, label: '投币的次数', prop: 'coinNum', query: false, type: 'text', resizable: true},
  211. // {width: 160, label: '开单时间', prop: 'createTime', query: false, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDateTime(val)}},
  212. // {
  213. // width:160,label: '费用明细',
  214. // prop: 'detail',
  215. // query: true,
  216. // type: 'text',
  217. // resizable: true
  218. // },
  219. // {width: 160, label: '优惠金额', prop: 'discountAmount', query: false, type: '', resizable: true},
  220. // {width: 160, label: '优惠方式', prop: 'discountType', query: false, type: 'dict', conf: {dict: 'Activity.discountType'}, resizable: true},
  221. // {
  222. // width: 160, label: '设备空闲关机倒计时剩余时间',
  223. // prop: 'idleRemainTime',
  224. // query: true,
  225. // type: 'text',
  226. // resizable: true
  227. // },
  228. // {width: 160, label: '会员折扣比例', prop: 'memberDiscount', query: false, type: 'text', resizable: true},
  229. // {width: 160, label: '开机方式', prop: 'openType', query: false, type: 'dict', conf: {dict: 'Order.openType'}, resizable: true},
  230. // {width: 160, label: '订单操作剩余操作时间(单位秒)', prop: 'operationRemainTime', query: false, type: 'text', resizable: true},
  231. // {width: 160, label: '本机订单号', prop: 'orderIdLocal', query: false, type: 'text', resizable: true},
  232. {width: 100, label: '订单状态', prop: 'orderStatus', query: false, type: 'dict', conf: {dict: 'Order.status'}, resizable: true},
  233. {width: 100, label: '支付状态', prop: 'payStatus', query: true, type: 'dict', conf: {dict: 'Order.pay'}, resizable: true},
  234. {width: 100, label: '发票状态', prop: 'invoiceStatus', query: false, type: 'dict', conf: {dict: 'Invoice.status'}, resizable: true},
  235. // {width: 160, label: '本次开机的预付金额', prop: 'prepayMoney', query: true, type: '', resizable: true},
  236. // {width: 160, label: '产品key', prop: 'productKey', query: false, type: 'text', resizable: true},
  237. // {width: 160, label: '站点ID', prop: 'stationId', query: true, type: 'text', resizable: true},
  238. // {label: '停机原因', prop: 'stopReason', query: false, type: 'text', resizable: true},
  239. {
  240. width: 160,
  241. label: '更新时间',
  242. fixed: 'right',
  243. prop: 'updateTime',
  244. query: false,
  245. sortable: 'custom',
  246. type: 'datetime',
  247. resizable: true,
  248. conf: {format: (val: any) => u.fmt.fmtDate(val)}
  249. },
  250. ],
  251. })
  252. // 监听双向绑定 modelValue 的变化
  253. // watch(
  254. // () => state.pageNum,
  255. // () => {
  256. // //:' +
  257. // 'name 名称 price 单价(单位分) ' +
  258. // 'seconds 时长(单位秒) ' +
  259. // 'amount 费用(单位分)' +
  260. // ' space⻋位或场地,' +
  261. // 'water清水,' +
  262. // 'foam泡沫,' +
  263. // 'leaner吸尘,' +
  264. // 'tap水龙头,' +
  265. // 'user_ext用户扩展,消毒或吹干等功能,' +
  266. // 'coat镀膜,' +
  267. // 'blow吹气
  268. // }
  269. // );
  270. //生命周期钩子
  271. onBeforeMount(() => {
  272. let token = Session.get("token")
  273. let encodeToken = encodeURIComponent(token)
  274. let exportUrl = `poi/export?type=washOrder&X-Token=${encodeToken}`
  275. //导入导出参数配置
  276. state.importConfig = {
  277. auths: ['washOrder.add'],
  278. url: `poi/import?type=washOrder&X-Token=${encodeToken}`,
  279. template: `${exportUrl}&isTemplate=true`
  280. }
  281. state.exportConfig = {url: exportUrl,}
  282. })
  283. onMounted(() => {
  284. console.log("ordering mounted")
  285. loadData();
  286. nextTick(() => {
  287. let bodyHeight = document.body.clientHeight;
  288. let queryHeight = queryRef.value.$el.clientHeight;
  289. state.tableData.height = bodyHeight - queryHeight - 220
  290. })
  291. mittBus.on("washOrder.refresh", () => {
  292. loadData();
  293. })
  294. });
  295. onBeforeUnmount(() => {
  296. mittBus.off("washOrder.refresh")
  297. })
  298. //region 方法区
  299. // 初始化表格数据
  300. const loadData = (refresh: boolean = false) => {
  301. if (refresh) {
  302. state.pageQuery.pageNum = 1;
  303. }
  304. state.tableData.loading = true;
  305. $body(`/washOrder/list`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  306. let {list, total} = res;
  307. list.forEach((item: any) => {
  308. if (item.detail) {
  309. // let parse = JSON.parse(item.detail);
  310. item.detail = item.detail.filter((k: any) => k.amount > 0 || k.seconds > 0).map((s: any) => {
  311. return {
  312. name: u.fmt.fmtDict(s.name, 'Order.feeType'),
  313. seconds: u.fmt.fmtDuration(s.seconds * 1000),
  314. price: u.fmt.fmtMoney(s.price),
  315. amount: u.fmt.fmtMoney(s.amount),
  316. }
  317. })
  318. } else {
  319. item.detail = {}
  320. }
  321. })
  322. state.tableData.data = list;
  323. state.pageQuery.total = total;
  324. state.tableData.loading = false;
  325. }).catch(e => {
  326. //console.error(e)
  327. state.tableData.loading = false;
  328. })
  329. };
  330. // 打开详情页弹窗
  331. const handleRowClick = (type: string, row: any) => {
  332. washOrderDialogRef.value.open(type, row);
  333. };
  334. // 删除点击
  335. const handleRowDelete = (row: any) => {
  336. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  337. $get(`/washOrder/delete/${row.id}`).then(() => {
  338. Msg.message("删除成功", 'success')
  339. }).catch(() => {
  340. Msg.message("删除失败", 'error')
  341. })
  342. });
  343. };
  344. //endregion
  345. // 暴露变量
  346. // defineExpose({
  347. // loadData,
  348. // });
  349. </script>