master
parent
7d2cc2cd36
commit
aa341e69e7
@ -0,0 +1,61 @@
|
||||
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/family/index",
|
||||
params,
|
||||
paramsSerializer: customParamsSerializer,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params, isLoading = true) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/api/admin/family/show",
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/api/admin/family/save",
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/api/admin/family/destroy",
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<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-input v-model="select.title" placeholder="title"></el-input>
|
||||
</div>
|
||||
<div>
|
||||
<el-select style="width:100%" clearable v-model="select.is_visible" placeholder="Visible">
|
||||
<el-option v-for="(item,index) in [{id: 1,value: 'Yes'}, {id: 0,value: 'No'}]" :key="index"
|
||||
:label="item.value" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="select.page=1,getList()">search</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="resetSearch">reset</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="editFamily('add')">add</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</lx-header>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<xy-table :list="list" :total="total" @pageIndexChange="pageIndexChange" @pageSizeChange="pageSizeChange"
|
||||
:table-item="table_item">
|
||||
<template v-slot:btns>
|
||||
<el-table-column align='center' label="Operate" width="180" header-align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" size="small" @click="editFamily('editor',scope.row.id)">edit</el-button>
|
||||
<el-popconfirm confirm-button-text="confirm" cancel-button-text="cancel" style="margin:0 10px"
|
||||
@confirm="deleteList(scope.row.id)" title="Are you sure to delete it?">
|
||||
<el-button type="danger" size="small" slot="reference">delete</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
</xy-table>
|
||||
</div>
|
||||
|
||||
<addFamily ref="addFamily" @refresh="getList"></addFamily>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import addFamily from './components/addFamily.vue';
|
||||
import {
|
||||
index,
|
||||
destroy
|
||||
} from "@/api/family"
|
||||
export default {
|
||||
components: {
|
||||
addFamily
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
select: {
|
||||
title: '',
|
||||
is_visible: '',
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
},
|
||||
list: [],
|
||||
total: 0,
|
||||
table_item: [{
|
||||
type: 'index',
|
||||
align: 'center',
|
||||
width: 50
|
||||
}, {
|
||||
prop: 'title',
|
||||
label: 'Name',
|
||||
align: 'left',
|
||||
}, {
|
||||
prop: 'is_visible',
|
||||
label: 'Visible',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
is_text: true,
|
||||
text_prop: 'is_visible_text',
|
||||
formatter: (cell, data, value) => {
|
||||
return value == 1 ? 'Yes' : 'No'
|
||||
}
|
||||
}, {
|
||||
prop: 'sort',
|
||||
label: 'Sort',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
}]
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
|
||||
editFamily(type, id, pName) {
|
||||
if (type == 'editor') {
|
||||
this.$refs.addFamily.id = id
|
||||
}
|
||||
this.$refs.addFamily.type = type
|
||||
this.$refs.addFamily.isShow = true
|
||||
},
|
||||
pageIndexChange(e) {
|
||||
this.select.page = e
|
||||
this.getList()
|
||||
},
|
||||
pageSizeChange(e) {
|
||||
this.select.page_size = e
|
||||
this.select.page = 1
|
||||
this.getList()
|
||||
},
|
||||
async getList() {
|
||||
const res = await index({
|
||||
page_size: this.select.page_size,
|
||||
page: this.select.page,
|
||||
sort_name: 'sort',
|
||||
sort_type: 'asc',
|
||||
filter:[{
|
||||
key:'title',
|
||||
op:'like',
|
||||
value:this.select.title
|
||||
},{
|
||||
key:'is_visible',
|
||||
op:'eq',
|
||||
value:this.select.is_visible
|
||||
}]
|
||||
})
|
||||
this.list = res.data
|
||||
this.total = res.total
|
||||
},
|
||||
resetSearch() {
|
||||
this.select.page = 1
|
||||
this.select.is_visible = ''
|
||||
this.select.title = ''
|
||||
this.getList()
|
||||
},
|
||||
deleteList(id) {
|
||||
var that = this;
|
||||
destroy({
|
||||
id: id
|
||||
}).then(response => {
|
||||
this.$Message.success('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>
|
||||
Loading…
Reference in new issue