<!--
|
* @Author: wuyue
|
* @Date: 2022-12-09 16:29:16
|
* @LastEditTime: 2022-12-22 14:09:05
|
* @LastEditors: wuyue
|
* @Descripttion:手动扣减
|
* @version:
|
-->
|
<template>
|
<div>
|
<el-dialog :visible.sync="dialogVisible" title="手动扣减" :close-on-click-modal="false"
|
:modal-append-to-body="false" v-if="dialogVisible">
|
<el-form size="mini" :model="form" label-width="120px" ref="form" :rules="formRules">
|
<el-form-item label="商品主编码:" prop="spuNum">
|
{{row.spuNum}}
|
</el-form-item>
|
<el-form-item label="商品名称:" prop="spuName">
|
{{row.spuName}}
|
</el-form-item>
|
<el-form-item label="库存扣减:" prop="spuName">
|
<el-table border size="mini" :data="form.tableData">
|
<el-table-column prop="stock" label="剩余库存"></el-table-column>
|
<el-table-column label="扣减数量">
|
<template slot-scope="scope">
|
<el-form-item :prop="`tableData.${scope.$index}.returnStock`" :rules="formRules.reduceNumRules">
|
<el-input-number :min="0" :max="999999999" v-model="scope.row.returnStock"></el-input-number>
|
</el-form-item>
|
</template>
|
</el-table-column>
|
</el-table>
|
<span class="itemTip">提示:扣减数量不得超出剩余库存</span>
|
</el-form-item>
|
<el-form-item label="扣减原因:" prop="remark">
|
<el-input v-model="form.remark" type="textarea" :autosize="{minRows:2,maxRows:4}"
|
placeholder="请输入扣减原因" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="操作日志:" prop="spuName">
|
<list-condition-template ref="table" :tableData="logData" :total="total" @page-info-change="handlePageInfoChange">
|
<template slot="columns">
|
<el-table-column prop="createTime" label="操作时间"></el-table-column>
|
<el-table-column prop="beforeStock" label="剩余库存">
|
</el-table-column>
|
<el-table-column prop="stock" label="扣减数量">
|
<template slot-scope="scope">
|
{{Math.abs(scope.row.stock)}}
|
</template>
|
</el-table-column>
|
<el-table-column prop="remark" label="备注">
|
</el-table-column>
|
<el-table-column prop="createName" label="操作人"></el-table-column>
|
</template>
|
</list-condition-template>
|
</el-form-item>
|
</el-form>
|
<div class="buttonPosition">
|
<el-button size="mini" @click="submit" type="primary" :loading="loading">保存</el-button>
|
<el-button size="mini" @click="dialogVisible = false">取消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import channelInventoryApi from '@/api/stockManagement/channelInventory'
|
import { inputNumberValid } from '@/utils/validator'
|
|
export default {
|
props: {
|
row: {
|
type: Object,
|
default: function() {
|
return {}
|
}
|
}
|
},
|
data() {
|
return {
|
dialogVisible: false,
|
form: {
|
spuName: null,
|
spuNum: null,
|
remark: null,
|
tableData: []
|
},
|
formRules: {
|
reduceNumRules: [{ required: true, validator: inputNumberValid }, {
|
validator: (rule, value, callback) => {
|
if (value > this.form.tableData[0].stock) {
|
callback(new Error('扣减数量不得大于剩余库存'))
|
} else {
|
callback()
|
}
|
}
|
},
|
],
|
remark: [{ max: 120, message: '扣减原因最多只能输入 120 个字' }]
|
},
|
loading: false,
|
logData: [],
|
total: 0
|
}
|
},
|
methods: {
|
// 弹出框打开关闭事件
|
toggleDialog() {
|
this.dialogVisible = !this.dialogVisible
|
if (this.dialogVisible) {
|
this.$nextTick(() => {
|
this.getStockLog()
|
this.form.spuName = this.row.spuName
|
this.form.spuNum = this.row.spuNum
|
this.form.remark = null
|
this.form.tableData = [{
|
stock: this.row.stock,
|
returnStock: undefined
|
}]
|
})
|
}
|
},
|
/**
|
* '分页信息改变时查询列表
|
*/
|
handlePageInfoChange(pageInfo) {
|
this.getStockLog(pageInfo)
|
},
|
// 获取库存日志
|
async getStockLog(pageInfo = { pageNum: 1, pageSize: 10 }) {
|
const params = {
|
channel: this.row.channel,
|
spuNums: [this.row.spuNum],
|
stockType: 'RETURN_STOCK_OUTPUT',
|
current: pageInfo.pageNum,
|
size: pageInfo.pageSize,
|
}
|
const res = await channelInventoryApi.querySoldStockOrderDetail(params)
|
if (res.data) {
|
this.logData = res.data.records
|
this.total = res.data.total
|
}
|
},
|
/**
|
* 提交
|
*/
|
submit() {
|
this.$refs.form.validate().then(async res => {
|
this.loading = true
|
try {
|
const params = {
|
channel: this.row.channel,
|
returnStock: this.form.tableData[0].returnStock,
|
remark: this.form.remark,
|
spuNum: this.row.spuNum,
|
spuName: this.row.spuName,
|
spuType: this.row.spuType,
|
}
|
const res = await channelInventoryApi.returnStockChannel(params)
|
if (res.data) {
|
this.$parent.queryList()
|
this.dialogVisible = false
|
}
|
this.loading = false
|
} catch (error) {
|
this.loading = false
|
}
|
})
|
}
|
}
|
}
|
</script>
|