Merge remote-tracking branch 'remotes/origin/test'

main
黄伟杰 3 weeks ago
commit e1886d0ebb

@ -1,149 +1,154 @@
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1200px" @closed="handleDialogClosed"> <div class="dv-repair-panel">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" v-loading="formLoading"> <div class="dv-repair-panel__header">
<el-row> <div class="dv-repair-panel__title">{{ dialogTitle }}</div>
<el-col :span="8"> <el-button text @click="closeForm">
<el-form-item :label="t('MoldManagement.MoldRepair.repairCode')" prop="repairCode"> <Icon icon="ep:close" />
<template #label> </el-button>
<span> </div>
{{ t('MoldManagement.MoldRepair.repairCode') }} <div class="dv-repair-dialog" v-loading="formLoading">
<el-tooltip :content="t('MoldManagement.MoldRepair.repairCode')" placement="top"> <el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px">
<Icon icon="ep:question-filled" /> <section class="dv-repair-section">
</el-tooltip> <div class="dv-repair-section__title">基本信息</div>
</span> <el-row :gutter="20">
</template> <el-col :span="8">
<el-row :gutter="10" style="width: 100%;"> <el-form-item :label="t('MoldManagement.MoldRepair.repairCode')" prop="repairCode">
<el-col :xs="24" :sm="18" :md="16" :lg="14" :xl="12"> <template #label>
<el-input <span>
:disabled="formData.isCode == true || formType === 'update'" {{ t('MoldManagement.MoldRepair.repairCode') }}
v-model="formData.repairCode" <el-tooltip :content="t('MoldManagement.MoldRepair.repairCode')" placement="top">
:placeholder="t('common.code')" <Icon icon="ep:question-filled" />
/> </el-tooltip>
</el-col> </span>
<el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="2"> </template>
<div> <div class="dv-repair-code-row">
<el-switch <el-input
v-model="formData.isCode" :disabled="formData.isCode == true || formType === 'update'"
:disabled="formType === 'update'" v-model="formData.repairCode"
/> :placeholder="t('common.code')"
</div> />
</el-col> <el-switch
</el-row> v-model="formData.isCode"
</el-form-item> :disabled="formType === 'update'"
</el-col> />
<el-col :span="8"> </div>
<el-form-item :label="t('MoldManagement.MoldRepair.repairName')" prop="repairName"> </el-form-item>
<el-input </el-col>
v-model="formData.repairName" <el-col :span="8">
:placeholder="t('MoldManagement.MoldRepair.placeholderRepairName')" <el-form-item :label="t('MoldManagement.MoldRepair.repairName')" prop="repairName">
:disabled="isRepairMode" <el-input
/> v-model="formData.repairName"
</el-form-item> :placeholder="t('MoldManagement.MoldRepair.placeholderRepairName')"
</el-col> :disabled="isRepairMode"
</el-row> />
<el-row> </el-form-item>
<el-col :span="8"> </el-col>
<el-form-item :label="t('MoldManagement.MoldRepair.mold')" prop="moldId"> <el-col :span="8">
<el-select <el-form-item :label="t('MoldManagement.MoldRepair.mold')" prop="moldId">
v-model="formData.moldId" filterable clearable :loading="moldLoading" <el-select
:disabled="isRepairMode" v-model="formData.moldId" filterable clearable :loading="moldLoading"
:placeholder="t('MoldManagement.MoldRepair.placeholderMold')" :disabled="isRepairMode"
class="!w-full" :placeholder="t('MoldManagement.MoldRepair.placeholderMold')"
> class="!w-full"
<el-option v-for="opt in moldOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" /> >
</el-select> <el-option v-for="opt in moldOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
</el-form-item> </el-select>
</el-col> </el-form-item>
<el-col :span="8"> </el-col>
<el-form-item :label="t('MoldManagement.MoldRepair.moldName')" prop="moldName" :required="false"> </el-row>
<el-input v-model="formData.moldName" :placeholder="t('MoldManagement.MoldRepair.placeholderMoldNameAuto')" disabled /> <el-row :gutter="20">
</el-form-item> <el-col :span="8">
</el-col> <el-form-item :label="t('MoldManagement.MoldRepair.moldName')" prop="moldName" :required="false">
<el-col :span="8"> <el-input v-model="formData.moldName" :placeholder="t('MoldManagement.MoldRepair.placeholderMoldNameAuto')" disabled />
<el-form-item :label="t('MoldManagement.MoldRepair.moldCode')" prop="moldCode" :required="false"> </el-form-item>
<el-input v-model="formData.moldCode" :placeholder="t('MoldManagement.MoldRepair.placeholderMoldCodeAuto')" disabled /> </el-col>
</el-form-item> <el-col :span="8">
</el-col> <el-form-item :label="t('MoldManagement.MoldRepair.moldCode')" prop="moldCode" :required="false">
<!-- <el-col :span="8"> <el-input v-model="formData.moldCode" :placeholder="t('MoldManagement.MoldRepair.placeholderMoldCodeAuto')" disabled />
<el-form-item label="规格型号" prop="machinerySpec" :required="false"> </el-form-item>
<el-input v-model="formData.machinerySpec" placeholder="自动带出" disabled /> </el-col>
</el-form-item> </el-row>
<el-form-item label="品牌" prop="machineryBrand" :required="false"> <el-row :gutter="20">
<el-input v-model="formData.machineryBrand" placeholder="自动带出" disabled /> <el-col :span="8">
</el-form-item> <el-form-item :label="t('MoldManagement.MoldRepair.repairUser')" prop="acceptedBy">
</el-col> --> <el-select
</el-row> v-model="formData.acceptedBy" filterable clearable
<el-row> :placeholder="t('MoldManagement.MoldRepair.placeholderAcceptUser')"
<el-col :span="8"> class="!w-full"
<el-form-item :label="t('MoldManagement.MoldRepair.repairUser')" prop="acceptedBy"> :disabled="isRepairMode">
<el-select <el-option v-for="item in users" :key="String(item.id)" :label="item.nickname" :value="String(item.id)" />
v-model="formData.acceptedBy" filterable clearable </el-select>
:placeholder="t('MoldManagement.MoldRepair.placeholderAcceptUser')" </el-form-item>
class="!w-full" </el-col>
:disabled="isRepairMode"> <el-col :span="8">
<el-option v-for="item in users" :key="String(item.id)" :label="item.nickname" :value="String(item.id)" /> <el-form-item :label="t('MoldManagement.MoldRepair.confirmUser')" prop="confirmBy">
</el-select> <el-select
</el-form-item> v-model="formData.confirmBy" filterable clearable
</el-col> :placeholder="t('MoldManagement.MoldRepair.placeholderConfirmUser')"
<el-col :span="8"> class="!w-full"
<el-form-item :label="t('MoldManagement.MoldRepair.confirmUser')" prop="confirmBy"> :disabled="isRepairMode">
<el-select <el-option v-for="item in users" :key="String(item.id)" :label="item.nickname" :value="String(item.id)" />
v-model="formData.confirmBy" filterable clearable </el-select>
:placeholder="t('MoldManagement.MoldRepair.placeholderConfirmUser')" </el-form-item>
class="!w-full" </el-col>
:disabled="isRepairMode"> </el-row>
<el-option v-for="item in users" :key="String(item.id)" :label="item.nickname" :value="String(item.id)" /> </section>
</el-select>
</el-form-item> <section v-if="showRepairFields" class="dv-repair-section">
</el-col> <div class="dv-repair-section__title">处理结果</div>
</el-row> <el-row :gutter="20">
<el-col :span="8">
<template v-if="showRepairFields"> <el-form-item :label="t('MoldManagement.MoldRepair.requireDate')" prop="requireDate">
<el-row> <el-date-picker
<el-col :span="8"> v-model="formData.requireDate" type="date" value-format="x"
<el-form-item :label="t('MoldManagement.MoldRepair.requireDate')" prop="requireDate"> :placeholder="t('MoldManagement.MoldRepair.placeholderRequireDate')"
<el-date-picker class="!w-full" :disabled="repairFieldsDisabled"
v-model="formData.requireDate" type="date" value-format="x" />
:placeholder="t('MoldManagement.MoldRepair.placeholderRequireDate')" </el-form-item>
class="!w-full" :disabled="repairFieldsDisabled" </el-col>
/> <el-col :span="8">
</el-form-item> <el-form-item :label="t('MoldManagement.MoldRepair.finishDate')" prop="finishDate">
</el-col> <el-date-picker
<el-col :span="8"> v-model="formData.finishDate" type="date" value-format="x"
<el-form-item :label="t('MoldManagement.MoldRepair.finishDate')" prop="finishDate"> :placeholder="t('MoldManagement.MoldRepair.placeholderFinishDate')"
<el-date-picker class="!w-full" :disabled="repairFieldsDisabled"
v-model="formData.finishDate" type="date" value-format="x" />
:placeholder="t('MoldManagement.MoldRepair.placeholderFinishDate')" </el-form-item>
class="!w-full" :disabled="repairFieldsDisabled" </el-col>
/> <el-col :span="8">
</el-form-item> <el-form-item :label="t('MoldManagement.MoldRepair.confirmDate')" prop="confirmDate">
</el-col> <el-date-picker
<el-col :span="8"> v-model="formData.confirmDate" type="date" value-format="x"
<el-form-item :label="t('MoldManagement.MoldRepair.confirmDate')" prop="confirmDate"> :placeholder="t('MoldManagement.MoldRepair.placeholderConfirmDate')"
<el-date-picker class="!w-full" :disabled="repairFieldsDisabled"
v-model="formData.confirmDate" type="date" value-format="x" />
:placeholder="t('MoldManagement.MoldRepair.placeholderConfirmDate')" </el-form-item>
class="!w-full" :disabled="repairFieldsDisabled" </el-col>
/> </el-row>
</el-form-item> <el-row :gutter="20">
</el-col> <el-col :span="24">
</el-row> <el-form-item :label="t('MoldManagement.MoldRepair.repairResult')" prop="repairResult">
<el-form-item :label="t('MoldManagement.MoldRepair.repairResult')" prop="repairResult"> <Editor v-model="formData.repairResult" height="150px" :readonly="repairFieldsDisabled" />
<Editor v-model="formData.repairResult" height="150px" :readonly="repairFieldsDisabled" /> </el-form-item>
</el-form-item> </el-col>
</template> </el-row>
</el-form> </section>
<el-tabs v-model="subTabsName"> </el-form>
<el-tab-pane :label="t('MoldManagement.MoldRepair.tabMoldRepairLine')" name="moldRepairLine">
<MoldRepairLineForm ref="moldRepairLineFormRef" :repair-id="formData.id" :line-mode="lineMode" /> <el-tabs v-model="subTabsName" style="margin-top: 16px;">
</el-tab-pane> <el-tab-pane :label="t('MoldManagement.MoldRepair.tabMoldRepairLine')" name="moldRepairLine">
</el-tabs> <MoldRepairLineForm ref="moldRepairLineFormRef" :repair-id="formData.id" :line-mode="lineMode" />
<template #footer> </el-tab-pane>
</el-tabs>
</div>
<div class="dv-repair-footer">
<el-button @click="closeForm">{{ t('common.cancel') }}</el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button> </div>
</template> </div>
</Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { MoldRepairApi, MoldRepairVO } from '@/api/mold/moldrepair' import { MoldRepairApi, MoldRepairVO } from '@/api/mold/moldrepair'
import { MoldRepairItemsApi } from '@/api/mold/moldRepairItems' import { MoldRepairItemsApi } from '@/api/mold/moldRepairItems'
@ -156,7 +161,6 @@ defineOptions({ name: 'MoldRepairForm' })
const { t } = useI18n() const { t } = useI18n()
const message = useMessage() const message = useMessage()
const dialogVisible = ref(false)
const dialogTitle = ref('') const dialogTitle = ref('')
const formLoading = ref(false) const formLoading = ref(false)
const formType = ref('') const formType = ref('')
@ -164,6 +168,7 @@ const isRepairMode = computed(() => formType.value === 'update' || formType.valu
const showRepairFields = computed(() => formType.value === 'update' || formType.value === 'repair') const showRepairFields = computed(() => formType.value === 'update' || formType.value === 'repair')
const repairFieldsDisabled = computed(() => formType.value !== 'repair') const repairFieldsDisabled = computed(() => formType.value !== 'repair')
const isHydrating = ref(false) const isHydrating = ref(false)
const openRequestId = ref(0)
const emit = defineEmits(['success', 'closed']) const emit = defineEmits(['success', 'closed'])
const formData = ref({ const formData = ref({
id: undefined, id: undefined,
@ -397,29 +402,21 @@ const prefillLinesByMold = async (moldId: number | undefined) => {
setLineRows(list.map(toMoldRepairLineRow)) setLineRows(list.map(toMoldRepairLineRow))
} }
let openRequestId = 0
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
const currentOpenId = ++openRequestId const currentOpenId = ++openRequestId.value
dialogVisible.value = true dialogTitle.value = type === 'repair' ? '维修处理结果' : t('action.' + type)
dialogTitle.value =
type === 'repair'
? t('MoldManagement.MoldRepair.dialogTitleRepair')
: type === 'create'
? t('MoldManagement.MoldRepair.dialogTitleCreate')
: t('MoldManagement.MoldRepair.dialogTitleUpdate')
formType.value = type formType.value = type
resetForm() resetForm()
await ensureUsersLoaded() await ensureUsersLoaded()
await ensureMoldOptionsLoaded() await ensureMoldOptionsLoaded()
if (currentOpenId !== openRequestId) return if (currentOpenId !== openRequestId.value) return
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
isHydrating.value = true isHydrating.value = true
formData.value = await MoldRepairApi.getMoldRepair(id) formData.value = await MoldRepairApi.getMoldRepair(id)
if (currentOpenId !== openRequestId) return if (currentOpenId !== openRequestId.value) return
;(formData.value as any).requireDate = (formData.value as any).requireDate ?? undefined ;(formData.value as any).requireDate = (formData.value as any).requireDate ?? undefined
;(formData.value as any).finishDate = (formData.value as any).finishDate ?? undefined ;(formData.value as any).finishDate = (formData.value as any).finishDate ?? undefined
@ -456,66 +453,25 @@ const open = async (type: string, id?: number) => {
} }
defineExpose({ open }) defineExpose({ open })
const handleDialogClosed = () => { const closeForm = () => {
openRequestId++ openRequestId.value++
emit('closed') emit('closed')
} }
onBeforeUnmount(() => {
openRequestId++
})
const submitForm = async () => { const submitForm = async () => {
await formRef.value.validate() await formRef.value.validate()
try {
await moldRepairLineFormRef.value.validate()
} catch {
subTabsName.value = 'moldRepairLine'
return
}
formLoading.value = true formLoading.value = true
try { try {
const data = { ...(formData.value as any) } as MoldRepairVO & { moldId?: number; componentId?: number } const data = { ...formData.value }
;(data as any).acceptedBy = normalizeUserId((data as any).acceptedBy) if (formType.value === 'create') {
;(data as any).confirmBy = normalizeUserId((data as any).confirmBy) await MoldRepairApi.createMoldRepair(data)
;(data as any).moldCode = (data as any).moldCode ?? (data as any).machineryCode message.success(t('common.createSuccess'))
;(data as any).moldName = (data as any).moldName ?? (data as any).machineryName
delete (data as any).machineryId
delete (data as any).machineryCode
delete (data as any).machineryName
if (formType.value === 'repair') {
;(data as any).status = 1
}
;(data as any).moldId = formData.value.moldId
const lineList = moldRepairLineFormRef.value.getData() || []
if (formType.value === 'repair') {
const requireDate = (data as any).requireDate
const finishDate = (data as any).finishDate
const confirmDate = (data as any).confirmDate
const repairResult = (data as any).repairResult
const updateReqVOList = lineList
await MoldRepairApi.updateMoldRepairStatus({
id: (data as any).id,
requireDate,
finishDate,
confirmDate,
repairResult,
updateReqVOList,
})
message.success(t('common.updateSuccess'))
} else { } else {
;(data as any).moldRepairLines = lineList await MoldRepairApi.updateMoldRepair(data)
if (formType.value === 'create') { message.success(t('common.updateSuccess'))
await MoldRepairApi.createMoldRepair(data)
message.success(t('common.createSuccess'))
} else {
await MoldRepairApi.updateMoldRepair(data)
message.success(t('common.updateSuccess'))
}
} }
dialogVisible.value = false await moldRepairLineFormRef.value?.submit()
closeForm()
emit('success') emit('success')
} finally { } finally {
formLoading.value = false formLoading.value = false
@ -546,3 +502,85 @@ const resetForm = () => {
formRef.value?.resetFields() formRef.value?.resetFields()
} }
</script> </script>
<style lang="scss" scoped>
.dv-repair-panel {
background: #fff;
border-radius: 12px;
box-shadow: var(--el-box-shadow-light);
}
.dv-repair-panel__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid #ebeef5;
}
.dv-repair-panel__title {
color: #1f2937;
font-size: 18px;
font-weight: 600;
}
.dv-repair-dialog {
max-height: calc(100vh - 220px);
padding: 20px 20px 0;
padding-right: 16px;
overflow-y: auto;
}
.dv-repair-section {
margin-bottom: 20px;
padding: 16px;
background: #f8f9fa;
border-radius: 8px;
}
.dv-repair-section__title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 16px;
padding-left: 8px;
border-left: 3px solid #409eff;
}
.dv-repair-code-row {
display: flex;
gap: 10px;
align-items: center;
}
.dv-repair-footer {
display: flex;
justify-content: flex-end;
gap: 12px;
width: 100%;
padding: 16px 20px 20px;
border-top: 1px solid #ebeef5;
}
@media (max-width: 1200px) {
.dv-repair-section .el-col {
flex: 0 0 100%;
}
}
@media (max-width: 768px) {
.dv-repair-panel__header {
padding: 14px 16px;
}
.dv-repair-dialog {
max-height: none;
padding: 16px 16px 0;
overflow-y: visible;
}
.dv-repair-footer {
padding: 16px;
}
}
</style>

@ -1,5 +1,6 @@
<template> <template>
<ContentWrap> <ContentWrap v-if="!formVisible">
<!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" min-label-width="68px"> <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" min-label-width="68px">
<el-form-item :label="t('MoldManagement.MoldRepair.repairCode')" prop="repairCode"> <el-form-item :label="t('MoldManagement.MoldRepair.repairCode')" prop="repairCode">
<el-input <el-input
@ -106,7 +107,8 @@
</el-form> </el-form>
</ContentWrap> </ContentWrap>
<ContentWrap> <ContentWrap v-if="!formVisible">
<!-- 列表 -->
<el-table <el-table
ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id" ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
@ -179,17 +181,19 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 -->
<Pagination <Pagination
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize" :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
@pagination="getList" /> @pagination="getList" />
</ContentWrap> </ContentWrap>
<MoldRepairForm v-if="formVisible" ref="formRef" @success="getList" @closed="formVisible = false" /> <div v-if="formVisible">
<MoldRepairForm ref="formRef" @success="handleFormSuccess" @closed="formVisible = false" />
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict' import { dateFormatter } from '@/utils/formatTime'
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { MoldRepairApi, MoldRepairVO } from '@/api/mold/moldrepair' import { MoldRepairApi, MoldRepairVO } from '@/api/mold/moldrepair'
import MoldRepairForm from './MoldRepairForm.vue' import MoldRepairForm from './MoldRepairForm.vue'
@ -302,8 +306,8 @@ const resetQuery = () => {
handleQuery() handleQuery()
} }
const formRef = ref()
const formVisible = ref(false) const formVisible = ref(false)
const formRef = ref()
const openForm = async (type: string, id?: number) => { const openForm = async (type: string, id?: number) => {
formVisible.value = true formVisible.value = true
@ -311,6 +315,11 @@ const openForm = async (type: string, id?: number) => {
formRef.value?.open(type, id) formRef.value?.open(type, id)
} }
const handleFormSuccess = () => {
formVisible.value = false
getList()
}
const buildIdsParam = (ids: number | number[]) => { const buildIdsParam = (ids: number | number[]) => {
return Array.isArray(ids) ? ids.join(',') : String(ids) return Array.isArray(ids) ? ids.join(',') : String(ids)
} }

Loading…
Cancel
Save