<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form-item label="问题" prop="question">
|
<el-input v-model="queryParams.question" 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" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['hosp:question:add']">新增
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
v-hasPermi="['hosp:question:edit']">修改
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button type="primary" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
v-hasPermi="['hosp:question:remove']">删除
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport"
|
v-hasPermi="['hosp:question:export']">导出
|
</el-button>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table border v-loading="loading" :data="questionList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="40" align="center" fixed="left" />
|
<el-table-column label="序号" align="center" prop="newID" width="50px" fixed="left" />
|
<el-table-column label="问题" align="center" prop="question" />
|
<el-table-column label="类型" align="center" prop="type">
|
<template slot-scope="scope">
|
<dict-tag :options="dict.type.question_type" :value="scope.row.type" />
|
</template>
|
</el-table-column>
|
<el-table-column label="是否必填" align="center" prop="isRequired">
|
<template slot-scope="scope">
|
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isRequired" />
|
</template>
|
</el-table-column>
|
<el-table-column label="创建人" align="center" prop="createBy" />
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="修改人" align="center" prop="updateBy" />
|
<el-table-column label="修改时间" align="center" prop="updateTime" width="180">
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.updateTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="备注" align="center" prop="remark" />
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="80px" fixed="right">
|
<template slot-scope="scope">
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
v-hasPermi="['hosp:question:edit']" title="修改">
|
</el-button>
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
v-hasPermi="['hosp:question:remove']" title="删除">
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<div class="pag">
|
<div class="pag1">
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
@pagination="getList" />
|
</div>
|
</div>
|
|
<!-- 添加或修改问卷问题对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="542px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="问题" prop="question">
|
<el-input v-model="form.question" placeholder="请输入问题" />
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
</el-form-item>
|
<el-divider content-position="center">问卷选项信息</el-divider>
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="addmembers()">添加
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click.native.prevent="Delete()">删除
|
</el-button>
|
</el-col>
|
</el-row>
|
<el-table border :data="form.tjSurveyOptionsList" ref="tjSurveyOptions" @selection-change="handleChange">
|
<el-table-column type="selection" width="50" align="center" />
|
<el-table-column label="选项" prop="ooption" width="150">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.ooption" placeholder="请输入选项" />
|
</template>
|
</el-table-column>
|
<el-table-column label="分数" prop="score" width="150">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.score" placeholder="请输入分数" />
|
</template>
|
</el-table-column>
|
<el-table-column label="备注" prop="remark" width="150">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.remark" placeholder="请输入备注" />
|
</template>
|
</el-table-column>
|
</el-table>
|
</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>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listQuestion,
|
getQuestion,
|
delQuestion,
|
addQuestion,
|
updateQuestion,
|
} from "@/api/hosp/question";
|
import { Message } from "element-ui";
|
export default {
|
dicts: ["question_type", "sys_yes_no"],
|
name: "Question",
|
data() {
|
let checkPhoneNum = (rule, value, callback) => {
|
console.log( value)
|
let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
|
if (value == "" && value == undefined && !value) {
|
return callback('');
|
} else if(value != undefined && value != ""){
|
return callback();
|
}else if (!patter.test(value)) {
|
return callback('');
|
}
|
};
|
return {
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 子表选中数据
|
checkedTjSurveyOptions: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 问卷问题表格数据
|
questionList: [],
|
// 问卷选项表格数据
|
tjSurveyOptionsList: [],
|
selectionList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
question: null,
|
type: null,
|
isRequired: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
question: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
type: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "change",
|
},
|
],
|
isRequired: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
deleted: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
},
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询问卷问题列表 */
|
getList() {
|
this.loading = true;
|
listQuestion(this.queryParams).then((response) => {
|
this.questionList = response.rows;
|
response.rows.forEach((item, index) => {
|
item.newID =
|
(this.queryParams.pageNum - 1) * this.queryParams.pageSize +
|
index +
|
1;
|
});
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
qid: null,
|
question: null,
|
type: null,
|
isRequired: "0",
|
remark: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
deleted: null,
|
};
|
this.tjSurveyOptionsList = [];
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map((item) => item.qid);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
},
|
// 新增行
|
addmembers() {
|
if (this.form.question) {
|
if (!this.form.tjSurveyOptionsList) {
|
this.form.tjSurveyOptionsList = [];
|
this.form.tjSurveyOptionsList.push({
|
id: parseInt(length),
|
qid: "",
|
qname: "",
|
Selection,
|
});
|
} else {
|
this.form.tjSurveyOptionsList.push({
|
id: parseInt(length),
|
qid: "",
|
qname: "",
|
Selection,
|
});
|
}
|
} else {
|
Message.warning("请先填写问题");
|
}
|
this.$forceUpdate();
|
},
|
handleChange(selection) {
|
this.selectionList =[]
|
this.selectionList = selection
|
|
},
|
// 删除行
|
Delete() {
|
if (!this.selectionList) {
|
this.$modal.msgSuccess('请选择需要删除的数据')
|
} else {
|
this.selectionList.forEach(item =>{
|
this.form.tjSurveyOptionsList.forEach((item1,index) => {
|
if(item.ooption == item1.ooption){
|
this.form.tjSurveyOptionsList.splice(index, 1);
|
}
|
})
|
})
|
|
}
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.open = true;
|
this.title = "添加问卷问题";
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const qid = row.qid || this.ids;
|
getQuestion(qid).then((response) => {
|
this.form = response.data;
|
this.form.tjSurveyOptionsList = response.data.tjSurveyOptionsList;
|
this.open = true;
|
this.title = "修改问卷问题";
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.qid != null) {
|
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 qids = row.qid || this.ids;
|
this.$modal
|
.confirm('是否确认删除院区信息编号为"' + qids + '"的数据项?')
|
.then(function () {
|
return delQuestion(qids);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => { });
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"hosp/question/export",
|
{
|
...this.queryParams,
|
},
|
`hosp_${new Date().getTime()}.xlsx`
|
);
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
|
.pag1 {
|
width: 30%;
|
}</style>
|