|
@@ -1,143 +1,234 @@
|
|
<template>
|
|
<template>
|
|
- <div>
|
|
|
|
- <a-modal
|
|
|
|
- centered
|
|
|
|
- wrapClassName="addHWModal-modal"
|
|
|
|
- :footer="null"
|
|
|
|
- :maskClosable="false"
|
|
|
|
- :title="textTitle"
|
|
|
|
- v-model="isshow"
|
|
|
|
- @cancle="isshow=false"
|
|
|
|
- :width="500">
|
|
|
|
- <a-spin :spinning="spinning" tip="Loading...">
|
|
|
|
- <a-form-model
|
|
|
|
- id="addHWModal-form"
|
|
|
|
- ref="ruleForm"
|
|
|
|
- :model="form"
|
|
|
|
- :rules="rules"
|
|
|
|
- >
|
|
|
|
- <a-row :gutter="20">
|
|
|
|
- <a-col :span="24">
|
|
|
|
- <a-form-model-item label="货位号" prop="shelfPlaceCode" :label-col="{span: 5}" :wrapper-col="{span: 18}">
|
|
|
|
- <a-input id="addHWModal-shelfPlaceCode" v-model.trim="form.shelfPlaceCode" allowClear placeholder="请输入货位号"/>
|
|
|
|
- </a-form-model-item>
|
|
|
|
|
|
+ <a-modal
|
|
|
|
+ centered
|
|
|
|
+ class="shelfSet-newHw-modal"
|
|
|
|
+ :footer="null"
|
|
|
|
+ :maskClosable="false"
|
|
|
|
+ :title="modalTit"
|
|
|
|
+ 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.shelfName || '--' }}</a-form-model-item>
|
|
|
|
+ <a-form-model-item label="货位号" prop="shelfPlaceCode">
|
|
|
|
+ <a-input v-model="form.shelfPlaceCode" placeholder="请输入货位号"></a-input>
|
|
|
|
+ </a-form-model-item>
|
|
|
|
+ <a-form-model-item label="绑定产品" v-if="type=='add'">
|
|
|
|
+ <productJqList ref="productJqList" :params="{customerSn:nowData&&nowData.customerSn}" @change="productJqChange"></productJqList>
|
|
|
|
+ </a-form-model-item>
|
|
|
|
+ <a-form-model-item label="产品名称" v-if="form.productSn">{{ productName || '--' }}</a-form-model-item>
|
|
|
|
+ <a-form-model-item v-if="form.productSn" label="销售价" prop="price">
|
|
|
|
+ <a-row>
|
|
|
|
+ <a-col :span="20">
|
|
|
|
+ <a-input-number
|
|
|
|
+ id="shelfSet-newHw-price"
|
|
|
|
+ v-model="form.price"
|
|
|
|
+ :precision="2"
|
|
|
|
+ :min="0.01"
|
|
|
|
+ :max="999999"
|
|
|
|
+ placeholder="请输入正数(最多允许两位小数)"
|
|
|
|
+ suffix="元"
|
|
|
|
+ style="width: 100%;display: inline-block;" />
|
|
</a-col>
|
|
</a-col>
|
|
|
|
+ <a-col :span="4"><span style="margin-left: 10px;">元</span></a-col>
|
|
</a-row>
|
|
</a-row>
|
|
- <a-form-model-item :label-col="{span: 0}" :wrapper-col="{span: 24}" style="text-align: center;">
|
|
|
|
- <a-button type="primary" @click="handleSubmit()" :style="{ marginRight: '8px' }" id="addHWModal-handleSubmit">保存</a-button>
|
|
|
|
- <a-button :style="{ marginLeft: '8px' }" @click="isshow=false" id="addHWModal-close">取消</a-button>
|
|
|
|
- </a-form-model-item>
|
|
|
|
- </a-form-model>
|
|
|
|
- </a-spin>
|
|
|
|
- </a-modal>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </a-form-model-item>
|
|
|
|
+ <a-form-model-item v-if="form.productSn" label="结算价" prop="cost">
|
|
|
|
+ <a-row>
|
|
|
|
+ <a-col :span="20">
|
|
|
|
+ <a-input-number
|
|
|
|
+ id="shelfSet-newHw-cost"
|
|
|
|
+ v-model="form.cost"
|
|
|
|
+ :precision="2"
|
|
|
|
+ :min="0"
|
|
|
|
+ :max="999999"
|
|
|
|
+ placeholder="请输入正数(最多允许两位小数)"
|
|
|
|
+ suffix="元"
|
|
|
|
+ style="width: 100%;display: inline-block;" />
|
|
|
|
+ </a-col>
|
|
|
|
+ <a-col :span="4"><span style="margin-left: 10px;">元</span></a-col>
|
|
|
|
+ </a-row>
|
|
|
|
+ </a-form-model-item>
|
|
|
|
+ <a-form-model-item v-if="form.productSn" label="最大库容" prop="maxQty">
|
|
|
|
+ <a-input-number
|
|
|
|
+ id="shelfSet-newHw-maxQty"
|
|
|
|
+ v-model="form.maxQty"
|
|
|
|
+ :precision="0"
|
|
|
|
+ :min="0"
|
|
|
|
+ :max="999999"
|
|
|
|
+ placeholder="请输入最大库容(正整数或0)"
|
|
|
|
+ suffix="元"
|
|
|
|
+ style="width: 100%;display: inline-block;" />
|
|
|
|
+ </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>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { saveHw, shelfHWDetail } from '@/api/shelf.js'
|
|
|
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
|
+import { VSelect } from '@/components'
|
|
|
|
+import productJqList from '@/views/common/productJqList.vue'
|
|
|
|
+import { addPlaceAndProduct } from '@/api/shelf'
|
|
export default {
|
|
export default {
|
|
- name: 'AddHWModal',
|
|
|
|
|
|
+ name: 'AddHwModal',
|
|
|
|
+ components: { VSelect, productJqList },
|
|
|
|
+ mixins: [commonMixin],
|
|
props: {
|
|
props: {
|
|
- openHWModal: {
|
|
|
|
|
|
+ openModal: { // 弹框显示状态
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false
|
|
default: false
|
|
},
|
|
},
|
|
- shelfSn: {
|
|
|
|
- type: [String, Number],
|
|
|
|
|
|
+ type: {
|
|
|
|
+ type: String,
|
|
default: ''
|
|
default: ''
|
|
},
|
|
},
|
|
nowData: {
|
|
nowData: {
|
|
type: Object,
|
|
type: Object,
|
|
- default: function () {
|
|
|
|
|
|
+ default: () => {
|
|
return {}
|
|
return {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
spinning: false,
|
|
spinning: false,
|
|
- isshow: this.openHWModal,
|
|
|
|
- textTitle: '新增货位',
|
|
|
|
- roleList: [],
|
|
|
|
- pageInfo: null,
|
|
|
|
|
|
+ isShow: this.openModal, // 是否打开弹框
|
|
|
|
+ formItemLayout: {
|
|
|
|
+ labelCol: { span: 4 },
|
|
|
|
+ wrapperCol: { span: 18 }
|
|
|
|
+ },
|
|
form: {
|
|
form: {
|
|
- shelfPlaceCode: '' // 货位号
|
|
|
|
|
|
+ shelfPlaceCode: '',
|
|
|
|
+ productSn: undefined,
|
|
|
|
+ productCode: undefined,
|
|
|
|
+ price: '',
|
|
|
|
+ cost: '',
|
|
|
|
+ maxQty: ''
|
|
},
|
|
},
|
|
rules: {
|
|
rules: {
|
|
- shelfPlaceCode: [ { required: true, message: '请输入货位号', trigger: 'blur' }, { pattern: '^[^\u4e00-\u9fa5]{0,}$', message: '货位号不支持汉字' }]
|
|
|
|
|
|
+ shelfPlaceCode: [{ required: true, message: '请输入货位号', trigger: 'blur' }],
|
|
|
|
+ price: [{ required: true, message: '请输入销售价', trigger: 'blur' }],
|
|
|
|
+ cost: [{ required: true, message: '请输入结算价', trigger: 'blur' }],
|
|
|
|
+ maxQty: [{ required: true, message: '请输入最大库容', trigger: 'blur' }]
|
|
|
|
+ },
|
|
|
|
+ productName: ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ modalTit () {
|
|
|
|
+ let title = ''
|
|
|
|
+ if (this.type == 'edit') {
|
|
|
|
+ title = '编辑货位'
|
|
|
|
+ } else if (this.type == 'add') {
|
|
|
|
+ title = '新增货位'
|
|
}
|
|
}
|
|
|
|
+ return title
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // 过滤空格
|
|
|
|
- filterEmpty () {
|
|
|
|
- let str = this.form.name
|
|
|
|
- str = str.replace(/\ +/g, '')
|
|
|
|
- str = str.replace(/[ ]/g, '')
|
|
|
|
- str = str.replace(/[\r\n]/g, '')
|
|
|
|
- this.form.name = str
|
|
|
|
|
|
+ // 产品 change
|
|
|
|
+ productJqChange (obj) {
|
|
|
|
+ this.form.productSn = obj.key || undefined
|
|
|
|
+ this.form.productCode = obj && obj.row && obj.row.code || ''
|
|
|
|
+ this.form.price = obj && obj.row && obj.row.price || ''
|
|
|
|
+ this.form.cost = obj && obj.row && obj.row.cost || ''
|
|
|
|
+ this.productName = obj && obj.row && obj.row.name || ''
|
|
},
|
|
},
|
|
- // 查询货位详情
|
|
|
|
- getShelfHWDetail () {
|
|
|
|
- this.spinning = true
|
|
|
|
- shelfHWDetail({ shelfPlaceSn: this.nowData.shelfPlaceSn }).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- this.form = Object.assign({}, res.data)
|
|
|
|
- }
|
|
|
|
- this.spinning = false
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 保存提交
|
|
|
|
- handleSubmit () {
|
|
|
|
|
|
+ // 保存
|
|
|
|
+ handleSave () {
|
|
const _this = this
|
|
const _this = this
|
|
this.$refs.ruleForm.validate(valid => {
|
|
this.$refs.ruleForm.validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- const params = JSON.parse(JSON.stringify(_this.form))
|
|
|
|
- params.shelfSn = _this.shelfSn ? _this.shelfSn : null
|
|
|
|
- console.log(params.id, params.shelfSn, '------------编辑新增')
|
|
|
|
|
|
+ const params = {}
|
|
|
|
+ const form = JSON.parse(JSON.stringify(_this.form))
|
|
|
|
+ params.shelfSn = _this.nowData && _this.nowData.shelfSn
|
|
|
|
+ params.shelfPlaceCode = form.shelfPlaceCode
|
|
|
|
+ if (this.type == 'edit') {
|
|
|
|
+ params.id = this.nowData.id
|
|
|
|
+ }
|
|
|
|
+ // 绑定了产品
|
|
|
|
+ if (form.productSn) {
|
|
|
|
+ params.shelfProductApiEntity = {
|
|
|
|
+ productSn: form.productSn,
|
|
|
|
+ productCode: form.productCode,
|
|
|
|
+ price: form.price,
|
|
|
|
+ cost: form.cost,
|
|
|
|
+ maxQty: form.maxQty
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 开始提交数据
|
|
_this.spinning = true
|
|
_this.spinning = true
|
|
- saveHw(params).then(res => {
|
|
|
|
|
|
+ addPlaceAndProduct(params).then(res => {
|
|
if (res.status == 200) {
|
|
if (res.status == 200) {
|
|
_this.$message.success(res.message)
|
|
_this.$message.success(res.message)
|
|
- _this.$emit('refresh')
|
|
|
|
- setTimeout(function () {
|
|
|
|
- _this.isshow = false
|
|
|
|
- _this.spinning = false
|
|
|
|
- }, 300)
|
|
|
|
|
|
+ _this.isShow = false
|
|
|
|
+ _this.$emit('ok', res.data)
|
|
|
|
+ _this.spinning = false
|
|
} else {
|
|
} else {
|
|
_this.spinning = false
|
|
_this.spinning = false
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- console.log('error submit!!')
|
|
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ },
|
|
|
|
+ resetData () {
|
|
|
|
+ this.form.productSn = undefined
|
|
|
|
+ this.form.productCode = undefined
|
|
|
|
+ this.form.price = ''
|
|
|
|
+ this.form.cost = ''
|
|
|
|
+ this.form.maxQty = ''
|
|
|
|
+ if (this.$refs.productJqList) {
|
|
|
|
+ this.$refs.productJqList.resetForm()
|
|
|
|
+ }
|
|
|
|
+ this.$refs.ruleForm.resetFields(['productSn'])
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
- openHWModal (newValue, oldValue) {
|
|
|
|
- console.log(newValue, 'newValue')
|
|
|
|
- this.isshow = newValue
|
|
|
|
|
|
+ // 父页面传过来的弹框状态
|
|
|
|
+ openModal (newValue, oldValue) {
|
|
|
|
+ this.isShow = newValue
|
|
},
|
|
},
|
|
- isshow (newValue, oldValue) {
|
|
|
|
|
|
+ // 重定义的弹框状态
|
|
|
|
+ isShow (newValue, oldValue) {
|
|
if (!newValue) {
|
|
if (!newValue) {
|
|
- console.log(!newValue, newValue)
|
|
|
|
- this.$refs.ruleForm.resetFields()
|
|
|
|
- this.form = {}
|
|
|
|
- this.textTitle = '新增货位'
|
|
|
|
this.$emit('close')
|
|
this.$emit('close')
|
|
|
|
+ this.resetData()
|
|
|
|
+ this.productName = ''
|
|
} else {
|
|
} else {
|
|
- if (this.nowData && this.nowData.id) { // 编辑
|
|
|
|
- console.log(this.shelfPlaceSn, 'this.shelfPlaceSn')
|
|
|
|
- this.textTitle = '编辑货位'
|
|
|
|
- this.getShelfHWDetail()
|
|
|
|
|
|
+ if (this.type == 'edit') {
|
|
|
|
+ this.form.shelfPlaceCode = this.nowData.shelfPlaceCode
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
+
|
|
<style lang="less">
|
|
<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>
|
|
</style>
|