index.vue 8.0 KB

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