<template>
|
<div class="app-container">
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
>新增</el-button
|
>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table
|
v-loading="loading"
|
:data="supplementList"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="index" label="序号" width="55" align="center" />
|
<el-table-column label="舰船类型" align="center" prop="shipDesign" />
|
<el-table-column label="单位" align="center" prop="unit" />
|
<el-table-column label="种类" align="center" prop="category" />
|
<el-table-column label="补给时间" align="center" prop="supplyTime" />
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['system:supplement:edit']"
|
>修改</el-button
|
>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['system:supplement:remove']"
|
>删除</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="shipTypeId">
|
<el-select
|
v-model="form.shipDesign"
|
placeholder="舰船类型"
|
clearable
|
@change="getShipDesign"
|
>
|
<el-option
|
v-for="s in shipTypeOptions"
|
:key="s.id"
|
:label="s.typeName + '-' + s.shipDesign"
|
:value="s.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="单位" prop="unit">
|
<el-input v-model="form.unit" placeholder="请输入单位" />
|
</el-form-item>
|
<el-form-item label="种类" prop="category">
|
<el-input v-model="form.category" placeholder="请输入种类" />
|
</el-form-item>
|
<el-form-item label="补给时间(时)" prop="supplyTime">
|
<el-input v-model="form.supplyTime" 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 {
|
listsupplement,
|
getsupplement,
|
delsupplement,
|
addsupplement,
|
updatesupplement,
|
} from "@/api/manage/supplement";
|
import { listAlldpShipTypeList, getdpShipType } from "@/api/manage/shipType";
|
const baseUrl = process.env.VUE_APP_BASE_API;
|
export default {
|
name: "supplement",
|
data() {
|
return {
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
//舰船类型选项
|
shipTypeOptions: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 单位补给表格数据
|
supplementList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
shipId: null,
|
shipName: null,
|
shipType: null,
|
shipModel: null,
|
shipOverview: null,
|
shipParameters: null,
|
updateTime: null,
|
updateUser: null,
|
whId: null,
|
beId: null,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
shipId: [{ required: true, message: "舰船编号不能为空", trigger: "blur" }],
|
shipType: [{ required: true, message: "舰船类型不能为空", trigger: "blur" }],
|
shipName: [{ required: true, message: "舰船名称不能为空", trigger: "blur" }],
|
},
|
uploadFileUrl: baseUrl + "common/upload",
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询列表 */
|
getList() {
|
this.loading = true;
|
listsupplement(this.queryParams).then((response) => {
|
this.supplementList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
shipId: null,
|
shipName: null,
|
shipType: null,
|
shipModel: null,
|
shipOverview: null,
|
shipParameters: null,
|
updateTime: null,
|
updateUser: null,
|
ID: null,
|
whId: null,
|
beId: 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;
|
},
|
getShipDesign(id) {
|
getdpShipType(id).then((response) => {
|
this.form.shipDesign = response.data.shipDesign;
|
console.log(response.data);
|
});
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
//获取舰船类型
|
listAlldpShipTypeList().then((response) => {
|
this.shipTypeOptions = response.data;
|
});
|
this.open = true;
|
this.title = "添加";
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
//获取舰船类型
|
listAlldpShipTypeList().then((response) => {
|
this.shipTypeOptions = response.data;
|
});
|
const ID = row.id;
|
getsupplement(ID).then((response) => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "修改";
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.id != null) {
|
updatesupplement(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addsupplement(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const IDs = row.id;
|
//查询是否有子设备
|
|
this.$modal
|
.confirm('是否确认删除"' + row.shipDesign + '"的数据项?')
|
.then(function () {
|
return delsupplement(IDs);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
|
},
|
};
|
</script>
|