完成药品管理的新增操作

master
ynmlzdwsp 11 months ago
parent 7a3be7c18f
commit 1f94efe60c

@ -63,7 +63,7 @@
title: "用户管理",
isBoss: true
}, {
icon: "el-icon-refrigerator",
icon: "el-icon-first-aid-kit",
index: "/drugReaction",
title: "药品管理",
isBoss: false

@ -5,23 +5,49 @@
<el-input v-model="queryParams.drug1" placeholder="药品A名称" class="handle-input mrb10"></el-input>
<el-input v-model="queryParams.drug2" placeholder="药品B名称" class="handle-input mrb10"></el-input>
<el-input v-model="queryParams.reaction" placeholder="相互作用效果" class="handle-input mrb10"></el-input>
<el-button type="primary" icon="el-icon-search" @click="searchUser()"></el-button>
<el-button type="primary" icon="el-icon-search" @click="handleQuery()"></el-button>
<el-button type="danger" @click="clearSearch()"></el-button>
<el-button type="primary" icon="el-icon-plus" @click="addDrugs()"></el-button>
</div>
<el-table :data="users" border class="table" header-cell-class-name="table-header">
<el-table :data="table1List" border class="table" header-cell-class-name="table-header">
<el-table-column prop="id" label="ID" width="55" align="center"></el-table-column>
<el-table-column prop="username" label="药品A名称" align="center"></el-table-column>
<el-table-column prop="phoneNumber" label="药品B名称" align="center"></el-table-column>
<el-table-column prop="email" label="相互作用效果" align="center"></el-table-column>
<el-table-column prop="introduction" label="简介" align="center"></el-table-column>
<el-table-column prop="createTime" label="注册时间" align="center"></el-table-column>
<el-table-column prop="drug1" label="药品A名称" align="center"></el-table-column>
<el-table-column prop="drug2" label="药品B名称" align="center"></el-table-column>
<el-table-column prop="reaction" label="相互作用效果" align="center"></el-table-column>
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.row)"></el-button>
<el-button type="text" icon="el-icon-delete" style="color: var(--orangeRed)" @click="handleDelete(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog title="新增药品作用" :visible.sync="dialogVisible">
<el-form :model="formData" :rules="rules" ref="drugForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="药品A名称" prop="drug1">
<el-input v-model="formData.drug1"></el-input>
</el-form-item>
<el-form-item label="药品B名称" prop="drug2">
<el-input v-model="formData.drug2"></el-input>
</el-form-item>
<el-form-item label="相互作用效果" prop="reaction">
<el-input v-model="formData.reaction"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submitForm('drugForm')"> </el-button>
</div>
</el-dialog>
<div class="pagination">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage1"
:current-page="1"
:page-sizes="[10, 15, 20, 25]"
:page-size="10"
layout="total, sizes, prev, pager, next, jumper"
@ -30,32 +56,15 @@
</div>
</div>
<!-- 编辑弹出框 -->
<el-dialog title="修改用户类型"
:visible.sync="editVisible"
width="30%"
:before-close="handleClose"
:append-to-body="true"
destroy-on-close
center>
<div class="myCenter">
<el-radio-group v-model="changeUser.userType">
<el-radio-button :label="0">Boss</el-radio-button>
<el-radio-button :label="1">管理员</el-radio-button>
<el-radio-button :label="2">普通用户</el-radio-button>
</el-radio-group>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose()"> </el-button>
<el-button type="primary" @click="saveEdit()"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {addTable1, listTable1, listTotal} from "../../utils/table1";
export default {
data() {
return {
@ -73,6 +82,9 @@ export default {
userType: null
},
editVisible: false,
table1List: [
],
//
queryParams: {
pageNum: 1,
@ -81,6 +93,24 @@ export default {
drug2: null,
reaction: null
},
//
formData: {
drug1: "",
drug2: "",
reaction: ""
},
dialogVisible: false,
rules: {
drug1: [
{ required: true, message: "请输入药品A名称", trigger: "blur" }
],
drug2: [
{ required: true, message: "请输入药品B名称", trigger: "blur" }
],
reaction: [
{ required: true, message: "请输入相互作用效果", trigger: "blur" }
]
}
}
},
@ -89,129 +119,96 @@ export default {
watch: {},
created() {
this.getUsers();
// this.getUsers();
this.handleQuery();
},
mounted() {
},
methods: {
clearSearch() {
this.pagination = {
current: 1,
size: 10,
total: 0,
searchKey: "",
userStatus: null,
userType: null
}
this.getUsers();
//
addDrugs(){
this.dialogVisible = true;
},
getUsers() {
this.$http.post(this.$constant.baseURL + "/admin/user/list", this.pagination, true)
.then((res) => {
if (!this.$common.isEmpty(res.data)) {
this.users = res.data.records;
this.pagination.total = res.data.total;
}
})
.catch((error) => {
this.$message({
message: error.message,
type: "error"
});
/** 查询药品作用列表条数 */
getTotal() {
listTotal(this.queryParams).then(response => {
this.pagination.total = parseInt(response);
console.log(this.pagination.total);
});
},
changeUserStatus(user) {
this.$http.get(this.$constant.baseURL + "/admin/user/changeUserStatus", {
userId: user.id,
flag: user.userStatus
}, true)
.then((res) => {
this.$message({
message: "修改成功!",
type: "success"
});
})
.catch((error) => {
this.$message({
message: error.message,
type: "error"
});
});
handleSizeChange(val) {
this.queryParams.pageSize = val; //
this.getList();
},
changeUserAdmire(user) {
if (!this.$common.isEmpty(user.admire)) {
this.$confirm('确认保存?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
center: true
}).then(() => {
this.$http.get(this.$constant.baseURL + "/admin/user/changeUserAdmire", {
userId: user.id,
admire: user.admire
}, true)
.then((res) => {
this.$message({
message: "修改成功!",
type: "success"
});
})
.catch((error) => {
this.$message({
message: error.message,
type: "error"
});
});
}).catch(() => {
this.$message({
type: 'success',
message: '已取消保存!'
});
handleCurrentChange(val) {
this.queryParams.pageNum = val; //
this.getList();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.getTotal();
},
/** 查询药品作用管理列表 */
getList() {
// this.loading = true;
this.table1List = []; //
listTable1(this.queryParams).then(response => {
this.table1List = response;
});
}
},
editUser(user) {
this.changeUser.id = user.id;
this.changeUser.userType = user.userType;
this.editVisible = true;
clearSearch() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
drug1: null,
drug2: null,
reaction: null
}
},
handlePageChange(val) {
this.pagination.current = val;
this.getUsers();
},
searchUser() {
this.pagination.total = 0;
this.pagination.current = 1;
this.getUsers();
},
handleClose() {
this.changeUser = {
id: null,
userType: null
};
this.editVisible = false;
},
saveEdit() {
this.$http.get(this.$constant.baseURL + "/admin/user/changeUserType", {
userId: this.changeUser.id,
userType: this.changeUser.userType
}, true)
.then((res) => {
this.handleClose();
this.getUsers();
//
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
addTable1(this.formData).then(() => {
this.dialogVisible = false;
this.getList();
this.getTotal();
this.$message({
message: "修改成功!",
message: "新增成功",
type: "success"
});
})
.catch((error) => {
this.$message({
message: error.message,
type: "error"
}).catch((error) => {
this.$message.error(error);
});
} else {
return false;
}
});
},
//
handleEdit(row) {
this.changeUser.id = row.id;
this.changeUser.userType = row.userType;
this.editVisible = true;
},
//
handleDelete(row) {
this.confirm("此操作将永久删除该药品作用, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
// TODO
}).catch(() => {});
}
}
}

@ -12,8 +12,8 @@
<el-table-column prop="id" label="ID" width="55" align="center"></el-table-column>
<el-table-column prop="userId" label="用户ID" align="center"></el-table-column>
<el-table-column prop="manName" label="男生昵称" align="center"></el-table-column>
<el-table-column prop="womanName" label="女生昵称" align="center"></el-table-column>
<el-table-column prop="manName" label="科研人员" align="center"></el-table-column>
<el-table-column prop="womanName" label="项目" align="center"></el-table-column>
<el-table-column label="背景封面" align="center">
<template slot-scope="scope">

@ -52,7 +52,7 @@ export function predictReaction(mol1, mol2) {
// })
// }
// // 新增药品作用管理
// export function addTable1(data) {
// return request({
// url: '/system/table1',
@ -60,7 +60,14 @@ export function predictReaction(mol1, mol2) {
// data: data
// })
// }
//
export function addTable1(data) {
const url = '/system/table1';
return axios.post(url, data)
.then(response => response.data)
.catch(error => console.error(error));
}
// // 修改药品作用管理
// export function updateTable1(data) {
// return request({

Loading…
Cancel
Save