重新返工页面
This commit is contained in:
parent
8363fea63b
commit
945e6ecbdb
@ -141,7 +141,7 @@
|
||||
v-if="scope.row.reportProcess == 2"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleRework(scope.row.id, scope.row.reportProcess)"
|
||||
@click="rework('update', scope.row.id)"
|
||||
>
|
||||
返工
|
||||
</el-button>
|
||||
@ -169,6 +169,7 @@
|
||||
</el-card>
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<TaskInReportForm ref="formRef" @success="getList"/>
|
||||
<reworkForm ref="reworkRef" @success="getList"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -266,36 +267,12 @@ const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
const reworkRef = ref()
|
||||
const rework = (type: string, id?: number) => {
|
||||
reworkRef.value.open(type, id)
|
||||
}
|
||||
// 返工
|
||||
|
||||
const handleRework = async (id: number, status?: number) => {
|
||||
if (status != "2") {
|
||||
message.error('该报工没有完成,不允许返工');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const {value} = await message.prompt('请输入返工原因');
|
||||
|
||||
// 构建更新数据
|
||||
const updateData = {
|
||||
id: id,
|
||||
remark: value,
|
||||
} as TaskInReportApi.TaskInReportVO;
|
||||
|
||||
// 执行更新
|
||||
await TaskInReportApi.rework(updateData);
|
||||
message.success('返工操作成功');
|
||||
|
||||
// 刷新列表
|
||||
await getList();
|
||||
} catch (error) {
|
||||
// 只在非取消操作时显示错误
|
||||
if (error !== 'cancel' && error !== 'closed') {
|
||||
console.error('返工操作失败:', error);
|
||||
message.error('返工操作失败,请重试');
|
||||
}
|
||||
}
|
||||
};
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="600px" @close="emits">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="返工原因" prop="remark">
|
||||
<el-input type="textarea" :rows="3" placeholder="请输入返工原因"
|
||||
v-model="formData.remark"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="emits">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as TaskInReportApi from '@/api/heli/taskinreport'
|
||||
|
||||
const {t} = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
import {formatAmount} from '@/utils/formatter'
|
||||
import {ifError} from "assert";
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
remark: undefined,
|
||||
})
|
||||
|
||||
const emits = async () => {
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
}
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
try {
|
||||
formData.value.id = id; // 现在类型匹配,不会报错
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({open}) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
|
||||
const submitForm = async () => {
|
||||
try {
|
||||
// 构建更新数据
|
||||
const data = formData.value as unknown as TaskInReportApi.TaskInReportVO
|
||||
|
||||
// 执行更新
|
||||
await TaskInReportApi.rework(data);
|
||||
message.success(t('common.updateSuccess'))
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} catch (error) {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user