123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <a-modal
- centered
- class="shelfSet-newHw-modal"
- :footer="null"
- :maskClosable="false"
- title="编辑"
- v-model="isShow"
- @cancel="isShow=false"
- :width="600">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="shelfSet-newHw-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol">
- <a-form-model-item label="产品编码">{{ nowData&&nowData.productVO.code || '--' }}</a-form-model-item>
- <a-form-model-item label="产品名称">{{ nowData&&nowData.productVO.name || '--' }}</a-form-model-item>
- <a-form-model-item label="货位编号" prop="stackPlaceCode">
- <a-input v-model="form.stackPlaceCode" placeholder="请输入货位编号(最多10个字符)"></a-input>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button type="primary" id="shelfSet-newHw-modal-save" @click="handleSave">保存</a-button>
- <a-button id="shelfSet-newHw-modal-back" @click="isShow=false" style="margin-left: 15px;">取消</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { stackPlaceSave } from '@/api/product'
- export default {
- name: 'EditHwModal',
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- type: {
- type: String,
- default: 'edit'
- },
- nowData: {
- type: Object,
- default: () => {
- return {}
- }
- }
- },
- data () {
- return {
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 18 }
- },
- form: {
- shelfPlaceCode: '',
- productSn: undefined,
- productCode: undefined,
- price: '',
- cost: '',
- maxQty: ''
- },
- rules: {
- shelfPlaceCode: [
- { required: true, message: '请输入货位编号', trigger: 'blur' }
- ]
- },
- productName: ''
- }
- },
- methods: {
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- const params = {
- 'stackPlaceCode': form.stackPlaceCode,
- 'product': {
- 'productSn': _this.nowData.productVO.productSn
- }
- }
- // 开始提交数据
- _this.spinning = true
- stackPlaceSave(params).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.isShow = false
- _this.$emit('ok', res.data)
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- },
- resetData () {
- this.form.stackPlaceCode = undefined
- this.$refs.ruleForm.resetFields()
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetData()
- } else {
- if (this.type == 'edit') {
- this.form.stackPlaceCode = this.nowData.stackPlaceCode
- }
- }
- }
- }
- }
- </script>
- <style lang="less">
- .shelfSet-newHw-modal {
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .ant-form-item{
- margin-bottom: 15px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|