<template>
|
<div
|
class="box-card"
|
v-loading="loading"
|
element-loading-text="拼命加载中"
|
element-loading-spinner="el-icon-loading"
|
>
|
<div class="box-content">
|
<v-header title="问题留言"></v-header>
|
<!-- 搜索操作 -->
|
<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.nickName"
|
placeholder="请输入用户昵称"
|
@keyup.enter="handleAction('search')"
|
></el-input>
|
</div>
|
<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.name"
|
placeholder="请输入用户姓名"
|
@keyup.enter="handleAction('search')"
|
></el-input>
|
</div>
|
<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.phone"
|
placeholder="请输入手机号"
|
@keyup.enter="handleAction('search')"
|
></el-input>
|
</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:btn="scope">
|
<!-- <el-button type="text" @click="handleAction('edit', scope.row)"-->
|
<!-- >编辑</el-button-->
|
<!-- >-->
|
<el-button type="text" @click="handleAction('delete', scope.row)"
|
>删除</el-button
|
>
|
<el-button type="text" v-if="scope.row.reply" @click="handleAction('reply', scope.row)"
|
>回复</el-button
|
>
|
<el-button type="text" v-else @click="handleAction('editReply', 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"
|
>
|
<el-form-item label="">
|
<div>{{ feedInfo.content }}</div>
|
</el-form-item>
|
<el-form-item label="" v-if="feedInfo.photoPath">
|
<el-image
|
style="width: 100px; height: 100px"
|
:src="feedInfo.photoPath"
|
:preview-src-list="[feedInfo.photoPath]"
|
fit="cover"></el-image>
|
</el-form-item>
|
<el-form-item label="内容" prop="reply">
|
<el-input
|
type="textarea"
|
class="textarea-width"
|
:rows="5"
|
resize="none"
|
placeholder="请输入回复内容"
|
maxlength="300"
|
clearable
|
show-word-limit
|
v-model="formInfo.reply"
|
></el-input>
|
</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 { 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: "nickName" },
|
{ label: "用户姓名", key: "name" },
|
{ label: "手机号", key: "phone" },
|
{ label: "反馈意见", key: "content" },
|
{ label: "反馈时间", key: "createAt" },
|
{
|
type: "custom",
|
label: "操作",
|
width: "200",
|
slot: "btn",
|
},
|
], // 列表属性
|
dialogTitle: "", // 弹框标题
|
dialogVisible: false, // 弹框状态
|
pageNum: 1, // 当前页
|
pageSize: 10, // 当前条数
|
total: 0, // 总数
|
feedInfo: {},
|
formInfo: {
|
reply: "",
|
}, // 表单
|
rules: {
|
reply: [
|
{
|
required: true,
|
message: "请输入回复内容",
|
trigger: "blur",
|
},
|
],
|
}, // 表单验证
|
searchVal: {
|
name: "",
|
nickName: "",
|
phone: "",
|
},
|
};
|
},
|
mounted() {
|
this.getTable();
|
},
|
methods: {
|
// 获取列表
|
getTable() {
|
this.loading = true;
|
const requestData = Object.assign(
|
{
|
pageNum: this.pageNum,
|
pageSize: this.pageSize,
|
type: 2,
|
},
|
this.searchVal
|
);
|
this.$api.post("feedBack/pagefeedbackProperty", 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) {
|
console.log(row)
|
switch (type) {
|
// 新增
|
case "reply": {
|
this.dialogTitle = "回复";
|
this.feedInfo = row;
|
this.formInfo.id = row.id;
|
this.formInfo.reply = row.reply
|
this.dialogVisible = true;
|
break;
|
}
|
case "editReply": {
|
this.dialogTitle = "回复";
|
this.feedInfo = row;
|
this.formInfo.id = row.id;
|
this.formInfo.reply = row.reply
|
this.dialogVisible = true;
|
break;
|
}
|
// 编辑
|
case "edit": {
|
this.dialogTitle = "修改回复";
|
this.$api.get(`feedBack/feedback/${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.del("feedBack/feedback?id=" + row.id, { 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("feedBack/feedback", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
this.getTable();
|
});
|
} else {
|
this.$api.post("feedBack/feedback", 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 = {
|
reply: "",
|
};
|
this.dialogVisible = false;
|
},
|
},
|
};
|
</script>
|
<style>
|
.el-dialog {
|
width: 800px !important;
|
}
|
</style>
|
<style scoped>
|
.textarea-width {
|
width: 400px;
|
}
|
</style>
|