|
@@ -5,10 +5,10 @@
|
|
|
:close-on-click-modal="false"
|
|
|
:visible.sync="visible">
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="auto">
|
|
|
- <el-row class="my-row">
|
|
|
+ <el-row class="my-row my-row-1">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="编码" prop="recordCode">
|
|
|
- <el-input v-model="dataForm.recordCode" placeholder="编码"></el-input>
|
|
|
+ <el-input v-model="dataForm.recordCode" :disabled="true" placeholder="编码系统自动生成"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" style="padding-left: 20px">
|
|
@@ -17,22 +17,34 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" style="padding-left: 20px">
|
|
|
- <el-form-item label="申请人部门" prop="orgId">
|
|
|
- <el-input :disabled="true" v-model="dataForm.orgName" placeholder="请选择入库申请人"></el-input>
|
|
|
+ <el-form-item label="申请人部门" prop="orgName">
|
|
|
+ <el-input :disabled="true" v-model="dataForm.orgName" placeholder="自动匹配"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <template v-for="(item, index) in dataForm">
|
|
|
+ <template v-for="(item, index) in dataList">
|
|
|
<div :key="index" class="my-line">
|
|
|
<el-row class="my-row">
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="名称" prop="materialName">
|
|
|
- <el-input v-model="item.materialName" placeholder="请填写名称"></el-input>
|
|
|
+ <el-select v-model="item.materialId"
|
|
|
+ remote
|
|
|
+ filterable
|
|
|
+ :remote-method="remoteMaterial"
|
|
|
+ @change="onMaterialChanged(item)"
|
|
|
+ placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in optionsMaterial"
|
|
|
+ :key="item.code"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.code">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="padding-left: 20px">
|
|
|
- <el-form-item label="批次号" prop="batchNumber">
|
|
|
- <el-input v-model="item.batchNumber" placeholder="请填写入库物品(零件)批次"></el-input>
|
|
|
+ <el-form-item label="类别" prop="categoryName">
|
|
|
+ <el-input v-model="item.categoryName" :disabled="true" placeholder="类别"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="text-align: right;">
|
|
@@ -42,17 +54,17 @@
|
|
|
<el-row class="my-row">
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="单位" prop="unitName">
|
|
|
- <el-input v-model="item.unitName" placeholder="缺字段"></el-input>
|
|
|
+ <el-input v-model="item.unitName" :disabled="true" placeholder="单位"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="padding-left: 20px">
|
|
|
- <el-form-item label="类别" prop="cateId">
|
|
|
- <dict-select :dict-id="item.cateId" v-bind:dict-type="dictType"/>
|
|
|
+ <el-form-item label="规格" prop="specifications">
|
|
|
+ <el-input v-model="item.specifications" :disabled="true" placeholder="规格"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="padding-left: 20px">
|
|
|
- <el-form-item label="规格" prop="specifications">
|
|
|
- <el-input v-model="item.specifications" placeholder="缺字段"></el-input>
|
|
|
+ <el-form-item label="批次号" prop="batchNumber">
|
|
|
+ <el-input v-model="item.batchNumber" placeholder="请填写入库物品(零件)批次"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -80,10 +92,15 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="padding-left: 20px">
|
|
|
- <el-form-item label="是否换算" prop="transfer">
|
|
|
- <el-select v-model="item.transfer">
|
|
|
- <el-option label="是" value="1"></el-option>
|
|
|
- <el-option label="否" value="0"></el-option>
|
|
|
+ <el-form-item label="是否换算" prop="unitNeedChange">
|
|
|
+ <el-select v-model="item.unitNeedChange"
|
|
|
+ placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in optionsConversion"
|
|
|
+ :key="item.code"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.code">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
@@ -109,53 +126,45 @@
|
|
|
<script>
|
|
|
import UserComponent from '../common/user-component'
|
|
|
import DictSelect from '../sys/dict-select'
|
|
|
- import {getUUID} from '../../../utils'
|
|
|
+ import { getUserInfo } from '@/api/user'
|
|
|
+ import { getMaterialList, getConversionList, inboundBatch } from '@/api/warehouse'
|
|
|
export default {
|
|
|
name: 'stock-order-inbound',
|
|
|
components: {DictSelect, UserComponent},
|
|
|
+ computed: {
|
|
|
+ orgId: {
|
|
|
+ get () { return this.$store.state.user.orgId }
|
|
|
+ }
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
visible: false,
|
|
|
dictType: 'material_type',
|
|
|
- dataForm: [{
|
|
|
- id: '',
|
|
|
- amount: 0,
|
|
|
- applicant: '',
|
|
|
- approver: '',
|
|
|
- batchNumber: '',
|
|
|
- cnt: '',
|
|
|
- materialId: '',
|
|
|
- materialName: '',
|
|
|
- notes: '',
|
|
|
- orgId: '',
|
|
|
- price: '',
|
|
|
- recordType: '',
|
|
|
- source: '',
|
|
|
- state: 0,
|
|
|
- templateItemPlanId: '',
|
|
|
- usage: '',
|
|
|
- userId: '',
|
|
|
- orgName: ''
|
|
|
- }],
|
|
|
+ dataForm: {},
|
|
|
+ dataList: [],
|
|
|
dataRule: {
|
|
|
- }
|
|
|
+ },
|
|
|
+ optionsMaterial: [],
|
|
|
+ optionsConversion: []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
init () {
|
|
|
this.visible = true
|
|
|
- this.dataForm = []
|
|
|
+ this.dataForm = {}
|
|
|
+ this.dataList = []
|
|
|
this.addOne()
|
|
|
},
|
|
|
addOne () {
|
|
|
- this.dataForm.push({
|
|
|
+ this.dataList.push({
|
|
|
id: '',
|
|
|
- code: getUUID(),
|
|
|
+ code: '',
|
|
|
amount: 0,
|
|
|
applicant: '',
|
|
|
approver: '',
|
|
|
batchNumber: '',
|
|
|
cnt: '',
|
|
|
+ categoryName: '',
|
|
|
materialId: '',
|
|
|
materialName: '',
|
|
|
notes: '',
|
|
@@ -167,12 +176,13 @@
|
|
|
templateItemPlanId: '',
|
|
|
usage: '',
|
|
|
userId: '',
|
|
|
- orgName: ''
|
|
|
+ orgName: '',
|
|
|
+ unitNeedChange: ''
|
|
|
})
|
|
|
},
|
|
|
removeOne (index) {
|
|
|
- this.dataForm.splice(index, 1)
|
|
|
- if (this.dataForm.length === 0) {
|
|
|
+ this.dataList.splice(index, 1)
|
|
|
+ if (this.dataList.length === 0) {
|
|
|
this.addOne()
|
|
|
}
|
|
|
},
|
|
@@ -180,29 +190,30 @@
|
|
|
dataFormSubmit () {
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl(`/biz-service/in-out-bound-ctl/inbound`),
|
|
|
- method: 'post',
|
|
|
- data: this.$http.adornData({
|
|
|
- 'amount': this.dataForm.amount,
|
|
|
- 'applicant': this.dataForm.applicant,
|
|
|
- 'approver': this.dataForm.approver,
|
|
|
- 'batchNumber': this.dataForm.batchNumber,
|
|
|
- 'cnt': this.dataForm.cnt,
|
|
|
- 'materialId': this.dataForm.materialId,
|
|
|
- 'materialName': this.dataForm.materialName,
|
|
|
- 'notes': this.dataForm.notes,
|
|
|
- 'price': this.dataForm.price,
|
|
|
- 'orgId': this.dataForm.orgId,
|
|
|
- 'recordType': this.dataForm.recordType,
|
|
|
- 'source': this.dataForm.source,
|
|
|
- 'state': this.dataForm.state,
|
|
|
- 'templateItemPlanId': this.dataForm.templateItemPlanId,
|
|
|
- 'usage': this.dataForm.usage,
|
|
|
- 'userId': this.dataForm.userId,
|
|
|
- 'creatorId': this.$store.state.user.id
|
|
|
+ let postData = []
|
|
|
+ this.dataList.forEach((item) => {
|
|
|
+ postData.push({
|
|
|
+ amount: item.amount,
|
|
|
+ applicant: item.applicant,
|
|
|
+ approver: item.approver,
|
|
|
+ batchNumber: item.batchNumber,
|
|
|
+ cnt: item.cnt,
|
|
|
+ materialId: item.materialId,
|
|
|
+ materialName: item.materialName,
|
|
|
+ materialTypeId: item.materialTypeId,
|
|
|
+ notes: item.notes,
|
|
|
+ orgId: this.orgId,
|
|
|
+ price: item.price,
|
|
|
+ recordCode: this.dataForm.recordCode,
|
|
|
+ recordType: this.dataForm.recordType,
|
|
|
+ source: item.source,
|
|
|
+ specifications: item.specifications,
|
|
|
+ unitName: item.unitName,
|
|
|
+ unitNeedChange: item.unitNeedChange
|
|
|
})
|
|
|
- }).then(({data}) => {
|
|
|
+ })
|
|
|
+ console.log('postData = ' + JSON.stringify(postData))
|
|
|
+ inboundBatch(postData).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.$message({
|
|
|
message: '操作成功',
|
|
@@ -224,17 +235,66 @@
|
|
|
this.$refs.dataForm.validateField(type)
|
|
|
},
|
|
|
userChanged (userId) {
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl('/user-service/user/info/' + userId),
|
|
|
- method: 'get'
|
|
|
- }).then(({data}) => {
|
|
|
+ getUserInfo(userId).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
+ console.log('user data = ' + JSON.stringify(data.data))
|
|
|
this.dataForm.orgId = data.data.orgId
|
|
|
this.dataForm.orgName = data.data.orgName
|
|
|
+ console.log('this.dataForm = ' + JSON.stringify(this.dataForm))
|
|
|
} else {
|
|
|
this.$message.error(data.msg)
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ // 远程方法:物料List
|
|
|
+ async remoteMaterial (query) {
|
|
|
+ if (!query) return
|
|
|
+ const params = {
|
|
|
+ materialName: query.trimStart()
|
|
|
+ }
|
|
|
+ await getMaterialList(params).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.optionsMaterial = []
|
|
|
+ data.data.records.forEach((item) => {
|
|
|
+ this.optionsMaterial.push({
|
|
|
+ code: item.materialId,
|
|
|
+ value: item.materialName,
|
|
|
+ cateId: item.cateId,
|
|
|
+ categoryName: item.categoryName,
|
|
|
+ specifications: item.specifications,
|
|
|
+ unitName: item.unitName
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onMaterialChanged (item) {
|
|
|
+ if (!item.materialId) return
|
|
|
+ let item2 = this.optionsMaterial.find((item1) => item1.code === item.materialId)
|
|
|
+ if (!item2) return
|
|
|
+ item.categoryName = item2.categoryName
|
|
|
+ item.cateId = item2.cateId
|
|
|
+ item.specifications = item2.specifications
|
|
|
+ item.unitName = item2.unitName
|
|
|
+ this.remoteNeedChange(item.materialId)
|
|
|
+ },
|
|
|
+ // 远程选择:是否需要换算
|
|
|
+ remoteNeedChange (materialId) {
|
|
|
+ if (!materialId) return
|
|
|
+ const params = {
|
|
|
+ materialId: materialId
|
|
|
+ }
|
|
|
+ getConversionList(params).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.optionsConversion = []
|
|
|
+ data.data.records.forEach((item) => {
|
|
|
+ this.optionsConversion.push({
|
|
|
+ code: item.conversionId,
|
|
|
+ value: '编码:' + item.conversionCode + ',单位:' + item.convertUnit
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -245,4 +305,7 @@
|
|
|
border-bottom: 1px solid #c0c4cc;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
+ .my-row-1{
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
</style>
|