index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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:8}" name="userName">
  7. <a-input v-model:value="searchParams.siteUserName" placeholder=""/>
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="所属驿站" :label-col="{span:8}" name="userName">
  12. <a-select
  13. ref="select"
  14. v-model:value="searchParams.siteID"
  15. :options="allSites"
  16. @change="loadData"
  17. :field-names="{ label: 'siteName', value: 'siteID' }" style="width: 200px" >
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :span="6">
  22. </a-col>
  23. <a-col :span="6" style="text-align: left">
  24. <a-button type="primary" html-type="submit" @click="onSearch">查询</a-button>
  25. <a-button
  26. style="margin: 0 8px"
  27. @click="
  28. () => {
  29. formRef.resetFields();
  30. loadData();
  31. }
  32. ">重置</a-button>
  33. </a-col>
  34. </a-row>
  35. <a-row class="edit-operation">
  36. <a-col :span="24" style="text-align: right">
  37. <a-button type="primary" html-type="submit" functioncode="T01010302" @click='onAdd' >新增</a-button>
  38. <BExportExcel :title="'导出'" :filename="'驿站人员信息'" :url="'/userInfo/export'" :params="{...searchParams, rows:100000,siteUserIDList:formState.selectedRowKeys.join(',')}"></BExportExcel>
  39. </a-col>
  40. </a-row>
  41. </a-form>
  42. <div class="search-result-list">
  43. <a-table :columns="columns" :data-source="dataList" :scroll="{ x:'100%', y: 500 }" :pagination="pagination"
  44. :loading="formState.loading"
  45. @change="handleTableChange"
  46. :row-selection="{ selectedRowKeys: formState.selectedRowKeys, onChange: onSelectChange}"
  47. :row-key="record=>record.siteUserID"
  48. bordered>
  49. <template #bodyCell="{ column, text, record }">
  50. <template v-if="column.key === 'operation'">
  51. <div class="table-operation">
  52. <a-button type="link" size="small" functioncode="T01010303" @click='onEdit(record.siteUserID)' >编辑</a-button>
  53. <a-button type="link" size="small" functioncode="T01010304" @click="onDel(record)" >删除</a-button>
  54. </div>
  55. </template>
  56. </template>
  57. </a-table>
  58. </div>
  59. </div>
  60. </template>
  61. <script lang="ts">
  62. import {reactive, ref, computed, defineComponent, createVNode} from 'vue';
  63. import {useTabsViewStore} from "@/store/modules/tabsView";
  64. import {DownOutlined, ExclamationCircleOutlined, UpOutlined} from '@ant-design/icons-vue';
  65. import type {FormInstance} from 'ant-design-vue';
  66. import type {TableColumnsType, TableProps} from 'ant-design-vue';
  67. import {getSiteUserList,delSiteUser} from '@/api/baseSettings/userInfo';
  68. import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
  69. import {getPaginationTotalTitle} from "@/utils/common";
  70. import {message, Modal} from "ant-design-vue";
  71. import {getSiteList} from "@/api/baseSettings/siteInfo";
  72. export default defineComponent({
  73. name: 'UserInfoList',
  74. components: {DownOutlined, UpOutlined, BExportExcel},
  75. setup() {
  76. const formRef = ref<FormInstance>();
  77. const tabsViewStore = useTabsViewStore();
  78. const allSites = ref<any>([]);
  79. const searchParams = reactive({
  80. pageIndex: 1,
  81. pageSize: 20,
  82. siteUserName: '',
  83. siteID:''
  84. });
  85. const formState = reactive({
  86. total: 0,
  87. selectedRowKeys: [],
  88. loading: false
  89. });
  90. const columns: TableColumnsType = [
  91. {title: '序号', align: "center",key: 'siteUserID',customRender: item => `${searchParams.pageSize * (searchParams.pageIndex - 1) + item.index + 1}`},
  92. {title: '人员名称', dataIndex: 'siteUserName', key: 'siteUserName', align: "center"},
  93. {title: '用户类型', dataIndex: 'roleName', key: 'roleName',width:120, align: "center"},
  94. {title: '性别', dataIndex: 'genderName', key: 'genderName', align: "center"},
  95. {title: '联系电话', dataIndex: 'mobile', key: 'mobile', align: "center"},
  96. {title: '所属驿站', dataIndex: 'siteName', key: 'siteName', align: "center"},
  97. {title: '操作', key: 'operation', fixed: 'right',width:170, align: "center"},
  98. ];
  99. const pagination = computed(() => ({
  100. total: formState.total,
  101. current: searchParams.pageIndex,
  102. pageSize: searchParams.pageSize,
  103. showSizeChanger: true,
  104. showTotal: total => getPaginationTotalTitle(total)
  105. }));
  106. const getAllSites = () => {
  107. getSiteList(searchParams).then((result :any) => {
  108. allSites.value = result.list;
  109. console.log('allSites',allSites);
  110. })
  111. }
  112. const dataList = ref([]);
  113. const handleTableChange: TableProps['onChange'] = (pag: { pageSize: number; current: number },) => {
  114. searchParams.pageIndex = pag.current;
  115. searchParams.pageSize = pag.pageSize;
  116. loadData();
  117. };
  118. const onSelectChange = (selectedRowKeys: any) => {
  119. formState.selectedRowKeys = selectedRowKeys;
  120. };
  121. const onSearch = () => {
  122. loadData();
  123. }
  124. const onDel= (item: any) => {
  125. if (item) {
  126. formState.selectedRowKeys.push(item.siteUserID as never)
  127. }
  128. if (formState.selectedRowKeys.length <= 0) {
  129. message.warning('请选择需要删除的数据!');
  130. return false;
  131. }
  132. Modal.confirm({
  133. title: '确认删除选中的人员信息?',
  134. icon: createVNode(ExclamationCircleOutlined),
  135. content: '',
  136. okText: '确认删除',
  137. okType: 'danger',
  138. okButtonProps: {},
  139. cancelText: '取消',
  140. onOk() {
  141. delSiteUser(formState.selectedRowKeys).then(() => {
  142. loadData();
  143. });
  144. },
  145. onCancel() {
  146. },
  147. });
  148. };
  149. const loadData = async function () {
  150. formState.loading = true;
  151. await getAllSites();
  152. const result: any = await getSiteUserList(searchParams);
  153. dataList.value = result.list;
  154. formState.total = result.total;
  155. formState.loading = false;
  156. }
  157. const onAdd =()=>{
  158. tabsViewStore.addTabByPath('/baseSettings/user/add', {id:null,op:1});
  159. };
  160. const onEdit = (id: string) => {
  161. tabsViewStore.addTabByPath('/baseSettings/user/edit', {id:id,op:2});
  162. };
  163. return {
  164. formRef,
  165. allSites,
  166. searchParams,
  167. formState,
  168. columns,
  169. pagination,
  170. dataList,
  171. handleTableChange,
  172. onSelectChange,
  173. onSearch,
  174. onAdd,
  175. onEdit,
  176. onDel,
  177. loadData
  178. };
  179. },
  180. created() {
  181. this.loadData();
  182. },
  183. activated() {
  184. if (history.state.params?.reload)
  185. this.loadData();
  186. }
  187. });
  188. </script>