index.vue 8.3 KB

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