|
@@ -1,12 +1,144 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
-
|
|
|
+ <div class="white pa-3">
|
|
|
+ <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch">
|
|
|
+ <template #button>
|
|
|
+ <m-button type="primary" icon="el-icon-plus" @click="onAdd">新增</m-button>
|
|
|
+ </template>
|
|
|
+ </m-search>
|
|
|
+ <m-table
|
|
|
+ v-loading="loading"
|
|
|
+ row-key="calculateConfigurationId"
|
|
|
+ :items="items"
|
|
|
+ :headers="headers"
|
|
|
+ :page-size="pageInfo.size"
|
|
|
+ :page-current="pageInfo.current"
|
|
|
+ :total="total"
|
|
|
+ :default-sort="{ prop: 'sort', order: 'ascending' }"
|
|
|
+ @page-change="onPageChange"
|
|
|
+ >
|
|
|
+ <template #actions="{ row }">
|
|
|
+ <m-button text type="primary" @click="onEdit(row)">编辑</m-button>
|
|
|
+ <m-button text type="danger" @click="onDelete(row)">删除</m-button>
|
|
|
+ </template>
|
|
|
+ </m-table>
|
|
|
+ <config-edit ref="editRefs" :title="title" @refresh="init"></config-edit>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import ConfigEdit from './configEdit'
|
|
|
+import {
|
|
|
+ getConfigPage,
|
|
|
+ getConfigCateGories,
|
|
|
+ deleteConfig,
|
|
|
+ getConfig
|
|
|
+} from '@/api/salary'
|
|
|
export default {
|
|
|
- name: 'salary-config'
|
|
|
+ name: 'salary-config',
|
|
|
+ components: { ConfigEdit },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ title: '',
|
|
|
+ searchItems: [
|
|
|
+ { label: '关键词', prop: 'keyword', type: 'input', option: { placeholder: '请输入关键词' } },
|
|
|
+ {
|
|
|
+ label: '分类',
|
|
|
+ prop: 'category',
|
|
|
+ type: 'autocomplete',
|
|
|
+ option: {
|
|
|
+ placeholder: '请输入分类',
|
|
|
+ fetchSuggestions: this.fetchSuggestions
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ searchValues: {},
|
|
|
+ headers: [
|
|
|
+ { label: '配置名称', prop: 'name' },
|
|
|
+ { label: '月份', prop: 'month' },
|
|
|
+ { label: '数值', prop: 'value' },
|
|
|
+ { label: '分类', prop: 'category' },
|
|
|
+ { label: '描述', prop: 'tag' },
|
|
|
+ { label: '创建时间', prop: 'createDate' },
|
|
|
+ { label: '操作', prop: 'actions' }
|
|
|
+ ],
|
|
|
+ items: [],
|
|
|
+ loading: false,
|
|
|
+ pageInfo: {
|
|
|
+ size: 10,
|
|
|
+ current: 1
|
|
|
+ },
|
|
|
+ total: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init () {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const { data } = await getConfigPage({
|
|
|
+ ...this.searchValues,
|
|
|
+ ...this.pageInfo
|
|
|
+ })
|
|
|
+ this.items = data.records
|
|
|
+ this.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async fetchSuggestions (category, cb) {
|
|
|
+ try {
|
|
|
+ const { data } = await getConfigCateGories({ category })
|
|
|
+ cb(data.map(e => {
|
|
|
+ return {
|
|
|
+ value: e
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSearch () {
|
|
|
+ this.pageInfo.current = 1
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ onAdd () {
|
|
|
+ this.title = '新增配置'
|
|
|
+ this.$refs.editRefs.open()
|
|
|
+ },
|
|
|
+ async onEdit (item) {
|
|
|
+ try {
|
|
|
+ const { data } = await getConfig(item.calculateConfigurationId)
|
|
|
+
|
|
|
+ this.title = '编辑配置'
|
|
|
+ this.$refs.editRefs.open(data)
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onDelete (item) {
|
|
|
+ this.$confirm('确定删除该配置吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(async () => {
|
|
|
+ try {
|
|
|
+ await deleteConfig(item.calculateConfigurationId)
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+ onPageChange (index) {
|
|
|
+ this.pageInfo.current = index
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|