index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="card-search">
  3. <a-form ref="formRef" name="advanced_search" class="ant-advanced-search-form" :model="searchParams" >
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="人员名称" :label-col="{span:6}" name="UserName">
  7. <a-input v-model:value="searchParams.userName" placeholder=""/>
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="7">
  11. </a-col>
  12. <a-col :span="6">
  13. </a-col>
  14. <a-col :span="5" style="text-align: right">
  15. <a-button type="primary" html-type="submit" @click="onSearch">查询</a-button>
  16. </a-col>
  17. </a-row>
  18. <a-row class="edit-operation">
  19. <a-col :span="24" style="text-align: right">
  20. <a-button type="primary" html-type="submit" @click='onOperates(null,"新增",false)' >新增</a-button>
  21. </a-col>
  22. </a-row>
  23. </a-form>
  24. <div class="search-result-list">
  25. <a-table :columns="columns" :data-source="dataList" :scroll="{ x:'100%', y: 500 }" :pagination="pagination"
  26. :loading="formState.loading"
  27. @change="handleTableChange"
  28. :row-selection="{ selectedRowKeys: formState.selectedRowKeys, onChange: onSelectChange}"
  29. :row-key="record=>record.szkey"
  30. bordered>
  31. <template #bodyCell="{ column, text, record }">
  32. <template v-if="column.key === 'operation'">
  33. <div class="table-operation">
  34. <a-button type="link" size="small" @click='onOperates(record.szkey.toString(),"修改",false)' >编辑</a-button>
  35. <a-button type="link" size="small" @click="onDel(record)" >删除</a-button>
  36. </div>
  37. </template>
  38. </template>
  39. </a-table>
  40. </div>
  41. </div>
  42. </template>
  43. <script lang="ts">
  44. import {reactive, ref, computed, defineComponent, createVNode} from 'vue';
  45. import {DownOutlined, ExclamationCircleOutlined, UpOutlined} from '@ant-design/icons-vue';
  46. import type {FormInstance} from 'ant-design-vue';
  47. import type {TableColumnsType, TableProps} from 'ant-design-vue';
  48. import {getList} from '@/api/baseSettings/userInfo';
  49. import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
  50. import {getPaginationTotalTitle} from "@/utils/common";
  51. import {message, Modal} from "ant-design-vue";
  52. export default defineComponent({
  53. name: 'UserInfoList',
  54. components: {DownOutlined, UpOutlined, BExportExcel},
  55. setup() {
  56. const formRef = ref<FormInstance>();
  57. const searchParams = reactive({
  58. pageIndex: 1,
  59. pageSize: 20,
  60. primaryKey:'',
  61. userName: ''
  62. });
  63. const formState = reactive({
  64. total: 0,
  65. selectedRowKeys: [],
  66. loading: false
  67. });
  68. const columns: TableColumnsType = [
  69. {title: '序号', align: "center",key: 'szkey',customRender: item => `${searchParams.pageSize * (searchParams.pageIndex - 1) + item.index + 1}`},
  70. {title: '人员名称', dataIndex: 'Name', key: 'Name', align: "center"},
  71. {title: '角色', dataIndex: 'UserTypeName', key: 'UserTypeName',width:120, align: "center"},
  72. {title: '性别', dataIndex: 'UserSex', key: 'UserSex', align: "center"},
  73. {title: '联系电话', dataIndex: 'UserMobile', key: 'UserMobile', align: "center"},
  74. {title: '操作', key: 'operation', fixed: 'right',width:170, align: "center"},
  75. ];
  76. const pagination = computed(() => ({
  77. total: formState.total,
  78. current: searchParams.pageIndex,
  79. pageSize: searchParams.pageSize,
  80. showSizeChanger: true,
  81. showTotal: total => getPaginationTotalTitle(total)
  82. }));
  83. const dataList = ref([]);
  84. const UserInfoEditModelRef = ref();
  85. const handleTableChange: TableProps['onChange'] = (pag: { pageSize: number; current: number },) => {
  86. searchParams.pageIndex = pag.current;
  87. searchParams.pageSize = pag.pageSize;
  88. loadData();
  89. };
  90. const onSelectChange = (selectedRowKeys: any) => {
  91. formState.selectedRowKeys = selectedRowKeys;
  92. };
  93. const onSearch = () => {
  94. loadData();
  95. }
  96. const onDel= (item: any) => {
  97. if (item) {
  98. formState.selectedRowKeys.push(item.szkey as never)
  99. }
  100. if (formState.selectedRowKeys.length <= 0) {
  101. message.warning('请选择需要删除的数据!');
  102. return false;
  103. }
  104. Modal.confirm({
  105. title: '确认删除选中的人员信息?',
  106. icon: createVNode(ExclamationCircleOutlined),
  107. content: '',
  108. okText: '确认删除',
  109. okType: 'danger',
  110. okButtonProps: {},
  111. cancelText: '取消',
  112. onOk() {
  113. },
  114. onCancel() {
  115. },
  116. });
  117. };
  118. const onOperates = (id: string,operation:string,isDetail:boolean) => {
  119. UserInfoEditModelRef.value.show(id,operation,isDetail);
  120. };
  121. const loadData = async function () {
  122. formState.loading = true;
  123. const result: any = await getList(searchParams);
  124. dataList.value = result.list;
  125. formState.total = result.total;
  126. formState.loading = false;
  127. }
  128. return {
  129. formRef,
  130. searchParams,
  131. formState,
  132. columns,
  133. pagination,
  134. dataList,
  135. UserInfoEditModelRef,
  136. handleTableChange,
  137. onSelectChange,
  138. onSearch,
  139. onOperates,
  140. onDel,
  141. loadData
  142. };
  143. },
  144. created() {
  145. this.loadData();
  146. },
  147. activated() {
  148. if (history.state.params?.reload)
  149. this.loadData();
  150. }
  151. });
  152. </script>