|
@@ -0,0 +1,450 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.title"
|
|
|
+ placeholder="请输入标题"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <!--<el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-hasPermi="['asking:question:add']"
|
|
|
+ >新增</el-button>-->
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="el-icon-edit"
|
|
|
+ size="mini"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ v-hasPermi="['asking:question:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="el-icon-delete"
|
|
|
+ size="mini"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete"
|
|
|
+ v-hasPermi="['asking:question:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <!-- <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="mini"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['asking:question:export']"
|
|
|
+ >导出</el-button>
|
|
|
+ </el-col>-->
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="questionList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="标题" align="center" prop="title" />
|
|
|
+ <el-table-column label="是否首页展示" align="center" prop="whetherShow">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-switch
|
|
|
+ v-model="scope.row.whetherShow"
|
|
|
+ active-value="Y"
|
|
|
+ inactive-value="N"
|
|
|
+ @change="handleSwitchChange(scope.row)"
|
|
|
+ ></el-switch>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="提问类型" align="center" prop="type" />
|
|
|
+ <el-table-column label="悬赏积分" align="center" prop="score" />
|
|
|
+ <el-table-column label="审核状态" align="center" prop="status">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="dict.type.examine_state"
|
|
|
+ :value="scope.row.status"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ v-if="scope.row.status == '3'"
|
|
|
+ @click="examine(scope.row,1)"
|
|
|
+ v-hasPermi="['asking:question:examine']"
|
|
|
+ >审核</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ @click="examine(scope.row,2)"
|
|
|
+ v-hasPermi="['asking:question:examine']"
|
|
|
+ >查看</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ v-if="scope.row.status != '1'"
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
+ v-hasPermi="['asking:question:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ v-if="scope.row.status != '1'"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['asking:question:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改问答列-问题对话框 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input v-model="form.title" placeholder="请输入标题" maxlength="50"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="正文" prop="text">
|
|
|
+ <editor v-model="form.text" :min-height="192" maxlength="1000"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否首页展示" prop="whetherShow">
|
|
|
+ <el-select v-model="form.whetherShow" placeholder="请选择是否首页展示">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in dict.type.sys_yes_no"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="提问类型" prop="typeId">
|
|
|
+ <el-select v-model="form.typeId" filterable placeholder="请选择提问类型">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in typeList"
|
|
|
+ :key="dict.id"
|
|
|
+ :label="dict.type"
|
|
|
+ :value="dict.id"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="悬赏积分" prop="score">
|
|
|
+ <el-input-number v-model="form.score" :min="0" :max="999999" label="请输入悬赏积分" disabled></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片" prop="path">
|
|
|
+ <image-upload v-model="form.path"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 审核 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="open1" width="700px" append-to-body>
|
|
|
+ <el-form ref="form1" :model="form1" label-width="100px">
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input v-model="form1.title" placeholder="请输入标题" disabled/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="正文" prop="text">
|
|
|
+ <editor v-model="form1.text" :min-height="192" disabled/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否首页展示" prop="whetherShow">
|
|
|
+ <el-select v-model="form1.whetherShow" placeholder="请选择是否首页展示" disabled>
|
|
|
+ <el-option
|
|
|
+ v-for="dict in dict.type.sys_yes_no"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="提问类型" prop="type">
|
|
|
+ <el-select v-model="form1.typeId" filterable placeholder="请选择提问类型" disabled>
|
|
|
+ <el-option
|
|
|
+ v-for="dict in typeList"
|
|
|
+ :key="dict.id"
|
|
|
+ :label="dict.type"
|
|
|
+ :value="dict.id"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="悬赏积分" prop="score">
|
|
|
+ <el-input v-model="form1.score" placeholder="请输入悬赏积分" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片" prop="path">
|
|
|
+ <image-upload v-model="form1.path"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button v-if="form1.a == '1'" type="primary" @click="through(1)">通 过</el-button>
|
|
|
+ <el-button v-if="form1.a == '1'" type="primary" @click="through(2)">不通过</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { listQuestion, getQuestion, delQuestion, addQuestion, updateQuestion, listType,through } from "@/api/asking/question";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "Question",
|
|
|
+ dicts: ['sys_yes_no','examine_state'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 遮罩层
|
|
|
+ loading: true,
|
|
|
+ // 选中数组
|
|
|
+ ids: [],
|
|
|
+ // 非单个禁用
|
|
|
+ single: true,
|
|
|
+ // 非多个禁用
|
|
|
+ multiple: true,
|
|
|
+ // 显示搜索条件
|
|
|
+ showSearch: true,
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 问答列-问题表格数据
|
|
|
+ questionList: [],
|
|
|
+ //类型配置
|
|
|
+ typeList: [],
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ open1: false,
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ title: null,
|
|
|
+ text: null,
|
|
|
+ whetherShow: null,
|
|
|
+ typeId: null,
|
|
|
+ type: null,
|
|
|
+ score: null,
|
|
|
+ status: null,
|
|
|
+ browse: null,
|
|
|
+ dataStatus: null
|
|
|
+ },
|
|
|
+ // 表单参数
|
|
|
+ form: {
|
|
|
+ whetherShow:'N'
|
|
|
+ },
|
|
|
+ form1:{},
|
|
|
+ // 表单校验
|
|
|
+ rules: {
|
|
|
+ title: [
|
|
|
+ { required: true, message: "标题不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ text: [
|
|
|
+ { required: true, message: "正文不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ typeId: [
|
|
|
+ { required: true, message: "提问类型不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ score: [
|
|
|
+ { required: true, message: "悬赏积分不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getList();
|
|
|
+ this.getTypeList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /**点击开关 */
|
|
|
+ handleSwitchChange(row) {
|
|
|
+ this.form.id = row.id
|
|
|
+ this.form.whetherShow = row.whetherShow
|
|
|
+ updateQuestion(this.form).then(response => {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ // 在这里处理开关状态改变后的逻辑,例如发送一个请求到服务器
|
|
|
+ // console.log('Switch value:', row.homeDisplay);
|
|
|
+ },
|
|
|
+ /** 查询问答列-问题列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ listQuestion(this.queryParams).then(response => {
|
|
|
+ this.questionList = response.rows;
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //查询类型配置
|
|
|
+ getTypeList() {
|
|
|
+ listType(this.queryParams).then(response => {
|
|
|
+ this.typeList = response.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.open1 = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ // 表单重置
|
|
|
+ reset() {
|
|
|
+ this.form = {
|
|
|
+ id: null,
|
|
|
+ title: null,
|
|
|
+ text: null,
|
|
|
+ whetherShow: 'N',
|
|
|
+ typeId: null,
|
|
|
+ score: null,
|
|
|
+ status: null,
|
|
|
+ browse: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ dataStatus: null
|
|
|
+ };
|
|
|
+ this.resetForm("form");
|
|
|
+
|
|
|
+ this.form1 = {
|
|
|
+ id: null,
|
|
|
+ name: null,
|
|
|
+ phone: null,
|
|
|
+ idCard: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ status: null,
|
|
|
+ delFlag: null
|
|
|
+ };
|
|
|
+ this.resetForm("form1");
|
|
|
+ },
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ /** 重置按钮操作 */
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+ // 多选框选中数据
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.ids = selection.map(item => item.id)
|
|
|
+ this.single = selection.length!==1
|
|
|
+ this.multiple = !selection.length
|
|
|
+ },
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd() {
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加问答列-问题";
|
|
|
+ },
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.reset();
|
|
|
+ const id = row.id || this.ids
|
|
|
+ getQuestion(id).then(response => {
|
|
|
+ this.form = response.data;
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改问答列-问题";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 审核 */
|
|
|
+ examine(row,a) {
|
|
|
+ this.reset();
|
|
|
+ const id = row.id || this.ids
|
|
|
+ getQuestion(id).then(response => {
|
|
|
+ this.form1 = response.data;
|
|
|
+ this.form1.a = a
|
|
|
+ this.open1 = true;
|
|
|
+ if (a == 1){
|
|
|
+ this.title = "审核";
|
|
|
+ }else {
|
|
|
+ this.title = "查看";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 审核通过 */
|
|
|
+ through(status) {
|
|
|
+ this.form1.status = status;
|
|
|
+ through(this.form1).then(response => {
|
|
|
+ this.open1 = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ this.form.type = this.typeList.filter((item) => {
|
|
|
+ return this.form.typeId == item.id;
|
|
|
+ })[0].type;
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.id != null) {
|
|
|
+ this.form.status = 3
|
|
|
+ updateQuestion(this.form).then(response => {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addQuestion(this.form).then(response => {
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ const ids = row.id || this.ids;
|
|
|
+ this.$modal.confirm('是否确认删除选中的数据项?').then(function() {
|
|
|
+ return delQuestion(ids);
|
|
|
+ }).then(() => {
|
|
|
+ this.getList();
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 导出按钮操作 */
|
|
|
+ handleExport() {
|
|
|
+ this.download('asking/question/export', {
|
|
|
+ ...this.queryParams
|
|
|
+ }, `question_${new Date().getTime()}.xlsx`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|