Browse Source

维修工单主子表

master
zhang_li 10 months ago
parent
commit
9781baa8f0
  1. 4
      .env.development
  2. 38
      src/api/eam/device/deviceMaintenanceDetail/index.ts
  3. 15
      src/components/BasicForm/src/BasicForm.vue
  4. 199
      src/components/Detail/src/Detail.vue
  5. 557
      src/components/Detail/src/DetailDeviceLedger.vue
  6. 89
      src/components/SearchTable/src/SearchTable.vue
  7. 3
      src/components/SearchTableItem/index.ts
  8. 144
      src/components/SearchTableItem/src/SearchTableItem.vue
  9. 4
      src/utils/disposition/tabsList.ts
  10. 16
      src/views/eam/device/deviceAccounts/index.vue
  11. 94
      src/views/eam/device/deviceMaintenanceMain/deviceMaintenanceMain.data.ts
  12. 85
      src/views/eam/device/deviceMaintenanceMain/index.vue

4
.env.development

@ -4,8 +4,8 @@ NODE_ENV=development
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://localhost:12080'
# VITE_BASE_URL='http://192.168.0.165:12080'
# VITE_BASE_URL='http://localhost:12080'
VITE_BASE_URL='http://192.168.0.165:12080'
# 上传路径
VITE_UPLOAD_URL='http://localhost:12080/admin-api/infra/file/upload'

38
src/api/eam/device/deviceMaintenanceDetail/index.ts

@ -1,51 +1,51 @@
import request from '@/config/axios'
export interface DeviceMaintenanceDetailVO {
describes: string
describes1: string
workOut: string
maintenances: string
  describes: string
  describes1: string
  workOut: string
  maintenances: string
}
// 查询维修工单子列表
export const getDeviceMaintenanceDetailPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/wms/purchasereceipt-request-detail/senior', data })
} else {
return await request.get({ url: `/admin-api/eam/device-maintenance-detail/page`, params })
}
  if (params.isSearch) {
    delete params.isSearch
    const data = {...params}
    return await request.post({ url: '/wms/purchasereceipt-request-detail/senior', data })
  } else {
    return await request.get({ url: `/eam/device-maintenance-detail/page`, params })
  }
}
// 查询维修工单子详情
export const getPurchasereceiptRequestDetail = async (id: number) => {
return await request.get({ url: `/eam/device-maintenance-detail/get?id=` + id })
export const getPurchasereceiptRequestDetail = async (id) => {
  return await request.get({ url: `/eam/device-maintenance-detail/selectListByNumber?id=` + id })
}
// 新增维修工单子
export const createDeviceMaintenanceDetail = async (data: DeviceMaintenanceDetailVO) => {
return await request.post({ url: `/eam/device-maintenance-detail/create`, data })
  return await request.post({ url: `/eam/device-maintenance-detail/create`, data })
}
// 修改维修工单子
export const updateDeviceMaintenanceDetail = async (data: DeviceMaintenanceDetailVO) => {
return await request.put({ url: `/eam/device-maintenance-detail/update`, data })
  return await request.put({ url: `/eam/device-maintenance-detail/update`, data })
}
// 删除维修工单子
export const deleteDeviceMaintenanceDetail = async (id: number) => {
return await request.delete({ url: `/eam/device-maintenance-detail/delete?id=` + id })
  return await request.delete({ url: `/eam/device-maintenance-detail/delete?id=` + id })
}
// 导出维修工单子 Excel
export const exportPurchasereceiptRequestDetail = async (params) => {
return await request.download({ url: `/wms/purchasereceipt-request-detail/export-excel`, params })
  return await request.download({ url: `/wms/purchasereceipt-request-detail/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/wms/purchasereceipt-request-detail/get-import-template' })
}
  return request.download({ url: '/wms/purchasereceipt-request-detail/get-import-template' })
}

15
src/components/BasicForm/src/BasicForm.vue

@ -104,10 +104,12 @@
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" />
</template>
</Dialog>
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
<SearchTableItem ref="searchTableRef" v-if="isSearchTableItem" @searchTableSuccess="searchTableSuccess" />
<SearchTable ref="searchTableRef" v-else @searchTableSuccess="searchTableSuccess" />
</template>
<script setup lang="ts">
import { SearchTable } from '@/components/SearchTable'
import { SearchTableItem } from '@/components/SearchTableItem'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import ButtonBase from '@/components/XButton/src/ButtonBase.vue'
import TableForm from '@/components/TableForm/src/TableForm.vue'
@ -232,6 +234,12 @@ const props = defineProps({
required: false,
default: null
},
//
isSearchTableItem: {
type: Boolean,
required: false,
default: false
},
})
const { t } = useI18n() //
@ -360,12 +368,11 @@ const open = async (type: string, row?: any, masterParmas?: any) => {
if (masterParmas) {
if (!row) {
row = {
masterId: masterParmas.masterId,
number: masterParmas.number
maintenanceNumber: masterParmas.maintenanceNumber,
}
}
}
if (row?.id || row?.masterId) {
if (row?.id || row?.maintenanceNumber) {
formLoading.value = true
try {
nextTick(() => {

199
src/components/Detail/src/Detail.vue

@ -33,7 +33,7 @@
<TableHead
v-if="!isBasic"
:HeadButttondata="HeadButttondata"
:masterId="masterParmas.masterId"
:number="masterParmas.maintenanceNumber"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@searchFormClick="searchFormClick"
@ -72,8 +72,14 @@
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
>
<template #photos="{ row }">
<div v-for="(item,index) in row.photos.split(',')" :key="index" style="color:#409eff ; cursor: pointer;" @click="openImage(item)">{{ item }}</div>
<template #photos="{ row }">
<div
v-for="(item, index) in row.photos.split(',')"
:key="index"
style="color: #409eff; cursor: pointer"
@click="openImage(item)"
>{{ item }}</div
>
</template>
<template #action="{ row }">
<ButtonBase
@ -117,21 +123,19 @@
@selectChangeDetail="selectChangeDetail"
:formTypeDetail="formTypeDetail"
:countPlanAllList="countPlanAllList"
:isSearchTableItem="isSearchTableItem"
/>
</div>
</template>
<script lang="ts" setup>
// import Annex from '@/components/Annex/src/Annex.vue'
// import Remarks from '@/components/Remarks/src/Remarks.vue'
// import ChangeRecord from '@/components/ChangeRecord/src/ChangeRecord.vue'
import Tabs from '@/components/Tabs/src/Tabs.vue'
// import * as RemarkApi from '@/api/wms/remark'
// import * as FileApi from '@/api/wms/file'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import DetailTable from '@/components/DetailTable/src/DetailTable.vue'
import { isString } from '@/utils/is'
import { Console } from 'console'
defineOptions({ name: 'Detail' })
@ -239,7 +243,7 @@ const props = defineProps({
buttondataTable: {
type: Array,
required: false,
default: ()=>{
default: () => {
return []
}
},
@ -256,11 +260,17 @@ const props = defineProps({
default: null
},
//
detailButtonIsShow:{
detailButtonIsShow: {
type: Boolean,
required: false,
default: false
}
},
//
isSearchTableItem: {
type: Boolean,
required: false,
default: false
},
})
const isShowDrawer = ref(false)
const detailLoading = ref(false)
@ -287,8 +297,6 @@ if (props.isBasic == true) {
if (tabsList.value) {
}
// Tabs
const current = ref(0)
const change = (item, index) => {
@ -298,9 +306,9 @@ const change = (item, index) => {
//
const masterParmas = ref({
masterId: '', //id
number: '', //
status: '' //
maintenanceNumber: '' //id
// number: '', //
// status: '' //
})
//
@ -318,11 +326,11 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
//
if (!props.isBasic) {
// id
masterParmas.value.masterId = row.id
masterParmas.value.number = row.number
masterParmas.value.status = row.status
masterParmas.value.maintenanceNumber = row.number
// masterParmas.value.number = row.number
// masterParmas.value.status = row.status
tableObjectRef.value.params = {
masterId: row.id
maintenanceNumber: row.number
}
await getList()
}
@ -331,66 +339,26 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
detailLoading.value = true
try {
detailData.value = row
getRemarkList()
getFileList()
getChangeRecordList()
//
if (routeName.value.indexOf('Job') > -1) {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
} else {
if(!props.detailButtonIsShow){
HeadButttondata.value = [
defaultButtons.defaultAddBtn({
hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'countPlan') {
HeadButttondata.value = [
defaultButtons.defaultAddBtn({
hide: isShowMainButton(row, ['1'])
}) //
]
}
//
if (props.fromeWhere == 'putawayRequest') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'countadjustRequest') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'purchasereceipt') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'customerreceipt') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
}
setBeiJian()
let detailButtonAdd: any = []
detailButtonAdd = [
defaultButtons.defaultAddBtn({
hide: isShowMainButton(row, ['1'])
})
]
HeadButttondata.value = [...detailButtonAdd]
//
if(!props.detailButtonIsShow){
buttondata.value = [...[
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.mainListDeleteBtn({
hide: isShowMainButton(row, ['1'])
})], //
if (!props.detailButtonIsShow) {
buttondata.value = [
...[
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.mainListDeleteBtn({
hide: isShowMainButton(row, ['1'])
})
], //
...props.buttondataTable
]
}
@ -399,9 +367,23 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
}
}
}
defineExpose({ openDetail }) // open
//
const setBeiJian = () => {
let isItemNUmbersTrue = false
isItemNUmbersTrue = detailAllSchemasRef.value.tableColumns.some(
(item) => item.field == 'itemNumbers1'
)
if (!isItemNUmbersTrue) return
tableObjectRef.value.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)
}
})
}
const tableObjectRef = ref()
const tableMethodsRef = ref()
const detailAllSchemasRef = ref()
@ -416,11 +398,7 @@ detailAllSchemasRef.value = props.detailAllSchemas
//
const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
return false
}
//
@ -463,33 +441,36 @@ const buttonTableClick = async (val, row) => {
//
handleDelete(row.id)
} else {
emit('tableFormButton',val, row)
emit('tableFormButton', val, row)
}
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = async (type: string, row?: number) => {
if (row) {
if (detailAllSchemasRef.value?.tableColumns?.length > 0) {
let isTrue = false
let isItemNUmbersTrue = false
isTrue = detailAllSchemasRef.value.tableColumns.some((item) => item.field == 'maintenances')
isItemNUmbersTrue = detailAllSchemasRef.value.tableColumns.some(
(item) => item.field == 'itemNumbers'
)
if (isTrue) {
if (row.maintenances && isString(row.maintenances)) {
row.maintenances = row.maintenances.split(',').map(Number)
}
}
}
}
formRef.value.open(type, row, masterParmas.value)
}
// form
const submitForm = async (formType, data) => {
try {
// detailValidate
const rs = (await props.detailValidate) ? props.detailValidate(data) : true
if (!rs) return
if (formType === 'create') {
await props.apiCreate(data)
message.success(t('common.createSuccess'))
} else {
await props.apiUpdate(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
await getList()
updateKey.value += 1
emit('detailSubmitForm', formType, data, getList, formRef.value)
} finally {
formRef.value.formLoading = false
// formRef.value.formLoading = false
}
}
@ -504,7 +485,8 @@ const emit = defineEmits([
'selectChangeDetail',
'detailOpenForm',
'tableFormButton',
'openImage'
'openImage',
'detailSubmitForm'
])
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
@ -517,6 +499,7 @@ const handleDelete = async (id: number) => {
//
await getList()
updateKey.value += 1
setBeiJian()
} catch {}
}
//
@ -528,7 +511,7 @@ const searchFormClick = async (searchData) => {
isSearch: true,
filters: searchData.filters
? searchData.filters
: [{ column: 'masterId', action: '==', value: masterParmas.value.masterId }]
: [{ column: 'number', action: '==', value: masterParmas.value.maintenanceNumber }]
}
detailAllSchemasRef.value = props.detailAllSchemas
tableObjectRef.value = tableObject
@ -550,9 +533,11 @@ const selectChangeDetail = (field, val) => {
emit('selectChangeDetail', field, val)
}
//
const openImage=(item)=>{
const openImage = (item) => {
emit('openImage', item)
}
defineExpose({ openDetail, tableObject }) // open
//
watch(
() => props.apiPage,
@ -560,10 +545,10 @@ watch(
const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage //
})
tableObject.params.masterId = masterParmas.value.masterId
tableObject.params.maintenanceNumber = masterParmas.value.maintenanceNumber
detailAllSchemasRef.value = props.detailAllSchemas
if (props.tableObjectExtend) {
props.tableObjectExtend.forEach(item => {
props.tableObjectExtend.forEach((item) => {
tableObject.params[item.key] = item.value
})
}

557
src/components/Detail/src/DetailDeviceLedger.vue

@ -0,0 +1,557 @@
<template>
<div>
<el-drawer
v-model="isShowDrawer"
title="详情"
direction="rtl"
size="80%"
v-loading="detailLoading"
>
<template #header>
<div class="font-size-18px">
{{ titleValueRef }} <span class="ml-20px font-size-16px">{{ titleNameRef }}</span>
</div>
</template>
<ContentWrap>
<Descriptions
:data="detailData"
labelClassName="label-class-name"
label-align="left"
direction="vertical"
:column="8"
:schema="allSchemas.detailSchema"
:columns="2"
width="200px"
/>
</ContentWrap>
<Tabs :tabsList="tabsList" :current="current" @change="change" />
<div class="flex">
<!-- 详情 -->
<ContentWrap class="w-[100%]">
<!-- 列表头部 -->
<TableHead
v-if="!isBasic"
:HeadButttondata="HeadButttondata"
:number="masterParmas.number"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@searchFormClick="searchFormClick"
:allSchemas="detailAllSchemas"
/>
<!-- 默认单表展现 -->
<Descriptions
v-if="isBasic && !tabsExtend"
:data="detailData"
:schema="allSchemas.detailSchema"
:columns="2"
/>
<!-- 单表切换tabs 展现table -->
<Table
v-if="isBasic && tabsExtend"
:columns="detailAllSchemasRef.tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{ total: tableObjectRef.total }"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
>
<!-- <template #action="{ row }">
<ButtonBase
:Butttondata="buttondata"
@button-base-click="buttonTableClick($event, row)"
/>
</template> -->
</Table>
<Table
v-if="!isBasic && fromeWhere != 'countPlan'"
:columns="detailAllSchemasRef.tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{ total: tableObjectRef.total }"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
>
<template #photos="{ row }">
<div v-for="(item,index) in row.photos.split(',')" :key="index" style="color:#409eff ; cursor: pointer;" @click="openImage(item)">{{ item }}</div>
</template>
<template #action="{ row }">
<ButtonBase
:Butttondata="buttondata"
@button-base-click="buttonTableClick($event, row)"
/>
</template>
</Table>
<DetailTable
v-if="!isBasic && fromeWhere == 'countPlan' && isShowDrawer"
:columns="detailAllSchemasRef.tableColumns"
:data="tableObjectRef.tableList"
:allList="allList"
:countScopeType="countScopeType"
:key="updateKey"
>
<template #action="{ row }">
<ButtonBase
:Butttondata="buttondata"
@button-base-click="buttonTableClick($event, row)"
/>
</template>
</DetailTable>
</ContentWrap>
</div>
</el-drawer>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="formRef"
@success="submitForm"
:rules="detailAllSchemasRules"
:formAllSchemas="detailAllSchemas"
:isBusiness="false"
:apiUpdate="apiUpdate"
:apiCreate="apiCreate"
:fromeWhere="fromeWhere"
:isDetail="true"
@searchTableSuccess="searchTableSuccess"
:detailData="detailData"
@submitForm="submitForm"
@selectChangeDetail="selectChangeDetail"
:formTypeDetail="formTypeDetail"
:countPlanAllList="countPlanAllList"
/>
</div>
</template>
<script lang="ts" setup>
import Tabs from '@/components/Tabs/src/Tabs.vue'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import DetailTable from '@/components/DetailTable/src/DetailTable.vue'
defineOptions({ name: 'Detail' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
routeName.value = routeName.value.substring(0, routeName.value.length - 4) + 'Detail'
const updateKey = ref(0)
const props = defineProps({
//
tabs: {
type: Object,
required: true,
default: null
},
//
isBasic: {
type: Boolean,
required: false,
default: false
},
//
allSchemas: {
type: Object,
required: true,
default: null
},
//
detailAllSchemas: {
type: Object,
required: true,
default: null
},
//
detailAllSchemasRules: {
type: Object,
required: true,
default: null
},
// API
apiCreate: {
type: Function,
required: false,
default: null
},
// API
apiUpdate: {
type: Function,
required: false,
default: null
},
// API
apiPage: {
type: Function,
required: false,
default: null
},
// API
apiDelete: {
type: Function,
required: false,
default: null
},
//
detailValidate: {
type: Function,
required: false,
default: null
},
// countPlan
fromeWhere: {
type: String,
required: false,
default: ''
},
//
allList: {
type: Object,
required: true,
default: null
},
//
countScopeType: {
type: Array,
required: false,
default: null
},
//
formTypeDetail: {
type: String,
required: false,
default: 'InputString'
},
//
countPlanAllList: {
type: Array,
required: false,
default: null
},
//
buttondataTable: {
type: Array,
required: false,
default: ()=>{
return []
}
},
// tabs table false
tabsExtend: {
type: Boolean,
required: false,
default: false
},
// tableObject
tableObjectExtend: {
type: Array,
required: false,
default: null
},
//
detailButtonIsShow:{
type: Boolean,
required: false,
default: false
}
})
const isShowDrawer = ref(false)
const detailLoading = ref(false)
const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : '')))
// Tabs
const current = ref(0)
const change = (item, index) => {
current.value = index
emit('changeTabs', item)
}
//
const masterParmas = ref({
number: '', //id
// number: '', //
// status: '' //
})
//
const HeadButttondata = ref()
// -
const buttondata = ref()
/** 打开弹窗 */
const detailData = ref()
const titleNameRef = ref()
const titleValueRef = ref()
const openDetail = async (row: any, titleName: any, titleValue: any, tableName: any) => {
titleNameRef.value = titleName
titleValueRef.value = titleValue
//
if (!props.isBasic) {
// id
masterParmas.value.number = row.number
// masterParmas.value.number = row.number
// masterParmas.value.status = row.status
tableObjectRef.value.params = {
number: row.number
}
await getList()
}
isShowDrawer.value = true
if (row) {
detailLoading.value = true
try {
detailData.value = row
//
if (routeName.value.indexOf('Job') > -1) {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
} else {
if(!props.detailButtonIsShow){
HeadButttondata.value = [
defaultButtons.defaultAddBtn({
hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'countPlan') {
HeadButttondata.value = [
defaultButtons.defaultAddBtn({
hide: isShowMainButton(row, ['1'])
}) //
]
}
//
if (props.fromeWhere == 'putawayRequest') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'countadjustRequest') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'purchasereceipt') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
//
if (props.fromeWhere == 'customerreceipt') {
HeadButttondata.value = [
defaultButtons.defaultFilterBtn(null) //
]
}
}
//
if(!props.detailButtonIsShow){
buttondata.value = [...[
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.mainListDeleteBtn({
hide: isShowMainButton(row, ['1'])
})], //
...props.buttondataTable
]
}
} finally {
detailLoading.value = false
}
}
}
defineExpose({ openDetail }) // open
const tableObjectRef = ref()
const tableMethodsRef = ref()
const detailAllSchemasRef = ref()
const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage //
})
tableObjectRef.value = tableObject
tableMethodsRef.value = tableMethods
detailAllSchemasRef.value = props.detailAllSchemas
//
const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
//
const { getList } = tableMethodsRef.value
//
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 updataTableColumns = (val) => {
// detailAllSchemas.tableColumns.value = val
// }
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') {
//
openForm('update', row)
emit('detailOpenForm', row)
} else if (val == 'delete') {
//
handleDelete(row.id)
} else {
emit('tableFormButton',val, row)
}
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = async (type: string, row?: number) => {
formRef.value.open(type, row, masterParmas.value)
}
// form
const submitForm = async (formType, data) => {
try {
// detailValidate
const rs = (await props.detailValidate) ? props.detailValidate(data) : true
if (!rs) return
if (formType === 'create') {
await props.apiCreate(data)
message.success(t('common.createSuccess'))
} else {
await props.apiUpdate(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
await getList()
updateKey.value += 1
} finally {
formRef.value.formLoading = false
}
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
emit('searchTableSuccessDetail', formField, searchField, val, formRef)
}
//
const emit = defineEmits([
'searchTableSuccessDetail',
'changeTabs',
'selectChangeDetail',
'detailOpenForm',
'tableFormButton',
'openImage'
])
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await props.apiDelete(id)
message.success(t('common.delSuccess'))
//
await getList()
updateKey.value += 1
} catch {}
}
//
const searchFormClick = async (searchData) => {
const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage //
})
tableObject.params = {
isSearch: true,
filters: searchData.filters
? searchData.filters
: [{ column: 'number', action: '==', value: masterParmas.value.number }]
}
detailAllSchemasRef.value = props.detailAllSchemas
tableObjectRef.value = tableObject
tableMethodsRef.value = tableMethods
tableObjectRef.value.tableList = []
const { getList } = tableMethods
await getList()
updateKey.value += 1
// tableObjectRef.value.params = {
// isSearch: true,
// filters: searchData.filters
// ? searchData.filters
// : [{ column: 'masterId', action: '==', value: masterParmas.value.masterId }]
// }
// getList() //
}
//
const selectChangeDetail = (field, val) => {
emit('selectChangeDetail', field, val)
}
//
const openImage=(item)=>{
emit('openImage', item)
}
//
watch(
() => props.apiPage,
() => {
const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage //
})
tableObject.params.number = masterParmas.value.number
detailAllSchemasRef.value = props.detailAllSchemas
if (props.tableObjectExtend) {
props.tableObjectExtend.forEach(item => {
tableObject.params[item.key] = item.value
})
}
tableObjectRef.value = tableObject
tableMethodsRef.value = tableMethods
const { getList } = tableMethods
getList()
}
)
</script>
<style lang="scss">
.el-drawer__body {
background: #f5f5f5 !important;
}
::v-deep(.label-class-name) {
color: #dedede;
}
</style>
<style scoped lang="scss"></style>

89
src/components/SearchTable/src/SearchTable.vue

@ -1,20 +1,31 @@
<template>
<Dialog :title="dialogTitle" v-model="searchDialogVisible" :width="'80%'">
<!-- 搜索工作栏 -->
<!-- <Search :schema="searchSchema" @search="setSearchParamsRef" @reset="setSearchParamsRef" /> -->
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
:routeName="routeName"
@searchFormClick="searchFormClick"
:allSchemas="allSchemasRef"
/>
<ContentWrap>
<Table
ref="searchTableRef"
:columns="tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{
total: tableObjectRef.total
}"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
v-model:sort="tableObjectRef.sort"
:selection="true"
:reserveSelection="true"
row-key="number"
>
<template #qty="{ row }">
<el-input v-model="row.qty" type="number" placeholder="请输入数量" />
</template>
</Table>
row-key="id"
/>
</ContentWrap>
<template #footer>
<div class="flex items-center">
@ -38,15 +49,15 @@ const searchDialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
//
const HeadButttondata = [
defaultButtons.defaultFilterBtn(null), //
]
/** 打开弹窗 */
const getListRef = ref()
const setSearchParamsRef = ref()
const tableObjectRef = ref({
tableList:'',
loading:false,
params:{}
})
const tableObjectRef = ref()
const getPage:any = ref()
const searchSchema = ref()
const tableColumns = ref()
@ -61,7 +72,6 @@ const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, s
searchDialogVisible.value = true
formFieldRef.value = formField
searchFieldRef.value = searchField
allSchemasRef.value = allSchemas
searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns.filter(item => (item.field !== 'action'))
@ -69,20 +79,53 @@ const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, s
typeRef.value = type
rowRef.value = row
multipleBol.value = multiple
// dialogTitle.value = t('action.' + type)
dialogTitle.value = titleName
const getList = async () => {
await getPage.value().then((res)=>{
tableObjectRef.value.tableList = res
const {tableObject, tableMethods } = useTable({
getListApi: getPage.value //
})
tableObjectRef.value = tableObject
searchConditionRef.value = searchCondition
if (searchCondition) tableObjectRef.value.params = searchCondition;
}
console.log(tableObjectRef.value)
//
const { getList } = tableMethods
// setSearchParamsRef.value = setSearchParams
setSearchParamsRef.value = tableObject.params
getListRef.value = getList
getList()
}
//
const searchFormClick = (searchData) => {
// console.log(99, rowRef.value)
// console.log(100, searchData)
// console.log(101, searchConditionRef.value)
// 20240104 searchData.filters
if (searchConditionRef.value) {
Object.keys(searchConditionRef.value).forEach(key => {
if (searchData.filters) {
searchData.filters.push({
action: "==",
column: key,
value: searchConditionRef.value[key]
})
// }
} else {
searchData.filters = [{
action: "==",
column: key,
value: searchConditionRef.value[key]
}]
}
});
}
tableObjectRef.value.params = {
isSearch: true,
filters: searchData.filters
}
getListRef.value() //
}
defineExpose({ open }) // open
@ -110,15 +153,9 @@ const submitForm = async () => {
return
}
}
let isQtyNone = selections.filter(item=>!item.qty)
if(isQtyNone&&isQtyNone.length>0){
message.warning('请填写数量')
formLoading.value = false
return
}
try {
searchDialogVisible.value = false
console.log(selections)
//
emit('searchTableSuccess', formFieldRef.value, searchFieldRef.value, selections, typeRef.value, rowRef.value)
} finally {

3
src/components/SearchTableItem/index.ts

@ -0,0 +1,3 @@
import SearchTableItem from './src/SearchTableItem.vue'
export { SearchTableItem }

144
src/components/SearchTableItem/src/SearchTableItem.vue

@ -0,0 +1,144 @@
<template>
<Dialog :title="dialogTitle" v-model="searchDialogVisible" :width="'80%'">
<ContentWrap>
<Table
ref="searchTableRef"
:columns="tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:selection="true"
:reserveSelection="true"
row-key="number"
>
<template #qty="{ row }">
<el-input v-model="row.qty" type="number" placeholder="请输入数量" />
</template>
</Table>
</ContentWrap>
<template #footer>
<div class="flex items-center">
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="searchDialogVisible = false"> </el-button>
</div>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as defaultButtons from '@/utils/disposition/defaultButtons'
// const { t } = useI18n() //
const message = useMessage() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const searchDialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
/** 打开弹窗 */
const getListRef = ref()
const setSearchParamsRef = ref()
const tableObjectRef = ref({
tableList: '',
loading: false,
params: {}
})
const getPage: any = ref()
const searchSchema = ref()
const tableColumns = ref()
const formFieldRef = ref()
const searchFieldRef = ref()
const typeRef = ref()
const rowRef = ref()
const allSchemasRef = ref()
const multipleBol = ref(false)
const searchConditionRef = ref()
const open = (
titleName: any,
allSchemas: any,
getApiPage: any,
formField: any,
searchField: any,
multiple: any,
type: any,
row: any,
searchCondition: any,
isCountRequestRe: any
) => {
searchDialogVisible.value = true
formFieldRef.value = formField
searchFieldRef.value = searchField
allSchemasRef.value = allSchemas
searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns.filter((item) => item.field !== 'action')
getPage.value = getApiPage
typeRef.value = type
rowRef.value = row
multipleBol.value = multiple
dialogTitle.value = titleName
const getList = async () => {
await getPage.value(searchCondition).then((res) => {
tableObjectRef.value.tableList = res
})
}
console.log(tableObjectRef.value)
getList()
}
defineExpose({ open }) // open
// Table ref
const searchTableRef = ref()
/** 提交表单 */
const emit = defineEmits(['searchTableSuccess']) // searchTableSuccess
const submitForm = async () => {
//
formLoading.value = true
const selections = searchTableRef.value.selections
//
if (!multipleBol.value) {
if (selections.length > 1 || selections.length == 0) {
message.warning('请选择一条数据!')
formLoading.value = false
return
}
//
} else {
if (selections.length == 0) {
message.warning('至少选择一条数据!')
formLoading.value = false
return
}
}
let isQtyNone = selections.filter((item) => !item.qty)
if (isQtyNone && isQtyNone.length > 0) {
message.warning('请填写数量')
formLoading.value = false
return
}
try {
searchDialogVisible.value = false
console.log(selections)
//
emit(
'searchTableSuccess',
formFieldRef.value,
searchFieldRef.value,
selections,
typeRef.value,
rowRef.value
)
} finally {
formLoading.value = false
}
}
</script>
<style scoped lang="scss">
</style>

4
src/utils/disposition/tabsList.ts

@ -1,5 +1,5 @@
// 页面tabs标签
export const ItemBasicTabsList = [{
// 设备台账tabs标签
export const DeviceLedgerTabsList = [{
label: "设备信息",
prop: 'info',
},

16
src/views/eam/device/deviceAccounts/index.vue

@ -49,6 +49,7 @@
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<SearchTable
ref="searchTableRef"
@ -57,12 +58,11 @@
/>
<!-- 详情 -->
<!-- <Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceAccounts.allSchemas" /> -->
<Detail
<DetailDeviceLedger
ref="detailRef"
:tabs="ItemBasicTabsList"
:tabs="DeviceLedgerTabsList"
:isBasic="true"
:allSchemas="DeviceAccounts.allSchemas"
:allSchemas="allSchemas"
@changeTabs="changeTabs"
:detailAllSchemas="detailAllSchemas"
:apiPage="apiPage"
@ -81,10 +81,10 @@ import { Item } from '@/views/eam/basic/item/item.data'
import { createDeviceItemBatch,getDeviceItemPage } from '@/api/eam/basic/rel'
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { ItemBasicTabsList } from '@/utils/disposition/tabsList'
import { DeviceLedgerTabsList } from '@/utils/disposition/tabsList'
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 DetailDeviceLedger from '@/components/Detail/src/DetailDeviceLedger.vue'
import * as ItemApi from '@/api/eam/basic/item'
defineOptions({ name: 'DeviceAccounts' })
@ -98,6 +98,10 @@ const deviceNumber = ref();
routeName.value = route.name
const tableColumns = ref(DeviceAccounts.allSchemas.tableColumns)
const allSchemas = ref(Item.allSchemas)
const detailAllSchemas = ref()
const apiPage = ref()
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {

94
src/views/eam/device/deviceMaintenanceMain/deviceMaintenanceMain.data.ts

@ -40,10 +40,13 @@ export const DeviceMaintenanceMain = useCrudSchemas(reactive<CrudSchema[]>([
table: {
width: '150',
},
isForm: false,
isSearch: true,
isTable: true,
},
{
label: '设备',
label: '设备模具编号',
field: 'deviceNumber',
sort: 'custom',
table: {
@ -202,55 +205,32 @@ export const DeviceMaintenanceDetail = useCrudSchemas(reactive<CrudSchema[]>([
field: 'describes',
sort: 'custom',
table: {
width: '150',
},
isForm: false,
isSearch: false,
isTable: false,
},
{
label: '故障真因',
field: 'describes1',
sort: 'custom',
table: {
width: '150',
},
isForm: false,
isSearch: false,
isTable: false,
},
{
label: '解决措施',
field: 'workOut',
sort: 'custom',
table: {
width: '150',
},
isForm: false,
isSearch: false,
isTable: false,
},
{
label: '维修人',
field: 'maintenances',
sort: 'custom',
table: {
width: '150',
},
api: () => userList,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return userList.find((account) => account.id == cellValue)?.name
},
search: {
show: true,
component: 'Select',
api: () => userList,
componentProps: {
optionsAlias: {
labelField: 'name',
valueField: 'id'
}
}
formatter: (_: Recordable, __: TableColumn, cellValue) => {
return userList.filter(item=>cellValue.includes(item.id)).map(cur=>cur.name).join(',')
},
tableForm: {
type: 'Select',
@ -262,19 +242,31 @@ export const DeviceMaintenanceDetail = useCrudSchemas(reactive<CrudSchema[]>([
labelField: 'name',
valueField: 'id'
}
},
form:{
component: 'Select',
api: () => userList,
componentProps: {
multiple:true,
collapseTags:true,
collapseTagsTooltip:true,
optionsAlias: {
labelField: 'name',
valueField: 'id'
}
}
}
},
{
label: '备件',
field: 'itemNUmbers',
field: 'itemNumbers1',
sort: 'custom',
table: {
width: '150',
},
tableForm:{
isInpuFocusShow: true, // 开启查询弹窗
searchListPlaceholder: '请选择备件',
searchField: 'itemNUmbers',
searchField: 'itemNumbers1',
searchTitle: '备件',
multiple:true,
searchAllSchemas: ItemSearchTable.allSchemas,
@ -286,10 +278,48 @@ export const DeviceMaintenanceDetail = useCrudSchemas(reactive<CrudSchema[]>([
isMainValue: true
}]
},
isForm: false,
form: {
// labelMessage: '信息提示说明!!!',
componentProps: {
isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择备件', // 输入框占位文本
searchField: 'itemNumbers1', // 查询弹窗赋值字段
searchTitle: '备件', // 查询弹窗标题
multiple:true,
searchAllSchemas: ItemSearchTable.allSchemas, // 查询弹窗所需类
searchPage: ItemApi.getItemList, // 查询弹窗所需分页方法
searchCondition: [{
key: 'deviceNumber',
value: 'deviceNumber',
message: '请选择设备模具编号!',
isMainValue: true
}]
}
},
isSearch: false,
isTable: false,
},
{
label: '备件1',
field: 'itemNumbers',
sort: 'custom',
table: {
},
isForm:false,
isDetail:false,
isTable:false,
isSearch: false,
isTableForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 300,
fixed: 'right'
},
isDetail:false
}
]))
// 表单校验
export const DeviceMaintenanceDetailRules = reactive({
@ -297,5 +327,5 @@ export const DeviceMaintenanceDetailRules = reactive({
describes1: [required],
workOut: [required],
maintenance: [required],
itemNUmbers: [required],
itemNumbers: [required],
})

85
src/views/eam/device/deviceMaintenanceMain/index.vue

@ -61,24 +61,27 @@
@handleDeleteTable="handleDeleteTable"
@searchTableSuccess="searchTableSuccess"
@submitForm="submitForm"
:isSearchTableItem="true"
/>
<!-- 详情 -->
<!-- <Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceMaintenanceMain.allSchemas" /> -->
<Detail
ref="detailRef"
:isBasic="true"
:isBasic="false"
:allSchemas="DeviceMaintenanceMain.allSchemas"
:detailAllSchemas="DeviceMaintenanceDetail.allSchemas"
:detailAllSchemasRules="DeviceMaintenanceDetailRules"
:apiCreate="DeviceMaintenanceDetailApi.createPurchasereturnRequestDetail"
:apiUpdate="DeviceMaintenanceDetailApi.updatePurchasereturnRequestDetail"
:apiPage="DeviceMaintenanceDetailApi.getPurchasereturnRequestDetailPage"
:apiDelete="DeviceMaintenanceDetailApi.deletePurchasereturnRequestDetail"
:apiCreate="DeviceMaintenanceDetailApi.createDeviceMaintenanceDetail"
:apiUpdate="DeviceMaintenanceDetailApi.updateDeviceMaintenanceDetail"
:apiPage="DeviceMaintenanceDetailApi.getDeviceMaintenanceDetailPage"
:apiDelete="DeviceMaintenanceDetailApi.deleteDeviceMaintenanceDetail"
:Echo="Echo"
@searchTableSuccessDetail="searchTableSuccessDetail"
@detailOpenForm="detailOpenForm"
:detailValidate="detailValidate"
@detailSubmitForm="detailSubmitForm"
:isSearchTableItem="true"
/>
<!-- 导入 -->
@ -120,20 +123,19 @@ const tableData = ref([])
const updataTableColumns = (val) => {
tableColumns.value = val
}
const itemNUmbers = ref()
//
const searchTableSuccess = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
if (type == 'tableForm') {
//
if (formField == 'itemNUmbers') {
if (formField == 'itemNumbers') {
let str = ''
val.forEach((element) => {
str += element.name + ':' + element.qty + ','
})
str = str.substring(0, str.length - 1)
row['itemNUmbers'] = str
row['itemNUmbers1'] = val
row['itemNumbers1'] = str
row['itemNumbers'] = val
}
} else {
// const setV = {}
@ -149,12 +151,15 @@ const searchTableSuccessDetail = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
if (formField == 'itemCode') {
setV['itemCode'] = val[0]['code']
} else {
setV['poNumber'] = val[0]['number']
setV['poLine'] = val[0]['lineNumber']
}
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)
})
}
@ -186,6 +191,7 @@ const buttonBaseClick = (val, item) => {
if (val == 'add') {
//
DeviceMaintenanceMain.allSchemas.formSchema[3].value = 'DEVICE'
DeviceMaintenanceMain.allSchemas.formSchema[0].componentProps.disabled = false
openForm('create')
} else if (val == 'import') {
//
@ -242,10 +248,11 @@ const onChange = (field, cur, item) => {
if (field == 'deviceNumber') {
// DeviceMaintenanceMain.allSchemas.formSchema[1].componentProps.disabled = true
// DeviceMaintenanceMain.allSchemas.formSchema[2].componentProps.disabled = true
formRef.value.formRef.formModel.factoryAreaNumber = Number(
item.componentProps.options.find((item) => item.number == cur).factoryAreaNumber
)
formRef.value.formRef.formModel.maintenance = String(userStore?.getUser?.id)
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)
}
}
// -
@ -369,7 +376,7 @@ const submitForm = async (formType, data) => {
return {
describes: item.describes,
describes1: item.describes1,
itemNUmbers: item.itemNUmbers1,
itemNumbers: item.itemNumbers1,
maintenances: item.maintenances.join(','),
workOut: item.workOut,
}
@ -417,6 +424,7 @@ const detailOpenForm = (type, row) =>{
}
// /
const detailValidate = (data) => {
return true;
let tag = false;
if(data.qty <= 0){
message.warning('数量必须大于0')
@ -427,6 +435,43 @@ const detailValidate = (data) => {
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 DeviceMaintenanceDetailApi.createDeviceMaintenanceDetail(data1)
message.success(t('common.createSuccess'))
} else {
await DeviceMaintenanceDetailApi.updateDeviceMaintenanceDetail(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 () => {

Loading…
Cancel
Save