NurseStationOperateUI/src/views/system/classifyItem/index.vue

536 lines
15 KiB
Vue
Raw Normal View History

2023-02-08 16:18:14 +08:00
<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="classifyCode">
<el-input
v-model="queryParams.classifyCode"
placeholder="请输入分类编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="分类名称" prop="classifyName">
<el-input
v-model="queryParams.classifyName"
placeholder="请输入分类名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
2023-02-22 11:10:40 +08:00
<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>
2023-02-08 16:18:14 +08:00
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
2023-02-09 14:25:13 +08:00
v-hasPermi="['system:classifyItem:add']"
2023-02-22 11:10:40 +08:00
>新增</el-button>
2023-02-08 16:18:14 +08:00
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
2023-02-09 14:25:13 +08:00
v-hasPermi="['system:classifyItem:edit']"
2023-02-22 11:10:40 +08:00
>修改</el-button>
2023-02-08 16:18:14 +08:00
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
2023-02-09 14:25:13 +08:00
v-hasPermi="['system:classifyItem:remove']"
2023-02-22 11:10:40 +08:00
>删除</el-button>
2023-02-08 16:18:14 +08:00
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['classify:info:export']"
>导出</el-button
>
2023-02-22 11:10:40 +08:00
</el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
2023-02-08 16:18:14 +08:00
</el-row>
2023-02-22 11:10:40 +08:00
<el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
2023-02-08 16:18:14 +08:00
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="分类编码" align="center" prop="classifyCode" />
<el-table-column label="分类名称" align="center" prop="classifyName" />
<!-- <el-table-column label="分类类型" align="center" prop="classifyType">
<template slot-scope="scope"
>{{ scope.row.classifyType == "NURSE_AGNECY" ? "护理机构分类" : "" }}
{{ scope.row.classifyType == "NURSE_ITEM" ? "护理项目分类" : "" }}
</template>
2023-02-22 11:10:40 +08:00
</el-table-column>-->
2023-02-08 16:18:14 +08:00
<el-table-column label="分类排序" align="center" prop="classifySort" />
2023-02-22 11:10:40 +08:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
2023-02-08 16:18:14 +08:00
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
2023-02-09 14:25:13 +08:00
v-hasPermi="['system:classifyItem:edit']"
2023-02-22 11:10:40 +08:00
>修改</el-button>
2023-02-08 16:18:14 +08:00
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
2023-02-09 14:25:13 +08:00
v-hasPermi="['system:classifyItem:remove']"
2023-02-22 11:10:40 +08:00
>删除</el-button>
2023-02-08 16:18:14 +08:00
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加护理项目分类信息对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="1000px"
append-to-body
2023-02-08 16:40:11 +08:00
:before-close="cancel"
2023-02-08 16:18:14 +08:00
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="80px"
:inline="true"
:before-close="cancel"
>
<div
v-for="(item, index) in form.nurseClassifyInfoList"
:key="index"
style="margin-bottom: 30px"
>
<el-form-item
label="分类名称"
:rules="rules.nurseClassifyInfoList.classifyName"
:prop="`nurseClassifyInfoList.${index}.classifyName`"
>
<el-input
2023-02-22 11:10:40 +08:00
maxlength="30"
2023-02-08 16:18:14 +08:00
style="width: 200px"
v-model="item.classifyName"
placeholder="请输入分类名称"
/>
</el-form-item>
<el-form-item
label="分类排序"
:rules="rules.nurseClassifyInfoList.classifySort"
:prop="`nurseClassifyInfoList.${index}.classifySort`"
>
<el-input
style="width: 200px"
v-model="item.classifySort"
placeholder="请输入分类排序"
oninput="value=value.replace(/[^\d]/g,'')"
2023-02-22 11:10:40 +08:00
maxlength="5"
2023-02-08 16:18:14 +08:00
/>
</el-form-item>
<el-form-item
label="分类图标"
:rules="rules.nurseClassifyInfoList.classifyPictureUrl"
:prop="`nurseClassifyInfoList.${index}.classifyPictureUrl`"
>
<stationAcatar
style="margin-top: -25px"
@imgUrl="imgclassifyPictureUrl"
@item="imgclassifyPictureitem"
:img="item.classifyPictureUrl"
:type="'nurseItemClassifyUrl'"
:item="item"
/>
</el-form-item>
<el-button
type="primary"
plain
icon="el-icon-circle-plus-outline"
style="margin-top: 2px; margin-left: 50px"
v-if="index == 0"
@click="addnurseClassifyitem"
></el-button>
<!-- circle -->
<el-button
type="danger"
icon="el-icon-delete"
plain
style="margin-top: 2px; margin-left: 50px"
v-if="index != 0"
@click="delnurseClassifyitem(index)"
></el-button>
</div>
</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-dialog
:title="title"
:visible.sync="editopen"
width="500px"
append-to-body
:before-close="cancel"
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="classifyName">
2023-02-22 11:10:40 +08:00
<el-input v-model="form.classifyName" placeholder="请输入分类名称" maxlength="30" />
2023-02-08 16:18:14 +08:00
</el-form-item>
<el-form-item label="分类图标" prop="classifyPictureUrl">
<stationAcatar
@imgUrl="imgclassifyPictureUrl"
@item="imgclassifyPictureitem"
:img="form.classifyPictureUrl"
:type="'nurseItemClassifyUrl'"
:item="form"
/>
</el-form-item>
<el-form-item label="分类排序" prop="classifySort">
<el-input
v-model="form.classifySort"
placeholder="请输入分类排序"
oninput="value=value.replace(/[^\d]/g,'')"
2023-02-22 11:10:40 +08:00
maxlength="5"
2023-02-08 16:18:14 +08:00
/>
</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 stationAcatar from "../stationAvatar/index.vue";
import {
listInfo,
getInfo,
delInfo,
addInfo,
2023-02-22 11:10:40 +08:00
updateInfo
2023-02-08 16:18:14 +08:00
} from "@/api/system/classifyItem.js";
import { updatePicture } from "@/api/system/station";
export default {
name: "classify",
components: { stationAcatar },
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
2023-02-22 11:10:40 +08:00
imgone: "",
2023-02-08 16:18:14 +08:00
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 护理机构和护理项目分类信息表格数据
infoList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
editopen: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: null,
classifyCode: null,
classifyName: null,
2023-02-22 11:10:40 +08:00
2023-02-08 16:18:14 +08:00
classifyLevel: null,
classifyType: null,
classifyPictureUrl: null,
2023-02-22 11:10:40 +08:00
classifySort: null
2023-02-08 16:18:14 +08:00
},
// 表单参数
form: {
2023-02-22 11:10:40 +08:00
nurseClassifyInfoList: []
2023-02-08 16:18:14 +08:00
},
idd: 0,
classifyPictureUrl: null,
2023-02-20 11:10:42 +08:00
imgsurl: { pictureUrlList: [] },
2023-02-08 16:18:14 +08:00
// 表单校验
rules: {
nurseClassifyInfoList: {
classifyName: [
{
required: true,
message: "请输入分类名称",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
2023-02-08 16:18:14 +08:00
],
classifyPictureUrl: [
{
required: true,
message: "请选择分类图标",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
2023-02-08 16:18:14 +08:00
],
classifySort: [
{
required: true,
message: "请输入分类排序",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
]
2023-02-08 16:18:14 +08:00
},
classifyName: [
{
required: true,
message: "请输入分类名称",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
2023-02-08 16:18:14 +08:00
],
classifyPictureUrl: [
{
required: true,
message: "请选择分类图标",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
2023-02-08 16:18:14 +08:00
],
classifySort: [
{
required: true,
message: "请输入分类排序",
2023-02-22 11:10:40 +08:00
trigger: "blur"
}
]
}
2023-02-08 16:18:14 +08:00
};
},
created() {
this.getList();
},
methods: {
//添加时删除item
delnurseClassifyitem(index) {
this.form.nurseClassifyInfoList.splice(index, 1);
},
//添加时新增item
addnurseClassifyitem() {
this.idd++;
var obj = {
classifyName: "",
classifyPictureUrl: "",
classifySort: "",
2023-02-22 11:10:40 +08:00
idd: this.idd
2023-02-08 16:18:14 +08:00
};
if (this.form.nurseClassifyInfoList.length == 5) {
this.$message.error("最多批量添加5条");
} else {
this.form.nurseClassifyInfoList.push(obj);
}
},
//接收图片
imgclassifyPictureUrl(e) {},
//接收图片所属的item
imgclassifyPictureitem(item) {
let items = JSON.parse(item);
if (items.idd && !items.id) {
2023-02-22 11:10:40 +08:00
this.form.nurseClassifyInfoList.forEach(e => {
2023-02-08 16:18:14 +08:00
if (e.idd == items.idd) {
e.classifyPictureUrl = items.classifyPictureUrl;
}
});
} else if (!items.idd && items.id) {
this.form.classifyPictureUrl = items.classifyPictureUrl;
}
},
/** 查询护理机构和护理项目分类信息列表 */
getList() {
this.loading = true;
2023-02-22 11:10:40 +08:00
listInfo(this.queryParams).then(response => {
2023-02-08 16:18:14 +08:00
this.infoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
if (this.editopen) {
var obj = { pictureUrlList: [] };
2023-02-20 11:10:42 +08:00
if (this.form.classifyPictureUrl != this.imgone) {
obj.pictureUrlList.push(this.form.classifyPictureUrl);
2023-02-08 16:18:14 +08:00
}
2023-02-22 11:10:40 +08:00
updatePicture(obj).then(res => {
2023-02-08 16:18:14 +08:00
this.editopen = false;
});
}
if (this.open) {
var obj = { pictureUrlList: [] };
if (this.form.nurseClassifyInfoList) {
2023-02-22 11:10:40 +08:00
this.form.nurseClassifyInfoList.forEach(e => {
2023-02-08 16:18:14 +08:00
obj.pictureUrlList.push(e.classifyPictureUrl);
});
}
2023-02-22 11:10:40 +08:00
updatePicture(obj).then(res => {
2023-02-08 16:18:14 +08:00
this.open = false;
});
}
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
parentId: null,
classifyCode: null,
classifyName: null,
classifyLevel: null,
classifyType: null,
classifyPictureUrl: null,
classifySort: null,
createBy: null,
createTime: null,
updateBy: null,
2023-02-22 11:10:40 +08:00
updateTime: null
2023-02-08 16:18:14 +08:00
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
2023-02-22 11:10:40 +08:00
this.ids = selection.map(item => item.id);
2023-02-08 16:18:14 +08:00
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.form = {
nurseClassifyInfoList: [
{
classifyName: "",
classifyPictureUrl: "",
classifySort: "",
2023-02-22 11:10:40 +08:00
idd: this.idd
}
]
2023-02-08 16:18:14 +08:00
};
this.open = true;
this.title = "添加护理项目分类信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
2023-02-22 11:10:40 +08:00
getInfo(id).then(response => {
2023-02-08 16:18:14 +08:00
this.form = response.data;
2023-02-20 11:10:42 +08:00
this.imgone = this.form.classifyPictureUrl;
2023-02-08 16:18:14 +08:00
this.classifyPictureUrl = response.data.classifyPictureUrl;
this.editopen = true;
this.title = "修改护理项目分类信息";
});
},
/** 提交按钮 */
submitForm() {
2023-02-22 11:10:40 +08:00
this.form.classifySort = Number(this.form.classifySort);
this.$refs["form"].validate(valid => {
2023-02-08 16:18:14 +08:00
if (valid) {
if (this.form.id != null) {
2023-02-22 11:10:40 +08:00
updateInfo(this.form).then(response => {
2023-02-08 16:18:14 +08:00
this.$modal.msgSuccess("修改成功");
2023-02-20 11:10:42 +08:00
if (this.form.classifyPictureUrl != this.imgone) {
2023-02-08 16:18:14 +08:00
var obj = { pictureUrlList: [] };
2023-02-20 11:10:42 +08:00
obj.pictureUrlList.push(this.imgone);
2023-02-22 11:10:40 +08:00
updatePicture(obj).then(res => {});
2023-02-08 16:18:14 +08:00
}
this.editopen = false;
this.getList();
});
} else {
2023-02-22 11:10:40 +08:00
if (this.form.nurseClassifyInfoList[0].classifySort) {
this.form.nurseClassifyInfoList[0].classifySort = parseInt(
this.form.nurseClassifyInfoList[0].classifySort
);
2023-02-21 11:55:48 +08:00
}
2023-02-22 11:10:40 +08:00
addInfo(this.form).then(response => {
2023-02-08 16:18:14 +08:00
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
console.log(row);
this.$modal
.confirm("是否确认删除?")
2023-02-22 11:10:40 +08:00
.then(function() {
2023-02-08 16:18:14 +08:00
return delInfo(ids);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
"classify/info/export",
{
2023-02-22 11:10:40 +08:00
...this.queryParams
2023-02-08 16:18:14 +08:00
},
`info_${new Date().getTime()}.xlsx`
);
2023-02-22 11:10:40 +08:00
}
}
2023-02-08 16:18:14 +08:00
};
</script>