莳松-行政管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-oa-manage-web/src/views/Pers/Employee/index.vue

161 lines
4.4 KiB

10 months ago
<template>
<div>
9 months ago
<el-form :model="searchForm" inline @submit.prevent>
10 months ago
<el-form-item>
9 months ago
<el-input
v-model="searchForm.name"
placeholder="请输入员工姓名"
clearable
@keyup.enter="handleQuery"
/>
10 months ago
</el-form-item>
<el-form-item>
9 months ago
<el-radio-group v-model="searchForm.status" @change="handleQuery">
10 months ago
<el-radio :label="0"> 在职 </el-radio>
<el-radio :label="1"> 离职 </el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
10 months ago
<el-button @click="handleQuery" v-hasPermi="['pers:employee:search']">搜索</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['pers:employee:add']"
>
新增
</el-button>
10 months ago
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="tableList" border stripe>
<el-table-column type="index" width="50" />
9 months ago
<el-table-column label="姓名" prop="name" />
9 months ago
<el-table-column label="职位" prop="post" />
10 months ago
<el-table-column label="手机号码" prop="mobile" width="120" />
5 months ago
<el-table-column label="微信号" prop="wxAlias" width="120" />
9 months ago
<el-table-column label="考勤方案" prop="attendanceSettingName" />
<el-table-column label="已开通系统" prop="instanceName" />
10 months ago
<el-table-column label="在职状态" key="status" width="150">
<template #default="scope">
<el-switch
v-model="scope.row.status"
:active-value="0"
:inactive-value="1"
6 months ago
active-text="在职"
inactive-text="离职"
10 months ago
v-hasPermi="['pers:employee:update']"
@change="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="操作" width="260">
<template #default="scope">
<el-button
type="primary"
link
@click="openForm('update', scope.row.id)"
v-hasPermi="['pers:employee:update']"
>
修改
</el-button>
<el-button
type="primary"
link
@click="handleDelete(scope.row.id)"
v-hasPermi="['pers:employee:delete']"
>
删除
</el-button>
</template>
</el-table-column>
10 months ago
</el-table>
<Pagination
:total="total"
v-model:page="searchForm.pageNo"
v-model:limit="searchForm.pageSize"
@pagination="getList"
/>
10 months ago
<DialogEmployee ref="formRef" @success="getList" />
10 months ago
</div>
</template>
10 months ago
<script name="OAEmployee" setup>
10 months ago
import DialogEmployee from './Comp/DialogEmployee.vue'
9 months ago
import { removeNullField } from '@/utils'
import * as EmployeeApi from '@/api/pers/employee'
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
10 months ago
const searchForm = ref({
name: undefined,
status: 0,
pageNo: 1,
pageSize: 20
})
10 months ago
onMounted(() => {
handleQuery()
})
10 months ago
/** 搜索按钮操作 */
const handleQuery = () => {
searchForm.value.pageNo = 1
getList()
}
const loading = ref(false)
const tableList = ref([])
const total = ref(0)
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
9 months ago
const data = await EmployeeApi.getEmployeePage(removeNullField(searchForm.value))
tableList.value = data.list
total.value = data.total
10 months ago
} finally {
loading.value = false
}
}
10 months ago
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type, id = undefined) => {
formRef.value.open(type, id)
}
/** 修改用户状态 */
const handleStatusChange = async (row) => {
try {
// 修改状态的二次确认
const text = row.status === 0 ? '启用' : '停用'
9 months ago
await message.confirm('确认要"' + text + '""' + row.name + '"用户吗?')
10 months ago
// 发起修改状态
9 months ago
await EmployeeApi.updateEmployeeStatus({ id: row.id, status: row.status })
10 months ago
// 刷新列表
await getList()
9 months ago
} catch (err) {
console.log(err)
10 months ago
// 取消后,进行恢复按钮
row.status = row.status === 0 ? 1 : 0
}
}
/** 删除按钮操作 */
const handleDelete = async (id) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
9 months ago
await EmployeeApi.deleteEmployee(id)
10 months ago
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
10 months ago
</script>
<style lang="scss" scoped></style>