|
@@ -1,23 +1,15 @@
|
|
|
<template>
|
|
|
<div class="pa-3 white">
|
|
|
- <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
|
|
|
- <m-table
|
|
|
- v-loading="loading"
|
|
|
- :items="items"
|
|
|
- :headers="headers"
|
|
|
- :page-size="pageInfo.size"
|
|
|
- :page-current="pageInfo.current"
|
|
|
- :total="total"
|
|
|
- @page-change="onPageChange"
|
|
|
- >
|
|
|
- <template #card-tools>
|
|
|
- <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
|
|
|
- </template>
|
|
|
- <template #actions="{ row }">
|
|
|
- <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
|
|
|
- <m-button type="danger" text @click="onDelete(row)">删除</m-button>
|
|
|
- </template>
|
|
|
- </m-table>
|
|
|
+ <el-tabs v-model="activeName" @tab-click="handleClick">
|
|
|
+ <el-tab-pane
|
|
|
+ v-for="item in items"
|
|
|
+ :key="item.name"
|
|
|
+ :label="item.label"
|
|
|
+ :name="item.name"
|
|
|
+ >
|
|
|
+ <component :is="item.component" :ref="item.name" :label="item.label" @hook:mounted="onComponentMounted"></component>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -26,75 +18,40 @@ export default {
|
|
|
name: 'salaryFixedRules',
|
|
|
data () {
|
|
|
return {
|
|
|
- searchItems: [
|
|
|
- {
|
|
|
- label: '名称',
|
|
|
- prop: 'name',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- placeholder: '请输入名称'
|
|
|
- }
|
|
|
- }
|
|
|
- ],
|
|
|
- searchValues: {
|
|
|
- name: null
|
|
|
- },
|
|
|
- headers: [
|
|
|
- { label: '名称', prop: 'name' },
|
|
|
- { label: '状态', prop: 'status' },
|
|
|
- { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
|
|
|
- ],
|
|
|
- items: [],
|
|
|
- total: 0,
|
|
|
- pageInfo: {
|
|
|
- current: 1,
|
|
|
- size: 10
|
|
|
- },
|
|
|
- loading: false
|
|
|
+ activeName: '',
|
|
|
+ items: []
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- this.onInit()
|
|
|
+ this.items = this.$route.meta.roles.filter(e => e.hidden === 1).sort((a, b) => a.sort - b.sort).map(e => {
|
|
|
+ return {
|
|
|
+ name: e.name,
|
|
|
+ label: e.label,
|
|
|
+ component: () => import(`./${e.component}/index.vue`)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (this.$route.query.name) {
|
|
|
+ this.activeName = this.$route.query.name
|
|
|
+ } else {
|
|
|
+ this.activeName = this.items[0].name
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ name () {
|
|
|
+ return this.items.find(e => e.name === this.activeName)?.label ?? ''
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
- async onInit () {
|
|
|
- this.loading = true
|
|
|
- try {
|
|
|
- // const { data } = await ApiName()
|
|
|
- // this.items = data.records
|
|
|
- // this.total = data.total
|
|
|
- } catch (error) {
|
|
|
- this.$message.error(error)
|
|
|
- } finally {
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- },
|
|
|
- onAdd () {
|
|
|
- this.$refs.fixedSalaryRulesRefs.open()
|
|
|
- },
|
|
|
- onEdit (item) {
|
|
|
- this.$refs.fixedSalaryRulesRefs.open(item)
|
|
|
- },
|
|
|
- onDelete (row) {
|
|
|
- this.$confirm('确定删除吗?', '提示')
|
|
|
- .then(async () => {
|
|
|
- try {
|
|
|
- // await ApiName({ id: row.id })
|
|
|
- this.$message.success('删除成功')
|
|
|
- this.onInit()
|
|
|
- } catch (error) {
|
|
|
- this.$message.error(error)
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(_ => {})
|
|
|
- },
|
|
|
- onSearch () {
|
|
|
- this.pageInfo.current = 1
|
|
|
- this.onInit()
|
|
|
+ onComponentMounted () {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs[this.activeName][0].onInit(this.name)
|
|
|
+ })
|
|
|
},
|
|
|
- onPageChange (index) {
|
|
|
- this.pageInfo.current = index
|
|
|
- this.onInit()
|
|
|
+ handleClick () {
|
|
|
+ this.$router.push(`${this.$route.path}?name=${this.activeName}`)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs[this.activeName][0].onInit(this.name)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|