diff --git a/dolphinscheduler-ui-next/src/service/modules/tenants/index.ts b/dolphinscheduler-ui-next/src/service/modules/tenants/index.ts index 025282e2a3e4effae3c3dd9026b2c548c3d09f73..f864bee9cea7919662cba743f955c7545e992ef9 100644 --- a/dolphinscheduler-ui-next/src/service/modules/tenants/index.ts +++ b/dolphinscheduler-ui-next/src/service/modules/tenants/index.ts @@ -49,15 +49,15 @@ export function verifyTenantCode(params: TenantCodeReq): any { }) } -export function updateTenant(data: TenantCodeReq, id: IdReq): any { +export function updateTenant(data: TenantCodeReq, idReq: IdReq): any { return axios({ - url: `/tenants/${id}`, + url: `/tenants/${idReq.id}`, method: 'put', data, }) } -export function deleteTenantById(id: IdReq): any { +export function deleteTenantById(id: number): any { return axios({ url: `/tenants/${id}`, method: 'delete', diff --git a/dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx b/dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx index 0e7fa305b241dc5ec78c7e721f4cfe3fb1c005a6..28f23f43f51af5478d6d95cd0e843e4fb86505cf 100644 --- a/dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx +++ b/dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx @@ -15,7 +15,7 @@ * limitations under the License. */ -import { defineComponent, onMounted, PropType, toRefs } from 'vue' +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' @@ -35,13 +35,20 @@ const TenantModal = defineComponent({ } const confirmModal = () => { - handleValidate() + handleValidate(props.statusRef) } onMounted(() => { getListData() }) + 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 { ...toRefs(variables), cancelModal, confirmModal } }, props: { @@ -52,6 +59,10 @@ const TenantModal = defineComponent({ statusRef: { type: Number as PropType, default: 0, + }, + row: { + type: Object as PropType, + default: {}, } }, render() { diff --git a/dolphinscheduler-ui-next/src/views/security/tenant/components/use-modalData.ts b/dolphinscheduler-ui-next/src/views/security/tenant/components/use-modalData.ts index b50c2f5e5bc3f7977dbb1df3a1df8687d99b2db3..d0d31a5fab202ab68eb4e5764f85999e9529fd3e 100644 --- a/dolphinscheduler-ui-next/src/views/security/tenant/components/use-modalData.ts +++ b/dolphinscheduler-ui-next/src/views/security/tenant/components/use-modalData.ts @@ -19,7 +19,7 @@ import { reactive, ref, SetupContext } from 'vue' import { useI18n } from 'vue-i18n' import { useAsyncState } from '@vueuse/core' import { queryList } from '@/service/modules/queues' -import { verifyTenantCode, createTenant } from '@/service/modules/tenants' +import { verifyTenantCode, createTenant, updateTenant } from '@/service/modules/tenants' export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "confirmModal")[]>) { const { t } = useI18n() @@ -27,9 +27,10 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con const variables = reactive({ tenantFormRef: ref(), model: { + id: ref(0), tenantCode: ref(''), description: ref(''), - queueId: ref(-1), + queueId: ref(0), generalOptions: [] }, rules: { @@ -59,11 +60,13 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con return state } - const handleValidate = () => { + const handleValidate = (statusRef: number) => { variables.tenantFormRef.validate((errors: any) => { if (!errors) { console.log('验证成功') - submitTenantModal() + + console.log('statusRef', statusRef) + statusRef === 0 ? submitTenantModal() : updateTenantModal() } else { console.log(errors, '验证失败') return @@ -86,6 +89,18 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con }) } + const updateTenantModal = () => { + const data = { + tenantCode: variables.model.tenantCode, + queueId: variables.model.queueId, + description: variables.model.description, + id: variables.model.id + } + updateTenant(data, {id: variables.model.id}).then((res: any) => { + ctx.emit('confirmModal', props.showModalRef) + }) + } + return { variables, getListData, diff --git a/dolphinscheduler-ui-next/src/views/security/tenant/index.tsx b/dolphinscheduler-ui-next/src/views/security/tenant/index.tsx index 566c67e255d725a43bed8a3827a136a21686cac6..180edb4fd532dffd661184c08eff576f52bb6027 100644 --- a/dolphinscheduler-ui-next/src/views/security/tenant/index.tsx +++ b/dolphinscheduler-ui-next/src/views/security/tenant/index.tsx @@ -109,7 +109,7 @@ const tenementManage = defineComponent({ onUpdatePageSize={this.requestData} /> - + ) }, diff --git a/dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts b/dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts index 14dd51c1e9c653d36704a33088e0199b0c67086c..623eeb9cde0a4df9c0709650cdd37f1655185d5c 100644 --- a/dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts +++ b/dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts @@ -28,6 +28,7 @@ export function useTable() { const handleEdit= (row: any) => { variables.showModalRef = true variables.statusRef = 1 + variables.row = row } const handleDelete = (row: any) => { @@ -82,28 +83,27 @@ export function useTable() { { icon: () => h(EditOutlined) } - ), - h( - NPopconfirm, - { - onPositiveClick: () => { handleDelete(row) } - }, - { - trigger: () => h( - NButton, - { - size: 'small', - style: {'margin-left': '5px'}, - }, - { - icon: () => h(DeleteOutlined), - } - ), - default: () => {return '确定删除吗?'} - } - ) - ] - ) + ), + h( + NPopconfirm, + { + onPositiveClick: () => { handleDelete(row) } + }, + { + trigger: () => h( + NButton, + { + size: 'small', + style: {'margin-left': '5px'}, + }, + { + icon: () => h(DeleteOutlined), + } + ), + default: () => {return '确定删除吗?'} + } + ) + ]) } } ] @@ -118,6 +118,7 @@ export function useTable() { totalPage: ref(1), showModalRef: ref(false), statusRef: ref(0), + row: {} }) const getTableData = (params: any) => {