<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="qyzt">
|
<el-select
|
v-model="queryParams.qyzt"
|
placeholder="请选择启用状态"
|
clearable
|
>
|
<el-option
|
v-for="dict in dict.type.dict_status"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
/>
|
</el-select>
|
</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:sendTemplate: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:sendTemplate: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:sendTemplate:remove']"
|
>删除
|
</el-button>
|
</el-col>
|
<right-toolbar
|
:showSearch.sync="showSearch"
|
@queryTable="getList"
|
></right-toolbar>
|
</el-row>
|
|
<el-table
|
v-loading="loading"
|
:data="biaoqianList"
|
@selection-change="handleSelectionChange"
|
border
|
>
|
<el-table-column type="selection" width="45" align="center" />
|
<el-table-column
|
label="序号"
|
align="center"
|
prop="newID"
|
width="60"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="编码"
|
align="center"
|
prop="id"
|
width="100"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="名称"
|
align="center"
|
prop="kjbq"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="用户名称"
|
align="center"
|
prop="userName"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="启用状态"
|
align="center"
|
prop="qyzt"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<el-switch
|
v-model="scope.row.qyzt"
|
active-value="0"
|
inactive-value="1"
|
@change="changeSwitch(scope.row)"
|
></el-switch>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="创建人"
|
align="center"
|
prop="createBy"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="创建时间"
|
align="center"
|
prop="createTime"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="操作"
|
align="center"
|
class-name="small-padding fixed-width"
|
width="120"
|
>
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['hosp:sendTemplate:edit']"
|
title="修改"
|
>
|
</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['hosp:sendTemplate: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="500px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="名称" prop="kjbq">
|
<el-input v-model="form.kjbq" 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 {
|
getTjAdviceKjbqByFl,
|
getInfo,
|
addTjAdviceKjbq,
|
updateTjAdviceKjbq,
|
updateQybzTjAdviceKjbqById,
|
deletedTjAdviceKjbq
|
} from "@/api/system/biaoqianzidian";
|
|
export default {
|
name: "SendTemplate",
|
dicts: ["dict_status", "sys_normal_disable"],
|
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 {
|
userId: "",
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 邮件短信模板表格数据
|
biaoqianList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
userId: null,
|
qyzt: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
tempTitle: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
tempContent: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "blur",
|
},
|
],
|
tempType: [
|
{
|
required: true,
|
validator: checkPhoneNum,
|
trigger: "change",
|
},
|
],
|
},
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询邮件短信模板列表 */
|
getList() {
|
getInfo().then((res) => {
|
this.userId = res.user.userId;
|
});
|
this.loading = true;
|
if (this.userId == "1") {
|
this.queryParams.userId = null;
|
} else {
|
this.queryParams.userId = this.userId;
|
}
|
getTjAdviceKjbqByFl(this.queryParams).then((response) => {
|
response.data.records.forEach((item, index) => {
|
item.newID =
|
(this.queryParams.pageNum - 1) * this.queryParams.pageSize +
|
index +
|
1;
|
});
|
this.biaoqianList = response.data.records;
|
// this.biaoqianList.forEach(item=>{
|
// console.log(this.biaoqianList);
|
// })
|
this.total = response.data.total;
|
this.loading = false;
|
});
|
},
|
// 开关事件
|
changeSwitch(row) {
|
this.rows = row;
|
let qybz = row.qyzt;
|
let text = row.qyzt === "0" ? "启用" : "停用";
|
this.$modal
|
.confirm('确认要"' + text + '""' + row.kjbq + '"模板吗?')
|
.then(function () {
|
return updateQybzTjAdviceKjbqById(row.id, qybz);
|
})
|
.then(() => {
|
this.$modal.msgSuccess(text + "成功");
|
this.getList();
|
})
|
.catch(function () {
|
row.qyzt = row.qyzt === "0" ? "1" : "0";
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
tempTitle: null,
|
tempContent: null,
|
tempType: null,
|
deleted: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
flag: null,
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
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;
|
this.form = row;
|
this.open = true;
|
// this.title = "修改快捷标签";
|
// getSendTemplate(id).then((response) => {
|
//
|
//
|
// });
|
},
|
|
// 删除模板
|
handleDelete(row) {
|
const ids = row.id || this.ids;
|
this.$modal
|
.confirm('是否确认删除标签字典编号为"' + ids + '"的数据项?')
|
.then(function () {
|
return deletedTjAdviceKjbq(ids);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
|
// 导出模板
|
handleExport() {
|
this.download(
|
"hosp/sendTemplate/export",
|
{
|
...this.queryParams,
|
},
|
`order_${new Date().getTime()}.xlsx`
|
);
|
},
|
// 模板新增或修改
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.id != null) {
|
updateTjAdviceKjbq(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addTjAdviceKjbq(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
},
|
};
|
</script>
|
|
<style>
|
.pag {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
.pag1 {
|
width: 30%;
|
}
|
</style>
|