<template>
|
<div class='page_party'>
|
<v-header title="社区党委管理"></v-header>
|
<!-- search-->
|
<!-- :bar="bar"-->
|
<!-- @on-search="onSearch"-->
|
<div class="add">
|
<el-button
|
type="primary"
|
size="small"
|
@click="add"
|
>新增</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="edit(item.scope)"
|
>编辑</span>
|
<span
|
class="col_primary"
|
@click="del(item.scope)"
|
>删除</span>
|
</div>
|
</template>
|
<template v-slot:pic="item">
|
<!-- {{item.scope.id}} -->
|
<img
|
id="image"
|
:src="item.scope.photoPath"
|
@click="onScaleImage(item.scope)"
|
alt=""
|
>
|
</template>
|
<template v-slot:sex="{scope}">
|
{{scope.sex ==1?'男':'女'}}
|
</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>
|
<!--弹出-->
|
<el-dialog
|
:title="title"
|
:modal="false"
|
destroy-on-close
|
:close-on-click-modal="false"
|
:visible.sync="dialogVisible"
|
width="600px"
|
>
|
<div class="dialog-main">
|
<el-form
|
ref="form"
|
label-width="100px"
|
>
|
<el-form-item label="手机号">
|
<el-input
|
v-model="os.phone"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="姓名">
|
<el-input
|
v-model="os.name"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="性别">
|
<el-select
|
v-model="os.sex"
|
placeholder="请选择"
|
>
|
<el-option
|
label="男"
|
:value="1"
|
/>
|
<el-option
|
label="女"
|
:value="2"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="出生年月">
|
<el-date-picker
|
v-model="os.birthTime"
|
type="date"
|
placeholder="选择日期"
|
:picker-options="pickerOptions"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="职位">
|
<el-input
|
v-model="os.position"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="职位二">
|
<el-input
|
v-model="os.positionTwo"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="岗位职责">
|
<el-input
|
type="textarea"
|
v-model="os.jobResponsibilities"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="照片">
|
<div class="avatar">
|
<v-upload
|
:boxWidth="400"
|
:boxHeight="300"
|
:width="250"
|
:height="285"
|
@path="onPath"
|
:pic="os.photoPath"
|
>1
|
</v-upload>
|
</div>
|
|
</el-form-item>
|
</el-form>
|
</div>
|
<span
|
slot="footer"
|
class="dialog-footer"
|
>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
@click="increase()"
|
>确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import vUpload from "com/upload/upload";
|
import { mapState } from "vuex";
|
export default {
|
props: {},
|
components: { vUpload },
|
data() {
|
return {
|
title: "新增",
|
dialogVisible: false,
|
bar: [
|
{ title: "党员姓名", name: "name" },
|
{
|
title: "身份",
|
name: "job",
|
type: "select",
|
list: [],
|
},
|
],
|
trs: [
|
{ text: "党员姓名", val: "name" },
|
{ text: "党员照片", val: "btn", slot: "pic" },
|
{ text: "性别", val: "btn", slot: "sex" },
|
{ text: "年龄", val: "age" },
|
{ text: "手机号", val: "phone" },
|
{ text: "是否注册", val: "btn", slot: "isReg" },
|
{ text: "职位", val: "position" },
|
{ text: "岗位职责", val: "jobResponsibilities" },
|
{ text: "操作", val: "btn" },
|
],
|
tds: [],
|
paged: { page: 0, total: 0, r: 0, limit: 10 },
|
os: {
|
id: "",
|
name: "",
|
photoPath: "",
|
sex: "",
|
age: "",
|
phone: "",
|
position: "",
|
position_two: "",
|
jobResponsibilities: "",
|
birthTime: "",
|
pageNum: 0,
|
pageSize: 0,
|
},
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() > Date.now();
|
},
|
},
|
};
|
},
|
watch: {
|
vuex_page: {
|
handler(n) {
|
if (n.page === this.$route.path) {
|
this.paged.page = 1;
|
this.init();
|
}
|
},
|
deep: true,
|
},
|
},
|
computed: {
|
...mapState({ vuex_page: "pageReset" }),
|
},
|
methods: {
|
updatepartycommittee() {
|
//编辑党委
|
this.$api.put(
|
"communitypartybuilding/updatepartycommittee",
|
this.os,
|
(e) => {
|
this.init();
|
this.dialogVisible = false;
|
}
|
);
|
},
|
increase() {
|
//新增/编辑
|
if (this.title === "编辑") {
|
this.updatepartycommittee();
|
return;
|
}
|
this.$api.post(
|
"communitypartybuilding/addpartycommittee",
|
this.os,
|
(e) => {
|
demo.toast("新增成功")
|
this.init();
|
this.dialogVisible = false;
|
}
|
);
|
},
|
onPath(e) {
|
// console.log(e)
|
this.os.photoPath = e;
|
},
|
// 查看大图
|
onScaleImage(v) {
|
this.$store.dispatch("setImage", {
|
time: Date.now(),
|
title: v.name,
|
pic: v.photoPath,
|
tool: true,
|
});
|
},
|
// 分页点击
|
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();
|
},
|
onSearch(v) {
|
let name = "";
|
if (v.job) {
|
name = this.bar[1].list.filter((k) => {
|
return v.job === k.value;
|
});
|
name = name[0].label;
|
}
|
this.os.roleId = v.job;
|
this.os.roleName = name;
|
this.os.name = v.name;
|
this.init();
|
},
|
_open(type, title, data) {
|
this.$store.dispatch("setFixed", {
|
event: "add",
|
data: {
|
type,
|
data,
|
title,
|
},
|
time: Date.now(),
|
});
|
},
|
// 新增
|
add() {
|
for (let i in this.os) {
|
this.os[i] = "";
|
}
|
this.title = "新增";
|
this.dialogVisible = true;
|
// this._open("party-add", "新增", { id: 0 });
|
},
|
// 编辑
|
edit(i) {
|
this.os = JSON.parse(JSON.stringify(i));
|
this.dialogVisible = true;
|
this.title = "编辑";
|
// this._open("party-add", "编辑[" + i.name + "]", i);
|
},
|
// 删除
|
del(v) {
|
let t = this;
|
t.$js.model("删除党委", "是否删除党委[" + v.name + "]", (res) => {
|
if (res) {
|
t.$api.del("communitypartybuilding/deletepartycommittee", v, () => {
|
demo.toast("删除成功");
|
t.$nextTick(() => {
|
t.init();
|
});
|
});
|
}
|
});
|
},
|
init() {
|
let v = demo.copy(
|
Object.assign(this.os, {
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit,
|
})
|
);
|
this.$api.post("communitypartybuilding/pagepartycommittee", v, (e) => {
|
this.paged.total = e.total;
|
this.paged.r++;
|
this.tds = e.records || [];
|
});
|
},
|
},
|
mounted() {
|
this.$api.identity((e) => {
|
this.bar[1].list = e.map((k) => {
|
return { label: k.roleName, value: k.roleId };
|
});
|
});
|
},
|
};
|
</script>
|
<style lang='less' scoped>
|
#image {
|
margin: auto;
|
max-width: 100px !important;
|
max-height: 100px !important;
|
width: 100px !important;
|
height: 100px !important;
|
}
|
.page_party {
|
overflow-y: auto;
|
.tab,
|
.add {
|
margin-bottom: 10px;
|
}
|
}
|
.dialog-main {
|
padding-right: 20px;
|
}
|
</style>
|