<template>
|
<div
|
class="box-card"
|
v-loading="loading"
|
element-loading-text="拼命加载中"
|
element-loading-spinner="el-icon-loading"
|
>
|
<div class="box-content">
|
<!-- 搜索操作 -->
|
<div class="search-input-box">
|
<div class="fl-fw">
|
<div class="fl-al mr-b-10">
|
<div class="fz-7 label-width-search">关键字:</div>
|
<el-input
|
clearable
|
class="iw-220"
|
v-model.trim="searchVal.keyword"
|
placeholder="请输入姓名、手机号"
|
@keyup.enter="handleAction('search')"
|
></el-input>
|
</div>
|
<div class="fl-al mr-b-10">
|
<div class="fz-7 label-width-search">预警信息推送:</div>
|
<el-select
|
class="iw-220"
|
v-model="searchVal.pushStatus"
|
placeholder="选择预警信息推送"
|
clearable
|
filterable
|
>
|
<el-option
|
v-for="item in earlyWarningLabel"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
></el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="fl-al mr-b-10">
|
<div class="fz-7 label-width-search"></div>
|
<el-button type="primary" @click="handleAction('search')"
|
>搜索</el-button
|
>
|
<el-button @click="handleAction('reset')">重置</el-button>
|
</div>
|
</div>
|
<!-- 列表 -->
|
<div class="table-content">
|
<!-- 新增按钮 -->
|
<div class="fl-al mr-b-10">
|
<el-button type="primary" @click="handleAction('add')"
|
>新增</el-button
|
>
|
</div>
|
<!-- 列表 -->
|
<TablePro :tableLsit="tableLsit" :columnList="columnList">
|
<template v-slot:pushStatus="scope">
|
<el-tag v-if="scope.row.pushStatus === 1">推送</el-tag>
|
<el-tag type="info" v-if="scope.row.pushStatus === 0"
|
>不推送</el-tag
|
>
|
</template>
|
<template v-slot:btn="scope">
|
<el-button type="text" @click="handleAction('edit', scope.row)"
|
>编辑</el-button
|
>
|
<el-button type="text" @click="handleAction('delete', scope.row)"
|
>删除</el-button
|
>
|
</template>
|
</TablePro>
|
<!-- 分页 -->
|
<div class="bottom-page">
|
<el-pagination
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="pageNum"
|
:page-sizes="[10, 20, 30, 40]"
|
:page-size="pageSize"
|
background
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total"
|
></el-pagination>
|
</div>
|
</div>
|
<!-- 新增编辑弹框 -->
|
<el-dialog
|
:close-on-click-modal="false"
|
:title="dialogTitle"
|
:visible.sync="dialogVisible"
|
:before-close="handleClose"
|
center
|
append-to-body
|
>
|
<el-form
|
:model="formInfo"
|
:rules="rules"
|
label-position="right"
|
ref="ruleForm"
|
label-width="120px"
|
class="demo-ruleForm"
|
>
|
<div class="fl-fw">
|
<el-form-item label="姓名" prop="name">
|
<el-input
|
class="input-width"
|
placeholder="请输入姓名"
|
v-model.trim="formInfo.name"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="手机号" prop="phone">
|
<el-input
|
class="input-width"
|
placeholder="请输入手机号"
|
maxlength="11"
|
v-model.trim="formInfo.phone"
|
></el-input>
|
</el-form-item>
|
</div>
|
<el-form-item label="预警信息推送" prop="pushStatus">
|
<div class="input-width">
|
<el-radio v-model="formInfo.pushStatus" :label="1">推送</el-radio>
|
<el-radio v-model="formInfo.pushStatus" :label="0"
|
>不推送</el-radio
|
>
|
</div>
|
</el-form-item>
|
</el-form>
|
<div class="fl-cen">
|
<el-button @click="handleClose">取 消</el-button>
|
<el-button
|
type="primary"
|
@click="handleAction('submit')"
|
:loading="btnloading"
|
>提交</el-button
|
>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
<script>
|
import { SUBSCRIBE_LABEL, EARLYWARNING_LABEL } from "../../utils/dictionary";
|
import { PHONE } from "../../utils/validation";
|
import { objCopyPro, showToast } from "../../utils/common";
|
export default {
|
data() {
|
return {
|
loading: false, // 页面loading
|
btnloading: false, // 提交按钮loading
|
tableLsit: [], // 列表
|
columnList: [
|
{ type: "index" },
|
{ label: "姓名", key: "name" },
|
{ label: "手机号", key: "phone" },
|
{ type: "custom", label: "预警信息推送", slot: "pushStatus" },
|
{
|
type: "custom",
|
label: "操作",
|
width: "150",
|
slot: "btn",
|
},
|
], // 列表属性
|
dialogTitle: "", // 弹框标题
|
dialogVisible: false, // 弹框状态
|
pageNum: 1, // 当前页
|
pageSize: 10, // 当前条数
|
total: 0, // 总数
|
formInfo: {
|
name: "",
|
phone: "",
|
pushStatus: 1,
|
}, // 表单
|
rules: {
|
name: [
|
{
|
required: true,
|
message: "请输入姓名",
|
trigger: "blur",
|
},
|
],
|
phone: [
|
{
|
required: true,
|
trigger: "blur",
|
validator: PHONE,
|
},
|
],
|
pushStatus: [
|
{
|
required: true,
|
message: "请选择预警信息推送",
|
trigger: "blur",
|
},
|
],
|
}, // 表单验证
|
searchVal: {
|
keyword: "",
|
pushStatus: "",
|
},
|
subcribeLabel: SUBSCRIBE_LABEL,
|
earlyWarningLabel: EARLYWARNING_LABEL,
|
};
|
},
|
mounted() {
|
this.getTable();
|
},
|
methods: {
|
// 获取列表
|
getTable() {
|
this.loading = true;
|
const requestData = Object.assign(
|
{
|
page: this.pageNum,
|
size: this.pageSize,
|
},
|
this.searchVal
|
);
|
this.$api.post("comActAcidMember/queryAll", requestData, (res) => {
|
this.loading = false;
|
this.tableLsit = res.records;
|
this.total = res.total;
|
});
|
},
|
// 切换条数
|
handleSizeChange(val) {
|
this.pageSize = val;
|
this.getTable();
|
},
|
// 切换页
|
handleCurrentChange(val) {
|
this.pageNum = val;
|
this.getTable();
|
},
|
// 页面操作
|
async handleAction(type, row) {
|
switch (type) {
|
// 新增
|
case "add": {
|
console.log(this.dialogVisible);
|
this.dialogTitle = "新增";
|
this.dialogVisible = true;
|
break;
|
}
|
// 编辑
|
case "edit": {
|
this.dialogTitle = "编辑";
|
this.$api.get(`comActAcidMember/${row.id}`, {}, (res) => {
|
this.formInfo = objCopyPro(this.formInfo, res);
|
this.dialogVisible = true;
|
});
|
break;
|
}
|
// 重置
|
case "reset": {
|
this.pageNum = 1;
|
this.pageSize = 10;
|
this.searchVal = { keyword: "", pushStatus: "" };
|
this.getTable();
|
break;
|
}
|
// 删除
|
case "delete": {
|
this.$confirm("此操纵将永久删除该数据,是否继续?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "info",
|
}).then(() => {
|
this.$api.get("comActAcidMember/del", { id: row.id }, () => {
|
showToast("删除成功");
|
this.getTable();
|
});
|
});
|
break;
|
}
|
// 提交
|
case "submit": {
|
this.$refs.ruleForm.validate((val) => {
|
if (val) {
|
this.btnloading = true;
|
if (this.dialogTitle === "新增") {
|
this.$api.post("comActAcidMember", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
this.getTable();
|
});
|
} else {
|
this.$api.post("comActAcidMember/update", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
this.getTable();
|
});
|
}
|
}
|
});
|
break;
|
}
|
// 搜索
|
case "search": {
|
this.pageNum = 1;
|
this.pageSize = 10;
|
this.getTable();
|
break;
|
}
|
default: {
|
break;
|
}
|
}
|
},
|
// 关闭弹框
|
handleClose() {
|
this.$refs.ruleForm.resetFields(); // 重置form表单
|
this.formInfo = {
|
name: "",
|
phone: "",
|
pushStatus: 1,
|
};
|
this.dialogVisible = false;
|
},
|
},
|
};
|
</script>
|
<style>
|
.el-dialog {
|
width: 800px !important;
|
}
|
</style>
|