|
|
@@ -0,0 +1,83 @@
|
|
|
+<template>
|
|
|
+ <div class="inbound-create admin-page">
|
|
|
+ <el-card>
|
|
|
+ <div slot="header" class="admin-page-header">
|
|
|
+ <span class="admin-page-title">创建入库单</span>
|
|
|
+ <el-button @click="$router.push('/inventory')">返回</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-form label-width="100px">
|
|
|
+ <el-form-item label="供应商">
|
|
|
+ <el-input v-model="form.supplierName" placeholder="供应商名称" style="width:300px;" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="入库明细">
|
|
|
+ <div v-for="(item, idx) in form.items" :key="idx" style="display:flex;gap:8px;margin-bottom:8px;align-items:center;">
|
|
|
+ <el-input v-model="item.productId" placeholder="商品ID" type="number" style="width:120px;" />
|
|
|
+ <el-input v-model="item.skuId" placeholder="SKU ID(选填)" type="number" style="width:120px;" />
|
|
|
+ <el-input v-model="item.quantity" placeholder="数量" type="number" style="width:100px;" />
|
|
|
+ <el-button type="danger" size="mini" @click="form.items.splice(idx,1)">删除</el-button>
|
|
|
+ </div>
|
|
|
+ <el-button type="primary" size="mini" @click="form.items.push({productId:'',skuId:'',quantity:1})">添加行</el-button>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="备注">
|
|
|
+ <el-input v-model="form.remark" type="textarea" :rows="2" style="width:400px;" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="success" @click="handleSubmit" :loading="submitting">提交入库单</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { createInboundOrder } from '@/api/admin'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'InventoryInboundCreate',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ submitting: false,
|
|
|
+ form: {
|
|
|
+ supplierName: '',
|
|
|
+ remark: '',
|
|
|
+ items: [{ productId: '', skuId: '', quantity: 1 }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async handleSubmit() {
|
|
|
+ const validItems = this.form.items.filter(i => i.productId && i.quantity > 0)
|
|
|
+ if (validItems.length === 0) {
|
|
|
+ return this.$message.warning('请添加入库明细')
|
|
|
+ }
|
|
|
+ this.submitting = true
|
|
|
+ try {
|
|
|
+ const items = validItems.map(i => ({
|
|
|
+ productId: parseInt(i.productId),
|
|
|
+ skuId: i.skuId ? parseInt(i.skuId) : null,
|
|
|
+ quantity: parseInt(i.quantity)
|
|
|
+ }))
|
|
|
+ await createInboundOrder({
|
|
|
+ supplierName: this.form.supplierName || null,
|
|
|
+ remark: this.form.remark || null,
|
|
|
+ items
|
|
|
+ })
|
|
|
+ this.$message.success('入库单已创建')
|
|
|
+ this.$router.push('/inventory')
|
|
|
+ } catch (e) {
|
|
|
+ this.$message.error('创建失败')
|
|
|
+ } finally {
|
|
|
+ this.submitting = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.inbound-create { padding: 20px; }
|
|
|
+</style>
|