|
@@ -0,0 +1,369 @@
|
|
|
|
|
+<script setup lang="ts">
|
|
|
|
|
+import { IotRyImproveDailyReportApi } from '@/api/pms/iotryimprovedailyreport'
|
|
|
|
|
+import { FormInstance, FormRules } from 'element-plus'
|
|
|
|
|
+import { Close } from '@element-plus/icons-vue'
|
|
|
|
|
+
|
|
|
|
|
+defineOptions({ name: 'IotRyEquipmentReportForm' })
|
|
|
|
|
+
|
|
|
|
|
+type FormMode = 'create' | 'edit' | 'detail' | 'approval'
|
|
|
|
|
+
|
|
|
|
|
+interface EquipmentReportForm {
|
|
|
|
|
+ id?: number
|
|
|
|
|
+ title: string
|
|
|
|
|
+ createTime: number | undefined
|
|
|
|
|
+ workLocation: string
|
|
|
|
|
+ workPurpose: string
|
|
|
|
|
+ relocationDays: number | undefined
|
|
|
|
|
+ productionStatus: string
|
|
|
|
|
+ nextPlan: string
|
|
|
|
|
+ personnel: string
|
|
|
|
|
+ auditStatus?: 0 | 10 | 20 | 30 | 40
|
|
|
|
|
+ opinion?: string
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+interface Props {
|
|
|
|
|
+ visible?: boolean
|
|
|
|
|
+ loadList: () => void | Promise<void>
|
|
|
|
|
+ reloadAfterCreate?: () => void | Promise<void>
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
+ visible: false
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const emits = defineEmits<{
|
|
|
|
|
+ 'update:visible': [value: boolean]
|
|
|
|
|
+}>()
|
|
|
|
|
+
|
|
|
|
|
+const defaultForm: EquipmentReportForm = {
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ createTime: undefined,
|
|
|
|
|
+ workLocation: '',
|
|
|
|
|
+ workPurpose: '',
|
|
|
|
|
+ relocationDays: undefined,
|
|
|
|
|
+ productionStatus: '',
|
|
|
|
|
+ nextPlan: '',
|
|
|
|
|
+ personnel: '',
|
|
|
|
|
+ auditStatus: undefined,
|
|
|
|
|
+ opinion: ''
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
|
|
+const formMode = ref<FormMode>('create')
|
|
|
|
|
+const form = ref<EquipmentReportForm>({ ...defaultForm })
|
|
|
|
|
+const formLoading = ref(false)
|
|
|
|
|
+const detailLoading = ref(false)
|
|
|
|
|
+const message = useMessage()
|
|
|
|
|
+
|
|
|
|
|
+const auditStatusMap = {
|
|
|
|
|
+ 0: { label: '未提交', type: 'info' },
|
|
|
|
|
+ 10: { label: '审批中', type: 'warning' },
|
|
|
|
|
+ 20: { label: '审核通过', type: 'success' },
|
|
|
|
|
+ 30: { label: '审核不通过', type: 'danger' },
|
|
|
|
|
+ 40: { label: '已取消', type: 'info' }
|
|
|
|
|
+} as const
|
|
|
|
|
+
|
|
|
|
|
+const rules: FormRules = {
|
|
|
|
|
+ title: [{ required: true, message: '请输入标题', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ createTime: [{ required: true, message: '请选择汇报时间', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ workLocation: [{ required: true, message: '请输入工作地点', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ workPurpose: [{ required: true, message: '请输入施工目的', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ relocationDays: [{ required: true, message: '请输入安全作业天数', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ productionStatus: [{ required: true, message: '请输入施工动态', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ nextPlan: [{ required: true, message: '请输入下步计划', trigger: ['blur', 'change'] }],
|
|
|
|
|
+ personnel: [{ required: true, message: '请输入人员情况', trigger: ['blur', 'change'] }]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const drawerTitle = computed(() => {
|
|
|
|
|
+ const titleMap: Record<FormMode, string> = {
|
|
|
|
|
+ create: '新建设备汇报',
|
|
|
|
|
+ edit: '编辑设备汇报',
|
|
|
|
|
+ detail: '查看设备汇报',
|
|
|
|
|
+ approval: '审批设备汇报'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return titleMap[formMode.value]
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const formDisabled = computed(() => formMode.value === 'detail')
|
|
|
|
|
+const mainFieldDisabled = computed(
|
|
|
|
|
+ () => formMode.value === 'detail' || formMode.value === 'approval'
|
|
|
|
|
+)
|
|
|
|
|
+const showAuditInfo = computed(() => formMode.value !== 'create')
|
|
|
|
|
+
|
|
|
|
|
+function getAuditStatus(status?: number) {
|
|
|
|
|
+ return auditStatusMap[status as keyof typeof auditStatusMap] || auditStatusMap[0]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function toFormData(row?: any): EquipmentReportForm {
|
|
|
|
|
+ if (!row) return { ...defaultForm }
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: row.id,
|
|
|
|
|
+ title: row.title,
|
|
|
|
|
+ createTime: row.createTime,
|
|
|
|
|
+ workLocation: row.workLocation,
|
|
|
|
|
+ workPurpose: row.workPurpose,
|
|
|
|
|
+ relocationDays: row.relocationDays,
|
|
|
|
|
+ productionStatus: row.productionStatus,
|
|
|
|
|
+ nextPlan: row.nextPlan,
|
|
|
|
|
+ personnel: row.personnel,
|
|
|
|
|
+ auditStatus: row.auditStatus,
|
|
|
|
|
+ opinion: row.opinion || ''
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function handleOpenForm(mode: FormMode = 'create', row?: any) {
|
|
|
|
|
+ formMode.value = mode
|
|
|
|
|
+ form.value = mode === 'create' ? { ...defaultForm } : toFormData(row)
|
|
|
|
|
+ emits('update:visible', true)
|
|
|
|
|
+
|
|
|
|
|
+ if (mode !== 'create' && row?.id) {
|
|
|
|
|
+ detailLoading.value = true
|
|
|
|
|
+ try {
|
|
|
|
|
+ const detail = await IotRyImproveDailyReportApi.getIotRyImproveDailyReport(row.id)
|
|
|
|
|
+ form.value = toFormData(detail)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ detailLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ formRef.value?.clearValidate()
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function handleCloseForm() {
|
|
|
|
|
+ emits('update:visible', false)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function submitForm() {
|
|
|
|
|
+ if (!formRef.value || formDisabled.value || formMode.value === 'approval') return
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ formLoading.value = true
|
|
|
|
|
+ await formRef.value.validate()
|
|
|
|
|
+
|
|
|
|
|
+ const data = { ...form.value, createTime: Number(form.value.createTime) }
|
|
|
|
|
+
|
|
|
|
|
+ if (data.id) {
|
|
|
|
|
+ await IotRyImproveDailyReportApi.updateIotRyImproveDailyReport({
|
|
|
|
|
+ id: data.id,
|
|
|
|
|
+ title: data.title,
|
|
|
|
|
+ createTime: data.createTime,
|
|
|
|
|
+ workLocation: data.workLocation,
|
|
|
|
|
+ workPurpose: data.workPurpose,
|
|
|
|
|
+ relocationDays: Number(data.relocationDays),
|
|
|
|
|
+ productionStatus: data.productionStatus,
|
|
|
|
|
+ personnel: data.personnel,
|
|
|
|
|
+ nextPlan: data.nextPlan
|
|
|
|
|
+ })
|
|
|
|
|
+ message.success('编辑成功')
|
|
|
|
|
+ await props.loadList()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await IotRyImproveDailyReportApi.createIotRyImproveDailyReport({
|
|
|
|
|
+ title: data.title,
|
|
|
|
|
+ createTime: data.createTime,
|
|
|
|
|
+ workLocation: data.workLocation,
|
|
|
|
|
+ workPurpose: data.workPurpose,
|
|
|
|
|
+ relocationDays: Number(data.relocationDays),
|
|
|
|
|
+ productionStatus: data.productionStatus,
|
|
|
|
|
+ personnel: data.personnel,
|
|
|
|
|
+ nextPlan: data.nextPlan
|
|
|
|
|
+ })
|
|
|
|
|
+ message.success('新增成功')
|
|
|
|
|
+ await (props.reloadAfterCreate ? props.reloadAfterCreate() : props.loadList())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ handleCloseForm()
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ formLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function submitApproval(auditStatus: 20 | 30) {
|
|
|
|
|
+ if (!form.value.id) return
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ formLoading.value = true
|
|
|
|
|
+ await IotRyImproveDailyReportApi.approvalIotRyImproveDailyReport({
|
|
|
|
|
+ id: form.value.id,
|
|
|
|
|
+ auditStatus,
|
|
|
|
|
+ opinion: form.value.opinion
|
|
|
|
|
+ })
|
|
|
|
|
+ message.success(auditStatus === 20 ? '审批通过' : '审批不通过')
|
|
|
|
|
+ await props.loadList()
|
|
|
|
|
+ handleCloseForm()
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ formLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+defineExpose({ handleOpenForm })
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<template>
|
|
|
|
|
+ <el-drawer
|
|
|
|
|
+ :model-value="visible"
|
|
|
|
|
+ @update:model-value="emits('update:visible', $event)"
|
|
|
|
|
+ header-class="mb-0!"
|
|
|
|
|
+ :with-header="false"
|
|
|
|
|
+ size="70%"
|
|
|
|
|
+ :close-on-press-escape="false"
|
|
|
|
|
+ :close-on-click-modal="false">
|
|
|
|
|
+ <div class="size-full flex flex-col gap-4">
|
|
|
|
|
+ <div class="flex justify-between items-center">
|
|
|
|
|
+ <div class="flex items-center gap-4">
|
|
|
|
|
+ <div class="text-xl font-bold text-gray-900 leading-tight">{{ drawerTitle }}</div>
|
|
|
|
|
+ <template v-if="showAuditInfo">
|
|
|
|
|
+ <el-tag :type="getAuditStatus(form.auditStatus).type">
|
|
|
|
|
+ {{ getAuditStatus(form.auditStatus).label }}
|
|
|
|
|
+ </el-tag>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <el-button link @click="handleCloseForm">
|
|
|
|
|
+ <el-icon size="24"><Close /></el-icon>
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form
|
|
|
|
|
+ ref="formRef"
|
|
|
|
|
+ v-loading="detailLoading"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ label-position="top"
|
|
|
|
|
+ :model="form"
|
|
|
|
|
+ require-asterisk-position="right"
|
|
|
|
|
+ class="flex flex-col"
|
|
|
|
|
+ :rules="rules"
|
|
|
|
|
+ :disabled="formDisabled">
|
|
|
|
|
+ <div class="grid grid-cols-2 gap-x-8">
|
|
|
|
|
+ <el-form-item class="col-span-2" label="标题" prop="title">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.title"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入标题"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="汇报时间" prop="createTime">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="form.createTime"
|
|
|
|
|
+ type="date"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ class="w-full!"
|
|
|
|
|
+ placeholder="请选择汇报时间"
|
|
|
|
|
+ value-format="x"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="工作地点" prop="workLocation">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.workLocation"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入工作地点"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="施工目的" prop="workPurpose">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.workPurpose"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入施工目的"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="安全作业天数" prop="relocationDays">
|
|
|
|
|
+ <el-input-number
|
|
|
|
|
+ v-model="form.relocationDays"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ :controls="false"
|
|
|
|
|
+ align="left"
|
|
|
|
|
+ class="w-full!"
|
|
|
|
|
+ placeholder="请输入安全作业天数"
|
|
|
|
|
+ :disabled="mainFieldDisabled">
|
|
|
|
|
+ <template #suffix>天</template>
|
|
|
|
|
+ </el-input-number>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="人员情况" prop="personnel">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.personnel"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入人员情况"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item class="col-span-2" label="施工动态" prop="productionStatus">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.productionStatus"
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :autosize="{ minRows: 8 }"
|
|
|
|
|
+ resize="none"
|
|
|
|
|
+ show-word-limit
|
|
|
|
|
+ :maxlength="2000"
|
|
|
|
|
+ placeholder="请输入施工动态,每行一条"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item class="col-span-2" label="下步计划" prop="nextPlan">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.nextPlan"
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :autosize="{ minRows: 2 }"
|
|
|
|
|
+ resize="none"
|
|
|
|
|
+ show-word-limit
|
|
|
|
|
+ :maxlength="1000"
|
|
|
|
|
+ placeholder="请输入下步计划"
|
|
|
|
|
+ :disabled="mainFieldDisabled" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item v-if="showAuditInfo" class="col-span-2" label="审批意见" prop="opinion">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="form.opinion"
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :autosize="{ minRows: 3 }"
|
|
|
|
|
+ resize="none"
|
|
|
|
|
+ show-word-limit
|
|
|
|
|
+ :maxlength="1000"
|
|
|
|
|
+ :placeholder="formMode === 'approval' ? '请输入审批意见' : '暂无审批意见'"
|
|
|
|
|
+ :disabled="formMode !== 'approval'" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="formMode === 'create' || formMode === 'edit'"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="submitForm"
|
|
|
|
|
+ :loading="formLoading">
|
|
|
|
|
+ 确 定
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="formMode === 'approval'"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ type="success"
|
|
|
|
|
+ @click="submitApproval(20)"
|
|
|
|
|
+ :loading="formLoading">
|
|
|
|
|
+ 审批通过
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="formMode === 'approval'"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ @click="submitApproval(30)"
|
|
|
|
|
+ :loading="formLoading">
|
|
|
|
|
+ 审批不通过
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button size="default" @click="handleCloseForm">取 消</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-drawer>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+:deep(.el-form-item__label) {
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|