Browse Source

1、工位管理增加班组、产线搜索及绑定

master_hella_20240701
bjang03 8 months ago
parent
commit
b96f23a321
  1. 0
      src/api/mes/index.ts
  2. 49
      src/api/mes/workstation/index.ts
  3. 12
      src/utils/disposition/defaultButtons.ts
  4. 248
      src/views/mes/workstation/index.vue
  5. 78
      src/views/mes/workstation/workstation.data.ts

0
src/api/mes/index.ts

49
src/api/mes/workstation/index.ts

@ -0,0 +1,49 @@
import request from '@/config/axios'
export interface WorkstationVO {
code: string
activeTime: Date
expireTime: Date
name: string
}
// 查询工位列表
export const getWorkstationPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/mes/workstation/senior', data })
} else {
return await request.get({ url: `/mes/workstation/page`, params })
}
}
// 查询工位详情
export const getWorkstation = async (id: number) => {
return await request.get({ url: `/mes/workstation/get?id=` + id })
}
// 新增工位
export const createWorkstation = async (data: WorkstationVO) => {
return await request.post({ url: `/mes/workstation/create`, data })
}
// 修改工位
export const updateWorkstation = async (data: WorkstationVO) => {
return await request.put({ url: `/mes/workstation/update`, data })
}
// 删除工位
export const deleteWorkstation = async (id: number) => {
return await request.delete({ url: `/mes/workstation/delete?id=` + id })
}
// 导出工位 Excel
export const exportWorkstation = async (params) => {
return await request.download({ url: `/mes/workstation/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/mes/workstation/get-import-template' })
}

12
src/utils/disposition/defaultButtons.ts

@ -735,6 +735,18 @@ export function mainThawRequesttBtn(option:any) {
hasPermi: '' hasPermi: ''
}) })
} }
// 主列表-绑定
export function mainListBindBtn(option:any) {
return __defaultBtnOption(option,{
label: '绑定',
name: 'bind',
hide: false,
type: 'primary',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 默认按钮规则 // 默认按钮规则
function __defaultBtnOption(option:any,specific:any){ function __defaultBtnOption(option:any,specific:any){
return { return {

248
src/views/mes/workstation/index.vue

@ -0,0 +1,248 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="Workstation.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="Workstation.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="WorkstationRules"
:formAllSchemas="Workstation.allSchemas"
:apiUpdate="WorkstationApi.updateWorkstation"
:apiCreate="WorkstationApi.createWorkstation"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="Workstation.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/mes/workstation/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { Workstation,WorkstationRules } from './workstation.data'
import * as WorkstationApi from '@/api/mes/workstation'
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 {mainBindBtn} from "@/utils/disposition/defaultButtons";
defineOptions({ name: 'Workstation' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(Workstation.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: WorkstationApi.getWorkstationPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:workstation:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'wms:workstation:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'wms:workstation: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:'wms:workstation:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:workstation:delete'}), //
defaultButtons.mainListBindBtn({hasPermi:'wms:workstation:update'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}else if (val == 'bind') { //
detailRef.value.openDetail(row, row.name, "绑定", 'mesWorkstation')
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =Workstation.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 WorkstationApi.createWorkstation(data)
message.success(t('common.createSuccess'))
} else {
await WorkstationApi.updateWorkstation(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, 'basicWorkstation')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await WorkstationApi.deleteWorkstation(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 WorkstationApi.exportWorkstation(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 WorkstationApi.importTemplate()
})
</script>

78
src/views/mes/workstation/workstation.data.ts

@ -0,0 +1,78 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const WorkstationRules = reactive({
code: [required],
name: [required]
})
export const Workstation = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '代码',
field: 'code',
sort: 'custom',
isSearch: true
},
{
label: '名称',
field: 'name',
sort: 'custom',
isSearch: true
},
{
label: '车间代码',
field: 'workshopCode',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '生产线代码',
field: 'productionLineCode',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '班组代码',
field: 'teamCode',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '生效时间',
field: 'activeTime',
sort: 'custom',
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '失效时间',
field: 'expireTime',
sort: 'custom',
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
Loading…
Cancel
Save