<template>
|
<div class="app-container">
|
<el-row :gutter="20">
|
<el-col :span="4" :xs="24">
|
<div class="head-container">
|
<el-input
|
v-model="deptName"
|
placeholder="请输入科室名称"
|
clearable
|
size="small"
|
prefix-icon="el-icon-search"
|
style="margin-bottom: 15px"
|
/>
|
</div>
|
<el-scrollbar style="height: 629px; width: 100%" class="outside1">
|
<div class="head-container">
|
<el-tree
|
:data="deptOptions"
|
:props="defaultProps"
|
:expand-on-click-node="false"
|
:filter-node-method="filterNode"
|
ref="tree"
|
node-key="id"
|
:default-expanded-keys="treeId"
|
highlight-current
|
@node-click="handleNodeClick"
|
/>
|
</div>
|
</el-scrollbar>
|
</el-col>
|
<el-col :span="20" :xs="24" style="display: flex">
|
<div style="width: 50%">
|
<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="intList"
|
@selection-change="handleSelectionChange"
|
style="width: 96%"
|
>
|
<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"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="类型"
|
align="center"
|
prop="type"
|
:show-overflow-tooltip="true"
|
>
|
<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="keywords"
|
:show-overflow-tooltip="true"
|
/> -->
|
<!-- <el-table-column
|
label="分类"
|
align="center"
|
prop="sort"
|
:show-overflow-tooltip="true"
|
/> -->
|
<el-table-column
|
label="是否必填"
|
align="center"
|
prop="isRequired"
|
:show-overflow-tooltip="true"
|
>
|
<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"
|
:show-overflow-tooltip="true"
|
/> -->
|
<!-- <el-table-column
|
label="创建时间"
|
align="center"
|
prop="createTime"
|
width="180"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
</template>
|
</el-table-column> -->
|
<!-- <el-table-column
|
label="修改人"
|
align="center"
|
prop="updateBy"
|
:show-overflow-tooltip="true"
|
/> -->
|
<!-- <el-table-column
|
label="修改时间"
|
align="center"
|
prop="updateTime"
|
width="180"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.updateTime) }}</span>
|
</template>
|
</el-table-column> -->
|
<!-- <el-table-column
|
label="备注"
|
align="center"
|
prop="remark"
|
:show-overflow-tooltip="true"
|
/> -->
|
<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="handleNodeClick"
|
/>
|
</div>
|
</div>
|
</div>
|
<div style="width: 50%" class="outside1">
|
<el-divider class="custom-divider">{{ mingcheng.tempName }}</el-divider>
|
<el-form
|
v-for="(item, index) in intList"
|
:key="index"
|
style="margin-left: 15px"
|
>
|
<el-form-item>
|
<span
|
style="color: red; margin-left: 5px"
|
v-if="item.isRequired == 'Y'"
|
>*</span
|
>
|
{{ index + 1 > 9 ? index + 1 : "0" + (index + 1) }}.{{
|
item.question
|
}}
|
<span v-if="item.type == '0'">(单选)</span>
|
<span v-if="item.type == '1'">(多选)</span><br />
|
<label
|
v-for="(item5, index) in item.tjSurveyOptionsList"
|
:key="index"
|
>
|
<!-- <img v-show="item.type == '1'" v-if="item5.qid ==item.qid" class="select-radio" src="../../../assets/images/weixuanzhong.png" alt="">
|
<img v-show="item.type == '1'" v-else class="select-radio1" src="../../../assets/images/xuanzhong.png" alt=""> -->
|
<input
|
v-show="item.type == '0'"
|
type="radio"
|
:name="item5.qid"
|
:value="item5.oid"
|
/><label class="inp" v-show="item.type == '0'">{{
|
item5.ooption
|
}}</label>
|
<input
|
v-show="item.type == '1'"
|
type="checkbox"
|
:name="item5.qid"
|
:value="item5.oid"
|
/><label class="inp" v-show="item.type == '1'">{{
|
item5.ooption
|
}}</label>
|
<el-rate
|
v-show="item.type == '2'"
|
v-model="myscore"
|
show-text
|
></el-rate>
|
<el-input
|
v-show="item.type == '3'"
|
v-model="inpu"
|
style="width: 340px"
|
/>
|
<el-date-picker
|
v-show="item.type == '4'"
|
v-model="value2"
|
align="right"
|
type="date"
|
placeholder="选择日期"
|
:picker-options="pickerOptions"
|
>
|
</el-date-picker>
|
<el-input-number
|
v-show="item.type == '5'"
|
v-model="num"
|
:min="1"
|
:max="10000"
|
></el-input-number>
|
<el-input-number
|
v-show="item.type == '6'"
|
v-model="numf"
|
:precision="2"
|
:step="0.0"
|
:max="10000"
|
></el-input-number>
|
</label>
|
</el-form-item>
|
</el-form>
|
</div>
|
</el-col>
|
</el-row>
|
|
<!-- 添加或修改问卷问题对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="542px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
<el-form-item label="问卷名称" prop="mid" style="margin-bottom: 20px">
|
<el-select v-model="form.mid" placeholder="请选择问卷名称">
|
<el-option
|
v-for="dict in wenjuanList"
|
:key="dict.mid"
|
:label="dict.tempName"
|
:value="dict.mid"
|
/>
|
</el-select>
|
<i
|
class="el-icon-circle-plus-outline"
|
@click="tiaozhuan"
|
style="margin-left: 5px"
|
></i>
|
</el-form-item>
|
<el-form-item label="问题" prop="question" style="margin-bottom: 20px">
|
<el-input v-model="form.question" placeholder="请输入问题" />
|
</el-form-item>
|
<el-form-item label="类型" prop="type" style="margin-bottom: 20px">
|
<el-select
|
v-model="form.type"
|
placeholder="请选择类型"
|
style="width: 100%"
|
filterable
|
clearable
|
>
|
<el-option
|
v-for="dict in dict.type.question_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="关键字" prop="keywords">
|
<el-input v-model="form.keywords" placeholder="请输入关键字" />
|
<!-- <el-select
|
v-model="form.type"
|
placeholder="请选择类型"
|
style="width: 100%"
|
filterable
|
clearable
|
>
|
<el-option
|
v-for="dict in dict.type.question_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select> -->
|
</el-form-item>
|
<el-form-item label="分类" prop="sort">
|
<el-input v-model="form.sort" placeholder="请输入分类" />
|
<!-- <el-select
|
v-model="form.type"
|
placeholder="请选择类型"
|
style="width: 100%"
|
filterable
|
clearable
|
>
|
<el-option
|
v-for="dict in dict.type.question_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select> -->
|
</el-form-item>
|
<el-form-item
|
label="必填"
|
prop="isRequired"
|
style="margin-bottom: 20px"
|
>
|
<el-radio v-model="form.isRequired" label="Y">是</el-radio>
|
<el-radio v-model="form.isRequired" label="N">否</el-radio>
|
</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 {
|
PostTemplentList,
|
getQuestionsByMid,
|
delQuestion,
|
addQuestion,
|
updateQuestion,
|
listByDeptId,
|
listByDeptId1
|
} 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) => {
|
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 {
|
mids: "",
|
mingcheng: {},
|
num: 0,
|
inpu: "",
|
myscore: this.value,
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() > Date.now();
|
},
|
shortcuts: [
|
{
|
text: "今天",
|
onClick(picker) {
|
picker.$emit("pick", new Date());
|
},
|
},
|
{
|
text: "昨天",
|
onClick(picker) {
|
const date = new Date();
|
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
picker.$emit("pick", date);
|
},
|
},
|
{
|
text: "一周前",
|
onClick(picker) {
|
const date = new Date();
|
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
picker.$emit("pick", date);
|
},
|
},
|
],
|
},
|
numf: 0,
|
value2: "",
|
intList: [],
|
deptOptions: undefined,
|
defaultProps: {
|
children: "children",
|
label: "name",
|
},
|
treeId: [],
|
deptName: "",
|
wenjuanList: [],
|
// 遮罩层
|
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,
|
},
|
Objdata:{},
|
queryParamse: {
|
pageNum: 1,
|
pageSize: 10000,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
question: [
|
{
|
required: true,
|
message: "问题不能为空",
|
trigger: "blur",
|
},
|
],
|
type: [
|
{
|
required: true,
|
message: "类型不能为空",
|
trigger: "change",
|
},
|
],
|
isRequired: [
|
{
|
required: true,
|
message: "是否必填不能为空",
|
trigger: "blur",
|
},
|
],
|
mid: [{ required: true, message: "问卷名称不能为空", trigger: "blur" }],
|
},
|
};
|
},
|
watch: {
|
// 根据名称筛选部门树
|
deptName(val) {
|
this.$refs.tree.filter(val);
|
},
|
treeId(newVal, oldVal) {
|
if (newVal) {
|
this.$nextTick(() => {
|
document
|
.querySelector(".el-tree-node__children .el-tree-node__content")
|
.click();
|
});
|
}
|
},
|
},
|
created() {
|
// this.getList();
|
this.getWenjuanList();
|
this.getDeptTree();
|
},
|
methods: {
|
/** 查询部门下拉树结构 */
|
getDeptTree() {
|
listByDeptId1().then((response) => {
|
this.deptOptions = response.data;
|
this.treeId.push(this.deptOptions[0].id);
|
});
|
},
|
// 节点单击事件
|
handleNodeClick(data) {
|
this.Objdata = data
|
this.loading = true;
|
this.mids = data.id;
|
let datas = {
|
mid: data.id,
|
pageNum: this.queryParams.pageNum,
|
pageSize: this.queryParams.pageSize,
|
};
|
getQuestionsByMid(datas).then((response) => {
|
// console.log(response);
|
response.data.sort(
|
(a, b) =>
|
new Date(a.createTime).getTime() - new Date(b.createTime).getTime()
|
); //这是升序,倒序的话翻过来
|
this.intList = response.data;
|
this.total = response.total;
|
this.intList.forEach((item) => {
|
if (item.template != null) {
|
this.mingcheng = item.template;
|
}
|
});
|
response.data.forEach((item, index) => {
|
item.newID =
|
(this.queryParams.pageNum - 1) * this.queryParams.pageSize +
|
index +
|
1;
|
});
|
this.loading = false;
|
});
|
},
|
// 筛选节点
|
filterNode(value, data) {
|
if (!value) return true;
|
return data.label.indexOf(value) !== -1;
|
},
|
/** 查询问卷列表 */
|
getWenjuanList() {
|
PostTemplentList(this.queryParamse).then((response) => {
|
this.wenjuanList = response.rows;
|
});
|
},
|
// /** 查询问卷问题列表 */
|
// 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.handleNodeClick();
|
let datas = {
|
mid: this.mids,
|
pageNum: this.queryParams.pageNum,
|
pageSize: this.queryParams.pageSize,
|
question: this.queryParams.question,
|
};
|
getQuestionsByMid(datas).then((response) => {
|
// console.log(response);
|
response.data.sort(
|
(a, b) =>
|
new Date(a.createTime).getTime() - new Date(b.createTime).getTime()
|
); //这是升序,倒序的话翻过来
|
this.intList = response.data;
|
this.total = response.total;
|
this.intList.forEach((item) => {
|
if (item.template != null) {
|
this.mingcheng = item.template;
|
}
|
});
|
response.data.forEach((item, index) => {
|
item.newID =
|
(this.queryParams.pageNum - 1) * this.queryParams.pageSize +
|
index +
|
1;
|
});
|
this.loading = false;
|
});
|
},
|
/** 重置按钮操作 */
|
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();
|
this.form = row;
|
this.form.tjSurveyOptionsList = row.tjSurveyOptionsList;
|
this.form.mid = Number(row.template.mid);
|
this.open = true;
|
this.title = "修改问卷问题";
|
// 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.$tab.refreshPage();
|
this.handleNodeClick(this.Objdata)
|
});
|
} else {
|
addQuestion(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
// this.$tab.refreshPage();
|
this.handleNodeClick(this.Objdata)
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const qids = row.qid || this.ids;
|
this.$modal
|
.confirm('是否确认删除问题编号为"' + qids + '"的数据项?')
|
.then(function () {
|
return delQuestion(qids);
|
})
|
.then(() => {
|
// this.$tab.refreshPage();
|
this.handleNodeClick(this.Objdata)
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"hosp/question/export",
|
{
|
...this.queryParams,
|
},
|
`hosp_${new Date().getTime()}.xlsx`
|
);
|
},
|
tiaozhuan() {
|
this.$router.push({ path: "/wemjuan" });
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: flex-start;
|
margin-left: 339px;
|
}
|
|
.pag1 {
|
width: 30%;
|
}
|
.el-icon-circle-plus-outline {
|
line-height: 20px;
|
font-size: 20px;
|
}
|
.outside1 {
|
width: 500px;
|
max-height: 700px;
|
overflow-y: auto;
|
display: flex;
|
margin-top: 8px;
|
flex-direction: column;
|
}
|
.custom-divider .el-divider__text {
|
font-size: 18px;
|
}
|
</style>
|