Files
fad_oa/ruoyi-ui/src/views/oa/oaOutWarehouse/index.vue

461 lines
14 KiB
Vue
Raw Normal View History

2024-11-04 17:17:12 +08:00
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
2024-11-06 16:59:14 +08:00
<!-- <el-form-item label="项目名" prop="projectId">-->
<!-- <el-input-->
<!-- v-model="queryParams.projectId"-->
<!-- placeholder="请输入项目名"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
2024-11-04 17:17:12 +08:00
<el-form-item>
2024-11-06 16:59:14 +08:00
<!-- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
2024-11-04 17:17:12 +08:00
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</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"
v-hasPermi="['oa:oaOutWarehouse:add']"
2024-11-06 16:59:14 +08:00
>新增
</el-button>
2024-11-04 17:17:12 +08:00
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['oa:oaOutWarehouse:remove']"
2024-11-06 16:59:14 +08:00
>删除
</el-button>
2024-11-04 17:17:12 +08:00
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['oa:oaOutWarehouse:export']"
2024-11-06 16:59:14 +08:00
>导出
</el-button>
2024-11-04 17:17:12 +08:00
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2024-11-06 14:50:00 +08:00
<el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
2024-11-06 16:59:14 +08:00
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" align="center" type="index"/>
<el-table-column label="项目名" align="center" prop="projectName"/>
<el-table-column label="创建时间" align="center" prop="createtime"/>
2024-11-04 17:17:12 +08:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
2024-11-06 14:50:00 +08:00
2024-11-04 17:17:12 +08:00
<el-button
size="mini"
type="text"
2024-11-06 14:50:00 +08:00
icon="el-icon-search"
@click="handleSearch(scope.row)"
2024-11-04 17:17:12 +08:00
v-hasPermi="['oa:oaOutWarehouse:remove']"
2024-11-06 16:59:14 +08:00
>查看详情
</el-button>
2024-11-04 17:17:12 +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="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item
prop="projectId"
label="项目名"
>
<el-select v-model="form.projectId" placeholder="请选择项目">
<el-option
v-for="item in projectList"
2024-11-06 14:50:00 +08:00
:key="item.projectId"
2024-11-04 17:17:12 +08:00
:label="item.projectName"
2024-11-06 14:50:00 +08:00
:value="item.projectId">
2024-11-04 17:17:12 +08:00
</el-option>
</el-select>
</el-form-item>
<el-form-item
v-for="(item, index) in form.outWareHouseList"
:label="'出库物料' + index"
2024-11-06 16:59:14 +08:00
:key="item.warehouseId"
2024-11-04 17:17:12 +08:00
:prop="'outWareHouseList.' + index + '.warehouseId'"
>
<el-row>
<el-col :span="8">物料名</el-col>
2024-11-06 16:59:14 +08:00
<el-col :span="4">当前库存</el-col>
2024-11-04 17:17:12 +08:00
<el-col :span="8">出库数量</el-col>
2024-11-06 16:59:14 +08:00
<el-col :span="4">操作</el-col>
2024-11-04 17:17:12 +08:00
</el-row>
<el-row>
<el-col :span="8">
2024-11-06 16:59:14 +08:00
<el-select
v-model="item.warehouseId"
filterable
remote
reserve-keyword
@change="(e)=>handleGetInventory(e,index)"
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading">
<el-option
v-for="item in oaWarehouseList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-col>
<el-col :span="4">
<el-tag type="info" v-if="item.inventory===undefined">请选择物料</el-tag>
<el-tag type="info" v-else>{{item.inventory}}</el-tag>
2024-11-04 17:17:12 +08:00
</el-col>
<el-col :span="8">
2024-11-06 16:59:14 +08:00
<el-input-number v-model="item.amount" :min="1" :max="item.inventory"></el-input-number>
2024-11-04 17:17:12 +08:00
</el-col>
<el-col :span="4">
<el-button @click.prevent="removeDomain(item)">删除</el-button>
2024-11-06 16:59:14 +08:00
</el-col>
2024-11-04 17:17:12 +08:00
</el-row>
</el-form-item>
<el-form-item>
<el-button @click="addDomain">新增出库</el-button>
<el-button @click="reset()">重置</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
2024-11-06 14:50:00 +08:00
<el-drawer
size="70%"
title="我是标题"
:visible.sync="drawer"
:with-header="false">
2024-11-06 16:59:14 +08:00
<!-- <el-form :model="query" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!-- <el-form-item label="项目名" prop="projectId">-->
<!-- <el-input-->
<!-- v-model="query.name"-->
<!-- placeholder="请输入物料名"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </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>-->
<!-- </el-form>-->
2024-11-06 14:50:00 +08:00
2024-11-06 16:59:14 +08:00
<el-button
style="margin: 25px"
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['oa:oaOutWarehouse:add']"
>新增
</el-button>
2024-11-06 14:50:00 +08:00
<el-table v-loading="loading" :data="oaOutWarehouseList" @selection-change="handleSelectionChange">
2024-11-06 16:59:14 +08:00
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" align="center" type="index"/>
<el-table-column label="物料名" align="center" prop="warehouseName"/>
<el-table-column label="出库数量" align="center" prop="amount"/>
<el-table-column label="出库时间" align="center" prop="createTime"/>
<el-table-column label="备注" align="center" prop="remark"/>
2024-11-06 14:50:00 +08:00
<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-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['oa:oaOutWarehouse:remove']"
2024-11-06 16:59:14 +08:00
>删除
</el-button>
2024-11-06 14:50:00 +08:00
</template>
</el-table-column>
</el-table>
</el-drawer>
2024-11-04 17:17:12 +08:00
</div>
</template>
<script>
2024-11-06 16:59:14 +08:00
import {
listOaOutWarehouse,
getOaOutWarehouse,
delOaOutWarehouse,
addOaOutWarehouse,
updateOaOutWarehouse,
outWareList,
queryOutWarehouseByProjectId
} from "@/api/oa/oaOutWarehouse";
2024-11-06 14:50:00 +08:00
import {listProject} from "@/api/oa/project";
2024-11-06 16:59:14 +08:00
import {listOaWarehouse} from "../../../api/oa/oaWarehouse";
2024-11-04 17:17:12 +08:00
export default {
name: "OaOutWarehouse",
data() {
return {
2024-11-06 14:50:00 +08:00
// 抽屉
2024-11-06 16:59:14 +08:00
drawer: false,
2024-11-06 14:50:00 +08:00
2024-11-04 17:17:12 +08:00
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 仓库出库表格数据
oaOutWarehouseList: [],
2024-11-06 14:50:00 +08:00
// 项目列表
2024-11-06 16:59:14 +08:00
projectList: [],
// 库存数据
oaWarehouseList: [],
2024-11-04 17:17:12 +08:00
// 弹出层标题
title: "",
2024-11-06 14:50:00 +08:00
// 选择对象
2024-11-06 16:59:14 +08:00
searchItem: {},
2024-11-04 17:17:12 +08:00
// 是否显示弹出层
open: false,
2024-11-06 16:59:14 +08:00
// 库存查询参数
warehouseParams: {
pageSize: 999,
pageNum: 1
},
2024-11-04 17:17:12 +08:00
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
2024-11-06 14:50:00 +08:00
projectName: undefined,
2024-11-04 17:17:12 +08:00
},
// 表单参数
form: {},
// 表单校验
rules: {
amount: [
2024-11-06 16:59:14 +08:00
{required: true, message: "出库数量不能为空", trigger: "blur"}
2024-11-04 17:17:12 +08:00
],
warehouseId: [
2024-11-06 16:59:14 +08:00
{required: true, message: "出库对象id不能为空", trigger: "blur"}
2024-11-04 17:17:12 +08:00
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询仓库出库列表 */
getList() {
this.loading = true;
2024-11-06 14:50:00 +08:00
listProject(this.queryParams).then(response => {
this.projectList = response.rows
2024-11-04 17:17:12 +08:00
this.total = response.total;
this.loading = false;
});
2024-11-06 16:59:14 +08:00
2024-11-04 17:17:12 +08:00
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined,
projectId: undefined,
amount: undefined,
remark: undefined,
warehouseId: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined,
delFlag: undefined,
2024-11-06 16:59:14 +08:00
selectLoading: false,
outWareHouseList: []
2024-11-04 17:17:12 +08:00
};
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)
2024-11-06 16:59:14 +08:00
this.single = selection.length !== 1
2024-11-04 17:17:12 +08:00
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加仓库出库";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const id = row.id || this.ids
2024-11-06 14:50:00 +08:00
// getOaOutWarehouse(id).then(response => {
// this.loading = false;
// this.form = response.data;
// this.open = true;
// this.title = "修改仓库出库";
// });
2024-11-04 17:17:12 +08:00
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updateOaOutWarehouse(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addOaOutWarehouse(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除仓库出库编号为"' + ids + '"的数据项?').then(() => {
this.loading = true;
return delOaOutWarehouse(ids);
}).then(() => {
2024-11-06 14:50:00 +08:00
this.handleSearch(this.searchItem);
2024-11-04 17:17:12 +08:00
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('oa/oaOutWarehouse/export', {
...this.queryParams
}, `oaOutWarehouse_${new Date().getTime()}.xlsx`)
},
addDomain() {
this.form.outWareHouseList.push({
value: '',
key: Date.now()
});
},
removeDomain(item) {
var index = this.form.outWareHouseList.indexOf(item)
if (index !== -1) {
this.form.outWareHouseList.splice(index, 1)
}
},
2024-11-06 16:59:14 +08:00
handleGetInventory(e,index){
this.form.outWareHouseList[index].inventory = this.oaWarehouseList[this.oaWarehouseList.findIndex(item=>item.id===e)].inventory
console.log(this.form.outWareHouseList[index])
},
2024-11-04 17:17:12 +08:00
querySearch(queryString, cb) {
var oaWarehouseList = this.oaWarehouseList;
var results = queryString ? oaWarehouseList.filter(this.createFilter(queryString)) : oaWarehouseList;
// 调用 callback 返回建议列表的数据
2024-11-06 16:59:14 +08:00
sys_oa_contract
2024-11-04 17:17:12 +08:00
cb(results);
},
createFilter(queryString) {
return (restaurant) => {
2024-11-06 16:59:14 +08:00
// console.log(restaurant)
// console.log(restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()))
2024-11-04 17:17:12 +08:00
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
};
},
2024-11-06 16:59:14 +08:00
remoteMethod(query) {
this.warehouseParams.name = query
this.selectLoading = true;
listOaWarehouse(this.warehouseParams).then(res => {
this.oaWarehouseList = res.rows.filter(item => {
return item.name.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
this.selectLoading = false;
})
2024-11-06 14:50:00 +08:00
},
// 查看出库详情
2024-11-06 16:59:14 +08:00
handleSearch(item) {
2024-11-06 14:50:00 +08:00
this.loading = true
this.searchItem = item;
this.form.projectId = item.projectId
queryOutWarehouseByProjectId(item.projectId).then(response => {
this.oaOutWarehouseList = response.rows;
this.drawer = true;
this.loading = false;
})
2024-11-04 17:17:12 +08:00
}
}
};
</script>