<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="tempName">
|
<el-input
|
v-model="queryParams.tempName"
|
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:surveyTemplate:add']"
|
>新增
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
icon="el-icon-edit"
|
size="mini"
|
:disabled="single"
|
@click="handleUpdate1"
|
v-hasPermi="['hosp:surveyTemplate:edit']"
|
>标题修改
|
</el-button>
|
</el-col>
|
<el-col :span="1.5" v-if="details">
|
<el-button
|
type="primary"
|
icon="el-icon-edit"
|
size="mini"
|
:disabled="single"
|
@click="handleUpdate"
|
v-hasPermi="['hosp:surveyTemplate: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:surveyTemplate: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:surveyTemplate:export']"
|
>导出
|
</el-button>
|
</el-col>
|
<right-toolbar
|
:showSearch.sync="showSearch"
|
@queryTable="getList"
|
></right-toolbar>
|
</el-row>
|
|
<el-table
|
border
|
v-loading="loading"
|
:data="surveyTemplateList"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="40px" align="center" />
|
<el-table-column label="序号" align="center" prop="newID" width="50px" />
|
<el-table-column label="模板名称" align="center" prop="tempName" />
|
<el-table-column label="模板类型" align="center" prop="tempType">
|
<template slot-scope="scope">
|
<dict-tag
|
:options="dict.type.question_template_type"
|
:value="scope.row.tempType"
|
/>
|
</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="qybz">
|
<template slot-scope="scope" v-if="scope.row.userId !== 1">
|
<el-switch
|
v-model="scope.row.qybz"
|
active-value="0"
|
inactive-value="1"
|
@change="handleStatusChange(scope.row)"
|
></el-switch>
|
</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"
|
>
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-view"
|
@click="xiangqing(scope.row)"
|
v-hasPermi="['web:tags:edit']"
|
title="预览"
|
></el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['hosp:surveyTemplate:edit']"
|
title="修改"
|
>
|
</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['hosp:surveyTemplate: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="450px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="模板名称" prop="tempName">
|
<el-input v-model="form.tempName" placeholder="请输入模板名称" />
|
</el-form-item>
|
<el-form-item label="模板类型" prop="tempType">
|
<el-select v-model="form.tempType" style="width: 100%">
|
<el-option
|
v-for="dict in dict.type.question_template_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
</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-drawer
|
title="问卷详情"
|
:visible.sync="drawer"
|
:with-header="true"
|
size="40%"
|
>
|
<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: 280px"
|
/>
|
<!-- <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>
|
<!-- <el-button type="primary" size="mini" @click="tijiao">提交</el-button> -->
|
</el-drawer>
|
<el-drawer
|
:visible.sync="previewDialogVisible"
|
:before-close="handleClose"
|
size="40%"
|
>
|
<pre-view :key="previewKey" :preview-qrcode="true" />
|
</el-drawer>
|
</div>
|
</template>
|
|
<script>
|
import PreView from "./editor/preview";
|
import VueQr from "vue-qr";
|
import {
|
listSurveyTemplate,
|
getSurveyTemplate,
|
delSurveyTemplate,
|
addSurveyTemplate,
|
updateSurveyTemplate,
|
getneedDesign,
|
getcanDelete,
|
updateQybz,
|
getQuesByMid,
|
} from "@/api/hosp/surveyTemplate";
|
import { Message } from "element-ui";
|
export default {
|
inject: ["reload"],
|
name: "SurveyTemplate",
|
components: {
|
PreView,
|
VueQr,
|
},
|
dicts: ["question_template_type"],
|
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 {
|
inpu: "",
|
num: 0,
|
myscore: null,
|
// 遮罩层
|
loading: true,
|
drawer: false,
|
previewKey: +new Date(),
|
previewDialogVisible: false,
|
// 选中数组
|
ids: [],
|
// 子表选中数据
|
checkedTjSurveyTempQues: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 问卷模板表格数据
|
surveyTemplateList: [],
|
// 问卷模板问题表格数据
|
tjSurveyTempQuesList: [],
|
selectionList: [],
|
// 弹出层标题
|
title: "",
|
intList: [],
|
// 是否显示弹出层
|
open: false,
|
DaTianYa: false,
|
details: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
tempName: null,
|
tempType: null,
|
deleted: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
deleted: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
},
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询问卷模板列表 */
|
getList() {
|
this.loading = true;
|
listSurveyTemplate(this.queryParams).then((response) => {
|
this.surveyTemplateList = 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 = {
|
mid: null,
|
tempName: null,
|
tempType: null,
|
remark: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
deleted: null,
|
};
|
this.tjSurveyTempQuesList = [];
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
console.log(selection);
|
this.ids = selection.map((item) => item.mid);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
if (selection.length != 0) {
|
selection.forEach((item) => {
|
if (item.designId != null) {
|
this.details = true;
|
} else {
|
this.details = false;
|
}
|
});
|
} else {
|
this.details = false;
|
}
|
},
|
handleTjSurveyTempQuesSelectionChange(selection) {
|
this.selectionList = [];
|
this.selectionList = selection;
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.title = "添加问卷模板";
|
|
getneedDesign().then((res) => {
|
if (res.msg == "false") {
|
this.DaTianYa = false;
|
} else {
|
this.DaTianYa = true;
|
}
|
this.open = true;
|
});
|
},
|
// 新增行
|
addmembers() {
|
if (this.form.tempName) {
|
if (!this.form.tjSurveyTempQuesList) {
|
this.form.tjSurveyTempQuesList = [];
|
this.form.tjSurveyTempQuesList.push({
|
id: parseInt(length),
|
qid: "",
|
qname: "",
|
Selection,
|
});
|
} else {
|
this.form.tjSurveyTempQuesList.push({
|
id: parseInt(length),
|
qid: "",
|
qname: "",
|
Selection,
|
});
|
}
|
} else {
|
Message.warning("请先填写模板名称");
|
}
|
this.$forceUpdate();
|
},
|
// 删除行
|
Delete() {
|
let that = this;
|
if (!that.selectionList) {
|
that.$modal.msgSuccess("请选择需要删除的数据");
|
} else {
|
that.selectionList.forEach((item) => {
|
that.form.tjSurveyTempQuesList.forEach((item1, index) => {
|
if (item.qid == item1.qid) {
|
that.form.tjSurveyTempQuesList.splice(index, 1);
|
}
|
});
|
});
|
}
|
},
|
xiangqing(row) {
|
const mid = row.mid;
|
getSurveyTemplate(mid).then((response) => {
|
if (response.data.designId == null) {
|
this.drawer = true;
|
getQuesByMid(mid)
|
.then((res) => {
|
res.data.sort(
|
(a, b) =>
|
new Date(a.createTime).getTime() -
|
new Date(b.createTime).getTime()
|
); //这是升序,倒序的话翻过来
|
this.intList = res.data;
|
})
|
.catch((err) => {
|
// 通过catch捕获错误消息
|
return err;
|
});
|
} else {
|
this.$router.push({
|
query: { key: response.data.designId },
|
});
|
this.previewDialogVisible = true;
|
}
|
});
|
},
|
handleClose() {
|
this.reload();
|
this.previewDialogVisible = false;
|
},
|
handleStatusChange(row) {
|
let text = row.qybz === "0" ? "启用" : "停用";
|
this.$modal
|
.confirm('确认要"' + text + '""' + row.tempName + '"问卷吗?')
|
.then(function () {
|
return updateQybz(row.mid, row.qybz);
|
})
|
.then(() => {
|
this.$modal.msgSuccess(text + "成功");
|
})
|
.catch(function () {
|
row.qybz = row.qybz === "0" ? "1" : "0";
|
});
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const mid = row.mid || this.ids;
|
getSurveyTemplate(mid).then((response) => {
|
this.form = response.data;
|
if (response.data.tjSurveyTempQuesList.length >= 1) {
|
this.form.tjSurveyTempQuesList = response.data.tjSurveyTempQuesList;
|
}
|
if (this.form.designId == null) {
|
this.DaTianYa = false;
|
this.title = "修改问卷模板";
|
this.open = true;
|
} else {
|
this.DaTianYa = true;
|
this.form.formKey = this.form.designId;
|
this.form.type = 1;
|
this.toProjectHandle(this.form, "editor");
|
}
|
});
|
},
|
|
/** 修改按钮操作 */
|
handleUpdate1(row) {
|
this.reset();
|
const mid = row.mid || this.ids;
|
getSurveyTemplate(mid).then((response) => {
|
this.form = response.data;
|
if (response.data.tjSurveyTempQuesList.length >= 1) {
|
this.form.tjSurveyTempQuesList = response.data.tjSurveyTempQuesList;
|
}
|
this.DaTianYa = false;
|
this.title = "修改问卷模板";
|
this.open = true;
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.mid != null) {
|
updateSurveyTemplate(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addSurveyTemplate(this.form).then((response) => {
|
if (this.DaTianYa == false) {
|
this.$modal.msgSuccess("新增成功");
|
} else {
|
this.toProjectHandle(response.data, "editor");
|
}
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
toProjectHandle(form, type) {
|
this.$router.push({
|
path: "/editor/moban",
|
query: { key: form.formKey, active: type, type: form.type },
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const mids = row.mid || this.ids;
|
this.$modal
|
.confirm('是否确认删除院区信息编号为"' + mids + '"的数据项?')
|
.then(function () {
|
let id = row.mid;
|
return getcanDelete(id).then((res) => {
|
if (res.data == true) {
|
delSurveyTemplate(mids);
|
} else {
|
this.$modal.msgError("问卷正在使用中");
|
}
|
});
|
// return delSurveyTemplate(mids);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {
|
this.$modal.msgError("问卷正在使用中");
|
});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"hosp/surveyTemplate/export",
|
{
|
...this.queryParams,
|
},
|
`hosp_${new Date().getTime()}.xlsx`
|
);
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
|
.pag1 {
|
width: 30%;
|
}
|
</style>
|