integrated_traffic_vue/src/views/enterprise_management/user/index.vue

302 lines
9.7 KiB
Vue
Raw Normal View History

2024-01-06 17:44:23 +08:00
<template>
<div>
<layout-card>
<el-row :gutter="12">
<el-col :span="5">
<layout-department-tree
:department-id="DEPARTMENT_ID"
@node-click="
router.push({
path: '/enterprise_management/user',
query: {
DEPARTMENT_ID: $event.id,
},
})
"
/>
</el-col>
<el-col :span="19">
<el-form
:model="searchForm"
label-width="50px"
@submit.prevent="fnResetPaginationTransfer"
>
<el-row>
<el-col :span="6">
<el-form-item
label="用户名/姓名"
prop="KEYWORDS"
label-width="100px"
>
<el-input
v-model="searchForm.KEYWORDS"
placeholder="请输入关键字"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="排班" prop="SHIFTDUTYONE">
<el-select
v-model="searchForm.SHIFTDUTYONE"
@change="fnGetUserScheduling($event, 'schedulingList1')"
>
<el-option
v-for="item in data.schedulingList"
:key="item.SHIFTWORKRULES_ID"
:label="item.NAME"
:value="item.SHIFTWORKRULES_ID"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label-width="0px" prop="SHIFTDUTYTWO">
<el-select v-model="searchForm.SHIFTDUTYTWO">
<el-option
v-for="item in data.schedulingList1"
:key="item.SHIFTWORKRULES_ID"
:label="item.NAME"
:value="item.SHIFTWORKRULES_ID"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label-width="10px">
<el-button type="primary" native-type="submit">
搜索
</el-button>
<el-button
native-type="reset"
@click="fnResetPaginationTransfer"
>
重置
</el-button>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="10px" class="end">
<el-button @click="fnImportDialogChangeShow">
导入
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<layout-table
v-model:pagination="pagination"
2024-02-21 09:42:49 +08:00
:data="list"
2024-01-06 17:44:23 +08:00
@get-data="fnGetDataTransfer"
>
<el-table-column label="序号" width="70">
2024-02-21 09:42:49 +08:00
<template #default="{ $index }">
2024-01-06 17:44:23 +08:00
{{ serialNumber(pagination, $index) }}
</template>
</el-table-column>
2024-03-22 14:59:41 +08:00
<el-table-column prop="USERNAME" label="用户名" width="150" />
2024-01-06 17:44:23 +08:00
<el-table-column prop="NAME" label="姓名" />
2024-03-22 14:59:41 +08:00
<el-table-column prop="PHONE" label="手机号" />
2024-01-06 17:44:23 +08:00
<el-table-column prop="DEPARTMENT_NAME" label="部门" />
<el-table-column
prop="POST_NAME"
label="岗位"
width="150"
show-overflow-tooltip
/>
<el-table-column prop="ROLE_NAME" label="角色" />
<el-table-column label="排班类型">
2024-02-21 09:42:49 +08:00
<template #default="{ row }">
2024-01-06 17:44:23 +08:00
<span v-if="row.SHIFTDUTYONENAME && row.SHIFTDUTYTWONAME">
{{ row.SHIFTDUTYONENAME }}-{{ row.SHIFTDUTYTWONAME }}
</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="操作" width="250">
2024-02-21 09:42:49 +08:00
<template #default="{ row }">
2024-01-06 17:44:23 +08:00
<el-button
v-if="buttonJurisdiction.edit"
type="primary"
text
link
@click="fnResetPassword(row.USER_ID, row.NAME)"
>
重置密码
</el-button>
<el-button
v-if="buttonJurisdiction.edit && row.ISMAIN === '0'"
type="primary"
text
link
2024-01-09 16:20:28 +08:00
@click="fnSchedule(row)"
2024-01-06 17:44:23 +08:00
>
排班表
</el-button>
<el-button
2024-03-22 14:59:41 +08:00
v-if="
!(
row.PERSONNEL_TYPE_BIANMA?.indexOf(
'TRAFFIC_EMPLOYMENT_DRIVE'
) >= 0
)
"
2024-01-06 17:44:23 +08:00
type="primary"
text
link
@click="
router.push({
path: '/enterprise_management/user/edit',
query: { USER_ID: row.USER_ID },
})
"
>
编辑
</el-button>
<el-button
2024-03-22 14:59:41 +08:00
v-if="
buttonJurisdiction.del &&
row.ISMAIN === '0' &&
!(
row.PERSONNEL_TYPE_BIANMA?.indexOf(
'TRAFFIC_EMPLOYMENT_DRIVE'
) >= 0
)
"
type="danger"
2024-01-06 17:44:23 +08:00
text
link
@click="fnDelete(row.USER_ID, row.NAME)"
>
删除
</el-button>
</template>
</el-table-column>
<template #button>
<el-button
v-if="buttonJurisdiction.add"
2024-02-21 09:42:49 +08:00
type="primary"
2024-01-06 17:44:23 +08:00
@click="
router.push({ path: '/enterprise_management/user/add' })
"
>
新增
</el-button>
</template>
</layout-table>
</el-col>
</el-row>
</layout-card>
<layout-import-file
v-model:visible="data.importDialogVisible"
2024-04-29 09:23:04 +08:00
template-url="template/userExcelTemplateTraffic.xls"
2024-01-06 17:44:23 +08:00
@submit="fnSubmitImport"
/>
2024-01-09 16:20:28 +08:00
<scheduling
2024-02-21 09:42:49 +08:00
:id="data.scheduleDialog.id"
2024-01-09 16:20:28 +08:00
v-model:visible="data.scheduleDialog.visible"
:info="data.scheduleDialog.info"
/>
2024-01-06 17:44:23 +08:00
</div>
</template>
<script setup>
import { serialNumber } from "@/assets/js/utils.js";
import useListData from "@/assets/js/useListData.js";
import {
getUserList,
getUserScheduling,
setUserDelete,
setUserImport,
setUserResetPassword,
} from "@/request/enterprise_management.js";
import { reactive, ref } from "vue";
import LayoutDepartmentTree from "@/components/department_tree/index.vue";
import useButtonJurisdiction from "@/assets/js/useButtonJurisdiction.js";
import { onBeforeRouteUpdate, useRoute, useRouter } from "vue-router";
import { debounce } from "throttle-debounce";
import { ElMessage, ElMessageBox } from "element-plus";
import LayoutImportFile from "@/components/import_file/index.vue";
2024-01-09 16:20:28 +08:00
import Scheduling from "./components/scheduling.vue";
2024-01-06 17:44:23 +08:00
const router = useRouter();
const route = useRoute();
const departmentIdDefault = "";
const DEPARTMENT_ID = ref(route.query.DEPARTMENT_ID || departmentIdDefault);
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
useListData(getUserList, {
2024-01-24 18:08:04 +08:00
otherParams: { DEPARTMENT_ID: DEPARTMENT_ID.value },
2024-01-06 17:44:23 +08:00
key: "userList",
});
const buttonJurisdiction = await useButtonJurisdiction("user");
const data = reactive({
schedulingList: [],
schedulingList1: [],
importDialogVisible: false,
2024-01-09 16:20:28 +08:00
scheduleDialog: {
visible: false,
info: {},
id: "",
},
2024-01-06 17:44:23 +08:00
});
const fnGetUserScheduling = async (PARENTID, list) => {
const resData = await getUserScheduling({ PARENTID });
data[list] = resData.varList;
searchForm.value.SHIFTDUTYTWO = "";
};
fnGetUserScheduling("0", "schedulingList");
const fnGetDataTransfer = () => {
fnGetData({
DEPARTMENT_ID: DEPARTMENT_ID.value,
});
};
const fnResetPaginationTransfer = () => {
fnResetPagination({
DEPARTMENT_ID: DEPARTMENT_ID.value,
});
};
onBeforeRouteUpdate((to) => {
DEPARTMENT_ID.value = to.query.DEPARTMENT_ID || departmentIdDefault;
fnResetPaginationTransfer();
});
const fnResetPassword = debounce(
1000,
async (USER_ID, NAME) => {
2024-03-22 14:59:41 +08:00
await ElMessageBox.confirm(`是否将【${NAME}】重置密码为Aa@123456`, {
2024-01-06 17:44:23 +08:00
type: "warning",
});
await setUserResetPassword({ USER_ID });
ElMessage.success("重置成功");
fnResetPaginationTransfer();
},
{ atBegin: true }
);
const fnDelete = debounce(
1000,
async (USER_ID, NAME) => {
await ElMessageBox.confirm(`确定要删除【${NAME}】吗?`, {
type: "warning",
});
await setUserDelete({ USER_ID });
ElMessage.success("删除成功");
fnResetPaginationTransfer();
},
{ atBegin: true }
);
const fnImportDialogChangeShow = () => {
data.importDialogVisible = !data.importDialogVisible;
};
const fnSubmitImport = async (formData) => {
const resData = await setUserImport(formData);
ElMessage.success(resData.msg);
fnImportDialogChangeShow();
fnResetPaginationTransfer();
};
2024-01-09 16:20:28 +08:00
const fnSchedule = (row) => {
data.scheduleDialog.visible = true;
data.scheduleDialog.info = row;
data.scheduleDialog.id = row.SHIFTDUTYTWO;
};
2024-01-06 17:44:23 +08:00
</script>
<style scoped lang="scss"></style>