<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.createAt.substring(0, 10) }}
|
</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.classifyName"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item required label="上传图标">
|
<article>
|
<div class="icon-image">
|
<v-u @path="onPath" :pic="fromContent.photoPath"></v-u>
|
</div>
|
</article>
|
</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: "classifyName", value: "" }],
|
fromContent: {
|
classifyName: "",
|
photoPath: ""
|
},
|
search: {},
|
trs: [
|
{ text: "标签名", val: "classifyName" },
|
{ text: "创建时间", val: "btn", slot: "time" },
|
{ text: "图标", val: "btn", slot: "icon" },
|
{ 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.get(
|
"Jinhui/workGuide/classify/delete",
|
{ workGuideClassifyId: id },
|
e => {
|
demo.toast("删除成功");
|
this.init();
|
this.centerDialogVisible = false;
|
}
|
);
|
},
|
onPath(v) {
|
this.fromContent.photoPath = v;
|
},
|
|
//新增
|
add() {
|
this.editId = "";
|
this.title = "新增";
|
this.centerDialogVisible = true;
|
this.fromContent.classifyName = "";
|
this.fromContent.photoPath = "";
|
},
|
|
edit(scope) {
|
this.editId = scope.id;
|
this.title = "编辑";
|
//编辑
|
console.log(scope);
|
this.fromContent.classifyName = scope.classifyName;
|
this.fromContent.photoPath = scope.pictureUrl;
|
this.editType = 2;
|
this.centerDialogVisible = true;
|
},
|
|
sub() {
|
let params = {
|
classifyName: this.fromContent.classifyName,
|
createAt: "",
|
id: this.editId,
|
sysFlag: 0,
|
// id:0,
|
pictureUrl: this.fromContent.photoPath,
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit
|
};
|
|
if (this.fromContent.classifyName == "") {
|
demo.toast("请输入分类名称");
|
return;
|
}
|
if (this.fromContent.photoPath == "") {
|
demo.toast("请上传图标");
|
return;
|
}
|
|
this.$api.post("Jinhui/workGuide/classify/add", 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.post("Jinhui/workGuide/classify/apage", params, e => {
|
this.tds = e.records;
|
log;
|
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>
|