|
@@ -1,104 +1,101 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
- title="新增换算"
|
|
|
+ :title="!id ? '新增': display ? '详情' : '修改'"
|
|
|
+ width="70%"
|
|
|
:close-on-click-modal="false"
|
|
|
:visible.sync="visible">
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
|
|
|
<el-row class="my-row">
|
|
|
- <el-form-item label="编码">
|
|
|
- <el-input v-model="dataForm.code" placeholder="编码"></el-input>
|
|
|
+ <el-form-item label="编码" prop="conversionCode">
|
|
|
+ <el-input v-model="dataForm.conversionCode" :disabled="true" placeholder="系统自动生成"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row class="my-row">
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="数量">
|
|
|
- <el-input v-model="dataForm.code" placeholder="数量"></el-input>
|
|
|
+ <el-form-item label="转换前数量">
|
|
|
+ <el-input value="1" :disabled="true" placeholder="数量"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12" style="padding-left: 20px">
|
|
|
- <el-form-item label="单位">
|
|
|
- <el-input v-model="dataForm.code" placeholder="单位"></el-input>
|
|
|
+ <el-form-item label="单位" prop="convertUnitBefore">
|
|
|
+ <el-input v-model="dataForm.convertUnitBefore" :disabled="display" placeholder="单位"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row class="my-row">
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="转换后数量">
|
|
|
- <el-input v-model="dataForm.code" placeholder="转换后数量"></el-input>
|
|
|
+ <el-form-item label="转换后数量" prop="cnt">
|
|
|
+ <el-input-number v-model="dataForm.cnt" :disabled="display" placeholder="转换后数量" :min="1" :step="1"></el-input-number>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12" style="padding-left: 20px">
|
|
|
- <el-form-item label="单位">
|
|
|
- <el-input v-model="dataForm.code" placeholder="转换后单位"></el-input>
|
|
|
+ <el-form-item label="单位" prop="convertUnit">
|
|
|
+ <el-input v-model="dataForm.convertUnit" :disabled="display" placeholder="转换后单位"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row class="my-row">
|
|
|
- <el-form-item label="备注说明:">
|
|
|
- <el-input v-model="dataForm.code" placeholder="编码"></el-input>
|
|
|
+ <el-form-item label="备注说明" prop="notes">
|
|
|
+ <el-input v-model="dataForm.notes" :disabled="display" placeholder="编码"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="visible = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
+ <el-button v-if="!display" @click="visible = false">取消</el-button>
|
|
|
+ <el-button v-if="!display" type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import UserComponent from '../common/user-component'
|
|
|
- import DictSelect from '../sys/dict-select'
|
|
|
- import {getUUID} from '../../../utils'
|
|
|
+ import { getConversionDetail, addOrUpdateConversion } from '../../../api/warehouse'
|
|
|
export default {
|
|
|
- name: 'stock-order-inbound',
|
|
|
- components: {DictSelect, UserComponent},
|
|
|
+ name: 'unit-add',
|
|
|
data () {
|
|
|
return {
|
|
|
visible: false,
|
|
|
- dictType: 'material_type',
|
|
|
- dataList: [],
|
|
|
+ display: false,
|
|
|
+ id: 0,
|
|
|
dataForm: {
|
|
|
- id: '',
|
|
|
- amount: 0,
|
|
|
- applicant: ''
|
|
|
+ cnt: 1
|
|
|
},
|
|
|
dataRule: {
|
|
|
+ convertUnitBefore: [{ required: true, message: '转换前单位不能为空', trigger: 'blur' }],
|
|
|
+ cnt: [{ required: true, message: '转换后数量不能为空', trigger: 'blur' }],
|
|
|
+ convertUnit: [{ required: true, message: '转换后单位不能为空', trigger: 'blur' }]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- init () {
|
|
|
+ async init (id, display) {
|
|
|
+ this.dataForm = {}
|
|
|
this.visible = true
|
|
|
- this.dataForm.code = getUUID()
|
|
|
+ this.id = id || 0
|
|
|
+ this.display = display
|
|
|
+ if (!id) return
|
|
|
+ await getConversionDetail(this.id).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.dataForm = data.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
},
|
|
|
// 表单提交
|
|
|
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
|
|
|
- })
|
|
|
- }).then(({data}) => {
|
|
|
+ let params = {
|
|
|
+ cnt: this.dataForm.cnt,
|
|
|
+ conversionCode: this.dataForm.conversionCode,
|
|
|
+ conversionId: this.id ? this.id : null,
|
|
|
+ convertUnit: this.dataForm.convertUnit,
|
|
|
+ convertUnitBefore: this.dataForm.convertUnitBefore,
|
|
|
+ orgId: this.orgId,
|
|
|
+ notes: this.dataForm.notes
|
|
|
+ }
|
|
|
+ addOrUpdateConversion(params, !this.id).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.$message({
|
|
|
message: '操作成功',
|
|
@@ -112,23 +109,7 @@
|
|
|
} else {
|
|
|
this.$message.error(data.msg)
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- validateField (type) {
|
|
|
- this.$refs.dataForm.validateField(type)
|
|
|
- },
|
|
|
- userChanged (userId) {
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl('/user-service/user/info/' + userId),
|
|
|
- method: 'get'
|
|
|
- }).then(({data}) => {
|
|
|
- if (data && data.code === '200') {
|
|
|
- this.dataForm.orgId = data.data.orgId
|
|
|
- this.dataForm.orgName = data.data.orgName
|
|
|
- } else {
|
|
|
- this.$message.error(data.msg)
|
|
|
+ }).catch(() => {})
|
|
|
}
|
|
|
})
|
|
|
}
|