2024-08-20 12:11:31 +00:00
|
|
|
<template>
|
|
|
|
<el-dialog :title="addData.id ? '编辑数据' : '新增数据'" :close-on-click-modal="false" :visible.sync="dialog.visible" width="900px" append-to-body>
|
|
|
|
<RenderItem v-for="item in itemList" :key="item.id" :item="item" :add-data="dialog.record"></RenderItem>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button type="ghost" @click.native="dialog.visible = false">取消</el-button>
|
|
|
|
<el-button type="primary" @click.native="addSubmit">确定</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { computed, defineComponent, reactive, ref, Ref, toRefs } from 'vue'
|
|
|
|
import { Message } from 'element-ui'
|
|
|
|
import RenderItem from './RenderItem.vue'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: { RenderItem },
|
|
|
|
props: {
|
|
|
|
dialog: {
|
2024-08-21 01:17:14 +00:00
|
|
|
type: Object,
|
2024-08-20 12:11:31 +00:00
|
|
|
},
|
|
|
|
itemList: {
|
2024-08-21 01:17:14 +00:00
|
|
|
type: Array,
|
|
|
|
},
|
2024-08-20 12:11:31 +00:00
|
|
|
},
|
|
|
|
setup(props: any, { emit }: any) {
|
|
|
|
// 添加
|
|
|
|
const { record } = props.dialog
|
|
|
|
const state = reactive({
|
2024-08-21 01:17:14 +00:00
|
|
|
addData: { ...record },
|
2024-08-20 12:11:31 +00:00
|
|
|
})
|
|
|
|
const addFormRef = ref(null)
|
|
|
|
function addSubmit() {
|
|
|
|
emit('setData', props.dialog.record)
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...toRefs(state),
|
|
|
|
addFormRef,
|
2024-08-21 01:17:14 +00:00
|
|
|
addSubmit,
|
2024-08-20 12:11:31 +00:00
|
|
|
}
|
2024-08-21 01:17:14 +00:00
|
|
|
},
|
2024-08-20 12:11:31 +00:00
|
|
|
})
|
|
|
|
</script>
|