221 lines
8.8 KiB
Vue
Raw Normal View History

2023-07-16 19:14:41 +08:00
<template>
<div class="admin">
<el-card class="!border-none" shadow="never">
<el-form class="mb-[-16px]" :model="formData" inline>
<el-form-item label="管理员名称">
2023-07-21 11:26:28 +08:00
<el-input v-model="formData.name" class="w-[280px]" clearable @keyup.enter="resetPage" />
2023-07-16 19:14:41 +08:00
</el-form-item>
<el-form-item label="管理员角色">
<el-select class="w-[280px]" v-model="formData.role_id">
2023-07-21 11:26:28 +08:00
<el-option label="全部" value />
<el-option v-for="(item, index) in optionsData.role" :key="index" :label="item.name"
:value="item.id" />
2023-07-16 19:14:41 +08:00
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
2023-07-21 11:26:28 +08:00
<export-data class="ml-2.5" :fetch-fun="adminLists" :params="formData" :page-size="pager.size" />
2023-07-16 19:14:41 +08:00
</el-form-item>
</el-form>
</el-card>
<el-card v-loading="pager.loading" class="mt-4 !border-none" shadow="never">
<el-button v-perms="['auth.admin/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" size="large">
<el-table-column label="ID" prop="id" min-width="60" />>
<el-table-column label="头像" min-width="100">
<template #default="{ row }">
<el-avatar :size="50" :src="row.avatar"></el-avatar>
</template>
</el-table-column>
2023-07-21 11:26:28 +08:00
<el-table-column label="账号" prop="account" min-width="120" />
2023-07-16 19:14:41 +08:00
<el-table-column label="名称" prop="name" min-width="100" />
2023-07-21 11:26:28 +08:00
<el-table-column label="角色" prop="role_name" min-width="100" show-tooltip-when-overflow />
<el-table-column label="部门" prop="dept_name" min-width="100" show-tooltip-when-overflow />
2023-07-16 19:14:41 +08:00
<el-table-column label="创建时间" prop="create_time" min-width="180" />
<el-table-column label="最近登录时间" prop="login_time" min-width="180" />
<el-table-column label="最近登录IP" prop="login_ip" min-width="120" />
<el-table-column label="状态" min-width="100" v-perms="['auth.admin/edit']">
<template #default="{ row }">
2023-07-21 11:26:28 +08:00
<el-switch v-if="row.root != 1" v-model="row.disable" :active-value="0" :inactive-value="1"
@change="changeStatus(row)" />
2023-07-16 19:14:41 +08:00
</template>
</el-table-column>
2023-07-21 11:26:28 +08:00
<el-table-column label="操作" width="330" align="center" fixed="right">
2023-07-16 19:14:41 +08:00
<template #default="{ row }">
2023-07-20 15:20:46 +08:00
<div style="display: flex">
2023-07-21 11:26:28 +08:00
<el-button v-perms="['auth.admin/edit']" type="primary" link
@click="handleCheck(row)">查看</el-button>
<el-button v-perms="['auth.admin/edit']" type="primary" link
@click="handleEdit(row)">编辑</el-button>
<el-button v-if="row.root != 1" v-perms="['auth.admin/delete']" type="danger" link
@click="handleDelete(row.id)">删除</el-button>
2023-07-21 17:54:11 +08:00
<el-button v-perms="['company/edit', 'company/add']" type="primary" link @click="
; (showPop = true),
(showConctactPop = true),
(contractId = row.id)
">生成合同</el-button>
2023-07-21 11:26:28 +08:00
<el-button v-perms="['company/edit', 'company/add']" type="primary" link
2023-07-21 17:54:11 +08:00
@click="; (showPop = true), (contractId = row.id)">发送短信</el-button>
2023-07-21 11:26:28 +08:00
</div>
2023-07-16 19:14:41 +08:00
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
2023-07-21 11:26:28 +08:00
<edit-popup v-if="showEdit" ref="editRef" :isCheck="isCheck" @success="getLists" @close="showEdit = false" />
2023-07-20 15:20:46 +08:00
<el-dialog v-model="showPop" @close="offPop">
<h1>重要提醒</h1>
2023-07-21 17:54:11 +08:00
<div class="content" v-if="showConctactPop">
请确认信息是否有误,发送合同,请确认信息是否有误,发送电子合同后短时间内将不可再次发送.
</div>
<div class="content" v-else>
确认签约短信将在60秒后发送,请注意查收,并点击短信链接进行线上合同签约
</div>
2023-07-20 15:20:46 +08:00
<p class="btn_menu">
2023-07-21 11:26:28 +08:00
<el-button type="primary" size="large" v-if="showConctactPop" @click="creContct">确认创建</el-button>
2023-07-20 15:20:46 +08:00
<el-button type="primary" size="large" v-else @click="sendMsg">确认</el-button>
<el-button type="info" size="large" @click="offPop">返回</el-button>
</p>
</el-dialog>
2023-07-16 19:14:41 +08:00
</div>
</template>
<script lang="ts" setup name="admin">
2023-07-21 17:54:11 +08:00
import { adminEdit, adminLists, adminDelete } from '@/api/perms/admin'
import { generateGontract, sendMsgApi } from '@/api/company'
import { roleAll } from '@/api/perms/role'
import { useDictOptions } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const route = useRoute()
2023-07-16 19:14:41 +08:00
// 表单数据
const formData = reactive({
2023-07-21 17:54:11 +08:00
name: '',
role_id: '',
company_id: route.query.company_id || ''
})
const contractId = ref('')
2023-07-20 15:20:46 +08:00
// 弹窗
2023-07-21 17:54:11 +08:00
const showPop = ref(false)
const showConctactPop = ref(false)
2023-07-21 11:26:28 +08:00
const offPop = () => {
2023-07-21 17:54:11 +08:00
showPop.value = false
showConctactPop.value = false
}
2023-07-21 11:26:28 +08:00
const creContct = () => {
2023-07-21 17:54:11 +08:00
generateGontract({ id: contractId.value })
offPop()
}
2023-07-21 11:26:28 +08:00
const sendMsg = () => {
sendMsgApi({ id: contractId.value }).then((res) => {
2023-07-21 17:54:11 +08:00
console.log(res)
})
offPop()
}
2023-07-21 11:26:28 +08:00
//
2023-07-21 17:54:11 +08:00
const showEdit = ref(false)
2023-07-16 19:14:41 +08:00
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: adminLists,
2023-07-21 11:26:28 +08:00
params: formData,
});
2023-07-16 19:14:41 +08:00
const changeStatus = (data: any) => {
adminEdit({
id: data.id,
account: data.account,
name: data.name,
role_id: data.role_id,
disable: data.disable,
2023-07-21 11:26:28 +08:00
multipoint_login: data.multipoint_login,
2023-07-16 19:14:41 +08:00
}).finally(() => {
2023-07-21 11:26:28 +08:00
getLists();
});
};
2023-07-20 15:20:46 +08:00
// 查看
2023-07-21 17:54:11 +08:00
const isCheck = ref(false)
2023-07-20 15:20:46 +08:00
const handleCheck = async (data: any) => {
2023-07-21 17:54:11 +08:00
isCheck.value = true
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
editRef.value?.isCheckFn(true)
}
2023-07-16 19:14:41 +08:00
const handleAdd = async () => {
2023-07-21 17:54:11 +08:00
isCheck.value = false
showEdit.value = true
await nextTick()
editRef.value?.open('add')
editRef.value?.isCheckFn(false)
}
2023-07-16 19:14:41 +08:00
const handleEdit = async (data: any) => {
2023-07-21 17:54:11 +08:00
isCheck.value = false
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
editRef.value?.isCheckFn(false)
}
2023-07-16 19:14:41 +08:00
const handleDelete = async (id: number) => {
2023-07-21 17:54:11 +08:00
await feedback.confirm('确定要删除?')
await adminDelete({ id })
getLists()
}
2023-07-20 15:20:46 +08:00
2023-07-16 19:14:41 +08:00
const { optionsData } = useDictOptions<{
2023-07-21 11:26:28 +08:00
role: any[];
2023-07-16 19:14:41 +08:00
}>({
role: {
2023-07-21 11:26:28 +08:00
api: roleAll,
},
});
2023-07-16 19:14:41 +08:00
onMounted(() => {
2023-07-21 11:26:28 +08:00
getLists();
});
2023-07-16 19:14:41 +08:00
</script>
2023-07-20 15:20:46 +08:00
<style lang="scss" scoped>
h1 {
text-align: center;
font-weight: bold;
font-size: 30px;
color: red;
margin-bottom: 10px;
}
.content {
font-size: 20px;
}
.info {
color: red;
font-weight: bold;
font-size: 18px;
display: inline-block;
margin: 0 5px;
}
.btn_menu {
margin-top: 10vh;
display: flex;
justify-content: space-around;
2023-07-20 22:05:24 +08:00
}
2023-07-21 11:22:49 +08:00
</style>