index.vue 13 KB

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