/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { defineComponent, onMounted, PropType, toRefs, watch } from 'vue' import Modal from '@/components/modal' import { NForm, NFormItem, NInput, NSelect } from 'naive-ui' import { useModalData } from './use-modalData' import { useI18n } from 'vue-i18n' const TenantModal = defineComponent({ name: 'tenant-modal', emits: ['cancelModal', 'confirmModal'], setup(props, ctx) { const { variables, getListData, handleValidate} = useModalData(props, ctx) const { t } = useI18n() const cancelModal = () => { if (props.statusRef === 0) { variables.model.tenantCode = '' variables.model.description = '' } ctx.emit('cancelModal', props.showModalRef) } const confirmModal = () => { handleValidate(props.statusRef) } watch(() => props.showModalRef, () => { props.showModalRef && getListData() }) watch(() => props.statusRef, () => { if (props.statusRef === 0) { variables.model.tenantCode = '' variables.model.description = '' } else { variables.model.id = props.row.id variables.model.tenantCode = props.row.tenantCode variables.model.queueId = props.row.queueId variables.model.description = props.row.description } }) watch(() => props.row, () => { variables.model.id = props.row.id variables.model.tenantCode = props.row.tenantCode variables.model.queueId = props.row.queueId variables.model.description = props.row.description }) return { t, ...toRefs(variables), cancelModal, confirmModal } }, props: { showModalRef: { type: Boolean as PropType, default: false, }, statusRef: { type: Number as PropType, default: 0, }, row: { type: Object as PropType, default: {}, } }, render() { const { t } = this return (
{{ default: () => ( ), }}
) }, }) export default TenantModal