index.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { defineComponent, toRefs, onMounted } from 'vue'
  18. import {
  19. NButton,
  20. NInput,
  21. NIcon,
  22. NDataTable,
  23. NPagination,
  24. NCard,
  25. } from 'naive-ui'
  26. import styles from './index.module.scss'
  27. import { useTable } from './use-table'
  28. import { SearchOutlined } from '@vicons/antd'
  29. import TenantModal from './components/tenant-modal'
  30. const tenementManage = defineComponent({
  31. name: 'tenement-manage',
  32. setup() {
  33. const { variables, getTableData } = useTable()
  34. const requestData = () => {
  35. getTableData({
  36. pageSize: variables.pageSize,
  37. pageNo: variables.page,
  38. searchVal: variables.searchVal,
  39. })
  40. }
  41. const handleModalChange = () => {
  42. variables.showModalRef = true
  43. variables.statusRef = 0
  44. }
  45. const onCancelModal = () => {
  46. variables.showModalRef = false
  47. }
  48. const onConfirmModal = () => {
  49. variables.showModalRef = false
  50. requestData()
  51. }
  52. onMounted(() => {
  53. requestData()
  54. })
  55. return {
  56. ...toRefs(variables),
  57. requestData,
  58. handleModalChange,
  59. onCancelModal,
  60. onConfirmModal,
  61. }
  62. },
  63. render() {
  64. return (
  65. <div class={styles.container}>
  66. <NCard>
  67. <div class={styles.header}>
  68. <div>
  69. <NButton size='small' onClick={this.handleModalChange}>
  70. 创建租户
  71. </NButton>
  72. </div>
  73. <div class={styles.search}>
  74. <NInput
  75. size='small'
  76. v-model={[this.searchVal, 'value']}
  77. on-input={this.requestData}
  78. placeholder='请输入关键词'
  79. clearable
  80. />
  81. <NButton size='small'>
  82. <NIcon>
  83. <SearchOutlined />
  84. </NIcon>
  85. </NButton>
  86. </div>
  87. </div>
  88. </NCard>
  89. <div class={styles.form}>
  90. <NDataTable columns={this.columns} data={this.tableData} />
  91. </div>
  92. <div class={styles.pagination}>
  93. <NPagination
  94. v-model:page={this.page}
  95. v-model:page-size={this.pageSize}
  96. page-count={this.totalPage}
  97. show-size-picker
  98. page-sizes={[10, 30, 50]}
  99. show-quick-jumper
  100. onUpdatePage={this.requestData}
  101. onUpdatePageSize={this.requestData}
  102. />
  103. </div>
  104. <TenantModal showModalRef={this.showModalRef} statusRef={this.statusRef} onCancelModal={this.onCancelModal} onConfirmModal={this.onConfirmModal}></TenantModal>
  105. </div>
  106. )
  107. },
  108. })
  109. export default tenementManage