yudao-dev/src/views/warehouse/part-material/warehouseRealtime/add-or-updata.vue
2023-11-04 16:40:16 +08:00

203 lines
4.8 KiB
Vue

<!--
* @Author: zwq
* @Date: 2023-08-01 13:52:10
* @LastEditors: zwq
* @LastEditTime: 2023-11-04 16:24:26
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
v-if="visible"
@keyup.enter.native="dataFormSubmit()"
label-width="100px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="仓库名称" prop="warehouseName">
<el-input
v-model="dataForm.warehouseName"
readonly
placeholder="请输入仓库名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物品名称" prop="goodsId">
<el-select
v-model="dataForm.goodsId"
filterable
clearable
:disabled="dataForm.id ? true : false"
:style="{ width: '100%' }"
@change="setGoodInfo"
placeholder="请选择物品名称">
<el-option
v-for="item in goodsArr"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物品编码" prop="code">
<el-input
v-model="dataForm.code"
readonly
placeholder="请输入物品编码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物品规格" prop="spec">
<el-input
v-model="dataForm.spec"
readonly
placeholder="请输入物品规格" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物品批次" prop="goodsBatch">
<el-input
v-if="!dataForm.id ? true : false"
v-model="dataForm.goodsBatch"
clearable
placeholder="请输入物品批次" />
<el-select
v-else
v-model="dataForm.goodsBatch"
filterable
clearable
@change="setBatchInfo"
placeholder="请选择物品名称">
<el-option
v-for="(item, index) in Batch"
:key="index"
:label="item.goodsBatch"
:value="item.goodsBatch"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="入库数量" prop="numDet">
<el-input-number
v-model="dataForm.numDet"
clearable
:min="0"
:max="max?max:9999999"
placeholder="请输入入库数量" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from '../../mixins/basic-add';
import {
createWarehouseRealtime,
outWarehouseRealtime,
getWarehouseRealtime,
getWarehouseRealtimeDet,
} from '@/api/warehouse/warehouseRealtime';
import { getListByType } from '@/api/warehouse/warehouseGoods';
import { getWarehouseList } from '@/api/warehouse/warehouse-info';
import { mapGetters } from 'vuex';
export default {
mixins: [basicAdd],
computed: {
...mapGetters(['nickname']),
},
data() {
return {
urlOptions: {
getOption: true,
createURL: createWarehouseRealtime,
updateURL: outWarehouseRealtime,
infoURL: getWarehouseRealtime,
},
dataForm: {
id: undefined,
warehouseName: '',
warehouseId: '',
goodsId: '',
code: '',
spec: '',
goodsBatch: '',
numDet: '',
operator: '',
},
goodsArr: [],
Batch: [],
max: 0,
dataRule: {
goodsId: [
{ required: true, message: '物品名称不能为空', trigger: 'change' },
],
goodsBatch: [
{
required: true,
message: '物品批次不能为空,若无请填写无',
trigger: 'blur',
},
],
numDet: [
{ required: true, message: '入库数量不能为空', trigger: 'blur' },
],
},
};
},
created() {},
methods: {
getArr() {
this.dataForm.operator = this.nickname
getListByType(4).then((response) => {
this.goodsArr = response.data;
});
getWarehouseList().then((response) => {
response.data.forEach((item) => {
if (item.storageType === 4) {
this.dataForm.warehouseName = item.name;
this.dataForm.warehouseId = item.id;
}
});
});
},
setGoodInfo() {
this.goodsArr.forEach((item) => {
if (item.id === this.dataForm.goodsId) {
this.dataForm.code = item.code;
this.dataForm.spec = item.spec;
}
});
},
setBatchInfo(){
this.Batch.forEach((item) => {
if (item.goodsBatch === this.dataForm.goodsBatch) {
this.max = item.numDet
}
});
},
outWare(data) {
this.getArr();
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
this.dataForm.realTimeId = data.id;
this.dataForm.id = data.id;
this.dataForm.goodsId = data.goodsId;
this.dataForm.code = data.code;
this.dataForm.spec = data.spec;
getWarehouseRealtimeDet(data.id).then((res) => {
this.Batch = res.data;
});
// this.urlOptions.infoURL(data.id).then((response) => {
// this.dataForm = response.data;
// });
});
},
},
};
</script>