mt-ck-wms-ui/src/views/report-manage/components/edit-substrate.vue

158 lines
5.6 KiB
Vue
Raw Normal View History

2022-03-05 19:43:42 +08:00
<!--
* @Descripttion:
* @version:
* @Author: fzq
* @Date: 2022-03-05 17:45:46
* @LastEditors: fzq
2022-03-10 21:15:33 +08:00
* @LastEditTime: 2022-03-07 09:19:34
2022-03-05 19:43:42 +08:00
-->
<template>
<!-- <el-dialog
:title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
:visible.sync="visible"
> -->
<el-dialog
:title="'btn.edit' | i18nFilter"
:visible.sync="visible"
>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="130px" @keyup.enter.native="dataFormSubmit()">
<el-form-item :label="$t('module.report.substrate.substrateCode')" prop="substrateCode">
<el-input v-model="dataForm.substrateCode" :placeholder="$i18nForm(['placeholder.input', $t('module.report.substrate.substrateCode')])" clearable />
</el-form-item>
<el-form-item :label="$t('module.report.substrate.location')" prop="location">
2022-03-06 19:36:26 +08:00
<el-input v-model="dataForm.location" :placeholder="$i18nForm(['placeholder.input', $t('module.report.substrate.location')])" clearable />
2022-03-05 19:43:42 +08:00
</el-form-item>
<el-form-item :label="$t('module.report.substrate.storeTime')" prop="storeTime">
<el-input v-model="dataForm.storeTime" :placeholder="$i18nForm(['placeholder.input', $t('module.report.substrate.storeTime')])" clearable />
</el-form-item>
<el-form-item :label="$t('module.report.substrate.substrateStatus')" prop="substrateStatus">
<el-input v-model="dataForm.substrateStatus" :placeholder="$i18nForm(['placeholder.input', $t('module.report.substrate.substrateStatus')])" clearable />
</el-form-item>
2022-03-06 19:36:26 +08:00
<el-form-item :label="$t('module.report.substrate.interCode')" prop="interCode">
<el-input v-model="dataForm.interCode" :placeholder="$i18nForm(['placeholder.input', $t('module.report.substrate.interCode')])" clearable />
</el-form-item>
2022-03-05 19:43:42 +08:00
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
<el-button type="primary" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { updateSubstrate, listSubstrate } from '@/api/report-manage/report'
export default {
props: {
id: {
type: String,
default: () => {
return ''
}
}
},
data() {
return {
visible: false,
dataForm: {
id: '',
substrateCode: '',
location: '',
storeTime: '',
2022-03-06 19:36:26 +08:00
substrateStatus: '',
code: '',
storageBoxId: '',
storageCode: '',
interCode: ''
},
list: {
id: '',
location: '',
storeTime: '',
substrateCode: '',
2022-03-05 19:43:42 +08:00
substrateStatus: ''
2022-03-06 19:36:26 +08:00
},
dataRule: {
substrateCode: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.report.substrate.substrateCode')]), trigger: 'blur' }
],
code: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.report.substrate.substrateCode')]), trigger: 'blur' }
],
interCode: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.report.substrate.substrateCode')]), trigger: 'blur' }
]
2022-03-05 19:43:42 +08:00
}
}
},
2022-03-06 19:36:26 +08:00
created() {
this.init()
},
2022-03-05 19:43:42 +08:00
methods: {
2022-03-06 19:36:26 +08:00
// init(id) {
// // this.dataForm.id = id || ''
// this.dataForm.storageBoxId = this.$route.query.id
// this.dataForm.storageCode = this.$route.query.code
// this.visible = true
// this.$nextTick(() => {
// this.$refs['dataForm'].resetFields()
// // console.log(this.dataForm)
// listSubstrate(this.dataForm).then(res => {
// this.dataForm.id = res.data.id
// this.dataForm.location = res.data.location
// this.dataForm.storeTime = res.data.storeTime
// this.dataForm.substrateCode = res.data.substrateCode
// this.dataForm.substrateStatus = res.data.substrateStatus
// // console.log(this.dataForm)
// })
// })
// },
2022-03-05 19:43:42 +08:00
init(id) {
2022-03-06 19:36:26 +08:00
// this.dataForm.id = id || ''
this.dataForm.storageBoxId = this.$route.query.id
this.dataForm.storageCode = this.$route.query.code
2022-03-05 19:43:42 +08:00
this.visible = true
2022-03-10 21:15:33 +08:00
// console.log(this.dataForm)
2022-03-06 19:36:26 +08:00
listSubstrate(this.dataForm).then(res => {
console.log(res.data[0])
this.dataForm.id = res.data[0].id
this.dataForm.location = res.data[0].location
this.dataForm.storeTime = res.data[0].storeTime
this.dataForm.substrateCode = res.data[0].substrateCode
this.dataForm.substrateStatus = res.data[0].substrateStatus
this.dataForm.interCode = res.data[0].interCode
// console.log(this.dataForm)
2022-03-05 19:43:42 +08:00
})
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
const data = {
'substrateStatus': this.dataForm.substrateStatus,
'storeTime': this.dataForm.storeTime,
'id': this.dataForm.id,
'substrateCode': this.dataForm.substrateCode,
2022-03-06 19:36:26 +08:00
'location': this.dataForm.location,
'interCode': this.dataForm.interCode,
'storageBoxId': this.dataForm.storageBoxId
2022-03-05 19:43:42 +08:00
}
2022-03-06 19:36:26 +08:00
console.log(data)
2022-03-05 19:43:42 +08:00
updateSubstrate(data).then(res => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
}
})
}
}
}
</script>