|
|
@ -52,7 +52,32 @@ |
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceMoldItems.allSchemas" /> |
|
|
|
|
|
|
|
<Dialog |
|
|
|
ref="updateDialog" |
|
|
|
title="本次修改修改描述" |
|
|
|
v-model="dialogVisible" |
|
|
|
:width="600" |
|
|
|
:maxHeight="700" |
|
|
|
:style="{height:'450px'}" |
|
|
|
:before-close="handleBeforeClose" |
|
|
|
> |
|
|
|
<el-form :model="updateFormValue" class="demo-form-inline"> |
|
|
|
<el-form-item label="备注"> |
|
|
|
<el-input |
|
|
|
type="textarea" |
|
|
|
v-model="updateFormValue.remark" |
|
|
|
placeholder="请对本次修改内容添加备注" |
|
|
|
clearable |
|
|
|
:rows="12" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<template #footer> |
|
|
|
<div style="text-align: center;"> |
|
|
|
<el-button type="primary" @click="onSubmit">提交</el-button> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</Dialog> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
@ -72,7 +97,15 @@ const route = useRoute() // 路由信息 |
|
|
|
const routeName = ref() |
|
|
|
routeName.value = route.name |
|
|
|
const tableColumns = ref(DeviceMoldItems.allSchemas.tableColumns) |
|
|
|
|
|
|
|
const updateDialog = ref() |
|
|
|
const dialogVisible = ref(false) |
|
|
|
const updateData = ref() |
|
|
|
const updateFormValue = reactive({ |
|
|
|
remark: '', |
|
|
|
}) |
|
|
|
const openDataOld = ref() |
|
|
|
const openDataNew = ref() |
|
|
|
const operatType = ref('') |
|
|
|
// 查询页面返回 |
|
|
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|
|
|
nextTick(() => { |
|
|
@ -134,8 +167,11 @@ const butttondata = [ |
|
|
|
// 列表-操作按钮事件 |
|
|
|
const buttonTableClick = async (val, row) => { |
|
|
|
if (val == 'edit') { // 编辑 |
|
|
|
operatType.value = 'edit' |
|
|
|
openForm('update', row) |
|
|
|
} else if (val == 'delete') { // 删除 |
|
|
|
operatType.value = 'delete' |
|
|
|
updateData.value = row |
|
|
|
handleDelete(row.id) |
|
|
|
} |
|
|
|
} |
|
|
@ -143,6 +179,8 @@ const buttonTableClick = async (val, row) => { |
|
|
|
/** 添加/修改操作 */ |
|
|
|
const basicFormRef = ref() |
|
|
|
const openForm = (type: string, row?: any) => { |
|
|
|
openDataOld.value = row |
|
|
|
updateFormValue.remark = '' |
|
|
|
basicFormRef.value.open(type, row) |
|
|
|
} |
|
|
|
|
|
|
@ -163,8 +201,14 @@ const formsSuccess = async (formType,data) => { |
|
|
|
await DeviceMoldItemsApi.creatMoldItems(data) |
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
} else { |
|
|
|
await DeviceMoldItemsApi.updateMoldItems(data) |
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
openDataNew.value = data |
|
|
|
if(judgeSame()){ |
|
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
getList() |
|
|
|
}else{ |
|
|
|
updateData.value = data |
|
|
|
dialogVisible.value = true |
|
|
|
} |
|
|
|
} |
|
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
getList() |
|
|
@ -181,11 +225,8 @@ const handleDelete = async (id: number) => { |
|
|
|
try { |
|
|
|
// 删除的二次确认 |
|
|
|
await message.delConfirm() |
|
|
|
// 发起删除 |
|
|
|
await DeviceMoldItemsApi.deleteDeviceMoldItems(id) |
|
|
|
message.success(t('common.delSuccess')) |
|
|
|
// 刷新列表 |
|
|
|
await getList() |
|
|
|
dialogVisible.value = true |
|
|
|
|
|
|
|
} catch {} |
|
|
|
} |
|
|
|
|
|
|
@ -230,6 +271,50 @@ const searchFormClick = (searchData) => { |
|
|
|
getList() // 刷新当前列表 |
|
|
|
} |
|
|
|
|
|
|
|
const onSubmit = async () => { |
|
|
|
console.log('submit!'); |
|
|
|
updateData.value.remark = updateFormValue.remark |
|
|
|
try { |
|
|
|
if(operatType.value == 'edit'){ |
|
|
|
await DeviceMoldItemsApi.updateMoldItems(updateData.value); |
|
|
|
message.success(t('common.updateSuccess')); |
|
|
|
// 假设这里是用户点击了"确定"并且操作成功 |
|
|
|
basicFormRef.value.dialogVisible = false; // 关闭basicFormRef窗口 |
|
|
|
dialogVisible.value = false; // 同时关闭updateDialog窗口 |
|
|
|
}else if(operatType.value == 'delete'){ |
|
|
|
// 发起删除 |
|
|
|
await DeviceMoldItemsApi.deleteDeviceMoldItems(updateData.value.id,updateData.value.remark) |
|
|
|
message.success(t('common.delSuccess')) |
|
|
|
dialogVisible.value = false; |
|
|
|
} |
|
|
|
// 刷新列表 |
|
|
|
await getList() |
|
|
|
} catch (error) { |
|
|
|
console.error(error); |
|
|
|
// 假设这里是操作失败,不关闭basicFormRef窗口 |
|
|
|
// 可以选择是否关闭updateDialog窗口或者显示错误信息 |
|
|
|
message.error(t('common.updateFailed')); |
|
|
|
} |
|
|
|
}; |
|
|
|
const handleBeforeClose = async(done)=>{ |
|
|
|
basicFormRef.value.formLoading = false |
|
|
|
done() |
|
|
|
} |
|
|
|
|
|
|
|
// 判断两个对象中相同字段的值是否全部相同 |
|
|
|
const judgeSame = () => { |
|
|
|
// 获取openDataOld.value对象的所有键(字段名) |
|
|
|
const keys = Object.keys(openDataOld.value); |
|
|
|
// 使用every()方法检查每个键对应的值是否相同 |
|
|
|
const isSame = keys.every(key => { |
|
|
|
// 检查openDataNew.value中是否有该键,并且两个对象中该键对应的值是否相同 |
|
|
|
return openDataNew.value.hasOwnProperty(key) && openDataOld.value[key] === openDataNew.value[key]; |
|
|
|
}); |
|
|
|
|
|
|
|
// 返回比较结果 |
|
|
|
return isSame; |
|
|
|
}; |
|
|
|
|
|
|
|
/** 初始化 **/ |
|
|
|
onMounted(async () => { |
|
|
|
getList() |
|
|
|