fix worker org

main
chenshuichuan 2 years ago
parent 1115fab85c
commit cbf3816814

@ -11,9 +11,9 @@ export interface OrganizationVO {
phone: string // 联系电话 phone: string // 联系电话
email: string // 邮箱 email: string // 邮箱
isEnable: boolean // 是否启用 isEnable: boolean // 是否启用
status: number // 组织状态 status: string // 组织状态
orgClass: number // 组织等级 orgClass: string // 组织等级
orgType: number // 组织类型 orgType: string // 组织类型
} }
// 产线工位 API // 产线工位 API
@ -47,4 +47,4 @@ export const OrganizationApi = {
exportOrganization: async (params) => { exportOrganization: async (params) => {
return await request.download({ url: `/mes/organization/export-excel`, params }) return await request.download({ url: `/mes/organization/export-excel`, params })
} }
} }

@ -8,46 +8,73 @@
class="-mb-15px" class="-mb-15px"
label-width="68px" label-width="68px"
> >
<el-form-item label="组织名称" prop="name"> <el-row>
<el-input <el-col :span="6">
v-model="queryParams.name" <el-form-item label="组织名称" prop="name">
class="!w-240px" <el-input
clearable v-model="queryParams.name"
placeholder="请输入组织名称" class="!w-150px"
@keyup.enter="handleQuery" clearable
/> placeholder="请输入组织名称"
</el-form-item> @keyup.enter="handleQuery"
/>
<el-form-item label="关联机台" prop="machineId"> </el-form-item>
<el-input </el-col>
v-model="queryParams.machineId" <el-col :span="6">
class="!w-240px" <el-form-item label="关联机台" prop="machineId">
clearable <el-input
placeholder="请输入关联机台" v-model="queryParams.machineId"
@keyup.enter="handleQuery" class="!w-150px"
/> clearable
</el-form-item> placeholder="请输入关联机台"
@keyup.enter="handleQuery"
<el-form-item label="组织状态" prop="status"> />
<el-select </el-form-item>
v-model="queryParams.status" </el-col>
class="!w-240px" <el-col :span="6">
clearable <el-form-item label="组织状态" prop="status">
placeholder="请选择组织状态" <el-select
> v-model="queryParams.status"
<el-option class="!w-150px"
v-for="dict in getStrDictOptions(DICT_TYPE.MES_ORG_STATUS)" clearable
:key="dict.value" placeholder="请选择组织状态"
:label="dict.label" >
:value="dict.value" <el-option
/> v-for="dict in getStrDictOptions(DICT_TYPE.MES_ORG_STATUS)"
</el-select> :key="dict.value"
</el-form-item> :label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="工作日期" prop="workDate">
<el-date-picker
v-model="queryParams.workDate"
@change="handleQuery"
type="date"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择工作日期"
class="!w-200px"
/>
<!-- <el-date-picker-->
<!-- v-model="queryParams.workDate"-->
<!-- @change="handleQuery"-->
<!-- value-format="YYYY-MM-DD HH:mm:ss"-->
<!-- type="daterange"-->
<!-- start-placeholder="开始日期"-->
<!-- end-placeholder="结束日期"-->
<!-- :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
<!-- class="!w-200px"-->
<!-- />-->
</el-form-item>
</el-col>
</el-row>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon class="mr-5px" icon="ep:search" /> 搜索</el-button> <el-button @click="handleQuery"><Icon class="mr-5px" icon="ep:search" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon class="mr-5px" icon="ep:refresh" /> 重置</el-button> <el-button @click="resetQuery"><Icon class="mr-5px" icon="ep:refresh" /> 重置</el-button>
<el-button <el-button
v-hasPermi="['mes:organization:export']" v-hasPermi="['mes:organization:export']"
:loading="exportLoading" :loading="exportLoading"
@ -81,7 +108,7 @@
</el-tabs> </el-tabs>
<el-row> <el-row>
<el-col :span="14"> <el-col :span="12">
<ContentWrap> <ContentWrap>
<el-table <el-table
v-if="refreshTable" v-if="refreshTable"
@ -91,89 +118,48 @@
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
:stripe="true" :stripe="true"
row-key="id" row-key="id"
highlight-current-row
@current-change="handleCurrentChange"
> >
<el-table-column align="center" label="组织名称" prop="name" width="180px"/> <el-table-column align="center" label="组织名称" prop="name" width="180px"/>
<el-table-column align="center" label="关联机台" prop="machineName" /> <el-table-column align="center" label="关联机台" prop="machineName" />
<el-table-column align="center" label="组织等级" prop="orgClass">
<el-table-column align="center" label="组织状态" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.MES_ORG_STATUS" :value="scope.row.status" /> <dict-tag v-if="notEmpty(scope.row.orgClass)" :type="DICT_TYPE.MES_ORG_CLASS" :value="scope.row.orgClass" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="组织等级" prop="orgClass"> <el-table-column align="center" label="类型" >
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.MES_ORG_CLASS" :value="scope.row.orgClass" /> <dict-tag v-if="notEmpty(scope.row.orgType)" :type="DICT_TYPE.MES_ORG_TYPE" :value="scope.row.orgType" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="类型" prop="orgType"> <el-table-column align="center" label="组织状态" >
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.MES_ORG_TYPE" :value="scope.row.orgType" /> <dict-tag v-if="notEmpty(scope.row.status) && scope.row.orgClass=='workplace'" :type="DICT_TYPE.MES_ORG_STATUS" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="150">
<el-table-column align="center" fixed="right" label="操作" width="80">
<template #default="scope"> <template #default="scope">
<el-button <el-button
v-if="scope.row.orgClass=='workplace' && scope.row.status=='free'"
v-hasPermi="['mes:organization:update']" v-hasPermi="['mes:organization:update']"
link link
type="primary" type="warning"
@click="openForm('update', scope.row.id)" @click="openForm('update', scope.row.id)"
> >
编辑 派工
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap> </ContentWrap>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <WorkerRight :org-id="orgId" :work-date="queryParams.workDate" :org-type="queryParams.orgType"/>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column
label="工作日期"
align="center"
prop="workDate"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="工位" align="center" prop="orgId" />
<el-table-column label="班别" align="center" prop="groupType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.MES_GROUP_TYPE" :value="scope.row.groupType" />
</template>
</el-table-column>
<el-table-column label="工人" align="center" prop="workerId" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['mes:org-worker:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
</el-col> </el-col>
</el-row> </el-row>
@ -183,20 +169,22 @@
<script lang="ts" setup> <script lang="ts" setup>
import {getIntDictOptions, getBoolDictOptions, DICT_TYPE, getStrDictOptions} from '@/utils/dict' import {getIntDictOptions, getBoolDictOptions, DICT_TYPE, getStrDictOptions} from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import {defaultProps, handleTree} from '@/utils/tree' import {defaultProps, handleTree} from '@/utils/tree'
import download from '@/utils/download' import download from '@/utils/download'
import { OrganizationApi, OrganizationVO } from '@/api/mes/organization' import { OrganizationApi, OrganizationVO } from '@/api/mes/organization'
import OrganizationForm from './OrganizationForm.vue' import OrganizationForm from './OrganizationForm.vue'
import {OrgWorkerApi, OrgWorkerVO} from "@/api/mes/orgworker";
/** 产线工位 列表 */ /** 产线工位 列表 */
defineOptions({ name: 'Organization' }) defineOptions({ name: 'WorkerIndex' })
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const orgId = ref()
const loading = ref(true) // const loading = ref(true) //
const list = ref<OrganizationVO[]>([]) // const list = ref<OrganizationVO[]>([]) //
const queryParams = reactive({ const queryParams = reactive({
name: undefined, name: undefined,
parentId: undefined, parentId: undefined,
@ -209,7 +197,8 @@ const queryParams = reactive({
status: undefined, status: undefined,
orgClass: undefined, orgClass: undefined,
orgType: undefined, orgType: undefined,
createTime: [] createTime: [],
workDate: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
@ -243,18 +232,6 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await OrganizationApi.deleteOrganization(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
@ -281,9 +258,18 @@ const toggleExpandAll = async () => {
refreshTable.value = true refreshTable.value = true
} }
const organizationTree = ref() // const organizationTree = ref() //
const getCurrentDate = () =>{
let now = new Date();
let year = now.getFullYear();
let month = now.getMonth() + 1;
if(month<10){month = '0'+month}
let day = now.getDate();
if(day<10)day = '0'+day;
return year + "-" + month + "-" + day +" 00:00:01";
}
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
queryParams.workDate = getCurrentDate()
await getList() await getList()
/** 获得产线工位树 */ /** 获得产线工位树 */
organizationTree.value = [] organizationTree.value = []
@ -299,4 +285,15 @@ const handleTabClick = (tab: TabsPaneContext) => {
handleQuery() handleQuery()
} }
/** 选中行操作 */
const currentRow = ref({}) //
const handleCurrentChange = (row) => {
currentRow.value = row
orgId.value = row.id
}
const notEmpty = (str:string) => {
return str != "" && str != null;
}
</script> </script>

@ -0,0 +1,175 @@
<template>
<!-- 列表 -->
<ContentWrap>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane label="所有" name="" />
<el-tab-pane label="白班" name="1" />
<el-tab-pane label="夜班" name="2" />
</el-tabs>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column
label="工作日期"
align="center"
prop="workDate"
:formatter="dateFormatter2"
width="140px"
/>
<el-table-column label="工位" align="center" prop="orgName" />
<el-table-column label="班别" align="center" prop="groupType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.MES_GROUP_TYPE" :value="scope.row.groupType" />
</template>
</el-table-column>
<el-table-column label="工人" align="center" prop="workerName" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['mes:org-worker:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import {dateFormatter, dateFormatter2} from '@/utils/formatTime'
import download from '@/utils/download'
import { OrgWorkerApi, OrgWorkerVO } from '@/api/mes/orgworker'
const message = useMessage() //
const { t } = useI18n() //
const props = defineProps<{
orgId?: number // org ID
orgType?: string
workDate?:undefined
}>()
const loading = ref(true) //
const list = ref<OrgWorkerVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
orgId: undefined,
workDate: undefined,
groupType: undefined,
orgType: undefined,
workerId: undefined,
reportId: undefined,
createTime: []
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await OrgWorkerApi.getOrgWorkerPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await OrgWorkerApi.deleteOrgWorker(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await OrgWorkerApi.exportOrgWorker(queryParams)
download.excel(data, '工位安排.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
/** tab 切换 */
let activeName = ''
const handleTabClick = (tab: TabsPaneContext) => {
queryParams.groupType = tab.paneName
handleQuery()
}
/** 监听主表的关联字段的变化,加载对应的子表数据 */
watch(
() => props.orgId,
(val: number) => {
queryParams.orgId = val
handleQuery()
},
{ immediate: true, deep: true }
)
watch(
() => props.orgType,
(val: string) => {
queryParams.orgType = val
handleQuery()
},
{ immediate: true, deep: true }
)
watch(
() => props.workDate,
(val: string) => {
console.log("workDate:"+val)
if (!val) {
return
}
queryParams.workDate = [val,val]
handleQuery()
},
{ immediate: true, deep: true }
)
</script>
Loading…
Cancel
Save