<template>
|
<div class="shop_work">
|
<v-header
|
title="办事指南"
|
search
|
:bar="bar"
|
@on-search="onSearch"
|
></v-header>
|
<div class="add">
|
<button class="m_btn bgc_primary small" @click="appPath('jh_work_add')">
|
新增
|
</button>
|
<button class="m_btn bgc_primary small" @click="classification()">
|
办事指南分类管理
|
</button>
|
</div>
|
<div class="tab">
|
<v-tool-table :trs="trs" :tds="tds">
|
<template v-slot:btn="item">
|
<div class="table_flex">
|
<!-- {{item.scope.id}} -->
|
<span class="col_primary" @click="onEdit(item.scope)">编辑</span>
|
<span class="col_primary" @click="onDel(item.scope)">删除</span>
|
</div>
|
</template>
|
<template v-slot:title="item">
|
<p class="text_overflow" style="text-align:left">
|
{{ item.scope.title }}
|
</p>
|
</template>
|
</v-tool-table>
|
</div>
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
</div>
|
</template>
|
|
<script>
|
import { mapState } from "vuex";
|
export default {
|
props: {},
|
components: {},
|
data() {
|
return {
|
bar: [
|
{ title: "标题", name: "title" },
|
{
|
title: "所属分类",
|
name: "classify",
|
type: "select",
|
plac: "请选择",
|
list: []
|
}
|
],
|
trs: [
|
{ text: "标题", val: "btn", slot: "title" },
|
{ text: "所属分类", val: "classifyName", width: "120px" },
|
{ text: "添加时间", val: "createAt", width: "120px" },
|
{ text: "操作", val: "btn", width: "130px" }
|
],
|
tds: [],
|
paged: { page: 0, total: 0, r: 0, limit: 10 },
|
os: {},
|
search: {}
|
};
|
},
|
computed: {
|
...mapState({ vuex_page: "pageReset" })
|
},
|
inject: ["appPath"],
|
watch: {
|
vuex_page: {
|
handler(n) {
|
if (n.page === this.$route.path) {
|
this.paged.page = 1;
|
this.init();
|
}
|
},
|
deep: true
|
}
|
},
|
methods: {
|
classification() {
|
this.$router.push("/jh_work_classification");
|
},
|
onEdit(e) {
|
this.appPath("jh_work_edit/" + e.id);
|
},
|
onDel(e) {
|
this.$js.model("删除", "确认删除?", res => {
|
if (res) {
|
this.$api.post(
|
"Jinhui/delectworkguide?workGuideId=" + e.id,
|
{ workGuideId: e.id },
|
() => {
|
this.tds = this.tds.filter(r => {
|
return r.id !== e.id;
|
});
|
demo.toast("删除成功");
|
}
|
);
|
}
|
});
|
},
|
onSearch(v) {
|
this.search = demo.copy(v);
|
this.paged.page = 1;
|
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();
|
},
|
//获取所属分类
|
getStatus() {
|
this.$api.post("Jinhui/workGuide/classify/apage", {}, e => {
|
this.bar[1].list = e.records.map(d => {
|
return {
|
value: d.id,
|
label: d.classifyName
|
};
|
});
|
});
|
},
|
// 获取数据
|
init() {
|
let v = demo.copy(
|
Object.assign(this.os, this.search, {
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit
|
})
|
);
|
this.$api.post("Jinhui/pageworkguide", v, e => {
|
this.paged.total = e.total;
|
this.paged.r++;
|
this.tds = e.records;
|
e.records.map((item, index) => {
|
item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
|
});
|
});
|
}
|
},
|
mounted() {
|
this.getStatus();
|
}
|
};
|
</script>
|
<style lang="less" scoped>
|
.shop_work {
|
overflow-y: auto;
|
.add .m_btn {
|
min-width: 80px;
|
}
|
.add,
|
.tab {
|
margin-bottom: 10px;
|
}
|
}
|
</style>
|