|
|
@@ -1,30 +1,30 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
- <el-form ref="dataForm" :model="dataForm" label-width="120px" inline>
|
|
|
+ <el-form ref="dataForm" :model="dataForm" :rules="rules" label-width="120px" inline>
|
|
|
<h3>通用入库单</h3>
|
|
|
<!-- <el-form-item label="名称" prop="name">
|
|
|
<el-input v-model="dataForm.name" :minlength="2" :maxlength="20" clearable
|
|
|
placeholder="请输入名称" style="width:200px" :disabled="type === 'detail'"></el-input>
|
|
|
</el-form-item> -->
|
|
|
- <el-form-item label="入库时间" prop="dateTime">
|
|
|
- <el-date-picker v-model="dataForm.dateTime" value-format="timestamp" type="datetime"
|
|
|
+ <el-form-item label="入库时间" prop="serialDate">
|
|
|
+ <el-date-picker v-model="dataForm.serialDate" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
|
|
|
placeholder="选择日期时间" style="width:200px" :disabled="type === 'detail'">
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="供应商" prop="type">
|
|
|
- <el-select v-model="dataForm.type" clearable placeholder="请选择" style="width: 200px;" :disabled="type === 'detail'">
|
|
|
- <el-option :key="item.dictValue" v-for="item in allTypeList" :label="item.dictLabel" :value="item.dictValue">
|
|
|
+ <el-form-item label="供应商" prop="supplierId">
|
|
|
+ <el-select v-model="dataForm.supplierId" clearable placeholder="请选择" style="width: 200px;" :disabled="type === 'detail'">
|
|
|
+ <el-option :key="item.id" v-for="item in supplierList" :label="item.businessName" :value="item.id">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="仓库" prop="type">
|
|
|
- <el-select v-model="dataForm.type" clearable placeholder="请选择" style="width: 200px;" :disabled="type === 'detail'">
|
|
|
- <el-option :key="item.dictValue" v-for="item in allTypeList" :label="item.dictLabel" :value="item.dictValue">
|
|
|
+ <el-form-item label="仓库" prop="warehouseId">
|
|
|
+ <el-select v-model="dataForm.warehouseId" clearable placeholder="请选择" style="width: 200px;" :disabled="type === 'detail'">
|
|
|
+ <el-option :key="item.id" v-for="item in warehouseList" :label="item.warehouseName" :value="item.id">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="经手人" prop="loginId">
|
|
|
- <el-select v-model="dataForm.loginId" clearable filterable placeholder="请选择" style="width: 200px" :disabled="type === 'detail'">
|
|
|
+ <el-form-item label="经手人" prop="addHandlerId">
|
|
|
+ <el-select v-model="dataForm.addHandlerId" clearable filterable placeholder="请选择" style="width: 200px" :disabled="type === 'detail'">
|
|
|
<el-option :key="item.loginId" v-for="item in recipientsList" :label="item.deptName+'_'+item.userName" :value="item.loginId">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
@@ -37,7 +37,7 @@
|
|
|
placeholder="请输入采购说明 最大120字"></el-input>
|
|
|
</el-form-item> -->
|
|
|
<el-form-item label="附件:" prop="fileIds">
|
|
|
- <el-upload :limit="1" :action="fileUrl" :file-list="dataForm.files" :on-success="handleFileSuccess"
|
|
|
+ <el-upload :limit="1" :action="fileUrl" :file-list="dataForm.fileList" :on-success="handleFileSuccess"
|
|
|
:before-upload="beforeUploadFile" :on-remove="handleRemove">
|
|
|
<el-button size="small" type="primary" :disabled="type === 'detail'">点击上传</el-button>
|
|
|
</el-upload>
|
|
|
@@ -47,39 +47,39 @@
|
|
|
<el-button size="small" type="primary" v-if="type !== 'detail'"
|
|
|
@click="handleSelectGoods" icon="el-icon-plus">商品/物料</el-button>
|
|
|
</div>
|
|
|
- <el-table size="small" :data="dataForm.item_list" border :cell-style="{ textAlign: 'center' }"
|
|
|
+ <el-table size="small" :data="dataForm.inventoryEntryInfos" border :cell-style="{ textAlign: 'center' }"
|
|
|
:header-cell-style="{ textAlign: 'center' }" style="width: 100%">
|
|
|
<el-table-column label="商品编号">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.goodCode }}
|
|
|
+ {{ scope.row.productCode }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品名称">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.goodName }}
|
|
|
+ {{ scope.row.productName }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="单价(¥)">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.price }}
|
|
|
+ {{ scope.row.createPrice.toFixed(2) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="库存数量">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.unit }}
|
|
|
+ {{ scope.row.createProductNumber }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="入库数量">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-form-item v-if="type !== 'detail'" :prop="'item_list.'+scope.$index+'.num'" :rules="{ required: true, message: '入库数量不能为空', trigger: 'blur' }" class="tableFormItem">
|
|
|
- <el-input-number v-model="scope.row.num" @change="handleChange(scope.row)" size="small" :min="1" :max="10000" label="入库数量"></el-input-number>
|
|
|
+ <el-form-item v-if="type !== 'detail'" :prop="'inventoryEntryInfos.'+scope.$index+'.updateNumber'" :rules="{ required: true, message: '入库数量不能为空', trigger: 'blur' }" class="tableFormItem">
|
|
|
+ <el-input-number v-model="scope.row.updateNumber" @change="handleChange(scope.row)" size="small" :min="1" :max="10000" label="入库数量"></el-input-number>
|
|
|
</el-form-item>
|
|
|
- <span v-else>{{ scope.row.num }}</span>
|
|
|
+ <span v-else>{{ scope.row.updateNumber }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="合计(¥)">
|
|
|
<template slot-scope="scope">
|
|
|
- {{ scope.row.total_price.toFixed(2) }}
|
|
|
+ {{ scope.row.sumPrice.toFixed(2) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<!-- <el-table-column label="备注">
|
|
|
@@ -90,7 +90,7 @@
|
|
|
<el-table-column label="操作" width="150" v-if="type !== 'detail'">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button size="mini" type="danger"
|
|
|
- @click="dataForm.item_list.splice(scope.$index, 1)">删除</el-button>
|
|
|
+ @click="dataForm.inventoryEntryInfos.splice(scope.$index, 1)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -104,8 +104,10 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { dataAdd, dataEdit } from "@/api/dictManage";
|
|
|
-import { allUserList,dataTypeList } from "@/api/public";
|
|
|
+import { createWarehousing, updateWarehousing, readWarehousing } from "@/api/warehousing";
|
|
|
+import { supplierList } from "@/api/supplier";
|
|
|
+import { warehouseList } from "@/api/warehouse";
|
|
|
+import { allUserList } from "@/api/public";
|
|
|
import waves from "@/directive/waves"; // 水波纹指令
|
|
|
|
|
|
export default {
|
|
|
@@ -114,13 +116,31 @@ export default {
|
|
|
return {
|
|
|
fileUrl:this.upLoadUrl,
|
|
|
recipientsList:[],
|
|
|
- allTypeList: [],
|
|
|
+ supplierList: [],
|
|
|
+ warehouseList: [],
|
|
|
id: '',
|
|
|
type: '',
|
|
|
/** 表单*/
|
|
|
dataForm: {
|
|
|
- item_list: []
|
|
|
- }
|
|
|
+ serialDate:'',
|
|
|
+ supplierId:undefined,
|
|
|
+ warehouseId:undefined,
|
|
|
+ addHandlerId:undefined,
|
|
|
+ fileIds:undefined,
|
|
|
+ fileList: [],
|
|
|
+ inventoryEntryInfos: []
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ serialDate: [
|
|
|
+ { required: true, message: '请选择入库时间', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ warehouseId: [
|
|
|
+ { required: true, message: '请选择仓库', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ addHandlerId: [
|
|
|
+ { required: true, message: '请选择经手人', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -129,7 +149,13 @@ export default {
|
|
|
handler(newVal) {
|
|
|
if (this.$route.name === 'warehousingAdd') {
|
|
|
this.dataForm = {
|
|
|
- item_list: []
|
|
|
+ serialDate:undefined,
|
|
|
+ supplierId:undefined,
|
|
|
+ warehouseId:undefined,
|
|
|
+ addHandlerId:undefined,
|
|
|
+ fileIds:undefined,
|
|
|
+ fileList: [],
|
|
|
+ inventoryEntryInfos: []
|
|
|
}
|
|
|
} else if (this.$route.name === 'warehousingDetail') {
|
|
|
this.type = 'detail'
|
|
|
@@ -142,45 +168,101 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.getSupplierList();
|
|
|
+ this.getStoreList();
|
|
|
this.getAllUserList();
|
|
|
- this.getPointRulesType();
|
|
|
},
|
|
|
methods: {
|
|
|
+ /** 获取供应商列表数据 */
|
|
|
+ getSupplierList(){
|
|
|
+ supplierList().then(response => {
|
|
|
+ this.supplierList = response.data.data;
|
|
|
+ }).catch(() => { });
|
|
|
+ },
|
|
|
+ /** 获取仓库列表数据 */
|
|
|
+ getStoreList() {
|
|
|
+ warehouseList().then(response => {
|
|
|
+ this.warehouseList = response.data.data;
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 获取人员列表数据 */
|
|
|
+ getAllUserList() {
|
|
|
+ allUserList().then(response => {
|
|
|
+ this.recipientsList = response.data.data;
|
|
|
+ }).catch(() => { });
|
|
|
+ },
|
|
|
/** 获取详情页面数据 */
|
|
|
getDataFormDetail() {
|
|
|
-
|
|
|
+ readWarehousing({ id: this.id }).then(response => {
|
|
|
+ let dataForm = response.data.data;
|
|
|
+ dataForm.inventoryEntryInfos = dataForm.inventoryEntryInfos == null ? [] : dataForm.inventoryEntryInfos
|
|
|
+ dataForm.inventoryOutInfos = dataForm.inventoryOutInfos == null ? [] : dataForm.inventoryOutInfos
|
|
|
+ this.dataForm = dataForm;
|
|
|
+ }).catch(() => {})
|
|
|
},
|
|
|
// 选择商品
|
|
|
async handleSelectGoods() {
|
|
|
- let selectedIds = this.dataForm.item_list.map(item => item.id);
|
|
|
- const Goods = await this.$EnPickerGoods({
|
|
|
- goodsApi: '/admin/list',
|
|
|
- selectedIds: selectedIds,
|
|
|
- // goodsApiParams: { warehouse_id: 12 }
|
|
|
- })
|
|
|
- if (!Goods.length) return
|
|
|
- const item_list = Goods.map(item => {
|
|
|
- item.id = item.id
|
|
|
- item.goodCode = item.goodCode
|
|
|
- item.goodName = item.goodName
|
|
|
- item.unit = item.unit
|
|
|
- item.unit = item.num
|
|
|
- item.total_price = 0
|
|
|
- return item
|
|
|
- })
|
|
|
- this.dataForm.item_list = this.dataForm.item_list && this.dataForm.item_list.length ? this.dataForm.item_list.concat(item_list) : this.dataForm.item_list = item_list
|
|
|
+ if (!this.dataForm.warehouseId) {
|
|
|
+ this.$message.error('请先选择仓库!')
|
|
|
+ return
|
|
|
+ }else{
|
|
|
+ console.log(this.dataForm.inventoryEntryInfos)
|
|
|
+ let selectedIds = this.dataForm.inventoryEntryInfos.map(item => item.id);
|
|
|
+ const Goods = await this.$EnPickerGoods({
|
|
|
+ // goodsApi: '/warehouse-entry/info/inventory',
|
|
|
+ selectedIds: selectedIds,
|
|
|
+ goodsApiParams: { warehouseId: this.dataForm.warehouseId }
|
|
|
+ })
|
|
|
+ if (!Goods.length) return
|
|
|
+ const inventoryEntryInfos = Goods.map(item => {
|
|
|
+ item.updateNumber = 1
|
|
|
+ item.sumPrice = item.createPrice * 1
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ this.dataForm.inventoryEntryInfos = this.dataForm.inventoryEntryInfos && this.dataForm.inventoryEntryInfos.length ? this.dataForm.inventoryEntryInfos.concat(inventoryEntryInfos) : this.dataForm.inventoryEntryInfos = inventoryEntryInfos
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
submitForm(){
|
|
|
-
|
|
|
+ this.$refs["dataForm"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if(this.dataForm.inventoryEntryInfos.length == 0){
|
|
|
+ this.$message.error('请选择商品/物料!')
|
|
|
+ return
|
|
|
+ }else{
|
|
|
+ if(this.id){
|
|
|
+ updateWarehousing(this.dataForm).then(() => {
|
|
|
+ this.$notify({
|
|
|
+ title: '成功',
|
|
|
+ message: '更新成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ this.roBack();
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ createWarehousing(this.dataForm).then(() => {
|
|
|
+ this.$notify({
|
|
|
+ title: "成功",
|
|
|
+ message: "创建成功",
|
|
|
+ type: "success",
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ this.roBack();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
handleChange(row) {
|
|
|
- if (row.price && row.num) {
|
|
|
- row.total_price = row.price * row.num
|
|
|
+ if (row.createPrice && row.updateNumber) {
|
|
|
+ row.sumPrice = row.createPrice * row.updateNumber
|
|
|
}
|
|
|
},
|
|
|
roBack() {
|
|
|
- const { callback } = this.$route.params
|
|
|
- if (typeof callback === 'function') callback()
|
|
|
+ // const { callback } = this.$route.params
|
|
|
+ // if (typeof callback === 'function') callback()
|
|
|
this.$store.dispatch('delVisitedViews', this.$route).then((views) => {
|
|
|
const latestView = views.slice(-1)[0]
|
|
|
if (latestView) {
|
|
|
@@ -189,7 +271,7 @@ export default {
|
|
|
this.$router.push('/')
|
|
|
}
|
|
|
})
|
|
|
- this.$router.push({ name: 'warehousing' })
|
|
|
+ // this.$router.push({ name: 'warehousing' })
|
|
|
},
|
|
|
handleRemove(file, fileList) {
|
|
|
console.log(file, fileList);
|
|
|
@@ -228,18 +310,6 @@ export default {
|
|
|
}
|
|
|
this.dataForm.fileIds = fileIds.join(",");
|
|
|
},
|
|
|
- getPointRulesType() {
|
|
|
- dataTypeList({dictType:'integral_rule_type'}).then(response => {
|
|
|
- this.allTypeList = response.data.data;
|
|
|
- }).catch(() => {
|
|
|
-
|
|
|
- });
|
|
|
- },
|
|
|
- getAllUserList() {
|
|
|
- allUserList().then(response => {
|
|
|
- this.recipientsList = response.data.data;
|
|
|
- }).catch(() => { });
|
|
|
- },
|
|
|
}
|
|
|
}
|
|
|
</script>
|