|
@@ -96,7 +96,7 @@
|
|
|
size="small"
|
|
|
type="link"
|
|
|
class="button-primary"
|
|
|
- @click="handleAdd(record)"
|
|
|
+ @click="handleAddNew(record)"
|
|
|
id="purchaseReturnEdit-add-btn">添加</a-button>
|
|
|
</template>
|
|
|
</s-table>
|
|
@@ -341,17 +341,35 @@ export default {
|
|
|
this.chooseQueryParam.productName = ''
|
|
|
this.$refs.chooseTable.refresh(true)
|
|
|
},
|
|
|
- // 添加/编辑
|
|
|
- handleAdd (row, isEdit) {
|
|
|
- // 添加时退货数量字段名为returnQty,编辑时退货数量字段名为qty
|
|
|
- if (!isEdit && (row.returnPrice === null || row.returnPrice == undefined || Number(row.returnPrice).toString().trim().length === 0)) {
|
|
|
- this.$message.warning('请输入退货价格')
|
|
|
+ // 添加
|
|
|
+ handleAddNew (record) {
|
|
|
+ const _this = this
|
|
|
+ if (record.returnQty === null || record.returnQty === undefined || Number(record.returnQty).toString().trim().length === 0) {
|
|
|
+ this.$message.warning('请输入退货数量')
|
|
|
return
|
|
|
}
|
|
|
- if (!isEdit && !row.returnQty) {
|
|
|
- this.$message.warning('请输入退货数量')
|
|
|
+ if (record.returnPrice === '' || record.returnPrice === null || record.returnPrice === undefined || Number(record.returnPrice).toString().trim().length === 0) {
|
|
|
+ this.$message.warning('请输入退货价格')
|
|
|
return
|
|
|
}
|
|
|
+ if (record.returnPrice === 0) {
|
|
|
+ this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '退货单价为0,确定添加?',
|
|
|
+ centered: true,
|
|
|
+ onOk () {
|
|
|
+ _this.handleAdd(record)
|
|
|
+ },
|
|
|
+ onCancel () {
|
|
|
+ record.returnPrice = ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.handleAdd(record)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 添加/编辑
|
|
|
+ handleAdd (row, isEdit) {
|
|
|
const params = {
|
|
|
id: isEdit ? row.id : undefined,
|
|
|
purchaseReturnSn: this.$route.params.sn,
|
|
@@ -371,17 +389,6 @@ export default {
|
|
|
remarks: row.remarks,
|
|
|
promotionFlag: row.promotionFlag
|
|
|
}
|
|
|
- if (isEdit) { // 编辑
|
|
|
- // 清空退货数量时,值应保持未清空前的值,因退货数量都不可为空
|
|
|
- if (!row.qty) {
|
|
|
- row.qty = row.qtyBackups
|
|
|
- return
|
|
|
- }
|
|
|
- if (!row.cost) {
|
|
|
- row.cost = row.costBackups
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
this.spinning = true
|
|
|
purchaseReturnDetailSave(params).then(res => {
|
|
|
if (res.status == 200) {
|
|
@@ -395,10 +402,6 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 双击快速添加
|
|
|
- handleClickRow (record) {
|
|
|
- this.handleAdd(record)
|
|
|
- },
|
|
|
// 导入明细
|
|
|
handleImport () {},
|
|
|
// 删除
|
|
@@ -460,6 +463,10 @@ export default {
|
|
|
},
|
|
|
// 已选产品 退货数量 blur
|
|
|
qtyBlur (val, record) {
|
|
|
+ if (val === '') {
|
|
|
+ record.qty = record.qtyBackups
|
|
|
+ return
|
|
|
+ }
|
|
|
// 光标移出,值发生改变再调用编辑接口
|
|
|
if (val != record.qtyBackups) {
|
|
|
this.handleAdd(record, 'edit')
|
|
@@ -467,8 +474,27 @@ export default {
|
|
|
},
|
|
|
// 已选产品 退货单价 blur
|
|
|
costBlur (val, record) {
|
|
|
- if (val && (val != record.costBackups)) {
|
|
|
- this.handleAdd(record, 'edit')
|
|
|
+ const _this = this
|
|
|
+ if (val === '') {
|
|
|
+ record.cost = record.costBackups
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (Number(val) !== record.costBackups) {
|
|
|
+ if (Number(val) === 0) {
|
|
|
+ this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定将退货单价修改为0?',
|
|
|
+ centered: true,
|
|
|
+ onOk () {
|
|
|
+ _this.handleAdd(record, 'edit')
|
|
|
+ },
|
|
|
+ onCancel () {
|
|
|
+ record.cost = record.costBackups
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.handleAdd(record, 'edit')
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
// 仓库
|