| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <!-- 完成任务 — 生产结论 -->
- <template>
- <el-dialog
- v-model="dialogVisible"
- :title="isCompletedEdit ? '修改生产结论' : '完成任务'"
- width="520px"
- class="dialog-form-layout"
- align-center
- destroy-on-close
- :close-on-click-modal="false"
- :append-to-body="true"
- @close="handleClose"
- >
- <el-form ref="formRef" :model="form" :rules="rules" label-position="top" class="biz-dialog-form">
- <el-form-item label="生产结论" prop="conclusion">
- <el-radio-group v-model="form.conclusion">
- <el-radio value="cg">成功</el-radio>
- <el-radio value="sb">失败</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="备注">
- <el-input
- v-model="form.remark"
- type="textarea"
- :rows="3"
- placeholder="选填"
- maxlength="512"
- />
- </el-form-item>
- </el-form>
- <template #footer>
- <el-button class="btn-ghost" @click="handleClose"><el-icon><Close /></el-icon>取消</el-button>
- <el-button class="btn-main" type="primary" :loading="submitting" @click="handleSubmit">
- <el-icon><Check /></el-icon>{{ isCompletedEdit ? '保存' : '确认完成' }}
- </el-button>
- </template>
- </el-dialog>
- </template>
- <script setup lang="ts">
- import { ref, reactive, computed, watch } from 'vue'
- import { Close, Check } from '@element-plus/icons-vue'
- import type { FormInstance, FormRules } from 'element-plus'
- const props = withDefaults(
- defineProps<{
- visible: boolean
- submitting?: boolean
- isCompletedEdit?: boolean
- initialConclusion?: string
- initialRemark?: string
- }>(),
- {
- isCompletedEdit: false,
- initialConclusion: '',
- initialRemark: ''
- }
- )
- const emit = defineEmits<{
- (e: 'update:visible', val: boolean): void
- (e: 'submit', payload: { conclusion: string; remark?: string }): void
- }>()
- const dialogVisible = computed({
- get: () => props.visible,
- set: (val) => emit('update:visible', val)
- })
- const formRef = ref<FormInstance>()
- const form = reactive({ conclusion: '', remark: '' })
- const rules: FormRules = {
- conclusion: [{ required: true, message: '请选择生产结论', trigger: 'change' }]
- }
- function handleClose() {
- dialogVisible.value = false
- }
- async function handleSubmit() {
- if (!formRef.value) return
- await formRef.value.validate()
- emit('submit', {
- conclusion: form.conclusion,
- remark: form.remark.trim() || undefined
- })
- }
- watch(
- () => props.visible,
- (val) => {
- if (val) {
- form.conclusion = props.initialConclusion || ''
- form.remark = props.initialRemark || ''
- formRef.value?.clearValidate()
- }
- }
- )
- </script>
|