index.vue 6.9 KB

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