gaojs
6 months ago
17 changed files with 981 additions and 164 deletions
@ -0,0 +1,64 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface ClassTypeRoleVO { |
|||
id: number |
|||
workerRoleId: string |
|||
engineerRoleId: string |
|||
type: string |
|||
factoryAreaCode: string |
|||
workshopCode: string |
|||
departmentCode: string |
|||
remark: string |
|||
siteId: string |
|||
available: string |
|||
deletionTime: Date |
|||
deleterId: byte[] |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询厂区班组角色维护列表
|
|||
export const getClassTypeRolePage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic/class-type-role/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic/class-type-role/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询厂区班组角色维护详情
|
|||
export const getClassTypeRole = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic/class-type-role/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增厂区班组角色维护
|
|||
export const createClassTypeRole = async (data: ClassTypeRoleVO) => { |
|||
return await request.post({ url: `/eam/basic/class-type-role/create`, data }) |
|||
} |
|||
|
|||
// 修改厂区班组角色维护
|
|||
export const updateClassTypeRole = async (data: ClassTypeRoleVO) => { |
|||
return await request.put({ url: `/eam/basic/class-type-role/update`, data }) |
|||
} |
|||
|
|||
// 删除厂区班组角色维护
|
|||
export const deleteClassTypeRole = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic/class-type-role/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出厂区班组角色维护 Excel
|
|||
export const exportClassTypeRole = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = { ...params } |
|||
return await request.downloadPost({ url: `/eam/basic/class-type-role/export-excel-senior`, data }) |
|||
} else { |
|||
return await request.download({ url: `/eam/basic/class-type-role/export-excel`, params }) |
|||
} |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic/class-type-role/get-import-template' }) |
|||
} |
@ -0,0 +1,191 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
import * as deptApi from '@/api/system/dept' |
|||
import * as roleApi from '@/api/system/role' |
|||
import { Role } from '@/views/system/role/role.data' |
|||
import { selectAllFactoryArea } from '@/api/system/dept' |
|||
import * as WorkshopApi from '@/api/wms/workshop' |
|||
import { Workshop } from '@/views/wms/basicDataManage/factoryModeling/workshop/workshop.data' |
|||
|
|||
const roleList = await roleApi.getSimpleRoleList({}) |
|||
const workshopList = await WorkshopApi.getWorkshopPage({ pageNo: 1, pageSize: 100 }) |
|||
const roleListNoPage = await roleApi.getRoleNoPage({}) |
|||
const workshopNoPage = await WorkshopApi.getWorkshopNoPage({ pageNo: 1, pageSize: 100 }) |
|||
// 表单校验
|
|||
export const ClassTypeRoleRules = reactive({ |
|||
workerRoleId: [required], |
|||
engineerRoleId: [required], |
|||
workerRoleName: [required], |
|||
engineerRoleName: [required], |
|||
workshopName: [required], |
|||
type: [required], |
|||
factoryAreaCode: [required], |
|||
concurrencyStamp: [required] |
|||
}) |
|||
|
|||
export const ClassTypeRole = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: '维修工角色', |
|||
field: 'workerRoleId', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
isDetail: false, |
|||
isForm: false, |
|||
isTable: true, |
|||
isTableForm: false, |
|||
search: { |
|||
component: 'Select', |
|||
componentProps: { |
|||
options: roleListNoPage, |
|||
optionsAlias: { |
|||
labelField: 'name', |
|||
valueField: 'id' |
|||
}, |
|||
filterable: true, |
|||
} |
|||
}, |
|||
formatter: (_: Recordable, __: TableColumn, cellValue: number) => { |
|||
return roleList.find((item) => item.id == cellValue)?.name |
|||
}, |
|||
}, |
|||
{ |
|||
label: '维修工角色', |
|||
field: 'workerRoleName', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
form: { |
|||
componentProps: { |
|||
isSearchList: true, // 开启查询弹窗
|
|||
searchListPlaceholder: '请选择角色', // 输入框占位文本
|
|||
searchField: 'id', // 查询弹窗赋值字段
|
|||
searchTitle: '维修工角色', // 查询弹窗标题
|
|||
searchAllSchemas: Role.allSchemas, // 查询弹窗所需类
|
|||
searchPage: roleApi.getRolePage, // 查询弹窗所需分页方法
|
|||
searchCondition: [] |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: '工程师角色', |
|||
field: 'engineerRoleId', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
isDetail: false, |
|||
isForm: false, |
|||
isTable: true, |
|||
isTableForm: false, |
|||
search: { |
|||
component: 'Select', |
|||
componentProps: { |
|||
options: roleListNoPage, |
|||
optionsAlias: { |
|||
labelField: 'name', |
|||
valueField: 'id' |
|||
}, |
|||
filterable: true, |
|||
} |
|||
}, |
|||
formatter: (_: Recordable, __: TableColumn, cellValue: number) => { |
|||
return roleList.find((item) => item.id == cellValue)?.name |
|||
}, |
|||
}, |
|||
{ |
|||
label: '工程师角色', |
|||
field: 'engineerRoleName', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
form: { |
|||
// labelMessage: '信息提示说明!!!',
|
|||
componentProps: { |
|||
isSearchList: true, // 开启查询弹窗
|
|||
searchListPlaceholder: '请选择角色', // 输入框占位文本
|
|||
searchField: 'id', // 查询弹窗赋值字段
|
|||
searchTitle: '工程师角色', // 查询弹窗标题
|
|||
searchAllSchemas: Role.allSchemas, // 查询弹窗所需类
|
|||
searchPage: roleApi.getRolePage, // 查询弹窗所需分页方法
|
|||
searchCondition: [] |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: '班组', |
|||
field: 'type', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
dictType: DICT_TYPE.BASIC_TEAM_TYPE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
}, |
|||
{ |
|||
label: '车间编号', |
|||
field: 'workshopCode', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
isDetail: false, |
|||
isForm: false, |
|||
isTable: true, |
|||
isTableForm: false, |
|||
search: { |
|||
component: 'Select', |
|||
componentProps: { |
|||
options: workshopNoPage, |
|||
optionsAlias: { |
|||
labelField: 'name', |
|||
valueField: 'code' |
|||
}, |
|||
filterable: true, |
|||
} |
|||
}, |
|||
formatter: (_: Recordable, __: TableColumn, cellValue: string) => { |
|||
return workshopList.list.find((item) => item.code == cellValue)?.name |
|||
}, |
|||
}, |
|||
{ |
|||
label: '车间编号', |
|||
field: 'workshopName', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
form: { |
|||
// labelMessage: '信息提示说明!!!',
|
|||
componentProps: { |
|||
isSearchList: true, // 开启查询弹窗
|
|||
searchListPlaceholder: '请选择车间代码', // 输入框占位文本
|
|||
searchField: 'code', // 查询弹窗赋值字段
|
|||
searchTitle: '车间信息', // 查询弹窗标题
|
|||
searchAllSchemas: Workshop.allSchemas, // 查询弹窗所需类
|
|||
searchPage: WorkshopApi.getWorkshopPage, // 查询弹窗所需分页方法
|
|||
searchCondition: [{ |
|||
key: 'available', |
|||
value: 'TRUE', |
|||
isMainValue: false |
|||
}] |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '是否可用', |
|||
field: 'available', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isTable: true, |
|||
isDetail: false, |
|||
isSearch: false, |
|||
isTableForm: false, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,264 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="ClassTypeRole.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="ClassTypeRole.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table |
|||
:columns="tableColumns" |
|||
:data="tableObject.tableList" |
|||
:loading="tableObject.loading" |
|||
:pagination="{ |
|||
total: tableObject.total |
|||
}" |
|||
v-model:pageSize="tableObject.pageSize" |
|||
v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
> |
|||
<template #code="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|||
<span>{{ row.code }}</span> |
|||
</el-button> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="ClassTypeRoleRules" |
|||
:formAllSchemas="ClassTypeRole.allSchemas" |
|||
:apiUpdate="ClassTypeRoleApi.updateClassTypeRole" |
|||
:apiCreate="ClassTypeRoleApi.createClassTypeRole" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="ClassTypeRole.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/eam/class-type-role/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { ClassTypeRole,ClassTypeRoleRules } from './classTypeRole.data' |
|||
import * as ClassTypeRoleApi from '@/api/eam/classTypeRole' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|||
import Detail from '@/components/Detail/src/Detail.vue' |
|||
import * as roleApi from '@/api/system/role' |
|||
import { Role } from '@/views/system/role/role.data' |
|||
import * as WorkshopApi from '@/api/wms/workshop' |
|||
import { Workshop } from '@/views/wms/basicDataManage/factoryModeling/workshop/workshop.data' |
|||
|
|||
|
|||
defineOptions({ name: 'ClassTypeRole' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(ClassTypeRole.allSchemas.tableColumns) |
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
if(formField == 'workerRoleName'){ |
|||
setV['workerRoleName'] = val[0]['name'] |
|||
setV['workerRoleId'] = val[0][searchField] |
|||
}else if(formField == 'engineerRoleName'){ |
|||
setV['engineerRoleName'] = val[0]['name'] |
|||
setV['engineerRoleId'] = val[0][searchField] |
|||
}else if(formField == 'workshopName'){ |
|||
setV['workshopName'] = val[0]['name'] |
|||
setV['workshopCode'] = val[0][searchField] |
|||
} |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: ClassTypeRoleApi.getClassTypeRolePage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn({hasPermi:'eam:class-type-role:create'}), // 新增 |
|||
// defaultButtons.defaultImportBtn({hasPermi:'eam:class-type-role:import'}), // 导入 |
|||
// defaultButtons.defaultExportBtn({hasPermi:'eam:class-type-role:export'}), // 导出 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
// defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
// { |
|||
// label: '自定义扩展按钮', |
|||
// name: 'zdy', |
|||
// hide: false, |
|||
// type: 'primary', |
|||
// icon: 'Select', |
|||
// color: '' |
|||
// }, |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { // 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { // 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { // 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
} else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
// 列表-操作按钮 |
|||
const butttondata = [ |
|||
defaultButtons.mainListEditBtn({hasPermi:'eam:class-type-role:update'}), // 编辑 |
|||
defaultButtons.mainListDeleteBtn({hasPermi:'eam:class-type-role:delete'}), // 删除 |
|||
] |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = async (type: string, row?: any) => { |
|||
const roleList = await roleApi.getSimpleRoleList({}) |
|||
const workshopList = await WorkshopApi.getWorkshopPage({ pageNo: 1, pageSize: 100 }) |
|||
if(row != undefined){ |
|||
row.workerRoleName = roleList.find(item => item.id == row.workerRoleId).name |
|||
row.engineerRoleName = roleList.find(item => item.id == row.engineerRoleId).name |
|||
row.workshopName = workshopList.list.find(item => item.code == row.workshopCode)?.name |
|||
} |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =ClassTypeRole.allSchemas.formSchema.some(function (item) { |
|||
return item.field === 'activeTime' || item.field === 'expireTime'; |
|||
}); |
|||
if(isHave){ |
|||
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|||
message.error('失效时间要大于生效时间') |
|||
return; |
|||
} |
|||
} |
|||
if(data.activeTime==0)data.activeTime = null; |
|||
if(data.expireTime==0)data.expireTime = null; |
|||
if (formType === 'create') { |
|||
await ClassTypeRoleApi.createClassTypeRole(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await ClassTypeRoleApi.updateClassTypeRole(data) |
|||
message.success(t('common.updateSuccess')) |
|||
} |
|||
basicFormRef.value.dialogVisible = false |
|||
getList() |
|||
} |
|||
|
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|||
detailRef.value.openDetail(row, titleName, titleValue, 'basicClassTypeRole') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await ClassTypeRoleApi.deleteClassTypeRole(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await ClassTypeRoleApi.exportClassTypeRole(tableObject.params) |
|||
download.excel(data, '厂区班组角色维护.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '厂区班组角色维护导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await ClassTypeRoleApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
@ -0,0 +1,85 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
|
|||
// 表单校验
|
|||
export const RoleRules = reactive({ |
|||
name: [required], |
|||
code: [required], |
|||
}) |
|||
|
|||
export const Role = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: '角色ID', |
|||
field: 'id', |
|||
sort: 'custom', |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '角色名称', |
|||
field: 'name', |
|||
sort: 'custom', |
|||
}, |
|||
{ |
|||
label: '角色权限字符串', |
|||
field: 'code', |
|||
sort: 'custom', |
|||
width: 200, |
|||
}, |
|||
{ |
|||
label: '显示顺序', |
|||
field: 'sort', |
|||
sort: 'custom', |
|||
form: { |
|||
component: 'InputNumber', |
|||
value: 0 |
|||
}, |
|||
}, |
|||
{ |
|||
label: '数据权限范围', |
|||
field: 'dataScope', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.DATA_SCOPE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
width: 200, |
|||
}, |
|||
{ |
|||
label: '数据部门范围', |
|||
field: 'dataScopeDeptIds', |
|||
sort: 'custom', |
|||
}, |
|||
{ |
|||
label: '角色状态', |
|||
field: 'status', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.ROLE_STATUS, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
}, |
|||
{ |
|||
label: '角色类型', |
|||
field: 'type', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.SYSTEM_ROLE_TYPE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
}, |
|||
{ |
|||
label: '创建时间', |
|||
field: 'createTime', |
|||
sort: 'custom', |
|||
formatter: dateFormatter, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
Loading…
Reference in new issue