<template>
|
<div class="page_service">
|
<v-header
|
title="工作人员"
|
:bar="bar"
|
search
|
@on-search="onSearch"
|
></v-header>
|
<div class="add">
|
<el-button type="primary" size="small" @click.stop="onAdd"
|
>新增</el-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.id)">删除</span>
|
</div>
|
</template>
|
<template v-slot:url="item">
|
<img
|
:src="item.scope.image"
|
alt=""
|
class="image-sq"
|
@click="onScaleImage(item.scope)"
|
/>
|
</template>
|
<template v-slot:isReg="{ scope }">
|
{{ scope.isReg == 1 ? "是" : "否" }}
|
</template>
|
</v-tool-table>
|
</div>
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
</div>
|
</template>
|
|
<script>
|
import { mapState } from "vuex";
|
import _text from "../../activity/status/_text";
|
export default {
|
props: {},
|
components: { _text },
|
data() {
|
return {
|
bar: [
|
{
|
title: "关键字",
|
name: "keyword",
|
plac: "请输入姓名、手机号",
|
width: "350px !important"
|
}
|
],
|
trs: [
|
{ text: "序号", val: "index" },
|
{ text: "工作人员姓名", val: "name" },
|
{ text: "手机号", val: "phone" },
|
{ text: "职务", val: "position" },
|
{ text: "照片", val: "btn", slot: "url" },
|
{ text: "操作", val: "btn" }
|
],
|
tds: [],
|
paged: { page: 0, total: 0, r: 0, limit: 10 },
|
os: {},
|
search: {},
|
id: "",
|
user: {}
|
};
|
},
|
computed: {
|
...mapState({ vuex_page: "pageReset" })
|
},
|
watch: {
|
vuex_page: {
|
handler(n) {
|
if (n.page === this.$route.path) {
|
// this.paged.page = 1;
|
this.init();
|
}
|
},
|
deep: true
|
}
|
},
|
methods: {
|
onScaleImage(v) {
|
this.$store.dispatch("setImage", {
|
time: Date.now(),
|
title: v.name,
|
pic: v.url
|
});
|
},
|
onEdit(i) {
|
this.$store.dispatch("setFixed", {
|
event: "add",
|
data: {
|
title: "编辑[" + i.name + "]",
|
type: "workPeople-add",
|
data: i
|
},
|
time: Date.now()
|
});
|
},
|
onDel(i) {
|
this.$js.model("", "是否删除", res => {
|
if (res) {
|
this.$api.del(`comPropertyWorker/delete?id=${i}`, {}, e => {
|
demo.toast("删除成功");
|
this.init();
|
});
|
}
|
});
|
},
|
onAdd() {
|
this.$store.dispatch("setFixed", {
|
event: "add",
|
data: {
|
title: "新增",
|
type: "workPeople-add",
|
data: { refId: this.id }
|
},
|
time: Date.now()
|
});
|
},
|
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();
|
},
|
// 获取数据
|
init() {
|
let v = demo.copy(
|
Object.assign(this.os, this.search, {
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit,
|
refId: this.id
|
})
|
);
|
this.$api.post("comPropertyWorker/page", v, e => {
|
e.records.map((item, index) => {
|
item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
|
});
|
this.paged.total = e.total;
|
this.paged.r++;
|
this.tds = e.records || [];
|
});
|
}
|
},
|
mounted() {
|
this.user = demo.$session.get("user");
|
this.id = this.user.propertyId || this.$route.query.id;
|
// this.id = ;
|
}
|
};
|
</script>
|
<style lang="less" scoped>
|
.page_service {
|
overflow-y: auto;
|
.tab,
|
.add {
|
margin-bottom: 10px;
|
}
|
}
|
.image-sq {
|
max-height: 35px !important;
|
max-width: 100% !important;
|
width: 35px;
|
height: 35px;
|
display: initial;
|
}
|
</style>
|