123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <div class="card-search">
- <a-form ref="formRef" name="advanced_search" class="ant-advanced-search-form" :model="searchParams" >
- <a-row :gutter="24">
- <a-col :span="6">
- <a-form-item label="人员名称" :label-col="{span:8}" name="siteUserName">
- <a-input v-model:value="searchParams.siteUserName" placeholder="" :allow-clear="true"/>
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item label="工号" :label-col="{span:8}" name="userNo">
- <a-input v-model:value="searchParams.userNo" placeholder="" :allow-clear="true"/>
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item label="所属驿站" :label-col="{span:8}" name="siteID">
- <a-select
- ref="select"
- v-model:value="searchParams.siteID"
- :options="allSites"
- @change="loadData"
- :field-names="{ label: 'siteName', value: 'siteID' }"
- :allow-clear="true"
- style="width: 200px" >
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :span="6" style="text-align: left">
- <a-button type="primary" html-type="submit" @click="onSearch">查询</a-button>
- <a-button
- style="margin: 0 8px"
- @click="
- () => {
- formRef.resetFields();
- loadData();
- }
- ">重置</a-button>
- </a-col>
- </a-row>
- <a-row class="edit-operation">
- <a-col :span="24" style="text-align: right">
- <a-button type="primary" html-type="submit" functioncode="T01010302" @click='onAdd' >新增</a-button>
- <BExportExcel :title="'导出'" :filename="'驿站人员信息'" :url="'userInfo/export'" :params="{...searchParams, rows:100000,siteUserIDList:formState.selectedRowKeys.join(',')}"></BExportExcel>
- </a-col>
- </a-row>
- </a-form>
- <div class="search-result-list">
- <a-table :columns="columns" :data-source="dataList" :scroll="{ x:'100%', y: 500 }" :pagination="pagination"
- :loading="formState.loading"
- @change="handleTableChange"
- :row-selection="{ selectedRowKeys: formState.selectedRowKeys, onChange: onSelectChange}"
- :row-key="record=>record.siteUserID"
- bordered>
- <template #bodyCell="{ column, text, record }">
- <template v-if="column.key === 'operation'">
- <div class="table-operation">
- <a-button type="link" size="small" functioncode="T01010303" @click='onEdit(record.siteUserID)' >编辑</a-button>
- <a-button type="link" size="small" functioncode="T01010304" @click="onDel(record)" >删除</a-button>
- </div>
- </template>
- </template>
- </a-table>
- </div>
- </div>
- </template>
- <script lang="ts">
- import {computed, createVNode, defineComponent, reactive, ref} from 'vue';
- import {useTabsViewStore} from "@/store/modules/tabsView";
- import {DownOutlined, ExclamationCircleOutlined, UpOutlined} from '@ant-design/icons-vue';
- import type {FormInstance, TableColumnsType, TableProps} from 'ant-design-vue';
- import {message, Modal} from "ant-design-vue";
- import {delSiteUser, getSiteUserList} from '@/api/baseSettings/userInfo';
- import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
- import {getPaginationTotalTitle} from "@/utils/common";
- import {getSiteList} from "@/api/baseSettings/siteInfo";
- export default defineComponent({
- name: 'UserInfoList',
- components: {DownOutlined, UpOutlined, BExportExcel},
- setup() {
- const formRef = ref<FormInstance>();
- const tabsViewStore = useTabsViewStore();
- const allSites = ref<any>([]);
- const searchParams = reactive({
- pageIndex: 1,
- pageSize: 20,
- siteUserName: '',
- siteID: '',
- userNo: ""
- });
- const formState = reactive({
- total: 0,
- selectedRowKeys: [],
- loading: false
- });
- const columns: TableColumnsType = [
- {title: '序号', align: "center",key: 'siteUserID',customRender: item => `${searchParams.pageSize * (searchParams.pageIndex - 1) + item.index + 1}`},
- {title: '工号', dataIndex: 'userNo', key: 'userNo', align: "center"},
- {title: '人员名称', dataIndex: 'siteUserName', key: 'siteUserName', align: "center"},
- {title: '用户类型', dataIndex: 'roleName', key: 'roleName',width:120, align: "center"},
- {title: '性别', dataIndex: 'genderName', key: 'genderName', align: "center"},
- {title: '联系电话', dataIndex: 'mobile', key: 'mobile', align: "center"},
- {title: '身份证号', dataIndex: 'idCard', key: 'idCard', align: "center"},
- {title: '所属驿站', dataIndex: 'siteName', key: 'siteName', align: "center"},
- {title: '操作', key: 'operation', fixed: 'right',width:100, align: "center"},
- ];
- const pagination = computed(() => ({
- total: formState.total,
- current: searchParams.pageIndex,
- pageSize: searchParams.pageSize,
- showSizeChanger: true,
- showTotal: total => getPaginationTotalTitle(total)
- }));
- const getAllSites = () => {
- getSiteList(searchParams).then((result :any) => {
- allSites.value = result.list;
- console.log('allSites',allSites);
- })
- }
- const dataList = ref([]);
- const handleTableChange: TableProps['onChange'] = (pag: { pageSize: number; current: number },) => {
- searchParams.pageIndex = pag.current;
- searchParams.pageSize = pag.pageSize;
- loadData();
- };
- const onSelectChange = (selectedRowKeys: any) => {
- formState.selectedRowKeys = selectedRowKeys;
- };
- const onSearch = () => {
- loadData();
- }
- const onDel= (item: any) => {
- if (item) {
- formState.selectedRowKeys.push(item.siteUserID as never)
- }
- if (formState.selectedRowKeys.length <= 0) {
- message.warning('请选择需要删除的数据!');
- return false;
- }
- Modal.confirm({
- title: '确认删除选中的人员信息?',
- icon: createVNode(ExclamationCircleOutlined),
- content: '',
- okText: '确认删除',
- okType: 'danger',
- okButtonProps: {},
- cancelText: '取消',
- onOk() {
- delSiteUser(formState.selectedRowKeys).then(() => {
- loadData();
- });
- },
- onCancel() {
- },
- });
- };
- const loadData = async function () {
- formState.loading = true;
- await getAllSites();
- const result: any = await getSiteUserList(searchParams);
- dataList.value = result.list;
- formState.total = result.total;
- formState.loading = false;
- }
- const onAdd =()=>{
- tabsViewStore.addTabByPath('/baseSettings/user/add', {id:null,op:1});
- };
- const onEdit = (id: string) => {
- tabsViewStore.addTabByPath('/baseSettings/user/edit', {id:id,op:2});
- };
- return {
- formRef,
- allSites,
- searchParams,
- formState,
- columns,
- pagination,
- dataList,
- handleTableChange,
- onSelectChange,
- onSearch,
- onAdd,
- onEdit,
- onDel,
- loadData
- };
- },
- created() {
- this.loadData();
- },
- activated() {
- if (history.state.params?.reload)
- this.loadData();
- }
- });
- </script>
|