未验证 提交 8ab3b1d5 编写于 作者: L labbomb 提交者: GitHub

[Feature][UI Next]Improve the tenant Modal (#7983)

* Enabling Route Forwarding

* Added the tenant management page

* tenant-modal

* Improve the tenant Modal

* Enabling Route Forwarding

* Improve the tenant Modal

* fix bug

* Improve the tenant Modal

* Improve the tenant Modal

* Improve the tenant Modal
上级 12d7e626
...@@ -49,15 +49,15 @@ export function verifyTenantCode(params: TenantCodeReq): any { ...@@ -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({ return axios({
url: `/tenants/${id}`, url: `/tenants/${idReq.id}`,
method: 'put', method: 'put',
data, data,
}) })
} }
export function deleteTenantById(id: IdReq): any { export function deleteTenantById(id: number): any {
return axios({ return axios({
url: `/tenants/${id}`, url: `/tenants/${id}`,
method: 'delete', method: 'delete',
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * 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 Modal from '@/components/modal'
import { NForm, NFormItem, NInput, NSelect } from 'naive-ui' import { NForm, NFormItem, NInput, NSelect } from 'naive-ui'
import { useModalData } from './use-modalData' import { useModalData } from './use-modalData'
...@@ -35,13 +35,20 @@ const TenantModal = defineComponent({ ...@@ -35,13 +35,20 @@ const TenantModal = defineComponent({
} }
const confirmModal = () => { const confirmModal = () => {
handleValidate() handleValidate(props.statusRef)
} }
onMounted(() => { onMounted(() => {
getListData() 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 } return { ...toRefs(variables), cancelModal, confirmModal }
}, },
props: { props: {
...@@ -52,6 +59,10 @@ const TenantModal = defineComponent({ ...@@ -52,6 +59,10 @@ const TenantModal = defineComponent({
statusRef: { statusRef: {
type: Number as PropType<number>, type: Number as PropType<number>,
default: 0, default: 0,
},
row: {
type: Object as PropType<any>,
default: {},
} }
}, },
render() { render() {
......
...@@ -19,7 +19,7 @@ import { reactive, ref, SetupContext } from 'vue' ...@@ -19,7 +19,7 @@ import { reactive, ref, SetupContext } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import { queryList } from '@/service/modules/queues' 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")[]>) { export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "confirmModal")[]>) {
const { t } = useI18n() const { t } = useI18n()
...@@ -27,9 +27,10 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con ...@@ -27,9 +27,10 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con
const variables = reactive({ const variables = reactive({
tenantFormRef: ref(), tenantFormRef: ref(),
model: { model: {
id: ref<number>(0),
tenantCode: ref(''), tenantCode: ref(''),
description: ref(''), description: ref(''),
queueId: ref<number>(-1), queueId: ref<number>(0),
generalOptions: [] generalOptions: []
}, },
rules: { rules: {
...@@ -59,11 +60,13 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con ...@@ -59,11 +60,13 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con
return state return state
} }
const handleValidate = () => { const handleValidate = (statusRef: number) => {
variables.tenantFormRef.validate((errors: any) => { variables.tenantFormRef.validate((errors: any) => {
if (!errors) { if (!errors) {
console.log('验证成功') console.log('验证成功')
submitTenantModal()
console.log('statusRef', statusRef)
statusRef === 0 ? submitTenantModal() : updateTenantModal()
} else { } else {
console.log(errors, '验证失败') console.log(errors, '验证失败')
return return
...@@ -86,6 +89,18 @@ export function useModalData(props: any, ctx: SetupContext<("cancelModal" | "con ...@@ -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 { return {
variables, variables,
getListData, getListData,
......
...@@ -109,7 +109,7 @@ const tenementManage = defineComponent({ ...@@ -109,7 +109,7 @@ const tenementManage = defineComponent({
onUpdatePageSize={this.requestData} onUpdatePageSize={this.requestData}
/> />
</div> </div>
<TenantModal showModalRef={this.showModalRef} statusRef={this.statusRef} onCancelModal={this.onCancelModal} onConfirmModal={this.onConfirmModal}></TenantModal> <TenantModal showModalRef={this.showModalRef} statusRef={this.statusRef} row={this.row} onCancelModal={this.onCancelModal} onConfirmModal={this.onConfirmModal}></TenantModal>
</div> </div>
) )
}, },
......
...@@ -28,6 +28,7 @@ export function useTable() { ...@@ -28,6 +28,7 @@ export function useTable() {
const handleEdit= (row: any) => { const handleEdit= (row: any) => {
variables.showModalRef = true variables.showModalRef = true
variables.statusRef = 1 variables.statusRef = 1
variables.row = row
} }
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
...@@ -102,8 +103,7 @@ export function useTable() { ...@@ -102,8 +103,7 @@ export function useTable() {
default: () => {return '确定删除吗?'} default: () => {return '确定删除吗?'}
} }
) )
] ])
)
} }
} }
] ]
...@@ -118,6 +118,7 @@ export function useTable() { ...@@ -118,6 +118,7 @@ export function useTable() {
totalPage: ref(1), totalPage: ref(1),
showModalRef: ref(false), showModalRef: ref(false),
statusRef: ref(0), statusRef: ref(0),
row: {}
}) })
const getTableData = (params: any) => { const getTableData = (params: any) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册