Browse Source

维修经验

master_hella_20240701
zhang_li 5 months ago
parent
commit
b985c8401c
  1. 49
      src/api/eam/repairExperience/index.ts
  2. 6
      src/components/BasicForm/src/BasicForm.vue
  3. 10
      src/components/Crontab/src/Crontab.vue
  4. 12
      src/utils/disposition/defaultButtons.ts
  5. 155
      src/views/eam/equipmentRepairRecordMain/index.vue
  6. 244
      src/views/eam/repairExperience/index.vue
  7. 109
      src/views/eam/repairExperience/repairExperience.data.ts

49
src/api/eam/repairExperience/index.ts

@ -0,0 +1,49 @@
import request from '@/config/axios'
export interface RepairExperienceVO {
id: number
name: string
content: string
repairNumber: string
}
// 查询维修经验记录列表
export const getRepairExperiencePage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/record/repair-experience/senior', data })
} else {
return await request.get({ url: `/record/repair-experience/page`, params })
}
}
// 查询维修经验记录详情
export const getRepairExperience = async (id: number) => {
return await request.get({ url: `/record/repair-experience/get?id=` + id })
}
// 新增维修经验记录
export const createRepairExperience = async (data: RepairExperienceVO) => {
return await request.post({ url: `/record/repair-experience/create`, data })
}
// 修改维修经验记录
export const updateRepairExperience = async (data: RepairExperienceVO) => {
return await request.put({ url: `/record/repair-experience/update`, data })
}
// 删除维修经验记录
export const deleteRepairExperience = async (id: number) => {
return await request.delete({ url: `/record/repair-experience/delete?id=` + id })
}
// 导出维修经验记录 Excel
export const exportRepairExperience = async (params) => {
return await request.download({ url: `/record/repair-experience/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/record/repair-experience/get-import-template' })
}

6
src/components/BasicForm/src/BasicForm.vue

@ -22,8 +22,9 @@
@onBlur="onBlur"
@onEnter="onEnter"
>
<template #crontab="formSchema" v-if="fromeWhere == 'countPlan'">
<crontab v-model="formSchema.crontab" />
<template #crontab="formSchema1" v-if="fromeWhere == 'countPlan'">
<crontab v-model="formSchema1.crontab" :disabled="formSchema?.find(item=>item.field == 'crontab')?.componentProps?.disabled "/>
</template>
<template #type="formSchema" v-if="fromeWhere == 'countPlan'">
<el-select
@ -335,6 +336,7 @@ const formRef = ref() // 表单 Ref
const formSchema = ref(props.formAllSchemas?.formSchema)
const tableAllSchemas = ref(props.tableAllSchemas)
const tableFormRules = ref(props.tableFormRules)
console.log(111,formSchema)
// -
// const buttondata = [

10
src/components/Crontab/src/Crontab.vue

@ -14,7 +14,11 @@ const props = defineProps({
type: String,
default: '* * * * * ?'
},
shortcuts: { type: Array as PropType<shortcutsType[]>, default: () => [] }
shortcuts: { type: Array as PropType<shortcutsType[]>, default: () => [] },
disabled: {
type: Boolean,
default: false
},
})
const defaultValue = ref('')
const dialogVisible = ref(false)
@ -505,9 +509,9 @@ const submit = () => {
}
</script>
<template>
<el-input v-model="defaultValue" class="input-with-select" v-bind="$attrs">
<el-input v-model="defaultValue" class="input-with-select" v-bind="$attrs" :disabled='props.disabled'>
<template #append>
<el-select v-model="select" placeholder="生成器" style="width: 115px">
<el-select v-model="select" placeholder="生成器" style="width: 115px" v-if="!props.disabled">
<el-option label="每分钟" value="0 * * * * ?" />
<el-option label="每小时" value="0 0 * * * ?" />
<el-option label="每天零点" value="0 0 0 * * ?" />

12
src/utils/disposition/defaultButtons.ts

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

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

@ -1,18 +1,22 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="EquipmentRepairRecordMain.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
<Search
:schema="EquipmentRepairRecordMain.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="EquipmentRepairRecordMain.allSchemas"
/>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="EquipmentRepairRecordMain.allSchemas"
/>
<!-- 列表 -->
<ContentWrap>
@ -27,13 +31,13 @@
v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<template #number="{row}">
<template #number="{ row }">
<el-button type="primary" link @click="openDetail(row, '代码', row.number)">
<span>{{ row.number }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" />
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event, row)" />
</template>
</Table>
</ContentWrap>
@ -51,27 +55,50 @@
/>
<!-- 详情 -->
<Detail ref="detailRef"
:isBasic="false"
:allSchemas="EquipmentRepairRecordMain.allSchemas"
:detailAllSchemas="EquipmentRepairRecordDetail.allSchemas"
:detailAllSchemasRules="EquipmentRepairRecordDetailRules"
:apiPage="EquipmentRepairRecordDetailApi.getEquipmentRepairRecordDetailPage"
:detailButtonIsShowAdd=false
:detailButtonIsShowEdit=false
:detailButtonIsShowDelete=false
<Detail
ref="detailRef"
:isBasic="false"
:allSchemas="EquipmentRepairRecordMain.allSchemas"
:detailAllSchemas="EquipmentRepairRecordDetail.allSchemas"
:detailAllSchemasRules="EquipmentRepairRecordDetailRules"
:apiPage="EquipmentRepairRecordDetailApi.getEquipmentRepairRecordDetailPage"
:detailButtonIsShowAdd="false"
:detailButtonIsShowEdit="false"
:detailButtonIsShowDelete="false"
/>
<!-- 生成维修经验表单弹窗添加/修改 -->
<BasicForm
ref="repairExperienceFormRef"
@success="repairExperienceFormsSuccess"
:rules="EquipmentRepairRecordMainRules"
:formAllSchemas="RepairExperience.allSchemas"
:apiUpdate="RepairExperienceApi.updateRepairExperience"
:apiCreate="RepairExperienceApi.createRepairExperience"
:isBusiness="false"
/>
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/equipment-repair-record-main/import" :importTemplateData="importTemplateData" @success="importSuccess" />
<ImportForm
ref="importFormRef"
url="/eam/equipment-repair-record-main/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { EquipmentRepairRecordMain,EquipmentRepairRecordMainRules } from './equipmentRepairRecordMain.data'
import { EquipmentRepairRecordDetail,EquipmentRepairRecordDetailRules } from '../equipmentRepairRecordDetail/equipmentRepairRecordDetail.data'
import {
EquipmentRepairRecordMain,
EquipmentRepairRecordMainRules
} from './equipmentRepairRecordMain.data'
import {
EquipmentRepairRecordDetail,
EquipmentRepairRecordDetailRules
} from '../equipmentRepairRecordDetail/equipmentRepairRecordDetail.data'
import { RepairExperience } 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'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
@ -112,10 +139,10 @@ const { getList, setSearchParams } = tableMethods
const HeadButttondata = [
// defaultButtons.defaultAddBtn({hasPermi:'eam:equipmentRepairRecordMain:create'}), //
// defaultButtons.defaultImportBtn({hasPermi:'eam:equipmentRepairRecordMain:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:equipmentRepairRecordMain:export'}), //
defaultButtons.defaultExportBtn({ hasPermi: 'eam:equipmentRepairRecordMain:export' }), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
defaultButtons.defaultSetBtn(null) //
// {
// label: '',
// name: 'zdy',
@ -128,16 +155,22 @@ const HeadButttondata = [
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
if (val == 'add') {
//
openForm('create')
} else if (val == 'import') { //
} else if (val == 'import') {
//
handleImport()
} else if (val == 'export') { //
} else if (val == 'export') {
//
handleExport()
} else if (val == 'refresh') { //
} else if (val == 'refresh') {
//
getList()
} else if (val == 'filtrate') { //
} else { //
} else if (val == 'filtrate') {
//
} else {
//
console.log('其他按钮', item)
}
}
@ -146,14 +179,20 @@ const buttonBaseClick = (val, item) => {
const butttondata = [
// defaultButtons.mainListEditBtn({hasPermi:'eam:equipmentRepairRecordMain:update'}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:equipmentRepairRecordMain:delete'}), //
defaultButtons.repairExperienceBtn({ hasPermi: 'eam:equipmentRepairRecordMain:repairExperience' }) //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
if (val == 'edit') {
//
openForm('update', row)
} else if (val == 'delete') { //
} else if (val == 'delete') {
//
handleDelete(row.id)
} else if (val == 'repairExperience') {
//
openRepairExperience('update', row)
}
}
@ -164,18 +203,18 @@ const openForm = (type: string, row?: any) => {
}
// form
const formsSuccess = async (formType,data) => {
var isHave =EquipmentRepairRecordMain.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
const formsSuccess = async (formType, data) => {
var isHave = EquipmentRepairRecordMain.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;
return
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if (data.activeTime == 0) data.activeTime = null
if (data.expireTime == 0) data.expireTime = null
if (formType === 'create') {
await EquipmentRepairRecordMainApi.createEquipmentRepairRecordMain(data)
message.success(t('common.createSuccess'))
@ -192,6 +231,29 @@ const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicEquipmentRepairRecordMain')
}
//
const repairExperienceFormRef = ref()
const openRepairExperience = (type: string, row?: any) => {
repairExperienceFormRef.value.open(type, row)
}
//
const repairExperienceFormsSuccess = async (formType, data) => {
console.log(data)
const data1 = {
repairNumber: data.number,
name: data.name,
content: data.content
}
console.log(data1)
try {
await RepairExperienceApi.createRepairExperience(data1)
message.success(t('common.createSuccess'))
repairExperienceFormRef.value.dialogVisible = false
getList()
} finally {
repairExperienceFormRef.value.formLoading = false
}
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
@ -214,7 +276,9 @@ const handleExport = async () => {
await message.exportConfirm()
//
exportLoading.value = true
const data = await EquipmentRepairRecordMainApi.exportEquipmentRepairRecordMain(tableObject.params)
const data = await EquipmentRepairRecordMainApi.exportEquipmentRepairRecordMain(
tableObject.params
)
download.excel(data, '设备维修记录主.xlsx')
} catch {
} finally {
@ -251,5 +315,4 @@ onMounted(async () => {
getList()
importTemplateData.templateUrl = await EquipmentRepairRecordMainApi.importTemplate()
})
</script>

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

@ -0,0 +1,244 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="RepairExperience.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="RepairExperience.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="RepairExperienceRules"
:formAllSchemas="RepairExperience.allSchemas"
:apiUpdate="RepairExperienceApi.updateRepairExperience"
:apiCreate="RepairExperienceApi.createRepairExperience"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="RepairExperience.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/record/repair-experience/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { RepairExperience,RepairExperienceRules } from './repairExperience.data'
import * as RepairExperienceApi from '@/api/eam/repairExperience/index'
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: 'RepairExperience' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(RepairExperience.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: RepairExperienceApi.getRepairExperiencePage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:repairExperience:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'wms:repairExperience:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'wms:repairExperience: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:repairExperience:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:repairExperience: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 =RepairExperience.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 RepairExperienceApi.createRepairExperience(data)
message.success(t('common.createSuccess'))
} else {
await RepairExperienceApi.updateRepairExperience(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, 'basicRepairExperience')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await RepairExperienceApi.deleteRepairExperience(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 RepairExperienceApi.exportRepairExperience(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 RepairExperienceApi.importTemplate()
})
</script>

109
src/views/eam/repairExperience/repairExperience.data.ts

@ -0,0 +1,109 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const RepairExperienceRules = reactive({
name: [required],
repairNumber: [required],
})
export const RepairExperience = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '经验标题',
field: 'name',
sort: 'custom',
isSearch: true,
},
{
label: '维修工单编号',
field: 'repairNumber',
sort: 'custom',
isSearch: true,
isForm: false,
},
{
label: '经验内容',
field: 'content',
sort: 'custom',
isTable:false,
isSearch:false,
form: {
component: 'Input',
componentProps: {
type:'textarea',
valueHtml: '',
height: 200
}
},
},
{
label: '维修工单来源',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '报修类型',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '设备/工装编号',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '设备/工装名称',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '故障时间',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '故障类型',
field: 'repairNumber',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '创建人',
field: 'createTime',
sort: 'custom',
isSearch:false,
isForm:false
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
isSearch:false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
Loading…
Cancel
Save