Browse Source

巡检点检界面

master
ljlong_2630 10 months ago
parent
commit
f0c563f0ae
  1. 99
      src/views/eam/device/deviceSpotInspectionRecordMain/deviceSpotInspectionRecordMain.data.ts
  2. 409
      src/views/eam/device/deviceSpotInspectionRecordMain/index.vue

99
src/views/eam/device/deviceSpotInspectionRecordMain/deviceSpotInspectionRecordMain.data.ts

@ -96,3 +96,102 @@ export const DeviceSpotInspectionRecordMain = useCrudSchemas(reactive<CrudSchema
}
}
]))
// 表单校验
export const DeviceSpotInspectionRecordDetailRules = reactive({
number: [required],
concurrencyStamp: [required],
name: [required],
equipmentPosition: [required]
})
export const DeviceSpotInspectionRecordDetail = useCrudSchemas(reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
sort: 'custom',
isForm: false
},
{
label: '检修工单号与主表一致',
field: 'number',
sort: 'custom',
isSearch: true
},
{
label: '是否符合TRUE/FALSE',
field: 'isConform',
sort: 'custom',
isSearch: true
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
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')]
}
},
isForm: false
},
{
label: '地点ID',
field: 'siteId',
sort: 'custom',
isSearch: true
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
isSearch: true
},
{
label: '并发乐观锁',
field: 'concurrencyStamp',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
}
},
{
label: '主表id',
field: 'masterId',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
}
},
{
label: '检查内容',
field: 'name',
sort: 'custom',
isSearch: true
},
{
label: '设备部位名称',
field: 'equipmentPosition',
sort: 'custom',
isSearch: true
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))

409
src/views/eam/device/deviceSpotInspectionRecordMain/index.vue

@ -1,18 +1,22 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="DeviceSpotInspectionRecordMain.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
<Search
:schema="DeviceSpotInspectionRecordMain.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="DeviceSpotInspectionRecordMain.allSchemas"
/>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="DeviceSpotInspectionRecordMain.allSchemas"
/>
<!-- 列表 -->
<ContentWrap>
@ -27,68 +31,143 @@
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>
<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(row)"
@button-base-click="buttonTableClick($event, row)"
/>
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
ref="formRef"
:rules="DeviceSpotInspectionRecordMainRules"
:formAllSchemas="DeviceSpotInspectionRecordMain.allSchemas"
:tableAllSchemas="DeviceSpotInspectionRecordDetail.allSchemas"
:tableFormRules="DeviceSpotInspectionRecordDetailRules"
:tableData="tableData"
:apiUpdate="DeviceSpotInspectionRecordMainApi.updateDeviceSpotInspectionRecordMain"
:apiCreate="DeviceSpotInspectionRecordMainApi.createDeviceSpotInspectionRecordMain"
:isBusiness="true"
@onChange="onChange"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
@submitForm="submitForm"
:isSearchTableItem="true"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceSpotInspectionRecordMain.allSchemas" />
<!-- <Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceSpotInspectionRecordMain.allSchemas" /> -->
<Detail
ref="detailRef"
:isBasic="false"
:allSchemas="DeviceSpotInspectionRecordMain.allSchemas"
:detailAllSchemas="DeviceSpotInspectionRecordDetail.allSchemas"
:detailAllSchemasRules="DeviceSpotInspectionRecordDetailRules"
:apiCreate="DeviceSpotInspectionRecordDetailApi.createDeviceSpotInspectionRecordDetail"
:apiUpdate="DeviceSpotInspectionRecordDetailApi.updateDeviceSpotInspectionRecordDetail"
:apiPage="DeviceSpotInspectionRecordDetailApi.getDeviceSpotInspectionRecordDetailPage"
:apiDelete="DeviceSpotInspectionRecordDetailApi.deleteDeviceSpotInspectionRecordDetail"
:Echo="Echo"
@searchTableSuccessDetail="searchTableSuccessDetail"
@detailOpenForm="detailOpenForm"
:detailValidate="detailValidate"
@detailSubmitForm="detailSubmitForm"
:isSearchTableItem="true"
/>
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/device-spot-inspection-record-main/import" :importTemplateData="importTemplateData" @success="importSuccess" />
<ImportForm
ref="importFormRef"
url="/eam/device-maintenance-main/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { DeviceSpotInspectionRecordMain,DeviceSpotInspectionRecordMainRules } from './deviceSpotInspectionRecordMain.data'
import {
DeviceSpotInspectionRecordMain,
DeviceSpotInspectionRecordMainRules,
DeviceSpotInspectionRecordDetail,
DeviceSpotInspectionRecordDetailRules
} from './deviceSpotInspectionRecordMain.data'
import * as DeviceSpotInspectionRecordMainApi from '@/api/eam/device/deviceSpotInspectionRecordMain'
import * as DeviceSpotInspectionRecordDetailApi from '@/api/eam/device/deviceSpotInspectionRecordDetail'
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 { useUserStore } from '@/store/modules/user'
defineOptions({ name: 'DeviceSpotInspectionRecordMain' })
const message = useMessage() //
const { t } = useI18n() //
const userStore = useUserStore() //
const route = useRoute() //
const routeName = ref()
const formRef = ref()
routeName.value = route.name
const tableColumns = ref(DeviceSpotInspectionRecordMain.allSchemas.tableColumns)
const apiPage = ref(DeviceSpotInspectionRecordDetailApi.getDeviceSpotInspectionRecordDetailPage)
const detailAllSchemas = ref(DeviceSpotInspectionRecordDetail.allSchemas)
const tableData = ref([])
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
const searchTableSuccess = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
if (type == 'tableForm') {
//
if (formField == 'itemNumbers1') {
let str = ''
val.forEach((element) => {
str += element.name + ':' + element.qty + ','
})
str = str.substring(0, str.length - 1)
row['itemNumbers1'] = str
row['itemNumbers'] = val
}
} else {
// const setV = {}
// setV[formField] = val[0][searchField]
// setV['supplierCode'] = val[0]['code']
// formRef.setValues(setV)
}
})
}
//
const searchTableSuccessDetail = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
if (formField == 'itemNumbers1') {
let str = ''
val.forEach((element) => {
str += element.name + ':' + element.qty + ','
})
str = str.substring(0, str.length - 1)
setV['itemNumbers'] = val
setV['itemNumbers1'] = str
}
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
//
// const Echo = ['ppNumber','poLine', 'batch', 'altBatch', 'itemCode', 'itemName', 'itemDesc1', 'itemDesc2', 'projectCode', 'qty', 'uom']
const Echo = []
const { tableObject, tableMethods } = useTable({
getListApi: DeviceSpotInspectionRecordMainApi.getDeviceSpotInspectionRecordMainPage //
@ -99,87 +178,111 @@ const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'eam:deviceSpotInspectionRecordMain:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'eam:deviceSpotInspectionRecordMain:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:deviceSpotInspectionRecordMain:export'}), //
defaultButtons.defaultAddBtn({
hide: !userStore?.userSelfInfo?.posts?.some((item) => item.code == 'worker')
}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
// {
// label: '',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
defaultButtons.defaultSetBtn(null) //
]
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
if (val == 'add') {
//
DeviceSpotInspectionRecordMain.allSchemas.formSchema[3].value = 'DEVICE'
DeviceSpotInspectionRecordMain.allSchemas.formSchema[0].componentProps.disabled = false
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)
}
}
//
const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
// -
const butttondata = [
defaultButtons.mainListEditBtn({hasPermi:'eam:deviceSpotInspectionRecordMain:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'eam:deviceSpotInspectionRecordMain:delete'}), //
]
const butttondata = (row) => {
return [
defaultButtons.mainListEditBtn(null), //
defaultButtons.acceptOrderBtn({
hide: !(
row.status == 'PENDING' &&
userStore?.userSelfInfo?.posts?.some((item) => item.code == 'worker')
)
}), //
defaultButtons.turnOrderBtn({
hide: !(row.status == 'PECEIVED' && row.maintenance == userStore.getUser.id)
}), //
defaultButtons.repairBtn({
hide: !(row.status == 'PECEIVED' && row.maintenance == userStore.getUser.id)
}), //
defaultButtons.verifyOrderBtn({
hide: !(
row.status == 'COMPLETED' &&
userStore?.userSelfInfo?.posts?.some((item) => item.code == 'engineer')
)
}), //
defaultButtons.finishOrderBtn({
hide: !(row.status == 'PECEIVED' && row.maintenance == userStore.getUser.id)
}) //
]
}
const onChange = (field, cur, item) => {
if (field == 'deviceNumber') {
// DeviceSpotInspectionRecordMain.allSchemas.formSchema[1].componentProps.disabled = true
// DeviceSpotInspectionRecordMain.allSchemas.formSchema[2].componentProps.disabled = true
formRef.value.formRef.formModel.factoryAreaNumber =String(item.componentProps.options.find((item) => item.number == cur).factoryAreaNumber)
console.log(typeof formRef.value.formRef.formModel.factoryAreaNumber)
// console.log(item)
// console.log(item.componentProps.options)
formRef.value.formRef.formModel.maintenance = Number(userStore?.getUser?.id)
}
}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
DeviceSpotInspectionRecordMain.allSchemas.formSchema[0].componentProps.disabled = false
if (val == 'edit') {
//
openForm('update', row)
} else if (val == 'delete') { //
DeviceSpotInspectionRecordMain.allSchemas.formSchema[0].componentProps.disabled = true
} else if (val == 'delete') {
//
handleDelete(row.id)
} else if (val == 'acceptOrder') {
acceptOrder(row)
} else if (val == 'turnOrder') {
openForm('turnOrder', row)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =DeviceSpotInspectionRecordMain.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 DeviceSpotInspectionRecordMainApi.createDeviceSpotInspectionRecordMain(data)
message.success(t('common.createSuccess'))
} else {
await DeviceSpotInspectionRecordMainApi.updateDeviceSpotInspectionRecordMain(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
tableData.value = [] //
formRef.value.open(type, row)
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicDeviceSpotInspectionRecordMain')
detailRef.value.openDetail(row, titleName, titleValue,'DeviceSpotInspectionRecordMain')
}
/** 删除按钮操作 */
@ -204,7 +307,7 @@ const handleExport = async () => {
//
exportLoading.value = true
const data = await DeviceSpotInspectionRecordMainApi.exportDeviceSpotInspectionRecordMain(tableObject.params)
download.excel(data, '修工单主.xlsx')
download.excel(data, '修工单主.xlsx')
} catch {
} finally {
exportLoading.value = false
@ -219,7 +322,7 @@ const handleImport = () => {
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '修工单主导入模版.xlsx'
templateTitle: '修工单主导入模版.xlsx'
})
//
const importSuccess = () => {
@ -235,10 +338,144 @@ const searchFormClick = (searchData) => {
getList() //
}
//
function acceptOrder(row) {
DeviceSpotInspectionRecordMainApi.orderStepChange(row)
}
//
function turnOrder() {}
//
function finishOrder() {}
//
function verifyOrder() {}
//
function repair() {}
//
function mainListDetail() {}
/**
* tableForm方法
*/
const tableFormKeys = {}
DeviceSpotInspectionRecordDetail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
//
const handleAddTable = () => {
tableData.value.push(JSON.parse(JSON.stringify(tableFormKeys)))
}
//
const handleDeleteTable = (item, index) => {
tableData.value.splice(index, 1)
}
//
const submitForm = async (formType, data) => {
data.subList = tableData.value.map((item) => {
return {
describes: item.describes,
describes1: item.describes1,
itemNumbers: item.itemNumbers1,
maintenances: item.maintenances.join(','),
workOut: item.workOut,
}
}) //
console.log(data.subList)
try {
if (formType === 'create') {
await DeviceSpotInspectionRecordMainApi.createDeviceSpotInspectionRecordMain(data)
message.success(t('common.createSuccess'))
} else {
await DeviceSpotInspectionRecordMainApi.updateDeviceSpotInspectionRecordMain(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
getList()
} finally {
formRef.value.formLoading = false
}
}
const detailOpenForm = (type, row) =>{
console.log("type",type);
console.log("row",row);
DeviceSpotInspectionRecordDetail.allSchemas.tableFormColumns.map((item) => {
// if(purchaseReceiptRecordNumberRef.value == ''){
// if (item.field == 'itemCode') {
// item.form.componentProps.disabled = true
// item.form.componentProps.isSearchList = true
// }
// if(item.field == 'poLine'){
// item.form.componentProps.disabled = true
// item.form.componentProps.isSearchList = false
// }
// }else{
// if (item.field == 'itemCode') {
// item.form.componentProps.disabled = true
// item.form.componentProps.isSearchList = false
// }
// if(item.field == 'poLine'){
// item.form.componentProps.disabled = true
// item.form.componentProps.isSearchList = true
// }
// }
})
}
// /
const detailValidate = (data) => {
return true;
let tag = false;
if(data.qty <= 0){
message.warning('数量必须大于0')
tag = false;
return tag;
}else {
tag = true;
return tag;
}
}
//
const detailSubmitForm= async (formType,data,getList,formRef,tableList) => {
try {
let data1 = {
id:data.id,
maintenanceNumber:data.maintenanceNumber,
describes:data.describes,
describes1:data.describes1,
itemNumbers:data.itemNumbers,
maintenances:data.maintenances.join(','),
workOut:data.workOut,
}
console.log(data1)
if (formType === 'create') {
await DeviceSpotInspectionRecordDetailApi.createDeviceSpotInspectionRecordDetail(data1)
message.success(t('common.createSuccess'))
} else {
await DeviceSpotInspectionRecordDetailApi.updateDeviceSpotInspectionRecordDetail(data1)
message.success(t('common.updateSuccess'))
}
formRef.dialogVisible = false
//
await getList()
detailRef.value.tableObject.tableList.forEach(item=>{
if (item.itemNumbers?.length>0) {
let str = ''
item.itemNumbers.forEach(element => {
str += element.name + ':' + element.qty + ','
})
item.itemNumbers1 = str.substring(0, str.length - 1)
}
})
} finally {
formRef.formLoading = false
}
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await DeviceSpotInspectionRecordMainApi.importTemplate()
})
</script>

Loading…
Cancel
Save