1 changed files with 352 additions and 0 deletions
@ -0,0 +1,352 @@ |
|||||||
|
<template> |
||||||
|
<div class="app-container app-container-bg"> |
||||||
|
<el-card class="first-card" ref='firstCard' shadow="always"> |
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" @submit.native.prevent> |
||||||
|
<el-form-item label="姓名" prop="name"> |
||||||
|
<el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="部门" prop="department"> |
||||||
|
<el-select v-model="queryParams.department" placeholder="请选择部门" @change="handleQuery"> |
||||||
|
<el-option v-for="t in departmentsList" :key="t.id" :label="t.name" :value="t.id"></el-option> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item> |
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
<el-row :gutter="10" class="mb8"> |
||||||
|
<el-col :span="1.5"> |
||||||
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['message:employee:add']">新增</el-button> |
||||||
|
</el-col> |
||||||
|
<el-col :span="1.5"> |
||||||
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate" v-hasPermi="['message:employee:edit']">修改</el-button> |
||||||
|
</el-col> |
||||||
|
<el-col :span="1.5"> |
||||||
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete" v-hasPermi="['message:employee:remove']">删除</el-button> |
||||||
|
</el-col> |
||||||
|
<el-col :span="1.5"> |
||||||
|
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['message:employee:export']">导出</el-button> |
||||||
|
</el-col> |
||||||
|
<el-col :span="1.5"> |
||||||
|
<el-button type="primary" plain icon="Paperclip" @click="handleBindStation" :disabled="multiple">绑定测站</el-button> |
||||||
|
</el-col> |
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
||||||
|
</el-row> |
||||||
|
</el-card> |
||||||
|
<div class="el-card-p card-shadow carder-border mt10 pad10 "> |
||||||
|
<el-table class="table-box" v-table-height v-loading="loading" :data="warnlevelList" @selection-change="handleSelectionChange"> |
||||||
|
<el-table-column type="selection" width="55" :align="alignment" /> |
||||||
|
<el-table-column type="index" width="55" :align="alignment" label="序号" /> |
||||||
|
<el-table-column label="姓名" :align="alignment" prop="name" /> |
||||||
|
<el-table-column label="地区" :align="alignment" prop="deptName" /> |
||||||
|
<el-table-column label="部门" :align="alignment" prop="belongTo" /> |
||||||
|
<el-table-column label="手机号" :align="alignment" prop="phone" /> |
||||||
|
<el-table-column label="备注" :align="alignment" prop="remarks" /> |
||||||
|
<el-table-column label="创建时间" :align="alignment" prop="createTime" width="180"> |
||||||
|
<template #default="scope"> |
||||||
|
<span>{{parseTime(scope.row.createTime,'{y}-{m}-{d}')}}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column label="操作" :align="alignment" class-name="small-padding fixed-width"> |
||||||
|
<template #default="scope"> |
||||||
|
<el-button type="text" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['basic:warnlevel:edit']">修改</el-button> |
||||||
|
<el-button text type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['basic:warnlevel:remove']">删除</el-button> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> |
||||||
|
</div> |
||||||
|
<el-dialog class="custom-dialog" :title="title" v-model="open" width="500px" append-to-body> |
||||||
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto"> |
||||||
|
<el-form-item label="姓名" prop="name"> |
||||||
|
<el-input v-model="form.name" placeholder="请输入姓名" clearable /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="归属地区" prop="deptId"> |
||||||
|
<el-tree-select check-strictly v-model="form.deptId" :data="deptOptions" value-key="id" placeholder="请选择归属地区" style="width: 100%;" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="部门" prop="department"> |
||||||
|
<el-select v-model="form.department" placeholder="请选择部门" style="width: 100%;"> |
||||||
|
<el-option v-for="t in departmentsList" :key="t.id" :label="t.name" :value="t.id"></el-option> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="手机号" prop="phone"> |
||||||
|
<el-input v-model="form.phone" placeholder="请输入手机号" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="备注" prop="remarks"> |
||||||
|
<el-input v-model="form.remarks" placeholder="请输入备注" /> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
<template #footer> |
||||||
|
<div class="dialog-footer"> |
||||||
|
<el-button type="primary" @click="submitForm(formRef)" v-loading='btnLoading'>确 定</el-button> |
||||||
|
<el-button @click="cancel">取 消</el-button> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
</el-dialog> |
||||||
|
<el-dialog class="custom-dialog" title="绑定测站" v-model="openBindStation" width="1000px" append-to-body> |
||||||
|
<el-transfer ref="transfer" v-model="bindStation" :data="stationData" filterable :filter-method="filterMethod" :titles="['可选', '已选']" /> |
||||||
|
<template #footer> |
||||||
|
<div class="dialog-footer"> |
||||||
|
<el-button type="primary" @click="transferSubmitForm()" v-loading='btnLoading'>确 定</el-button> |
||||||
|
<el-button @click="transferCancel">取 消</el-button> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
</el-dialog> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<script setup> |
||||||
|
import { ref, reactive, onMounted, } from 'vue' |
||||||
|
import dayjs from 'dayjs' |
||||||
|
const { proxy } = getCurrentInstance() |
||||||
|
const alignment = 'center' |
||||||
|
const showSearch = ref(true) |
||||||
|
const queryParams = reactive({ |
||||||
|
pageNum: 1, |
||||||
|
pageSize: 10, |
||||||
|
name: '', |
||||||
|
department: "" |
||||||
|
}) |
||||||
|
const loading = ref(false) |
||||||
|
const total = ref(0) |
||||||
|
const warnlevelList = ref([]) |
||||||
|
const getList = async () => { |
||||||
|
loading.value = true; |
||||||
|
try { |
||||||
|
const res = await proxy.axiosGet('/message/employee/list', queryParams) |
||||||
|
if (res.code == 200) { |
||||||
|
warnlevelList.value = res.rows |
||||||
|
total.value = res.total |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
|
||||||
|
} finally { |
||||||
|
loading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
const departmentsList = ref([]) |
||||||
|
const getDepartmentsList = async () => { |
||||||
|
try { |
||||||
|
let res = await proxy.axiosGet('/message/employee/getDepartment'); |
||||||
|
if (res.code === 0) { |
||||||
|
departmentsList.value = res.data |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
const deptOptions = ref([]); |
||||||
|
const getTreeselect = async () => { |
||||||
|
try { |
||||||
|
let res = await proxy.axiosGet('/system/dept/treeselect'); |
||||||
|
if (res.code === 200) { |
||||||
|
deptOptions.value = res.data; |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
console.log(error) |
||||||
|
} |
||||||
|
} |
||||||
|
/** 搜索按钮操作 */ |
||||||
|
const handleQuery = () => { |
||||||
|
queryParams.pageNum = 1 |
||||||
|
getList() |
||||||
|
} |
||||||
|
const resetQuery = () => { |
||||||
|
proxy.resetForm("queryForm"); |
||||||
|
handleQuery(); |
||||||
|
} |
||||||
|
|
||||||
|
// 多选框选中数据 |
||||||
|
let ids = ref([]) |
||||||
|
let deptIds = ref([]) |
||||||
|
let names = ref([]) |
||||||
|
let single = ref(true) |
||||||
|
let multiple = ref(true) |
||||||
|
const handleSelectionChange = (selection) => { |
||||||
|
ids.value = selection.map(item => item.id) |
||||||
|
deptIds.value = selection.map(item => item.deptId) |
||||||
|
names.value = selection.map(item => item.name) |
||||||
|
single.value = selection.length !== 1 |
||||||
|
multiple.value = !selection.length |
||||||
|
} |
||||||
|
/** 新增按钮操作 */ |
||||||
|
const open = ref(false) |
||||||
|
const title = ref("") |
||||||
|
const handleAdd = () => { |
||||||
|
reset(); |
||||||
|
open.value = true; |
||||||
|
title.value = "添加员工"; |
||||||
|
} |
||||||
|
/** 修改按钮操作 */ |
||||||
|
const form = reactive({}) |
||||||
|
const rules = reactive({ |
||||||
|
|
||||||
|
phone: [ |
||||||
|
{ required: true, pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' } |
||||||
|
] |
||||||
|
}) |
||||||
|
const handleUpdate = async (row) => { |
||||||
|
reset(); |
||||||
|
let id = row.id || ids.value |
||||||
|
try { |
||||||
|
let res = await proxy.axiosGet('/message/employee/' + id); |
||||||
|
if (res.code === 200) { |
||||||
|
Object.assign(form, res.data); |
||||||
|
open.value = true; |
||||||
|
title.value = "修改员工"; |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
console.log(error) |
||||||
|
} |
||||||
|
} |
||||||
|
/** 删除按钮操作 */ |
||||||
|
const handleDelete = (row) => { |
||||||
|
let stnms = row.name || names.value |
||||||
|
const stnmIds = row.id || ids.value; |
||||||
|
proxy.$modal.confirm('是否确认删除姓名为"' + stnms + '"的数据项?').then(async function () { |
||||||
|
let res = await proxy.axiosGet('/message/employee/remove/' + stnmIds); |
||||||
|
if (res.code === 200) { |
||||||
|
proxy.$modal.msgSuccess("删除成功"); |
||||||
|
getList(); |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
/** 导出按钮操作 */ |
||||||
|
const handleExport = async () => { |
||||||
|
proxy.download("message/employee/export", { |
||||||
|
...queryParams.value, |
||||||
|
}, `employee_${dayjs(new Date()).format('YYYY-MM-DD')}.xlsx`); |
||||||
|
} |
||||||
|
// 绑定测站按钮操作 |
||||||
|
const openBindStation = ref(false) |
||||||
|
const bindStation = ref([]) |
||||||
|
const stationData = ref([]) |
||||||
|
let bindIds = null |
||||||
|
const handleBindStation = () => { |
||||||
|
bindStation.value = [] |
||||||
|
let id = ids.value; |
||||||
|
bindIds = id |
||||||
|
if (id.length == 1) { |
||||||
|
getBindEmp(id); |
||||||
|
} |
||||||
|
openBindStation.value = true |
||||||
|
let deptId = deptIds.value[0]; |
||||||
|
generateData(deptId) |
||||||
|
} |
||||||
|
const getBindEmp = async (id) => { |
||||||
|
let res = await proxy.axiosPost('message/employeebind/getBindList/' + id); |
||||||
|
var list = res.data; |
||||||
|
if (list) { |
||||||
|
bindStation.value = list; |
||||||
|
} |
||||||
|
} |
||||||
|
const generateData = async (deptId) => { |
||||||
|
let data = []; |
||||||
|
let cities = []; |
||||||
|
let pinyin = []; |
||||||
|
let res = await proxy.axiosGet('/basic/info/queryInfoHasPinyin', { deptId: deptId }); |
||||||
|
let resData = res.data; |
||||||
|
for (var i = 0; i < resData.length; i++) { |
||||||
|
cities.push(resData[i].pinyinName); |
||||||
|
pinyin.push(resData[i].pinyin); |
||||||
|
data.push({ |
||||||
|
label: resData[i].pinyinName, |
||||||
|
key: resData[i].stnmId, |
||||||
|
pinyin: resData[i].pinyin |
||||||
|
}); |
||||||
|
} |
||||||
|
stationData.value = data; |
||||||
|
} |
||||||
|
const filterMethod = (query, item) => { |
||||||
|
return item.pinyin.indexOf(query) > -1; |
||||||
|
} |
||||||
|
// 穿梭框弹窗取消按钮 |
||||||
|
const transferCancel = () => { |
||||||
|
openBindStation.value = false |
||||||
|
bindStation.value = [] |
||||||
|
} |
||||||
|
const transferSubmitForm = async () => { |
||||||
|
let params = { |
||||||
|
ids: bindIds, |
||||||
|
stnmIds: bindStation.value |
||||||
|
} |
||||||
|
let res = await proxy.axiosPost('message/employeebind/bindStation', params); |
||||||
|
if (res.code == 0) { |
||||||
|
proxy.$modal.msgSuccess("执行成功"); |
||||||
|
openBindStation.value = false; |
||||||
|
} |
||||||
|
} |
||||||
|
/************************************************************* 弹窗 ***************************************/ |
||||||
|
let formRef = ref(null) |
||||||
|
// 取消按钮 |
||||||
|
const cancel = () => { |
||||||
|
open.value = false; |
||||||
|
reset(); |
||||||
|
} |
||||||
|
const reset = () => { |
||||||
|
Object.assign(form, { |
||||||
|
id: null, |
||||||
|
name: null, |
||||||
|
deptId: null, |
||||||
|
department: null, |
||||||
|
phone: null, |
||||||
|
remarks: null |
||||||
|
}); |
||||||
|
proxy.resetForm("formRef"); |
||||||
|
} |
||||||
|
/** 提交按钮 */ |
||||||
|
const submitForm = async (formEl) => { |
||||||
|
if (!formEl) return |
||||||
|
await formEl.validate((valid, fields) => { |
||||||
|
if (valid) { |
||||||
|
if (form.id != null) { |
||||||
|
editMethod(); |
||||||
|
} else { |
||||||
|
addMethod(); |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
const btnLoading = ref(false) |
||||||
|
// 新增方法 |
||||||
|
const addMethod = async () => { |
||||||
|
btnLoading.value = true |
||||||
|
try { |
||||||
|
let res = await proxy.axiosPost('/message/employee/add', form); |
||||||
|
if (res.code === 200) { |
||||||
|
proxy.$modal.msgSuccess("新增成功"); |
||||||
|
open.value = false; |
||||||
|
getList(); |
||||||
|
btnLoading.value = false |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
btnLoading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
// 修改方法 |
||||||
|
const editMethod = async () => { |
||||||
|
btnLoading.value = true |
||||||
|
try { |
||||||
|
let res = await proxy.axiosPut('/message/employee/update', form); |
||||||
|
if (res.code === 200) { |
||||||
|
proxy.$modal.msgSuccess("修改成功"); |
||||||
|
open.value = false; |
||||||
|
getList(); |
||||||
|
btnLoading.value = false |
||||||
|
} |
||||||
|
} catch (error) { |
||||||
|
btnLoading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
onMounted(() => { |
||||||
|
getList() |
||||||
|
getDepartmentsList() |
||||||
|
getTreeselect() |
||||||
|
}) |
||||||
|
</script> |
||||||
|
<style scoped lang="scss"> |
||||||
|
:deep(.el-transfer-panel) { |
||||||
|
width: 390px !important; |
||||||
|
} |
||||||
|
</style> |
||||||
Loading…
Reference in new issue