<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="proName">
|
<el-input
|
v-model="queryParams.proName"
|
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="['advice:advice: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="['advice:advice: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="['advice:advice:remove']"
|
>删除</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
icon="el-icon-download"
|
size="mini"
|
@click="handleExport"
|
v-hasPermi="['advice:advice:export']"
|
>导出</el-button
|
>
|
</el-col>
|
<right-toolbar
|
:showSearch.sync="showSearch"
|
@queryTable="getList"
|
></right-toolbar>
|
</el-row>
|
|
<el-table
|
v-loading="loading"
|
:data="adviceList"
|
@selection-change="handleSelectionChange"
|
border
|
|
>
|
<el-table-column type="selection" width="55" align="center" fixed />
|
<el-table-column label="序号" align="center" prop="newID" width="55px" fixed />
|
<el-table-column label="所选项目" align="center" prop="proName" width="120px" :show-overflow-tooltip="true" />
|
<el-table-column label="标题" align="center" prop="title" width="120px" :show-overflow-tooltip="true" />
|
<el-table-column
|
label="建议"
|
align="center"
|
prop="advice"
|
width="1249px"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="操作"
|
align="center"
|
fixed="right"
|
class-name="small-padding fixed-width"
|
width="80px"
|
>
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['advice:advice:edit']"
|
title="修改"
|
></el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['advice:advice: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.page"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</div>
|
</div>
|
|
<!-- 添加或修改advice对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="检查项目" prop="proName">
|
<el-select
|
v-model="form.proId"
|
placeholder="请输入项目名称"
|
filterable
|
style="width: 240px"
|
clearable
|
>
|
<el-option
|
v-for="dict in projectList"
|
:key="dict.proName"
|
:label="dict.proName"
|
:value="dict.proId"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="建议标题" prop="title">
|
<el-input v-model="form.title" placeholder="请输入名称标题" />
|
</el-form-item>
|
|
<el-form-item label="建议内容" prop="advice">
|
<el-input
|
type="textarea"
|
v-model="form.advice"
|
:autosize="{ minRows: 9, maxRows: 10 }"
|
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>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listAdvice,
|
getAdvice,
|
delAdvice,
|
addAdvice,
|
updateAdvice,
|
} from "@/api/advice/advice";
|
import { listProject } from "@/api/hosp/project";
|
|
export default {
|
name: "Advice",
|
data() {
|
return {
|
projectList: [],
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// advice表格数据
|
adviceList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
page: 1,
|
pageSize: 10,
|
proName: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
proId: [{ required: true, message: "", trigger: "blur" }],
|
},
|
};
|
},
|
created() {
|
this.getList();
|
this.getlistProject();
|
},
|
methods: {
|
/** 查询advice列表 */
|
getList() {
|
this.loading = true;
|
// let data ={
|
// proName:this.queryParams.proName,
|
// page:this.queryParams.page,
|
// pageSize:this.queryParams.pageSize,
|
// }
|
listAdvice(this.queryParams).then((response) => {
|
response.data.list.forEach((item, index) => {item.newID =(this.queryParams.page - 1) * this.queryParams.pageSize +index +1;
|
});
|
this.adviceList = response.data.list;
|
this.total = response.data.total;
|
this.loading = false;
|
});
|
|
},
|
getlistProject(){
|
listProject(this.queryParams).then((response) => {
|
this.projectList = response.data;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
proName: null,
|
title: null,
|
advice: null,
|
createTime: null,
|
createBy: null,
|
updateTime: null,
|
updateBy: null,
|
deleted: null,
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.page = 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;
|
getAdvice(id).then((response) => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "体检建议信息维护";
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.id != null) {
|
updateAdvice(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addAdvice(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const ids = row.id || this.ids;
|
this.$modal
|
.confirm('是否确认删除advice编号为"' + ids + '"的数据项?')
|
.then(function () {
|
return delAdvice(ids);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"advice/advice/export",
|
{
|
...this.queryParams,
|
},
|
`advice_${new Date().getTime()}.xlsx`
|
);
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
.pag1 {
|
width: 30%;
|
}
|
</style>
|