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.
248 lines
9.6 KiB
248 lines
9.6 KiB
<template>
|
|
<div class="main-container">
|
|
<el-card class="box-card !border-none" shadow="never">
|
|
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-lg">{{pageName}}</span>
|
|
<el-button type="primary" @click="addEvent">
|
|
{{ t('addStaff') }}
|
|
</el-button>
|
|
</div>
|
|
|
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never">
|
|
<el-form :inline="true" :model="staffTable.searchParam" ref="searchFormRef">
|
|
<el-form-item :label="t('name')" prop="name">
|
|
<el-input v-model="staffTable.searchParam.name" :placeholder="t('namePlaceholder')" />
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('gender')" prop="gender">
|
|
<el-select class="w-[280px]" v-model="staffTable.searchParam.gender" clearable :placeholder="t('genderPlaceholder')">
|
|
<el-option label="全部" value=""></el-option>
|
|
<el-option
|
|
v-for="(item, index) in genderList"
|
|
:key="index"
|
|
:label="item.name"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('phone')" prop="phone">
|
|
<el-input v-model="staffTable.searchParam.phone" :placeholder="t('phonePlaceholder')" />
|
|
</el-form-item>
|
|
<el-form-item :label="t('email')" prop="email">
|
|
<el-input v-model="staffTable.searchParam.email" :placeholder="t('emailPlaceholder')" />
|
|
</el-form-item>
|
|
<el-form-item :label="t('position')" prop="position">
|
|
<el-input v-model="staffTable.searchParam.position" :placeholder="t('positionPlaceholder')" />
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('status')" prop="status">
|
|
<el-select class="w-[280px]" v-model="staffTable.searchParam.status" clearable :placeholder="t('statusPlaceholder')">
|
|
<el-option label="全部" value=""></el-option>
|
|
<el-option
|
|
v-for="(item, index) in statusList"
|
|
:key="index"
|
|
:label="item.name"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="t('roleId')" prop="role_id">
|
|
<el-select class="w-[280px]" v-model="staffTable.searchParam.role_id" clearable :placeholder="t('roleIdPlaceholder')">
|
|
<el-option
|
|
v-for="(item, index) in roleIdList"
|
|
:key="index"
|
|
:label="item['description']"
|
|
:value="item['id']"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
<el-button type="primary" @click="loadStaffList()">{{ t('search') }}</el-button>
|
|
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-card>
|
|
|
|
<div class="mt-[10px]">
|
|
<el-table :data="staffTable.data" size="large" v-loading="staffTable.loading">
|
|
<template #empty>
|
|
<span>{{ !staffTable.loading ? t('emptyData') : '' }}</span>
|
|
</template>
|
|
<el-table-column prop="name" :label="t('name')" min-width="120" :show-overflow-tooltip="true"/>
|
|
|
|
<el-table-column :label="t('gender')" min-width="180" align="center" :show-overflow-tooltip="true">
|
|
<template #default="{ row }">
|
|
<div v-for="(item, index) in genderList">
|
|
<div v-if="item.value == row.gender">{{ item.name }}</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column prop="phone" :label="t('phone')" min-width="120" :show-overflow-tooltip="true"/>
|
|
|
|
<el-table-column prop="email" :label="t('email')" min-width="120" :show-overflow-tooltip="true"/>
|
|
|
|
<el-table-column prop="position" :label="t('position')" min-width="120" :show-overflow-tooltip="true"/>
|
|
|
|
<el-table-column :label="t('status')" min-width="180" align="center" :show-overflow-tooltip="true">
|
|
<template #default="{ row }">
|
|
<div v-for="(item, index) in statusList">
|
|
<div v-if="item.value == row.status">{{ item.name }}</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column prop="role_id_name" :label="t('roleId')" min-width="120" :show-overflow-tooltip="true"/>
|
|
|
|
|
|
<el-table-column :label="t('operation')" fixed="right" min-width="120">
|
|
<template #default="{ row }">
|
|
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button>
|
|
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
<div class="mt-[16px] flex justify-end">
|
|
<el-pagination v-model:current-page="staffTable.page" v-model:page-size="staffTable.limit"
|
|
layout="total, sizes, prev, pager, next, jumper" :total="staffTable.total"
|
|
@size-change="loadStaffList()" @current-change="loadStaffList" />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { reactive, ref, watch } from 'vue'
|
|
import { t } from '@/lang'
|
|
import { useDictionary } from '@/app/api/dict'
|
|
import { getStaffList, deleteStaff, getWithRolesList } from '@/addon/zhjw/api/staff'
|
|
import { img } from '@/utils/common'
|
|
import { ElMessageBox,FormInstance } from 'element-plus'
|
|
import { useRouter } from 'vue-router'
|
|
import { useRoute } from 'vue-router'
|
|
const route = useRoute()
|
|
const pageName = route.meta.title;
|
|
|
|
let staffTable = reactive({
|
|
page: 1,
|
|
limit: 10,
|
|
total: 0,
|
|
loading: true,
|
|
data: [],
|
|
searchParam:{
|
|
"name":"",
|
|
"gender":"",
|
|
"phone":"",
|
|
"email":"",
|
|
"position":"",
|
|
"status":"",
|
|
"role_id":""
|
|
}
|
|
})
|
|
|
|
const searchFormRef = ref<FormInstance>()
|
|
|
|
// 选中数据
|
|
const selectData = ref<any[]>([])
|
|
|
|
// 字典数据
|
|
const genderList = ref([] as any[])
|
|
const genderDictList = async () => {
|
|
genderList.value = await (await useDictionary('sex')).data.dictionary
|
|
}
|
|
genderDictList();
|
|
const statusList = ref([] as any[])
|
|
const statusDictList = async () => {
|
|
statusList.value = await (await useDictionary('zz_status')).data.dictionary
|
|
}
|
|
statusDictList();
|
|
|
|
|
|
/**
|
|
* 获取人员管理列表
|
|
*/
|
|
const loadStaffList = (page: number = 1) => {
|
|
staffTable.loading = true
|
|
staffTable.page = page
|
|
|
|
getStaffList({
|
|
page: staffTable.page,
|
|
limit: staffTable.limit,
|
|
...staffTable.searchParam
|
|
}).then(res => {
|
|
staffTable.loading = false
|
|
staffTable.data = res.data.data
|
|
staffTable.total = res.data.total
|
|
}).catch(() => {
|
|
staffTable.loading = false
|
|
})
|
|
}
|
|
loadStaffList()
|
|
|
|
const router = useRouter()
|
|
|
|
/**
|
|
* 添加人员管理
|
|
*/
|
|
const addEvent = () => {
|
|
router.push('/staff/staff_edit')
|
|
}
|
|
|
|
/**
|
|
* 编辑人员管理
|
|
* @param data
|
|
*/
|
|
const editEvent = (data: any) => {
|
|
router.push('/staff/staff_edit?id='+data.id)
|
|
}
|
|
|
|
/**
|
|
* 删除人员管理
|
|
*/
|
|
const deleteEvent = (id: number) => {
|
|
ElMessageBox.confirm(t('staffDeleteTips'), t('warning'),
|
|
{
|
|
confirmButtonText: t('confirm'),
|
|
cancelButtonText: t('cancel'),
|
|
type: 'warning',
|
|
}
|
|
).then(() => {
|
|
deleteStaff(id).then(() => {
|
|
loadStaffList()
|
|
}).catch(() => {
|
|
})
|
|
})
|
|
}
|
|
|
|
|
|
const roleIdList = ref([])
|
|
const setRoleIdList = async () => {
|
|
roleIdList.value = await (await getWithRolesList({})).data
|
|
}
|
|
setRoleIdList()
|
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
if (!formEl) return
|
|
formEl.resetFields()
|
|
loadStaffList()
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
/* 多行超出隐藏 */
|
|
.multi-hidden {
|
|
word-break: break-all;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>
|
|
|