| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
- <div class="query-box">
- <div class="query-box__left">
- <el-form-item label="" prop="drugsName">
- <el-input v-model="queryParams.drugsName" placeholder="请输入药品名称" clearable size="small" @keyup.enter.native="handleQuery"/>
- </el-form-item>
- <el-form-item label="" prop="drugsType">
- <el-select v-model="queryParams.drugsType" placeholder="请选择药品分类" clearable size="small">
- <el-option v-for="item in drugsTypeArr" :key="item.dictValue" :value="item.dictValue" :label="item.dictLabel"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="drugsSpecsType">
- <el-select v-model="queryParams.drugsSpecsType" placeholder="请选择中药类型" clearable size="small">
- <el-option v-for="item in chinesMedicineTypeArr" :key="item.dictValue" :value="item.dictValue" :label="item.dictLabel"></el-option>
- </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>
- </div>
- </div>
- </el-form>
- <el-table v-loading="loading" :data="inventoryList" @selection-change="handleSelectionChange" border :row-class-name="setBGClass" size="mini">
- <el-table-column type="index" width="55" align="center" label="序号"/>
- <el-table-column label="药品名称" align="center" prop="drugsName" />
- <el-table-column label="药品规格" align="center" prop="specsName" />
- <el-table-column label="药品产地" align="center" prop="priceName" />
- <el-table-column label="单位" align="center" prop="packingUnit">
- <template slot-scope="scope">
- <dict-tag :options="unitArr" :value="scope.row.packingUnit" />
- </template>
- </el-table-column>
- <el-table-column label="中药类型" align="center" prop="drugsSpecsType">
- <template slot-scope="scope">
- <dict-tag :options="chinesMedicineTypeArr" :value="scope.row.drugsSpecsType"></dict-tag>
- </template>
- </el-table-column>
- <el-table-column label="库存上限" align="center" prop="stockMax">
- <template slot-scope="scope">{{parseInt(scope.row.stockMax)||'-'}}</template>
- </el-table-column>
- <el-table-column label="库存下限" align="center" prop="stockMin">
- <template slot-scope="scope">{{parseInt(scope.row.stockMin)||'-'}}</template>
- </el-table-column>
- <el-table-column label="修改人" align="center" prop="updateBy" />
- <el-table-column label="修改时间" align="center" prop="updateTime" width="148" />
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="scope">
- <el-button size="mini" type="primary" style="width: 40px" @click="handleUpdate(scope.row)" v-hasPermi="['inventory:inventory:edit']">设置</el-button>
- </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="500px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="库存上限" prop="stockMax">
- <el-input-number controls-position="right" size="mini" v-model="form.stockMax" placeholder="请输入库存上限" />
- </el-form-item>
- <el-form-item label="库存下限" prop="stockMin">
- <el-input-number controls-position="right" size="mini" v-model="form.stockMin" 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 {
- listInventory,
- getInventory,
- delInventory,
- addInventory,
- updateInventory,
- exportInventory,
- } from "@/api/inventory/inventory";
- export default {
- name: "Inventory",
- data() {
- return {
- drugsTypeArr: [],
- chinesMedicineTypeArr: [],
- unitArr: [],
- // 遮罩层
- loading: true,
- // 导出遮罩层
- exportLoading: false,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 药品库存表格数据
- inventoryList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- pharmacyId: window.localStorage.getItem("pharmacyId"),
- drugsType: null,
- drugsSpecsType: null,
- },
- // 表单参数
- form: {},
- // 表单校验
- rules: {
- pharmacyId: [
- { required: true, message: "药房id不能为空", trigger: "blur" },
- ],
- validTime: [
- { required: true, message: "有效时间不能为空", trigger: "blur" },
- ],
- },
- };
- },
- created() {
- this.getDicts("drugs_type").then((response) => {
- this.drugsTypeArr = response.data;
- });
- this.getDicts("chinese_medicine_type").then((response) => {
- this.chinesMedicineTypeArr = response.data;
- });
- this.getDicts("unit").then((response) => {
- this.unitArr = response.data;
- });
- this.getList();
- },
- methods: {
- setBGClass (r) {
- if (r.row.stockMin && (r.row.stock < r.row.stockMin)) {
- return 'redColumn'
- }
- if (r.row.stockMax && (r.row.stock > r.row.stockMax)) {
- return 'greenColumn'
- }
- },
- /** 查询药品库存列表 */
- getList() {
- this.loading = true;
- listInventory(this.queryParams).then((response) => {
- this.inventoryList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- //this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- pharmacyId: window.localStorage.getItem("pharmacyId"),
- specsId: null,
- priceId: null,
- stock: null,
- purchasePrice: null,
- retailPrice: null,
- approvalCode: null,
- stockMax: null,
- stockMin: null,
- site: null,
- productionCode: null,
- validTime: null,
- del: null,
- state: null,
- createBy: null,
- updateBy: null,
- createTime: null,
- updateTime: 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.open = true;
- this.title = "修改药品库存";
- this.form = Object.assign({}, row);
- // getInventory({ id, pageNum: 1, pageSize: 10 }).then((response) => {
- // this.form = response.rows[0];
- // //console.log(response.rows);
- // });
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- if (this.form.stockMax < this.form.stockMin) {
- return this.msgError('库存上限需大于库存下限')
- }
- if (this.form.id != null) {
- updateInventory({
- id: this.form.id,
- stockMax: this.form.stockMax,
- stockMin: this.form.stockMin
- }).then((response) => {
- this.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- } else {
- addInventory(this.form).then((response) => {
- this.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids;
- this.$confirm(
- '确定需要删除选中数据吗?',
- "警告",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- )
- .then(function () {
- return delInventory(ids);
- })
- .then(() => {
- this.getList();
- this.msgSuccess("删除成功");
- })
- .catch(() => {});
- },
- /** 导出按钮操作 */
- async handleExport() {
- this.exportLoading = true;
- try {
- await this.$confirm("是否确认导出所有药品库存数据项?", "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- });
- const data = await exportInventory(this.queryParams)
- this.$message.success(`导出 ${data.name} 成功`);
- } catch (e) {}
- this.exportLoading = false;
- },
- },
- };
- </script>
- <style>
- .redColumn, .redColumn:hover, .el-table__body tr.redColumn.hover-row > td {
- background: #F56C6C!important;
- color: #fff!important;
- }
- .greenColumn, .greenColumn:hover, .el-table__body tr.greenColumn.hover-row > td {
- background: #67C23A!important;
- color: #fff!important;
- }
- </style>
|