master
parent
1baa5529bf
commit
5f8d8b43cc
@ -0,0 +1,60 @@
|
||||
import request from "@/utils/request";
|
||||
function customParamsSerializer(params) {
|
||||
let result = '';
|
||||
for (let key in params) {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
if (Array.isArray(params[key])) {
|
||||
params[key].forEach((item,index) => {
|
||||
if(item.key){
|
||||
result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
|
||||
|
||||
}else{
|
||||
result +=`${key}[${index}]=${item}&`
|
||||
}
|
||||
});
|
||||
} else {
|
||||
result += `${key}=${params[key]}&`;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.slice(0, -1);
|
||||
}
|
||||
|
||||
export function index(params,isLoading = false) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/api/admin/plan-type/index",
|
||||
params,
|
||||
paramsSerializer: customParamsSerializer,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params, isLoading = true) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/api/admin/plan-type/show",
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/api/admin/plan-type/save",
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/api/admin/plan-type/destroy",
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 845 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
@ -0,0 +1,55 @@
|
||||
import { debounce } from '@/utils'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
$_sidebarElm: null,
|
||||
$_resizeHandler: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$_resizeHandler = debounce(() => {
|
||||
if (this.chart) {
|
||||
this.chart.resize()
|
||||
}
|
||||
}, 100)
|
||||
this.$_initResizeEvent()
|
||||
this.$_initSidebarResizeEvent()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$_destroyResizeEvent()
|
||||
this.$_destroySidebarResizeEvent()
|
||||
},
|
||||
// to fixed bug when cached by keep-alive
|
||||
// https://github.com/PanJiaChen/vue-element-admin/issues/2116
|
||||
activated() {
|
||||
this.$_initResizeEvent()
|
||||
this.$_initSidebarResizeEvent()
|
||||
},
|
||||
deactivated() {
|
||||
this.$_destroyResizeEvent()
|
||||
this.$_destroySidebarResizeEvent()
|
||||
},
|
||||
methods: {
|
||||
// use $_ for mixins properties
|
||||
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
|
||||
$_initResizeEvent() {
|
||||
window.addEventListener('resize', this.$_resizeHandler)
|
||||
},
|
||||
$_destroyResizeEvent() {
|
||||
window.removeEventListener('resize', this.$_resizeHandler)
|
||||
},
|
||||
$_sidebarResizeHandler(e) {
|
||||
if (e.propertyName === 'width') {
|
||||
this.$_resizeHandler()
|
||||
}
|
||||
},
|
||||
$_initSidebarResizeEvent() {
|
||||
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
|
||||
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
|
||||
},
|
||||
$_destroySidebarResizeEvent() {
|
||||
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
<template>
|
||||
<div style="padding: 0 20px">
|
||||
|
||||
<div>
|
||||
<div ref="lxHeader">
|
||||
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
||||
<div slot="content">
|
||||
<div class="searchwrap" style="display: flex;align-items: center;">
|
||||
<div>
|
||||
<el-date-picker v-model="select.year" style="width:100%" format="yyyy" value-format="yyyy" type="year"
|
||||
placeholder="选择年份">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
<div>
|
||||
<el-input v-model="select.name" placeholder="类型名称"></el-input>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="select.page=1,getList()">查询</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="editType('add')">新增</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</lx-header>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<xy-table :list="list" :total="total" :table-item="table_item">
|
||||
<template v-slot:btns>
|
||||
<el-table-column align='center' label="操作" width="280" header-align="center">
|
||||
<template slot-scope="scope">
|
||||
<Button class="slot-btns-item" size="small" type="primary" @click="editType('sub',scope.row.id)">
|
||||
子类型
|
||||
</Button>
|
||||
<Button style="margin-left: 10px" @click="editType('editor',scope.row.id)""
|
||||
class="slot-btns-item" size="small" type="primary">
|
||||
编辑
|
||||
</Button>
|
||||
<Poptip :transfer="true" style="margin-left: 10px" confirm placement="bottom" title="确认要删除吗"
|
||||
@on-ok="() => deleteList(scope.row.id)">
|
||||
<i-button class="slot-btns-item" size="small" type="error">删除
|
||||
</i-button>
|
||||
</Poptip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
</xy-table>
|
||||
</div>
|
||||
|
||||
<add-plan-type ref="addPlanType" @refresh="getList"></add-plan-type>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import addPlanType from './component/addPlanType.vue';
|
||||
import {
|
||||
index,
|
||||
destroy
|
||||
} from "@/api/budget/plantype.js"
|
||||
import {
|
||||
buildTree
|
||||
} from '@/utils'
|
||||
export default {
|
||||
components: {
|
||||
addPlanType
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
select: {
|
||||
name: '',
|
||||
year: this.$moment().format('YYYY'),
|
||||
page: 1,
|
||||
page_size: 999,
|
||||
},
|
||||
list: [],
|
||||
total: 0,
|
||||
table_item: [{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
align: 'left',
|
||||
}, {
|
||||
prop: 'sort',
|
||||
label: '排序',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
}]
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
|
||||
editType(type, id, pName) {
|
||||
if (type == 'editor') {
|
||||
this.$refs.addPlanType.id = id
|
||||
}
|
||||
if (type == 'sub') {
|
||||
this.$refs.addPlanType.id = id
|
||||
}
|
||||
let arr = [{
|
||||
id: 0,
|
||||
name: '根目录'
|
||||
}]
|
||||
arr.push(...this.list)
|
||||
|
||||
this.$refs.addPlanType.list = arr
|
||||
this.$refs.addPlanType.type = type
|
||||
this.$refs.addPlanType.isShow = true
|
||||
},
|
||||
async getList() {
|
||||
const res = await index({
|
||||
page_size: this.select.page_size,
|
||||
page: this.select.page,
|
||||
sort_name: 'sort',
|
||||
sort_type: 'asc',
|
||||
filter: [{
|
||||
key: 'year',
|
||||
op: 'eq',
|
||||
value: this.select.year?this.select.year:''
|
||||
}, {
|
||||
key: 'name',
|
||||
op: 'like',
|
||||
value: this.select.name
|
||||
}]
|
||||
})
|
||||
this.list = buildTree(res.data)
|
||||
console.log("this.list", this.list)
|
||||
this.total = res.total
|
||||
},
|
||||
deleteList(id) {
|
||||
console.log("123")
|
||||
var that = this;
|
||||
destroy({
|
||||
id: id
|
||||
}).then(response => {
|
||||
this.$Message.success('操作成功');
|
||||
this.getList()
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
reject(error)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.searchwrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&>div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 10px;
|
||||
|
||||
span {
|
||||
min-width: 70px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue