<template>
|
<div class="app-container">
|
<div class="filter-container">
|
<el-input v-model="queryParams.dicItemName" placeholder="字典数据名称" class="filter-item search-item" />
|
<el-button class="filter-item" type="primary" @click="search">
|
{{ $t('table.search') }}
|
</el-button>
|
<el-button class="filter-item" type="success" @click="reset">
|
{{ $t('table.reset') }}
|
</el-button>
|
<el-button class="filter-item" type="primary" @click.native="add">
|
{{ $t('table.add') }}
|
</el-button>
|
<el-button class="el-icon-delete table-operation" style="color: #f50;" @click.native="batchDelete">
|
{{ $t('table.delete') }}
|
</el-button>
|
</div>
|
<el-table
|
ref="table"
|
:key="tableKey"
|
v-loading="loading"
|
:data="list"
|
border
|
fit
|
style="width: 100%;"
|
:highlight-current-row="true"
|
@selection-change="onSelectChange"
|
>
|
<el-table-column type="selection" align="center" width="40px" />
|
<el-table-column v-if="fsnumShow" label="" prop="dicItemId" :show-overflow-tooltip="false" align="center" />
|
<el-table-column label="字典项名称" prop="dicItemName" :show-overflow-tooltip="true" align="center" min-width="100px" />
|
<el-table-column label="字典项代码" align="center" :show-overflow-tooltip="true">
|
<template slot-scope="scope">
|
<span>{{ scope.row.dicItemCode }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="字典项说明" prop="dicItemDescribe" :show-overflow-tooltip="true" align="center" min-width="170px" />
|
<el-table-column label="字典代码" prop="dicCode" :show-overflow-tooltip="true" align="center" min-width="170px" />
|
<el-table-column :label="$t('table.operation')" align="center" min-width="150px" class-name="small-padding fixed-width" fixed="right">
|
<template slot-scope="{row}">
|
<i class="el-icon-setting table-operation" style="color: #2db7f5;" @click="edit(row)" />
|
<i class="el-icon-delete table-operation" style="color: #f50;" @click="singleDelete(row)" />
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination v-show="total>0" :total="total" :page.sync="pagination.num" :limit.sync="pagination.size" @pagination="search" />
|
<dic-edit
|
ref="edit"
|
:dialog-visible="dialog.isVisible"
|
:title="dialog.title"
|
:type="dialog.type"
|
@close="editClose"
|
@success="editSuccess"
|
/>
|
</div>
|
</template>
|
<script>
|
import Pagination from '@/components/Pagination'
|
import dicEdit from './dicEdit'
|
export default {
|
name: 'Index',
|
components: { Pagination, dicEdit },
|
filters: {
|
approveFilter(status) {
|
const map = {
|
1: 'success',
|
0: 'danger'
|
}
|
return map[status]
|
}
|
},
|
data() {
|
return {
|
fsnumShow: false,
|
dialog: {
|
isVisible: false,
|
title: '',
|
type: ''
|
},
|
tableKey: 0,
|
loading: false,
|
list: null,
|
total: 0,
|
queryParams: {},
|
selection: [],
|
pagination: {
|
size: 10,
|
num: 1
|
}
|
}
|
},
|
created() {
|
const dicId = this.$route.params && this.$route.params.dicId
|
this.queryParams.dicId = dicId
|
this.search()
|
},
|
methods: {
|
transApprove(v) {
|
switch (v) {
|
case 0:
|
return 'false'
|
case 1:
|
return 'true'
|
default:
|
return ''
|
}
|
},
|
editSuccess() {
|
this.search()
|
},
|
editClose() {
|
this.dialog.isVisible = false
|
},
|
onSelectChange(selection) {
|
this.selection = selection
|
},
|
add() {
|
this.$refs.edit.setaddDicItem(this.queryParams.dicId)
|
this.dialog.title = this.$t('common.add')
|
this.dialog.isVisible = true
|
this.dialog.type = 'add'
|
},
|
edit(row) {
|
this.$refs.edit.setdicItem(row)
|
this.dialog.title = this.$t('common.edit')
|
this.dialog.isVisible = true
|
this.dialog.type = 'edit'
|
},
|
batchDelete() {
|
if (!this.selection.length) {
|
this.$message({
|
message: this.$t('tips.noDataSelected'),
|
type: 'warning'
|
})
|
return
|
}
|
this.$confirm(this.$t('tips.confirmDelete'), this.$t('common.tips'), {
|
confirmButtonText: this.$t('common.confirm'),
|
cancelButtonText: this.$t('common.cancel'),
|
type: 'warning'
|
}).then(() => {
|
const dicItemId = []
|
this.selection.forEach((c) => {
|
dicItemId.push(c.dicItemId)
|
})
|
this.delete(dicItemId)
|
}).catch(() => {
|
this.clearSelections()
|
})
|
},
|
singleDelete(row) {
|
this.$refs.table.toggleRowSelection(row, true)
|
this.delete(row.dicItemId)
|
},
|
delete(ids) {
|
this.loading = true
|
this.$delete(`system/dicItem/${ids}`).then(() => {
|
this.$message({
|
message: this.$t('tips.deleteSuccess'),
|
type: 'success'
|
})
|
this.search()
|
})
|
},
|
clearSelections() {
|
this.$refs.table.clearSelection()
|
},
|
search() {
|
this.fetch({
|
...this.queryParams
|
})
|
},
|
reset() {
|
this.queryParams = {}
|
this.search()
|
},
|
|
fetch(params = {}) {
|
params.pageSize = this.pagination.size
|
params.pageNum = this.pagination.num
|
this.loading = true
|
this.$get('system/dicItem/list', {
|
...params
|
}).then((r) => {
|
const data = r.data.data
|
this.total = data.total
|
this.list = data.rows
|
this.loading = false
|
})
|
}
|
}
|
}
|
</script>
|
<style lang="scss" scoped>
|
</style>
|