index.vue 8.6 KB

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