mt-ck-wms-ui/src/views/basicData/Cache/components/shelfAttr-add.vue

181 lines
6.1 KiB
Vue
Raw Normal View History

2021-09-13 14:56:28 +08:00
<!--
* @Author: zwq
* @Date: 2020-12-29 16:37:56
2022-03-03 20:48:59 +08:00
* @LastEditors: fzq
2022-03-10 21:15:33 +08:00
* @LastEditTime: 2022-03-10 19:38:31
2021-09-13 14:56:28 +08:00
* @Description:
-->
<template>
2022-03-03 20:48:59 +08:00
<!-- 新增/编辑识别 :title="!dataForm.areaId ? 'btn.add' : 'btn.edit' | i18nFilter" -->
2021-09-13 14:56:28 +08:00
<el-dialog
2022-03-03 20:48:59 +08:00
:title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
2021-09-13 14:56:28 +08:00
:visible.sync="visible"
>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="130px" @keyup.enter.native="dataFormSubmit()">
<el-form-item :label="$t('module.basicData.cache.ShelfName')" prop="name">
2022-02-25 15:12:37 +08:00
<el-input v-model="dataForm.shelfName" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.ShelfName')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
<el-form-item :label="$t('module.basicData.cache.ShelfCode')" prop="code">
<el-input v-model="dataForm.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.ShelfCode')])" clearable />
</el-form-item>
2022-03-03 20:48:59 +08:00
<!-- 选择货架code的下拉框
2021-09-13 14:56:28 +08:00
<el-form-item v-if="isPage" :label="$t('module.basicData.cache.AreaName')" prop="areaId">
<el-select v-model="dataForm.areaId" filterable :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.AreaName')])" clearable>
<el-option
v-for="item in areaArr"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
2022-03-03 20:48:59 +08:00
</el-form-item> -->
<el-form-item :label="$t('module.basicData.cache.StorageQuantity')" prop="total">
<el-input-number v-model="dataForm.total" :step="1" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.StorageQuantity')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
2022-03-03 20:48:59 +08:00
<el-form-item :label="$t('module.basicData.cache.rowNum')" prop="rowNum">
<el-input-number v-model="dataForm.rowNum" :step="1" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.rowNum')])" clearable />
</el-form-item>
<el-form-item :label="$t('module.basicData.cache.columnNum')" prop="columnNum">
<el-input-number v-model="dataForm.columnNum" :step="1" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.cache.columnNum')])" clearable />
2021-09-13 14:56:28 +08:00
</el-form-item>
</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>
2022-03-10 21:15:33 +08:00
import { shelfDetail, shelfUpdate, shelfAdd, shelfCode } from '@/api/basicData/Cache/shelf'
2021-09-13 14:56:28 +08:00
export default {
props: {
areaId: {
type: String,
default: () => {
return ''
}
}
},
data() {
return {
visible: false,
isPage: false,
dataForm: {
2022-02-25 15:12:37 +08:00
abbr: 'n',
2021-09-13 14:56:28 +08:00
id: 0,
areaId: '',
2022-02-25 15:12:37 +08:00
shelfName: '',
2021-09-13 14:56:28 +08:00
code: '',
2022-02-25 15:12:37 +08:00
shelfNumber: '',
total: ''
2021-09-13 14:56:28 +08:00
},
areaArr: [],
dataRule: {
2022-02-25 15:12:37 +08:00
shelfName: [
2021-09-13 14:56:28 +08:00
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.cache.ShelfName')]), trigger: 'blur' }
],
code: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.cache.ShelfCode')]), trigger: 'blur' }
],
areaId: [
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.cache.AreaName')]), trigger: 'change' }
]
}
}
},
methods: {
2022-03-10 21:15:33 +08:00
// init(id, isPage) {
// this.isPage = isPage || false
// this.dataForm.id = id || ''
// if (!this.isPage) {
// this.dataForm.areaId = this.areaId
// }
// this.areaArr.splice(0, this.areaArr.length)
// const params = {
// current: 1,
// size: 500
// }
// shelfList(params).then(response => {
// if (response.data.records) {
// this.areaArr = response.data.records
// }
// })
// this.visible = true
// this.$nextTick(() => {
// this.$refs['dataForm'].resetFields()
// if (this.dataForm.id) {
// shelfDetail(this.dataForm.id).then(res => {
// this.dataForm = res.data
// })
// } else {
// shelfCode().then(res => {
// this.dataForm.code = res.data
// })
// }
// })
// },
init(id) {
2021-09-13 14:56:28 +08:00
this.dataForm.id = id || ''
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
2022-03-10 21:15:33 +08:00
// console.log(this.dataForm)
2021-09-13 14:56:28 +08:00
shelfDetail(this.dataForm.id).then(res => {
2022-03-10 21:15:33 +08:00
// console.log(res)
2021-09-13 14:56:28 +08:00
this.dataForm = res.data
})
} else {
2022-03-10 21:15:33 +08:00
this.dataForm.shelfName = ''
2021-09-13 14:56:28 +08:00
shelfCode().then(res => {
this.dataForm.code = res.data
})
}
})
2022-03-10 21:15:33 +08:00
// console.log(this.dataForm)
2021-09-13 14:56:28 +08:00
},
2022-03-10 21:15:33 +08:00
// getClose() {
// this.dataForm.shelfName = ''
// console.log(this.dataForm)
// },
2021-09-13 14:56:28 +08:00
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
const data = this.dataForm
2022-03-03 20:48:59 +08:00
// console.log(data)
2021-09-13 14:56:28 +08:00
if (this.dataForm.id) {
shelfUpdate(data).then(res => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
} else {
shelfAdd(data).then(res => {
2022-03-10 21:15:33 +08:00
// console.log(res)
2021-09-13 14:56:28 +08:00
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
}
}
})
}
}
}
</script>