index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.statMonth"-->
  31. <!-- placeholder="统计时间"-->
  32. <!-- clearable-->
  33. <!-- @blur="loadData(true)"-->
  34. <!-- class="wd150 mr10">-->
  35. <!-- </el-input>-->
  36. <el-date-picker
  37. placeholder="统计时间(月)"
  38. @change="loadData(true)"
  39. value-format="YYYY-MM"
  40. v-model="state.formQuery.statMonth"
  41. type="month"
  42. class="wd150 mr10"
  43. />
  44. <ext-select
  45. v-model="state.formQuery.stationId"
  46. placeholder="站点"
  47. clearable
  48. url="station/listStation"
  49. urlMethod="get"
  50. data-key=""
  51. label-key="stationName"
  52. value-key="stationId"
  53. @on-change="loadData(true)"
  54. class="wd150 mr10">
  55. </ext-select>
  56. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  57. <SvgIcon name="ele-Search"/>
  58. 查询
  59. </el-button>
  60. </el-form>
  61. <el-table
  62. border
  63. stripe="stripe"
  64. :height="state.tableData.height"
  65. highlight-current-row
  66. current-row-key="id"
  67. row-key="id"
  68. :data="state.tableData.data"
  69. v-loading="state.tableData.loading"
  70. @selection-change="handleTableSelectionChange"
  71. @sort-change="handleTableSortChange">
  72. <template #empty>
  73. <el-empty></el-empty>
  74. </template>
  75. <el-table-column
  76. v-for="field in state.tableData.columns"
  77. :key="field.prop"
  78. :label="field.label"
  79. :column-key="field.prop"
  80. :width="field.width"
  81. :min-width="field.minWidth"
  82. :fixed="field.fixed"
  83. :sortable="field.sortable"
  84. :show-overflow-tooltip="!field.fixed&&field.width>150"
  85. >
  86. <template #default="{row}">
  87. <template v-if="field.prop==='action'">
  88. <el-button v-auth="'stationStatMonth.modify'" size="small" plain type="warning" @click="onRowClick('edit',row)">编辑</el-button>
  89. <el-button v-auth="'stationStatMonth.list'" size="small" plain type="primary" @click="onRowClick('view',row)">查看</el-button>
  90. <el-button v-auth="'statement.add'" size="small" plain type="success" @click="handleCreateStatements(row)">生成对账单</el-button>
  91. </template>
  92. <template v-else-if="field.prop==='stationId'">
  93. <div class="text-align-center">
  94. {{row.stationId}}
  95. <hr>
  96. {{row.stationName}}
  97. </div>
  98. </template>
  99. <template v-else-if="['totalMoney','elecMoney','actualElecMoney','serviceMoney','serviceMoneyDiscount','discountAmount','avgOrderMoney','actualPower'].includes(field.prop)">
  100. {{ u.fmt.fmtMoney(row[field.prop]) }}
  101. </template>
  102. <template v-else>
  103. <div>{{row[field.prop]}}</div>
  104. </template>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  109. </el-card>
  110. </div>
  111. <StationStatMonthDialog ref="stationStatMonthDialogRef" @refresh="loadData(true)"/>
  112. </template>
  113. <script setup lang="ts" name="StationStatMonthList">
  114. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  115. import {$body,$get} from "/@/utils/request";
  116. import {Msg} from "/@/utils/message";
  117. import u from "/@/utils/u";
  118. import ExtPage from '/@/components/form/ExtPage.vue'
  119. import mittBus from '/@/utils/mitt';
  120. import ExtSelect from "/@/components/form/ExtSelect.vue";
  121. const StationStatMonthDialog = defineAsyncComponent(() => import("/@/views/admin/station/stat/dialog.vue"));
  122. //定义引用
  123. const queryRef = ref();
  124. const stationStatMonthDialogRef = ref();
  125. //定义变量
  126. const state = reactive({
  127. formQuery: {},
  128. pageQuery: {
  129. pageNum: 1,
  130. pageSize: 10,
  131. total: 0
  132. },
  133. tableData: {
  134. height: 500,
  135. data: [] as Array < any >,
  136. loading: false,
  137. columns: [
  138. {label: '站点', prop: 'stationId', resizable: true,width:140,fixed:'left'},
  139. {label: '统计时间', prop: 'statMonth', resizable: true,width:90},
  140. {label: '订单电量', prop: 'totalPower', resizable: true,width:100},
  141. {label: '订单金额', prop: 'totalMoney', resizable: true,width:100},
  142. {label: '订单电费', prop: 'elecMoney', resizable: true,width:100},
  143. {label: '实际抄表电费', prop: 'actualElecMoney', resizable: true,width:120},
  144. {label: '实际抄表电量', prop: 'actualPower', resizable: true,width:120},
  145. {label: '订单服务费', prop: 'serviceMoney', resizable: true,width:110},
  146. {label: '服务费优惠金额', prop: 'serviceMoneyDiscount', resizable: true,width:135},
  147. {label: '总优惠金额', prop: 'discountAmount', resizable: true,width:110},
  148. {label: '充电人数', prop: 'chargeUsers', resizable: true,width:100},
  149. {label: '充电有效订单数', prop: 'validOrders', resizable: true,width:135},
  150. {label: '订单平均充电量', prop: 'avgOrderElec', resizable: true,width:145},
  151. {label: '订单平均充电费用', prop: 'avgOrderMoney', resizable: true,width:145},
  152. {label: '单枪平均日充电量', prop: 'avgConnectorElec', resizable: true,width:145},
  153. // {label: '创建时间', prop: 'createTime', sortable: 'custom', resizable: true,width:200,fixed: 'right',},
  154. {
  155. label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
  156. }
  157. ],
  158. },
  159. })
  160. // 监听双向绑定 modelValue 的变化
  161. // watch(
  162. // () => state.pageIndex,
  163. // () => {
  164. //
  165. // }
  166. // );
  167. //生命周期钩子
  168. onBeforeMount(() => {
  169. })
  170. onMounted(() => {
  171. loadData();
  172. nextTick(() => {
  173. let bodyHeight = document.body.clientHeight;
  174. let queryHeight = queryRef.value.$el.clientHeight;
  175. state.tableData.height = bodyHeight - queryHeight - 320
  176. })
  177. mittBus.on("stationStatMonth.refresh", () => {
  178. loadData();
  179. })
  180. });
  181. onBeforeUnmount(() => {
  182. mittBus.off("stationStatMonth.refresh")
  183. })
  184. //region 方法区
  185. // 初始化表格数据
  186. const handleCreateStatements = (statMonth) => {
  187. $get(`statements/create/${statMonth.id}`).then(()=>{
  188. Msg.message(`生成对账单成功`)
  189. })
  190. }
  191. const loadData = (refresh: boolean = false) => {
  192. if (refresh) {
  193. state.pageQuery.pageNum = 1;
  194. }
  195. state.tableData.loading = true;
  196. $get(`/stat/listStatMonth`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  197. let {list, total} = res;
  198. state.tableData.data = list;
  199. state.pageQuery.total = total;
  200. state.tableData.loading = false;
  201. }).catch(e => {
  202. console.error(e)
  203. state.tableData.loading = false;
  204. })
  205. };
  206. // 打开修改站点统计表-月弹窗
  207. const onRowClick = (type: string, row: any) => {
  208. stationStatMonthDialogRef.value.open(type, row);
  209. };
  210. // 删除站点统计表-月
  211. const onRowDel = (row: any) => {
  212. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  213. $get(`/stationStatMonth/delete/${row.id}`).then(() => {
  214. Msg.message("删除成功", 'success')
  215. }).catch(() => {
  216. Msg.message("删除失败", 'error')
  217. })
  218. });
  219. };
  220. const handleTableSelectionChange = (selection: any) => {
  221. console.log("handleTableSelectionChange>>", selection)
  222. // emit("on-check-change", selection)
  223. }
  224. const handleTableSortChange = (column, prop, order) => {
  225. console.log("handleTableSortChange>>", column, prop, order)
  226. // emit("on-sort-change", column)
  227. }
  228. //endregion
  229. // 暴露变量
  230. // defineExpose({
  231. // loadData,
  232. // });
  233. </script>