<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<el-form :model="searchForm"
|
:inline="true">
|
<el-form-item label="储罐号:">
|
<el-input v-model="searchForm.tankNo"
|
placeholder="请输入"
|
clearable
|
prefix-icon="Search"
|
@change="handleQuery" />
|
</el-form-item>
|
<el-form-item label="大类:">
|
<el-input v-model="searchForm.category"
|
placeholder="请输入"
|
clearable
|
prefix-icon="Search"
|
@change="handleQuery" />
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary"
|
@click="handleQuery"> 搜索
|
</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
</div>
|
<div class="table_list">
|
<div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
|
<el-button type="primary"
|
@click="openForm('add')">新增储罐</el-button>
|
<el-button type="danger"
|
plain
|
@click="handleDelete()">删除
|
</el-button>
|
</div>
|
<el-table :data="tableData"
|
border
|
v-loading="tableLoading"
|
@selection-change="handleSelectionChange">
|
<el-table-column align="center"
|
type="selection"
|
width="55" />
|
<el-table-column align="center"
|
label="序号"
|
type="index"
|
width="60" />
|
<el-table-column label="储罐号"
|
prop="tankNo"
|
min-width="140"
|
show-overflow-tooltip />
|
<el-table-column label="大类"
|
prop="category"
|
min-width="120"
|
show-overflow-tooltip />
|
<el-table-column label="油品"
|
prop="oilProduct"
|
min-width="120"
|
show-overflow-tooltip />
|
<el-table-column label="罐容"
|
prop="capacity"
|
min-width="120" />
|
<el-table-column label="库存余量(m³)"
|
prop="remaining"
|
min-width="140" />
|
<el-table-column label="租客信息"
|
prop="tenantInfo"
|
min-width="160"
|
show-overflow-tooltip />
|
<el-table-column label="创建时间"
|
prop="createTime"
|
min-width="180">
|
<template #default="scope">
|
{{ scope.row.createTime ? scope.row.createTime.replace('T', ' ').slice(0, 19) : '--' }}
|
</template>
|
</el-table-column>
|
<el-table-column fixed="right"
|
label="操作"
|
width="120"
|
align="center">
|
<template #default="scope">
|
<el-button link
|
type="primary"
|
@click="openForm('edit', scope.row)">编辑
|
</el-button>
|
<el-button link
|
type="danger"
|
@click="handleDelete([scope.row])">删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination v-show="total > 0"
|
:total="total"
|
layout="total, sizes, prev, pager, next, jumper"
|
:page="page.current"
|
:limit="page.size"
|
@pagination="paginationChange" />
|
</div>
|
<FormDialog v-model="dialogFormVisible"
|
:title="operationType === 'add' ? '新增储罐' : '编辑储罐'"
|
:width="'40%'"
|
:operation-type="operationType"
|
@close="closeDia"
|
@confirm="submitForm"
|
@cancel="closeDia">
|
<el-form :model="form"
|
label-width="120px"
|
label-position="top"
|
:rules="rules"
|
ref="formRef">
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="储罐号:"
|
prop="tankNo">
|
<el-input v-model="form.tankNo"
|
placeholder="请输入"
|
clearable />
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="大类:"
|
prop="category">
|
<el-input v-model="form.category"
|
placeholder="请输入"
|
clearable />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="油品:"
|
prop="oilProduct">
|
<el-select v-model="form.oilProduct"
|
placeholder="请选择"
|
clearable
|
style="width: 100%">
|
<el-option label="汽#92"
|
value="汽#92" />
|
<el-option label="汽#95"
|
value="汽#95" />
|
<el-option label="柴#0"
|
value="柴#0" />
|
<el-option label="柴#-35"
|
value="柴#-35" />
|
<el-option label="原油"
|
value="原油" />
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="罐容:"
|
prop="capacity">
|
<el-input-number v-model="form.capacity"
|
:precision="2"
|
:step="1"
|
:min="0"
|
style="width: 100%" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="库存余量(m³):"
|
prop="remaining">
|
<el-input-number v-model="form.remaining"
|
:precision="2"
|
:step="1"
|
:min="0"
|
style="width: 100%" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="租客信息:"
|
prop="tenantInfo">
|
<el-input v-model="form.tenantInfo"
|
placeholder="请输入租客信息"
|
clearable />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</FormDialog>
|
</div>
|
</template>
|
|
<script setup>
|
import FormDialog from "@/components/Dialog/FormDialog.vue";
|
import pagination from "@/components/PIMTable/Pagination.vue";
|
import { ref, reactive, toRefs, getCurrentInstance } from "vue";
|
import { Search } from "@element-plus/icons-vue";
|
import { ElMessageBox } from "element-plus";
|
import {
|
listTankInfo,
|
addTankInfo,
|
updateTankInfo,
|
delTankInfo,
|
} from "@/api/basicData/tankInfo.js";
|
|
const { proxy } = getCurrentInstance();
|
const tableData = ref([]);
|
const selectedRows = ref([]);
|
const tableLoading = ref(false);
|
const dialogFormVisible = ref(false);
|
const operationType = ref("");
|
const page = reactive({
|
current: 1,
|
size: 10,
|
});
|
const total = ref(0);
|
|
const data = reactive({
|
searchForm: {
|
tankNo: "",
|
category: "",
|
},
|
form: {
|
id: null,
|
tankNo: "",
|
category: "",
|
oilProduct: "",
|
capacity: null,
|
remaining: null,
|
tenantInfo: "",
|
},
|
rules: {
|
tankNo: [{ required: true, message: "请输入储罐号", trigger: "blur" }],
|
category: [{ required: true, message: "请输入大类", trigger: "blur" }],
|
},
|
});
|
const { searchForm, form, rules } = toRefs(data);
|
|
const getList = () => {
|
tableLoading.value = true;
|
listTankInfo({ ...searchForm.value, ...page })
|
.then(res => {
|
tableLoading.value = false;
|
tableData.value = res.data.records || [];
|
total.value = res.data.total || 0;
|
})
|
.catch(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
|
const paginationChange = obj => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
|
const handleSelectionChange = selection => {
|
selectedRows.value = selection;
|
};
|
|
const openForm = (type, row) => {
|
operationType.value = type;
|
form.value = {};
|
proxy.resetForm("formRef");
|
dialogFormVisible.value = true;
|
if (type === "edit" && row) {
|
const { id, tankNo, category, oilProduct, capacity, remaining, tenantInfo } = row;
|
form.value = { id, tankNo, category, oilProduct, capacity, remaining, tenantInfo };
|
}
|
};
|
|
const submitForm = () => {
|
proxy.$refs["formRef"].validate(valid => {
|
if (valid) {
|
const api = form.value.id ? updateTankInfo : addTankInfo;
|
api(form.value).then(() => {
|
proxy.$modal.msgSuccess("操作成功");
|
closeDia();
|
getList();
|
});
|
}
|
});
|
};
|
|
const closeDia = () => {
|
proxy.resetForm("formRef");
|
dialogFormVisible.value = false;
|
};
|
|
const handleDelete = rows => {
|
let ids = [];
|
if (rows) {
|
ids = rows.map(item => item.id);
|
} else if (selectedRows.value.length > 0) {
|
ids = selectedRows.value.map(item => item.id);
|
} else {
|
proxy.$modal.msgWarning("请选择数据");
|
return;
|
}
|
ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
delTankInfo(ids).then(() => {
|
proxy.$modal.msgSuccess("删除成功");
|
getList();
|
});
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
|
getList();
|
</script>
|
|
<style scoped lang="scss">
|
.search_form {
|
margin-bottom: 16px;
|
}
|
</style>
|