<template>
|
<div>
|
<div class="add">
|
<span class="back-color" @click="$router.back()"
|
><i class="el-icon-arrow-left"></i>返回上一级</span
|
>
|
</div>
|
<v-header
|
title="空间分类管理"
|
search
|
:bar="bar"
|
@on-search="onSearch"
|
></v-header>
|
<div class="but">
|
<el-button @click="add()" size="small" type="primary">新增</el-button>
|
</div>
|
<div>
|
<v-tool-table :trs="trs" :tds="tds">
|
<template v-slot:time="{ scope }">
|
{{ scope.creationTime }}
|
</template>
|
<template v-slot:icon="{ scope }">
|
<img :src="scope.pictureUrl" />
|
</template>
|
<template v-slot:btn="{ scope }">
|
<el-button type="text" @click="edit(scope)">编辑</el-button>
|
<el-button type="text" @click="clear(scope.id)">删除</el-button>
|
</template>
|
</v-tool-table>
|
</div>
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
<!---->
|
<el-dialog
|
:title="title"
|
:modal="false"
|
destroy-on-close
|
:close-on-click-modal="false"
|
:visible.sync="centerDialogVisible"
|
width="600px"
|
center
|
>
|
<div class="dialog-box">
|
<el-form ref="form" label-width="100px">
|
<el-form-item required label="分类名称">
|
<el-input
|
v-model="fromContent.intendantName"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="centerDialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="sub()">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import vU from "com/upload/upload1";
|
export default {
|
props: [],
|
components: { vU },
|
data() {
|
return {
|
Authorization: "",
|
title: "新增",
|
editType: 1, //1新增 2 编辑
|
editId: "",
|
centerDialogVisible: false,
|
bar: [{ title: "分类名称", name: "intendantName", value: "" }],
|
fromContent: {
|
intendantName: ""
|
},
|
search: {},
|
trs: [
|
{ text: "标签名", val: "intendantName" },
|
{ text: "创建时间", val: "btn", slot: "time" },
|
{ text: "操作", val: "btn" }
|
],
|
tds: [],
|
paged: { page: 0, total: 10, r: 0, limit: 10 }
|
};
|
},
|
created() {
|
this.init();
|
},
|
mounted() {
|
this.Authorization = "Bearer " + demo.$local.get("token") || "";
|
},
|
methods: {
|
clear(id) {
|
this.$api.del(
|
"Jinhui/JinhuiInterspace/interspaceTypeExpurgateData?id=" + id,
|
{},
|
e => {
|
demo.toast("删除成功");
|
this.init();
|
this.centerDialogVisible = false;
|
}
|
);
|
},
|
onPath(v) {
|
this.fromContent.photoPath = v;
|
},
|
|
//新增
|
add() {
|
this.title = "新增";
|
this.centerDialogVisible = true;
|
this.fromContent.intendantName = "";
|
},
|
|
edit(scope) {
|
this.editId = scope.id;
|
this.title = "编辑";
|
//编辑
|
console.log(scope);
|
this.fromContent.intendantName = scope.intendantName;
|
this.editType = 2;
|
this.centerDialogVisible = true;
|
},
|
|
sub() {
|
let params = {
|
intendantName: this.fromContent.intendantName
|
};
|
|
if (this.fromContent.intendantName == "") {
|
demo.toast("请输入分类名称");
|
return;
|
}
|
|
let url = this.editId
|
? "Jinhui/JinhuiInterspace/interspaceTypeEditData"
|
: "Jinhui/JinhuiInterspace/interspaceTypeAddData";
|
if (this.editId) {
|
params.id = this.editId;
|
}
|
|
this.$api.post(url, params, e => {
|
this.init();
|
this.centerDialogVisible = false;
|
});
|
},
|
|
init() {
|
let v = {
|
createAt: "",
|
id: 0,
|
sysFlag: 0
|
};
|
let params = demo.copy(
|
Object.assign(v, this.search, {
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit
|
})
|
);
|
this.$api.get("Jinhui/interspaceTypeGetList", params, e => {
|
console.log(e.recods);
|
this.tds = e.records;
|
this.paged.total = e.total;
|
});
|
},
|
|
onSearch(e) {
|
this.search = e;
|
this.init();
|
},
|
|
onPage(v) {
|
//分页
|
if (v.page === this.paged.page && v.page && !v.reset) {
|
return 0;
|
}
|
this.paged.page = v.page;
|
this.paged.limit = v.limit;
|
this.init();
|
}
|
}
|
};
|
</script>
|
<style lang="less" scoped>
|
.but {
|
padding-bottom: 20px;
|
display: flex;
|
}
|
.upload-box {
|
margin: 0 16px;
|
}
|
.add {
|
text-align: right;
|
padding-top: 10px;
|
.back-color {
|
color: #409eff;
|
cursor: pointer;
|
}
|
}
|
.icon-image {
|
width: 50px;
|
height: 50px;
|
overflow: hidden;
|
}
|
</style>
|