123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <template>
- <div class="p-4">
- <BasicTable @register="registerTable">
- <template #toolbar>
- <a-button
- type="primary"
- @click="handleCreate"
- v-if="getCheckPerm('lanuser-add')"
- >新增账号</a-button
- >
- </template>
- <template #role="{ record }">
- {{ renderRoleType(record.role) }}
- </template>
- <template #status="{ record }">
- {{ renderStatus(record.status) }}
- </template>
- <template #createTime="{ record }">
- <Time :value="record.createTime" mode="datetime" />
- </template>
- <!-- , -->
- <template #action="{ record }">
- <TableAction
- :actions="[
- {
- color: 'warning',
- label: '重置密码',
- ifShow:getCheckPerm('lanuser-pasword'),
- onClick: handleOpenModal.bind(null, record),
- },{
- label: '编辑',
- ifShow:getCheckPerm('lanuser-update'),
- onClick: handleEdit.bind(null, record),
- },
- {
- label: '删除',
- color: 'error',
- ifShow:getCheckPerm('lanuser-delete'),
- onClick:handDelconfirm.bind(null, record),
- },
- ]"
- />
- </template>
- </BasicTable>
- <DetailsModal @register="registerDetail" @ok="reload" />
- <SetpaswordModal @register="register" @reload="reload" />
- <addDetailsModal @register="registerAddDetail" @ok="reload" />
- </div>
- </template>
- <script lang="ts">
- import { defineComponent, computed, onMounted, ref, h } from 'vue';
- import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { useModal } from '/@/components/Modal';
- import { uploadApi } from '/@/api/sys/upload';
- import SetpaswordModal from './setpaswordModal.vue';
- import DetailsModal from './detailsModal.vue';
- import addDetailsModal from './adddetailsModal.vue';
- import { Switch } from 'ant-design-vue';
- // import DelListModal from './delListModal.vue';
- import { Alert } from 'ant-design-vue';
- // import { h } from 'vue';
- import { delUcenterUser, preDelApi, updateApi, getNumByStaff } from '/@/api/staff/list';
- import { ListApi } from '/@/api/account';
- import { useI18n } from '/@/hooks/web/useI18n';
- // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
- import { RoleEnum } from '/@/enums/roleEnum';
- import { useGo } from '/@/hooks/web/usePage';
- import { Time } from '/@/components/Time';
- import { useUserStore } from '/@/store/modules/user';
- import { usePermissionStore } from '/@/store/modules/permission';
- import { getRoleListByParam } from '/@/api/staff/list'; //roleLIstApi
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- Time,
- SetpaswordModal,
- DetailsModal,
- addDetailsModal,
- Alert,
- },
- setup() {
- const [register, { openModal }] = useModal();
- const surplusSubNum = ref({
- lookNum: 0,
- shotNum: 0,
- });
- const [registerDetail, { openModal: openDetaileModal }] = useModal();
- const [registerAddDetail, { openModal: openAddDetaileModal }] = useModal();
- const [registerDelList, { openModal: openDelListeModal }] = useModal();
- const { createConfirm, createMessage } = useMessage();
- const userStore = useUserStore();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const roleList = computed(() => userStore.getRoleList);
- console.log('getRoleList', roleList);
- const go = useGo();
- const { t } = useI18n();
- onMounted(() => {
- // getNumByStaffData();
- });
- const columns: BasicColumn[] = [
- {
- title: '人员ID',
- dataIndex: 'ryId',
- fixed: 'left',
- width: 60,
- },
- {
- title: t('routes.staff.userName'),
- dataIndex: 'nickName',
- width: 120,
- },
- {
- title: '人员编号',
- dataIndex: 'userName',
- width: 150,
- },
- // {
- // title: '手机',
- // dataIndex: 'phone',
- // width: 160,
- // },
- // {
- // title: t('common.roleName'),
- // dataIndex: 'roleName',
- // width: 100,
- // },
- // {
- // title: '创建人',
- // dataIndex: 'sysUserName',
- // width: 80,
- // },
- {
- title: '注册时间',
- dataIndex: 'createTime',
- slots: { customRender: 'createTime' },
- width: 130,
- },
- {
- title: '状态',
- dataIndex: 'status',
- // ifShow:getCheckPerm('sysuser-enable'),
- width: 80,
- customRender: ({ record }) => {
- return record.status == 1 ? '正常' : '冻结';
- // if (!Reflect.has(record, 'status')) {
- // record.pendingStatus = false;
- // }
- // return h(Switch, {
- // checked: record.status == 1 ? true : false,
- // checkedChildren: '启用',
- // unCheckedChildren: '禁用',
- // loading: false,
- // onChange: async (checked: boolean) => {
- // record.pendingStatus = true;
- // const newStatus = checked?1:0;
- // await updateApi({...record,status:newStatus});
- // Reflect.set(record, 'status', checked);
- // createMessage.success(t('common.optSuccess'));
- // reload()
- // },
- // });
- },
- },
- // {
- // title: '操作',
- // dataIndex: '',
- // // ifShow: !getCheckRole('tourist'),
- // slots: { customRender: 'action' },
- // fixed: 'right',
- // width: 100,
- // },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 100,
- schemas: [
- {
- field: 'nickName',
- label: t('routes.staff.userName'),
- component: 'Input',
- componentProps: {
- maxLength: 15,
- },
- colProps: {
- xl: 6,
- xxl: 6,
- },
- },
- {
- field: 'userName',
- label: '人员编号',
- component: 'Input',
- componentProps: {
- maxLength: 15,
- },
- colProps: {
- xl: 6,
- xxl: 6,
- },
- },
- ],
- };
- const [registerTable, { reload }] = useTable({
- // title: t('routes.staff.staffList'),
- api: ListApi,
- columns: columns,
- useSearchForm: true,
- formConfig: searchForm,
- showTableSetting: true,
- tableSetting: { fullScreen: true },
- showIndexColumn: false,
- canResize: true,
- rowKey: 'id',
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- pagination: { pageSize: 20 },
- afterFetch: (T) => {
- return T;
- },
- bordered: true,
- sortFn: (sortInfo) => {
- let order = sortInfo.order && sortInfo.order.replace('end', '');
- return { ...sortInfo, sidx: sortInfo.field, order: order };
- },
- });
- function renderRoleType(type: number): string {
- switch (type) {
- case 0:
- return t('routes.staff.roleType.0');
- case 1:
- return t('routes.staff.roleType.1');
- default:
- return '';
- }
- }
- function renderStatus(type: number): string {
- switch (type) {
- case 1:
- return t('common.normal');
- case 0:
- return t('common.unNormal');
- default:
- return '';
- }
- }
- function handleOpenModal(record: Recordable) {
- openModal(true, record);
- }
- function handleCreate() {
- openAddDetaileModal(true,{});
- }
- function handleEdit(record: Recordable) {
- openDetaileModal(true, {
- ...record,
- phone:record.userName,
- });
- }
- function getNumByStaffData() {
- getNumByStaff({}).then((res) => {
- surplusSubNum.value.lookNum = res.lookNum;
- surplusSubNum.value.shotNum = res.shotNum;
- });
- }
- async function handleDelete(record) {
- let check = await preDelApi(record.id); //
- if (Array.isArray(check)) {
- return openDelListeModal(true, {
- ...record,
- option: check,
- });
- }
- createMessage.success(t('common.optSuccess'));
- reload();
- // handDelconfirm(record);
- }
- function handDelconfirm(record) {
- createConfirm({
- iconType: 'warning',
- title: '警告',
- content: `此操作将对${record.userName}进行删除, 是否继续?`,
- onOk: async () => {
- await delUcenterUser({ id: record.id });
- createMessage.success(t('common.optSuccess'));
- reload();
- },
- });
- }
- return {
- registerTable,
- registerDetail,
- registerDelList,
- registerAddDetail,
- openDelListeModal,
- createMessage,
- handDelconfirm,
- t,
- reload,
- go,
- renderRoleType,
- renderStatus,
- handleCreate,
- handleOpenModal,
- register,
- handleEdit,
- handleDelete,
- uploadApi: uploadApi as any,
- RoleEnum,
- surplusSubNum,
- getCheckPerm,
- getNumByStaffData,
- };
- },
- });
- </script>
|