Browse Source

工装物料代码

master_hella_20240701
ljlong_2630 4 months ago
parent
commit
1614b4b1b1
  1. 79
      src/api/eam/toolAccounts/index.ts
  2. 61
      src/api/eam/toolMod/index.ts
  3. 244
      src/views/eam/toolAccounts/index.vue
  4. 279
      src/views/eam/toolAccounts/toolAccounts.data.ts
  5. 285
      src/views/eam/toolMod/index.vue
  6. 320
      src/views/eam/toolMod/operateForm.vue
  7. 155
      src/views/eam/toolMod/toolMod.data.ts

79
src/api/eam/toolAccounts/index.ts

@ -0,0 +1,79 @@
import request from '@/config/axios'
export interface ToolAccountsVO {
id: number
code: string
name: string
specification: string
type: string
equity: string
electricMachine: string
isCustomerAptitude: boolean
customerId: string
storageLocation: string
useDept: string
principal: string
principalTelephone: string
status: string
startDate: Date
supplierCode: string
purchaseTime: Date
purchaseDept: string
purchaser: string
productionDate: Date
manufactureCode: string
equipmentLife: string
acceptanceDate: Date
purchasePrice: number
factoryAreaCode: string
workshopCode: string
workshopSectionCode: string
departmentCode: string
remark: string
siteId: string
available: string
deletionTime: Date
deleterId: byte[]
concurrencyStamp: number
}
// 查询工装台账列表
export const getToolAccountsPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/eam/tool-accounts/senior', data })
} else {
return await request.get({ url: `/eam/tool-accounts/page`, params })
}
}
// 查询工装台账详情
export const getToolAccounts = async (id: number) => {
return await request.get({ url: `/eam/tool-accounts/get?id=` + id })
}
// 新增工装台账
export const createToolAccounts = async (data: ToolAccountsVO) => {
return await request.post({ url: `/eam/tool-accounts/create`, data })
}
// 修改工装台账
export const updateToolAccounts = async (data: ToolAccountsVO) => {
return await request.put({ url: `/eam/tool-accounts/update`, data })
}
// 删除工装台账
export const deleteToolAccounts = async (id: number) => {
return await request.delete({ url: `/eam/tool-accounts/delete?id=` + id })
}
// 导出工装台账 Excel
export const exportToolAccounts = async (params) => {
return await request.download({ url: `/eam/tool-accounts/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/eam/tool-accounts/get-import-template' })
}

61
src/api/eam/toolMod/index.ts

@ -0,0 +1,61 @@
import request from '@/config/axios'
export interface ToolModVO {
id: number
modCode: string
toolCode: string
type: string
departmentCode: string
remark: string
siteId: string
available: string
deletionTime: Date
deleterId: byte[]
concurrencyStamp: number
}
// 查询工装物料关联列表
export const getToolModPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/eam/basic/tool-mod/senior', data })
} else {
return await request.get({ url: `/eam/basic/tool-mod/page`, params })
}
}
// 查询工装物料关联详情
export const getToolMod = async (id: number) => {
return await request.get({ url: `/eam/basic/tool-mod/get?id=` + id })
}
// 新增工装物料关联
export const createToolMod = async (data: ToolModVO) => {
return await request.post({ url: `/eam/basic/tool-mod/create`, data })
}
// 修改工装物料关联
export const updateToolMod = async (data: ToolModVO) => {
return await request.put({ url: `/eam/basic/tool-mod/update`, data })
}
// 删除工装物料关联
export const deleteToolMod = async (id: number) => {
return await request.delete({ url: `/eam/basic/tool-mod/delete?id=` + id })
}
// 导出工装物料关联 Excel
export const exportToolMod = async (params) => {
return await request.download({ url: `/eam/basic/tool-mod/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/eam/basic/tool-mod/get-import-template' })
}
// 新增工装物料关联
export const createToolModBatch = async (data: ToolModVO) => {
return await request.post({ url: `/eam/basic/tool-mod/createBatch`, data })
}

244
src/views/eam/toolAccounts/index.vue

@ -0,0 +1,244 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="ToolAccounts.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ToolAccounts.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="ToolAccountsRules"
:formAllSchemas="ToolAccounts.allSchemas"
:apiUpdate="ToolAccountsApi.updateToolAccounts"
:apiCreate="ToolAccountsApi.createToolAccounts"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ToolAccounts.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/tool-accounts/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { ToolAccounts,ToolAccountsRules } from './toolAccounts.data'
import * as ToolAccountsApi from '@/api/eam/toolAccounts'
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'
defineOptions({ name: 'ToolAccounts' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(ToolAccounts.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: ToolAccountsApi.getToolAccountsPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'eam:tool-accounts:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'eam:tool-accounts:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:tool-accounts: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:tool-accounts:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'eam:tool-accounts:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =ToolAccounts.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 ToolAccountsApi.createToolAccounts(data)
message.success(t('common.createSuccess'))
} else {
await ToolAccountsApi.updateToolAccounts(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, 'basicToolAccounts')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ToolAccountsApi.deleteToolAccounts(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 ToolAccountsApi.exportToolAccounts(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 ToolAccountsApi.importTemplate()
})
</script>

279
src/views/eam/toolAccounts/toolAccounts.data.ts

@ -0,0 +1,279 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const ToolAccountsRules = reactive({
code: [required],
name: [required],
concurrencyStamp: [required]
})
export const ToolAccounts = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '工装编号',
field: 'code',
sort: 'custom',
isSearch: true,
isForm: false,
},
{
label: '名称',
field: 'name',
sort: 'custom',
isSearch: true
},
{
label: '型号',
field: 'specification',
sort: 'custom',
isSearch: true
},
{
label: '类型',
field: 'type',
sort: 'custom',
isSearch: false,
form: {
component: 'Select'
}
},
{
label: '产权',
field: 'equity',
sort: 'custom',
isSearch: false
},
{
label: '电机',
field: 'electricMachine',
sort: 'custom',
isSearch: false
},
{
label: '是否客户资质',
field: 'isCustomerAptitude',
sort: 'custom',
isSearch: false,
form: {
component: 'Switch'
}
},
{
label: '客户id',
field: 'customerId',
sort: 'custom',
isSearch: false
},
{
label: '存放位置',
field: 'storageLocation',
sort: 'custom',
isSearch: false
},
{
label: '使用部门',
field: 'useDept',
sort: 'custom',
isSearch: false
},
{
label: '负责人',
field: 'principal',
sort: 'custom',
isSearch: false
},
{
label: '负责人联系方式',
field: 'principalTelephone',
sort: 'custom',
isSearch: false
},
{
label: '设备状态',
field: 'status',
sort: 'custom',
isSearch: false,
form: {
component: 'Switch'
}
},
{
label: '启用日期',
field: 'startDate',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '供应商编号',
field: 'supplierCode',
sort: 'custom',
isSearch: false
},
{
label: '采购时间',
field: 'purchaseTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '采购部门',
field: 'purchaseDept',
sort: 'custom',
isSearch: true
},
{
label: '采购人',
field: 'purchaser',
sort: 'custom',
isSearch: true
},
{
label: '出厂日期',
field: 'productionDate',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '生产厂商编码',
field: 'manufactureCode',
sort: 'custom',
isSearch: false
},
{
label: '设备使用寿命',
field: 'equipmentLife',
sort: 'custom',
isSearch: false
},
{
label: '验收日期',
field: 'acceptanceDate',
sort: 'custom',
formatter: dateFormatter,
isSearch: false,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '价格',
field: 'purchasePrice',
sort: 'custom',
isSearch: false
},
{
label: '所属厂区编号',
field: 'factoryAreaCode',
sort: 'custom',
isSearch: true
},
{
label: '车间编号',
field: 'workshopCode',
sort: 'custom',
isSearch: true
},
{
label: '工段编号',
field: 'workshopSectionCode',
sort: 'custom',
isSearch: true
},
{
label: '部门',
field: 'departmentCode',
sort: 'custom',
isSearch: false
},
{
label: '备注',
field: 'remark',
sort: 'custom',
isSearch: false
},
// {
// label: '是否可用',
// field: 'available',
// sort: 'custom',
// dictType: DICT_TYPE.TRUE_FALSE,
// dictClass: 'string', // 默认都是字符串类型其他暂不考虑
// isSearch: false,
// form: {
// component: 'Switch',
// value: 'TRUE',
// componentProps: {
// inactiveValue: 'FALSE',
// activeValue: 'TRUE'
// }
// }
// },
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))

285
src/views/eam/toolMod/index.vue

@ -0,0 +1,285 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="ToolMod.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ToolMod.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(row)" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<!-- <BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="ToolModRules"
:formAllSchemas="ToolMod.allSchemas"
:apiUpdate="ToolModApi.updateToolMod"
:apiCreate="ToolModApi.createToolMod"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/> -->
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ToolMod.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/basic/tool-mod/import" :importTemplateData="importTemplateData" @success="importSuccess" />
<!-- 表单弹窗添加/修改 -->
<teamForm ref="basicFormRef" @success="formsSuccess" :formAllSchemas="ToolMod.allSchemas"/>
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { ToolMod,ToolModRules } from './toolMod.data'
import * as ToolModApi from '@/api/eam/toolMod'
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 TeamForm from "./operateForm.vue";
defineOptions({ name: 'ToolMod' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(ToolMod.allSchemas.tableColumns)
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: ToolModApi.getToolModPage //
})
const judgeStatus = (row) =>{
if(row.available === 'TRUE'){
return true
}else{
return false
}
}
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'eam:tool-mod:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'eam:tool-mod:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:tool-mod: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 = (row) => {
return [
defaultButtons.mainListEditBtn({hasPermi:'eam:tool-mod:update'}), //
defaultButtons.mainListEnableBtn({hasPermi:'eam:tool-mod:enable',hide: judgeStatus(row)}), //
defaultButtons.mainListDisableBtn({hasPermi:'eam:tool-mod:disable',hide: !judgeStatus(row)}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:tool-mod:delete'}), //
]}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
} else if (val == 'enable') { //
handleEnable(row,'TRUE')
}else if (val == 'disable') {//
handleEnable(row,'FALSE')
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =ToolMod.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 ToolModApi.createToolMod(data)
message.success(t('common.createSuccess'))
} else {
await ToolModApi.updateToolMod(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, 'basicToolMod')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ToolModApi.deleteToolMod(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 ToolModApi.exportToolMod(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() //
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
if (formField == 'modCodeShow') {
let str = ''
let modCodeList = Array(String)
val.forEach((element) => {
str += element.name + ':' + element.code + ','
modCodeList.push(element.code)
})
str = str.substring(0, str.length - 1)
setV['modCodeShow'] = str
setV['modCodeList'] = modCodeList
formRef.setValues(setV);
}else if(formField == 'toolCodeShow'){
let str = val[0].name + ':' + val[0].code
str = str.substring(0, str.length - 1)
setV['toolCodeShow'] = str
setV['toolCode'] = val[0].code
formRef.setValues(setV);
}
})
}
const handleEnable = (row,enable) =>{
message.confirm(t('您确定'+(enable=='TRUE'?'启用':'禁用')+'该项吗, 是否继续?')).then(() => {
row.available = enable
ToolModApi.updateToolMod(row).then(res => {
message.success(t('common.updateSuccess'))
})
})
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await ToolModApi.importTemplate()
})
</script>

320
src/views/eam/toolMod/operateForm.vue

@ -0,0 +1,320 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<el-form
ref="basicFormRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="80px"
>
<el-row>
<el-col :span="24">
<el-form-item label="工装" prop="toolCode">
<div class="tag-container flex gap-2">
<el-tag v-for="ent in toolCodeList" :key="ent.code" closable :disable-transitions="false"
@close="handleToolClose(ent.code)">
{{ ent.name}}
</el-tag>
<el-input
v-if="inputToolVisible"
ref="InputRef"
v-model="inputToolValue"
class="w-20"
size="small"
/>
<el-button v-else class="button-new-tag" size="small" @click="addTool">
选定工装 +
</el-button>
</div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="物料" prop="modCodeList">
<div class="tag-container flex gap-2">
<el-tag v-for="ent in tags" :key="ent.code" closable :disable-transitions="false"
@close="handleClose(ent.code)">
{{ ent.name}}
</el-tag>
<el-input
v-if="inputVisible"
ref="InputRef"
v-model="inputValue"
class="w-20"
size="small"
/>
<el-button v-else class="button-new-tag" size="small" @click="addMod">
添加物料 +
</el-button>
</div>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="类型" prop="type">
<el-select v-model="formData.type" placeholder="请选择类型">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.DEVICE_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入内容" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
<!--添加班组人员弹窗-->
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import request from "@/config/axios";
import download from '@/utils/download'
import { ToolMod,ToolModRules } from './toolMod.data'
import {Itembasic} from "@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data";
import * as ItembasicApi from "@/api/wms/itembasic";
import { ToolAccounts,ToolAccountsRules } from '../toolAccounts/toolAccounts.data'
import * as ToolAccountsApi from '@/api/eam/toolAccounts'
import * as ToolModApi from '@/api/eam/toolMod'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
defineOptions({ name: 'OperateForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const tags=ref([])
const toolCodeList = ref([])
const inputValue = ref('')
const inputToolValue = ref('')
const inputVisible = ref(false)
const inputToolVisible = ref(false)
const isDisabled = ref(false)
const isToolDisabled = ref(false)
const InputRef = ref<InstanceType<typeof ElInput>>()
const formData = ref({
toolCode: '',
modCodeList: [],
type: null,
remark: ''
})
const formRules = reactive({
modCodeList: [required],
toolCode: [required],
type: [required],
concurrencyStamp: [required]
})
const basicFormRef = ref() // Ref
const handleClose = (code) => {
tags.value = tags.value.filter(item=>{
return item.code!=code
})
}
const handleToolClose = (code) => {
toolCodeList.value = toolCodeList.value.filter(item=>{
return item.code!=code
})
}
/** 弹窗相关参数 */
const searchTableRef = ref();
const _searchTableTitle = ref();
const _searchTableAllSchemas = ref();
const _searchTablePage = ref();
const _formField = ref();
const _searchField = ref();
const _multiple = ref();
const _type = ref();
const _row = ref();
const _searchCondition = ref({})
const addTool = () =>{
addToolCommon(true,'toolCodeList')
}
const addMod = () =>{
addModCommon(true,'modCodeList')
}
/** 选择物料弹窗 */
const addModCommon = (multiple,field) => {
_searchCondition.value = {}
const filters: any[] = []
filters.push({
action: "==",
column: 'available',
value: 'TRUE'
})
//
_searchCondition.value.isSearch = true
_searchCondition.value.filters = filters
_searchTableTitle.value = '选择物料'
_multiple.value = multiple
_formField.value = field
_searchField.value = field
_searchTablePage.value = ItembasicApi.getItembasicPage,
_searchTableAllSchemas.value = Itembasic.allSchemas,
openCommon()
}
/** 选择物料弹窗 */
const addToolCommon = (multiple,field) => {
_searchCondition.value = {}
const filters: any[] = []
filters.push({
action: "==",
column: 'available',
value: 'TRUE'
})
//
_searchCondition.value.isSearch = true
_searchCondition.value.filters = filters
_searchTableTitle.value = '选定工装'
_multiple.value = multiple
_formField.value = field
_searchField.value = field
_searchTablePage.value = ToolAccountsApi.getToolAccountsPage,
_searchTableAllSchemas.value = ToolAccounts.allSchemas,
openCommon()
}
/** 弹窗选择之后 回调函数 */
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
if (formField === 'modCodeList') {
tags.value = [];
val.forEach(item => {
let newMod = {}
newMod['code'] = item.code;
newMod['name'] = item.name;
tags.value.push(newMod);
});
}else if (formField === 'toolCodeList') {
toolCodeList.value = [];
val.forEach(item => {
let newTool = {}
newTool['code'] = item.code;
newTool['name'] = item.name;
toolCodeList.value.push(newTool);
});
}
}
/*打开弹窗*/
const openCommon = () => {
searchTableRef.value.open(
_searchTableTitle.value,
_searchTableAllSchemas.value,
_searchTablePage.value,
_formField.value,
_searchField.value,
_multiple.value,
_type.value,
_row.value,
_searchCondition.value
)
}
/** 初始化弹窗 */
const open = async (type: string, row?: object) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (row) {
isDisabled.value = true;
formLoading.value = true
try {
// formData.value = await request.get({ url: `/wms/itembasic/get?id=` + row.id });
// tags.value=formData.value
} finally {
formLoading.value = false
}
}
else {
isDisabled.value = false;
tags.value=[];
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
formData.value.modCodeList = tags.value.map(item=>item.code)
formData.value.toolCode = toolCodeList.value[0].code
//
if (!basicFormRef) return
const valid = await basicFormRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as ToolModApi.ToolModVO
if (formType.value === 'create') {
await ToolModApi.createToolModBatch(data)
message.success(t('common.createSuccess'))
} else {
await ToolModApi.updateToolMod(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
toolCode: '',
modCodeList: [],
type: null,
remark: ''
}
basicFormRef.value?.resetFields()
}
</script>
<style scoped>
.tag-container {
margin-top: 10px; /* 可根据需要调整标签容器与表单项之间的间距 */
border: 1px solid #ccc; /* 添加边框样式 */
padding: 10px; /* 可根据需要调整容器内边距 */
width: 950px; /* 设置固定宽度为 950px */
overflow-y: auto; /* 当内容溢出容器高度时显示滚动条 */
word-wrap: break-word; /* 使用 word-wrap 属性实现超出范围换行 */
overflow-wrap: break-word; /* 兼容性更好的写法 */
flex-wrap: wrap;
}
.input-with-button {
display: flex;
align-items: center;
width: 100%;
}
.input-with-button > .el-input {
flex: 1;
/*margin-right: 10px;*/
}
</style>

155
src/views/eam/toolMod/toolMod.data.ts

@ -0,0 +1,155 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import {Itembasic} from "@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data";
import * as ItembasicApi from "@/api/wms/itembasic";
import { ToolAccounts,ToolAccountsRules } from '../toolAccounts/toolAccounts.data'
import * as ToolAccountsApi from '@/api/eam/toolAccounts'
// 表单校验
export const ToolModRules = reactive({
modCode: [required],
toolCode: [required],
type: [required],
concurrencyStamp: [required]
})
export const ToolMod = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '工装编码',
field: 'toolCode',
sort: 'custom',
isSearch: false,
isDetail: false,
isForm: false,
isTable: true,
isTableForm: false,
},
// {
// label: '工装编码',
// field: 'toolCodeShow',
// sort: 'custom',
// isSearch: true,
// form: {
// componentProps: {
// isSearchList: true,
// searchListPlaceholder: '请选择工装代码',
// searchField: 'toolCodeShow',
// searchTitle: '客户物料基础信息',
// searchAllSchemas: ToolAccounts.allSchemas,
// searchPage: ToolAccountsApi.getToolAccountsPage,
// searchCondition: [{
// key: 'available',
// value: 'TRUE',
// isMainValue: false
// }]
// }
// },
// search: {
// componentProps: {
// isSearchList: true,
// searchListPlaceholder: '请选择工装代码',
// searchField: 'toolCodeShow',
// searchTitle: '客户物料基础信息',
// searchAllSchemas: ToolAccounts.allSchemas,
// searchPage: ToolAccountsApi.getToolAccountsPage,
// searchCondition: [{
// key: 'available',
// value: 'TRUE',
// isMainValue: false
// }]
// }
// }
// },
{
label: '物料编号',
field: 'modCode',
sort: 'custom',
isSearch: false,
isDetail: false,
isForm: false,
isTable: true,
isTableForm: false,
},
// {
// label: '物料编号',
// field: 'modCodeShow',
// sort: 'custom',
// isSearch: true,
// form: {
// componentProps: {
// isSearchList: true,
// searchListPlaceholder: '请选择物料代码',
// searchField: 'modCodeShow',
// searchTitle: '客户物料基础信息',
// multiple:true,
// searchAllSchemas: Itembasic.allSchemas,
// searchPage: ItembasicApi.getItembasicPage,
// searchCondition: [{
// key: 'available',
// value: 'TRUE',
// isMainValue: false
// }]
// }
// },
// search: {
// componentProps: {
// isSearchList: true,
// searchListPlaceholder: '请选择物料代码',
// searchField: 'modCodeShow',
// searchTitle: '客户物料基础信息',
// multiple: true,
// searchAllSchemas: Itembasic.allSchemas,
// searchPage: ItembasicApi.getItembasicPage,
// searchCondition: [{
// key: 'available',
// value: 'TRUE',
// isMainValue: false
// }]
// }
// }
// },
{
label: '类型',
field: 'type',
sort: 'custom',
dictType: DICT_TYPE.DEVICE_TYPE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
isSearch: true,
form: {
component: 'Select'
}
},
// {
// label: '部门',
// field: 'departmentCode',
// sort: 'custom',
// isSearch: true
// },
{
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'
}
}
]))
Loading…
Cancel
Save