index.vue 7.2 KB

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