Browse Source

保养经验

master_hella_20240701
zhang_li 5 months ago
parent
commit
b43a6c3ac2
  1. 51
      src/api/eam/maintainExperience/index.ts
  2. 14
      src/utils/disposition/defaultButtons.ts
  3. 43
      src/views/eam/equipmentMaintenanceRecordMain/index.vue
  4. 6
      src/views/eam/equipmentRepairRecordMain/index.vue
  5. 256
      src/views/eam/maintainExperience/index.vue
  6. 93
      src/views/eam/maintainExperience/maintainExperience.data.ts

51
src/api/eam/maintainExperience/index.ts

@ -0,0 +1,51 @@
import request from '@/config/axios'
export interface MaintainExperienceVO {
id: number
name: string
content: string
masterId: number
orderType: string
maintainNumber: string
}
// 查询保养经验记录列表
export const getMaintainExperiencePage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/record/maintain-experience/senior', data })
} else {
return await request.get({ url: `/record/maintain-experience/page`, params })
}
}
// 查询保养经验记录详情
export const getMaintainExperience = async (id: number) => {
return await request.get({ url: `/record/maintain-experience/get?id=` + id })
}
// 新增保养经验记录
export const createMaintainExperience = async (data: MaintainExperienceVO) => {
return await request.post({ url: `/record/maintain-experience/create`, data })
}
// 修改保养经验记录
export const updateMaintainExperience = async (data: MaintainExperienceVO) => {
return await request.put({ url: `/record/maintain-experience/update`, data })
}
// 删除保养经验记录
export const deleteMaintainExperience = async (id: number) => {
return await request.delete({ url: `/record/maintain-experience/delete?id=` + id })
}
// 导出保养经验记录 Excel
export const exportMaintainExperience = async (params) => {
return await request.download({ url: `/record/maintain-experience/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/record/maintain-experience/get-import-template' })
}

14
src/utils/disposition/defaultButtons.ts

@ -1136,7 +1136,7 @@ export function sparePartBtn(option:any) {
hasPermi: ''
})
}
// 主列表-备件
// 主列表-生成维修经验
export function repairExperienceBtn(option:any) {
return __defaultBtnOption(option,{
label: '生成维修经验',
@ -1148,6 +1148,18 @@ export function repairExperienceBtn(option:any) {
hasPermi: ''
})
}
// 主列表-生成保养经验
export function maintainExperienceBtn(option:any) {
return __defaultBtnOption(option,{
label: '生成保养经验',
name: 'maintainExperience',
hide: false,
type: 'primary',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 默认按钮规则
function __defaultBtnOption(option:any,specific:any){
return {

43
src/views/eam/equipmentMaintenanceRecordMain/index.vue

@ -62,7 +62,16 @@
:detailButtonIsShowDelete=false
/>
<!-- 生成保养经验表单弹窗添加/修改 -->
<BasicForm
ref="maintainExperienceFormRef"
@success="maintainExperienceFormsSuccess"
:rules="MaintainExperienceRules"
:formAllSchemas="MaintainExperience.allSchemas"
:apiUpdate="MaintainExperienceApi.updateMaintainExperience"
:apiCreate="MaintainExperienceApi.createMaintainExperience"
:isBusiness="false"
/>
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/equipment-maintenance-record-main/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
@ -73,6 +82,8 @@ import { EquipmentMaintenanceRecordMain,EquipmentMaintenanceRecordMainRules } fr
import { EquipmentMaintenanceRecordDetail,EquipmentMaintenanceRecordDetailRules } from '../equipmentMaintenanceRecordDetail/equipmentMaintenanceRecordDetail.data'
import * as EquipmentMaintenanceRecordMainApi from '@/api/eam/equipmentMaintenanceRecordMain'
import * as EquipmentMaintenanceRecordDetailApi from '@/api/eam/equipmentMaintenanceRecordDetail'
import { MaintainExperience,MaintainExperienceRules } from '../maintainExperience/maintainExperience.data'
import * as MaintainExperienceApi from '@/api/eam/maintainExperience'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
@ -147,6 +158,7 @@ const buttonBaseClick = (val, item) => {
const butttondata = [
//defaultButtons.mainListEditBtn({hasPermi:'eam:equipmentMaintenanceRecordMain:update'}), //
//defaultButtons.mainListDeleteBtn({hasPermi:'eam:equipmentMaintenanceRecordMain:delete'}), //
defaultButtons.maintainExperienceBtn({ hasPermi: 'eam:equipmentMaintenanceRecordMain:maintainExperience' }) //
]
// -
@ -155,6 +167,9 @@ const buttonTableClick = async (val, row) => {
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
} else if (val == 'maintainExperience') {
//
openMaintainExperience('update', row)
}
}
@ -163,7 +178,11 @@ const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
//
const maintainExperienceFormRef = ref()
const openMaintainExperience = (type: string, row?: any) => {
maintainExperienceFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =EquipmentMaintenanceRecordMain.allSchemas.formSchema.some(function (item) {
@ -193,6 +212,26 @@ const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicEquipmentMaintenanceRecordMain')
}
//
const maintainExperienceFormsSuccess = async (formType, data) => {
console.log(data)
const data1 = {
maintainRecordNumber: data.recordNo,
name: data.name,
content: data.content,
masterId: data.id,
orderType: 'MAINTAIN',
}
console.log(data1)
try {
await MaintainExperienceApi.createMaintainExperience(data1)
message.success(t('common.createSuccess'))
maintainExperienceFormRef.value.dialogVisible = false
getList()
} finally {
maintainExperienceFormRef.value.formLoading = false
}
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {

6
src/views/eam/equipmentRepairRecordMain/index.vue

@ -70,7 +70,7 @@
<BasicForm
ref="repairExperienceFormRef"
@success="repairExperienceFormsSuccess"
:rules="EquipmentRepairRecordMainRules"
:rules="RepairExperienceRules"
:formAllSchemas="RepairExperience.allSchemas"
:apiUpdate="RepairExperienceApi.updateRepairExperience"
:apiCreate="RepairExperienceApi.createRepairExperience"
@ -95,7 +95,7 @@ import {
EquipmentRepairRecordDetail,
EquipmentRepairRecordDetailRules
} from '../equipmentRepairRecordDetail/equipmentRepairRecordDetail.data'
import { RepairExperience } from '../repairExperience/repairExperience.data'
import { RepairExperience,RepairExperienceRules } from '../repairExperience/repairExperience.data'
import * as EquipmentRepairRecordMainApi from '@/api/eam/equipmentRepairRecordMain'
import * as EquipmentRepairRecordDetailApi from '@/api/eam/equipmentRepairRecordDetail'
import * as RepairExperienceApi from '@/api/eam/repairExperience'
@ -244,7 +244,7 @@ const repairExperienceFormsSuccess = async (formType, data) => {
name: data.name,
content: data.content,
masterId: data.id,
ooderType: 'REPAIR',
orderType: 'REPAIR',
}
console.log(data1)
try {

256
src/views/eam/maintainExperience/index.vue

@ -0,0 +1,256 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="MaintainExperience.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="MaintainExperience.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 #name="{row}">
<el-button type="primary" link @click="openDetail(row, '经验标题', row.maintainRecoedNumber)">
<span>{{ row.name }}</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="MaintainExperienceRules"
:formAllSchemas="MaintainExperience.allSchemas"
:apiUpdate="MaintainExperienceApi.updateMaintainExperience"
:apiCreate="MaintainExperienceApi.createMaintainExperience"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail
ref="detailRef"
:isBasic="false"
:allSchemas="MaintainExperience.allSchemas"
:detailAllSchemas="EquipmentMaintenanceRecordDetail.allSchemas"
:detailAllSchemasRules="EquipmentMaintenanceRecordDetailRules"
:apiPage="EquipmentMaintenanceRecordDetailApi.getEquipmentMaintenanceRecordDetailPage"
:detailButtonIsShowAdd="false"
:detailButtonIsShowEdit="false"
:detailButtonIsShowDelete="false"
/>
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/record/maintain-experience/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { MaintainExperience,MaintainExperienceRules } from './maintainExperience.data'
import * as MaintainExperienceApi from '@/api/eam/maintainExperience'
import { EquipmentMaintenanceRecordDetail,EquipmentMaintenanceRecordDetailRules } from '../equipmentMaintenanceRecordDetail/equipmentMaintenanceRecordDetail.data'
import * as EquipmentMaintenanceRecordDetailApi from '@/api/eam/equipmentMaintenanceRecordDetail'
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: 'MaintainExperience' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(MaintainExperience.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: MaintainExperienceApi.getMaintainExperiencePage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:maintainExperience:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'wms:maintainExperience:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'wms:maintainExperience: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:maintainExperience:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:maintainExperience: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 =MaintainExperience.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 MaintainExperienceApi.createMaintainExperience(data)
message.success(t('common.createSuccess'))
} else {
await MaintainExperienceApi.updateMaintainExperience(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, 'basicMaintainExperience')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await MaintainExperienceApi.deleteMaintainExperience(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 MaintainExperienceApi.exportMaintainExperience(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 MaintainExperienceApi.importTemplate()
})
</script>

93
src/views/eam/maintainExperience/maintainExperience.data.ts

@ -0,0 +1,93 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const MaintainExperienceRules = reactive({
name: [required],
maintainNumber: [required],
})
export const MaintainExperience = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '经验标题',
field: 'name',
sort: 'custom',
isSearch: true,
},
{
label: '经验内容',
field: 'content',
sort: 'custom',
isTable:false,
form: {
componentProps: {
type: 'textarea',
height: 200
}
},
},
{
label: '保养工单编号',
field: 'maintainNumber',
sort: 'custom',
isSearch: true,
isForm: false,
},
{
label: '工单类型',
field: 'orderType',
sort: 'custom',
isForm: false,
isTable: false,
form: {
component: 'SelectV2'
},
},
{
label: '来源字典',
field: 'sources',
sort: 'custom',
dictType: DICT_TYPE.EAM_MAINTENANCE_SOURCES,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
isSearch: false,
isForm:false
},
{
label: '保养类型',
field: 'type',
sort: 'custom',
dictType: DICT_TYPE.DEVICE_TYPE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
isSearch: false,
isForm:false
},
{
label: '设备/工装编号',
field: 'equipmentCode',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '设备/工装名称',
field: 'equipmentName',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
detail:{
dateFormat: 'YYYY-MM-DD HH:mm:ss'
}
},
]))
Loading…
Cancel
Save