优化进销存库存上传下载

This commit is contained in:
gyq
2024-06-20 09:06:35 +08:00
parent 2026193f0f
commit 7605011b63
13 changed files with 372 additions and 191 deletions

View File

@@ -5,7 +5,7 @@
</div>
<div class="head-container">
<el-table :data="tableData.detail.stockSnap" v-loading="tableData.loading" height="400px">
<el-table-column :label="`商品名称${tableData.detail.stockSnap.length}`" prop="name"></el-table-column>
<el-table-column :label="`商品名称`" prop="name"></el-table-column>
<el-table-column label="变动数量" prop="number">
<template v-slot="scope">
{{ scope.row.number }}{{ scope.row.unitName }}
@@ -16,7 +16,7 @@
<div class="head-container">
<div class="row">备注{{ tableData.detail.remark }}</div>
<div class="row">操作人{{ tableData.detail.operatorSnap.name }}</div>
<div class="row">创建时间{{ tableData.detail.createdAt }}</div>
<div class="row">创建时间{{ dayjs(tableData.detail.createdAt).format('YYYY-MM-DD HH:mm:ss') }}</div>
</div>
</el-dialog>
</template>

View File

@@ -1,23 +1,30 @@
<template>
<div class="app-container">
<div class="head-container">
<el-row :gutter="20">
<el-col :span="6">
<el-input v-model="query.name" size="small" clearable placeholder="商品名称" style="width: 100%;"
class="filter-item" @keyup.enter.native="getTableData" />
</el-col>
<el-col :span="6">
<div class="row_wrap">
<div class="row">
<el-input v-model="query.name" size="small" clearable placeholder="商品名称"
@keyup.enter.native="getTableData" />
<el-select v-model="query.isStock" placeholder="库存开关">
<el-option label="开" :value="1"></el-option>
<el-option label="关" :value="0"></el-option>
</el-select>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-col>
</el-row>
</div>
<div class="row">
<el-button icon="el-icon-download" :loading="downloadLoading" @click="protHandle">导出库存</el-button>
<el-button icon="el-icon-upload2" :loading="uploadLoading"
@click="dialogVisible = true">导入库存</el-button>
</div>
</div>
</div>
<div class="head-container">
<el-table :data="tableData.list" v-loading="tableData.loading">
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="shop_info">
<el-image :src="scope.row.coverImg" class="cover">
<el-image :src="scope.row.img" class="cover">
<div class="img_error" slot="error">
<i class="icon el-icon-document-delete"></i>
</div>
@@ -25,20 +32,21 @@
<div class="info">
<span>{{ scope.row.name }}</span>
<div>
<el-tag type="primary">{{ scope.row.typeEnum | typeEnum }}</el-tag>
<el-tag type="primary">{{ scope.row.type }}</el-tag>
</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column label="库存" prop="stockNumber">
<el-table-column label="库存" prop="number">
<template v-slot="scope">
{{ `${scope.row.stockNumber} ${scope.row.unitName}` }}
{{ `${scope.row.number} ${scope.row.unitName}` }}
</template>
</el-table-column>
<el-table-column label="库存开关">
<template v-slot="scope">
<el-switch v-model="scope.row.isStock" :active-value="1" :inactive-value="0"></el-switch>
<el-switch v-model="scope.row.isStock" :active-value="1" :inactive-value="0"
@change="showChange($event, scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="操作" width="100">
@@ -54,22 +62,33 @@
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<invoicingDetail ref="invoicingDetail" />
<!-- 导入库存弹窗 -->
<el-dialog title="导入库存" :visible.sync="dialogVisible">
<UploadExcel :beforeUpload="excelSuccessUpload" />
</el-dialog>
</div>
</template>
<script>
import { tbProductGet } from '@/api/invoicing'
import { stock, stockdownload, stockdoImport, stockStateChange } from '@/api/invoicing'
import settings from '@/settings'
import invoicingDetail from './components/invoicingDetail'
import UploadExcel from '@/components/UploadExcel/'
import { downloadFile } from "@/utils/index";
export default {
components: {
invoicingDetail
invoicingDetail,
UploadExcel
},
data() {
return {
dialogVisible: false,
query: {
name: ''
name: '',
isStock: ''
},
downloadLoading: false,
uploadLoading: false,
tableData: {
page: 0,
size: 10,
@@ -89,25 +108,60 @@ export default {
this.getTableData()
},
methods: {
async excelSuccessUpload(file) {
console.log(file);
try {
this.uploadLoading = true
this.dialogVisible = false
const res = await stockdoImport(file)
this.uploadLoading = false
this.$notify.success('导入成功')
this.getTableData()
} catch (error) {
this.dialogVisible = false
this.uploadLoading = false
console.log(error);
}
},
// 导出库存
async protHandle() {
try {
this.downloadLoading = true;
const file = await stockdownload({
name: this.query.name,
isStock: this.query.isStock
})
downloadFile(file, "商品库存", "xlsx");
this.downloadLoading = false;
} catch (error) {
this.downloadLoading = false;
console.log(error);
}
},
// 状态切换
async showChange(e, row) {
try {
await stockStateChange({
proId: row.proId,
isStock: row.isStock
})
this.getTableData()
} catch (error) {
console.error(error);
}
},
async getTableData() {
this.tableData.loading = true
try {
const res = await tbProductGet({
const res = await stock({
page: this.tableData.page,
size: this.tableData.size,
sort: this.tableData.sort,
name: this.query.name,
isStock: this.query.isStock,
shopId: localStorage.getItem('shopId')
})
this.tableData.loading = false
this.tableData.list = res.content.map(item => {
let stockNumber = 0
for (let i of item.skuList) {
stockNumber += i.stockNumber
}
item.stockNumber = stockNumber
return item
})
this.tableData.list = res.content
this.tableData.total = res.totalElements
} catch (error) {
console.log(error);
@@ -120,7 +174,7 @@ export default {
},
// 重置查询
resetHandle() {
this.query.blurry = ''
this.query.name = ''
this.tableData.page = 0;
this.getTableData()
}
@@ -148,4 +202,15 @@ export default {
justify-content: space-between;
}
}
.row_wrap {
display: flex;
justify-content: space-between;
.row {
display: flex;
align-items: center;
gap: 10px;
}
}
</style>

View File

@@ -13,7 +13,7 @@
<el-table :data="tableData.list" v-loading="tableData.loading">
<el-table-column label="类型" prop="type">
<template v-slot="scope">
{{ scope.row.type == 'reject' ? '退货出库' : '供应商入库' }}
{{ scope.row.type }}
</template>
</el-table-column>
<el-table-column label="商品数量" prop="totalAmount">

View File

@@ -89,8 +89,8 @@
</el-table-column>
<el-table-column label="进价">
<template v-slot="scope">
<el-input-number v-model="scope.row.guidePrice" :min="0" controls-position="right"
@change="e => scope.row.totalAmount = e * scope.row.number"></el-input-number>
<!-- <el-input-number v-model="scope.row.guidePrice" :min="0" controls-position="right"
@change="e => scope.row.totalAmount = e * scope.row.number"></el-input-number> -->
<div class="tips">成本价{{ scope.row.costPrice }}/{{ scope.row.unitName }}</div>
</template>
</el-table-column>
@@ -103,8 +103,9 @@
</el-table-column>
<el-table-column label="小计">
<template v-slot="scope">
<el-input-number v-model="scope.row.totalAmount" :min="0"
controls-position="right"></el-input-number>
<!-- <el-input-number v-model="scope.row.totalAmount" :min="0"
controls-position="right"></el-input-number> -->
<el-input :value="scope.row.costPrice * scope.row.number" readonly style="width: 100px;" />
</template>
</el-table-column>
<el-table-column label="变动后剩余库存">

View File

@@ -39,7 +39,8 @@
</el-col>
<el-col :span="8">
<el-form-item label="实收金额">
<el-input v-model="queryForm.paidAmount" placeholder="请输入实收金额" style="width: 220px;"></el-input>
<el-input v-model="queryForm.paidAmount" placeholder="请输入实收金额"
style="width: 220px;"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -53,7 +54,8 @@
</el-col>
<el-col :span="8">
<el-form-item label="批号">
<el-input v-model="queryForm.batchNumber" placeholder="请输入批号" style="width: 220px;"></el-input>
<el-input v-model="queryForm.batchNumber" placeholder="请输入批号"
style="width: 220px;"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -87,8 +89,8 @@
</el-table-column>
<el-table-column label="进价">
<template v-slot="scope">
<el-input-number v-model="scope.row.guidePrice" :min="0" controls-position="right"
@change="e => scope.row.totalAmount = e * scope.row.number"></el-input-number>
<!-- <el-input-number v-model="scope.row.guidePrice" :min="0" controls-position="right"
@change="e => scope.row.totalAmount = e * scope.row.number"></el-input-number> -->
<div class="tips">成本价{{ scope.row.costPrice }}/{{ scope.row.unitName }}</div>
</template>
</el-table-column>
@@ -101,8 +103,9 @@
</el-table-column>
<el-table-column label="小计">
<template v-slot="scope">
<el-input-number v-model="scope.row.totalAmount" :min="0"
controls-position="right"></el-input-number>
<!-- <el-input-number v-model="scope.row.totalAmount" :min="0"
controls-position="right"></el-input-number> -->
<el-input :value="scope.row.costPrice * scope.row.number" readonly style="width: 100px;" />
</template>
</el-table-column>
<el-table-column label="变动后剩余库存">

View File

@@ -5,7 +5,8 @@
<el-input v-model="query.name" clearable placeholder="供应商" @keyup.enter.native="getTableData"
style="width: 200px;" />
<el-select v-model="query.type" placeholder="付款状态">
<el-option :label="item.label" :value="item.value" v-for="item in types" :key="item.id"></el-option>
<el-option label="待支付" value="0"></el-option>
<el-option label="已完结" value="1"></el-option>
</el-select>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
@@ -37,7 +38,7 @@
</el-table-column>
<el-table-column label="上笔进货日期" prop="lastTransactAt">
<template v-slot="scope">
{{ dayjs(scope.row.lastTransactAt).format('YYYY-MM-DD HH:mm:ss') }}
{{ scope.row.lastTransactAt && dayjs(scope.row.lastTransactAt).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</el-table-column>
<el-table-column label="操作" width="80">
@@ -77,7 +78,6 @@ export default {
}
},
mounted() {
this.dictDetail()
this.getTableData()
},
methods: {
@@ -111,14 +111,6 @@ export default {
paginationChange(e) {
this.tableData.page = e - 1
this.getTableData()
},
async dictDetail() {
const { content } = await dictDetail({
dictName: 'purveyor_transact_status',
size: 100,
page: 0
})
this.types = content
}
}
}

View File

@@ -3,7 +3,7 @@
<div class="head-container">
<el-radio-group v-model="query.time" @change="timeChange">
<el-radio-button :label="item.value" v-for="item in timeList" :key="item.label">{{ item.label
}}</el-radio-button>
}}</el-radio-button>
</el-radio-group>
</div>
<div class="head-container" v-if="query.time == 'custom'">
@@ -14,7 +14,8 @@
<div class="head-container">
<div class="filter_wrap">
<el-select v-model="query.type" placeholder="付款状态">
<el-option :label="item.label" :value="item.value" v-for="item in types" :key="item.id"></el-option>
<el-option label="待支付" value="0"></el-option>
<el-option label="已完结" value="1"></el-option>
</el-select>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
@@ -98,7 +99,9 @@
</el-table-column>
<el-table-column label="状态" prop="status">
<template v-slot="scope">
<el-tag type="info">{{ types.find(item => item.value == scope.row.status).label }}</el-tag>
<el-tag type="info">
{{ types.find(item => item.value == scope.row.status).label }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" prop="remark"></el-table-column>
@@ -162,7 +165,20 @@ export default {
value: 'custom'
}
],
types: [],
types: [
{
value: 0,
label: '待付款'
},
{
value: 1,
label: '已付款'
},
{
value: '-1',
label: '作废'
}
],
selectCount: 0,
query: {
type: '',
@@ -181,7 +197,6 @@ export default {
}
},
mounted() {
this.dictDetail()
this.getTableData()
this.tbShopPurveyorTransactSum()
},
@@ -217,14 +232,6 @@ export default {
this.tableData.page = e - 1
this.getTableData()
},
async dictDetail() {
const { content } = await dictDetail({
dictName: 'purveyor_transact_status',
size: 100,
page: 0
})
this.types = content
},
// 选择时间
timeChange(e) {
this.query.createdAt = []

View File

@@ -5,7 +5,8 @@
<el-input v-model="query.name" clearable placeholder="供应商" @keyup.enter.native="getTableData"
style="width: 200px;" />
<el-select v-model="query.type" placeholder="付款状态">
<el-option :label="item.label" :value="item.value" v-for="item in types" :key="item.id"></el-option>
<el-option label="待支付" value="0"></el-option>
<el-option label="已完结" value="1"></el-option>
</el-select>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
@@ -37,7 +38,7 @@
</el-table-column>
<el-table-column label="上笔进货日期" prop="lastTransactAt">
<template v-slot="scope">
{{ dayjs(scope.row.lastTransactAt).format('YYYY-MM-DD HH:mm:ss') }}
{{ scope.row.lastTransactAt && dayjs(scope.row.lastTransactAt).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</el-table-column>
<el-table-column label="操作" width="80">
@@ -50,13 +51,14 @@
</el-table>
</div>
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
@current-change="paginationChange" @size-change="pagesizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
</template>
<script>
import dayjs from 'dayjs'
import { tbShopPurveyorTransactGet, dictDetail } from '@/api/invoicing'
import { tbShopPurveyorTransactGet } from '@/api/invoicing'
export default {
data() {
return {
@@ -77,7 +79,6 @@ export default {
}
},
mounted() {
this.dictDetail()
this.getTableData()
},
methods: {
@@ -112,13 +113,9 @@ export default {
this.tableData.page = e - 1
this.getTableData()
},
async dictDetail() {
const { content } = await dictDetail({
dictName: 'purveyor_transact_status',
size: 100,
page: 0
})
this.types = content
pagesizeChange(e) {
this.tableData.size = e
this.getTableData()
}
}
}

View File

@@ -2,8 +2,8 @@
<div class="app-container">
<div class="head-container">
<div class="filter_wrap">
<el-input v-model="query.name" size="small" clearable placeholder="供应商" @keyup.enter.native="getTableData"
style="width: 200px;" />
<el-input v-model="query.name" size="small" clearable placeholder="供应商"
@keyup.enter.native="getTableData" style="width: 200px;" />
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</div>
@@ -32,7 +32,8 @@
</el-table>
</div>
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
@current-change="paginationChange" @size-change="pagesizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<addSupplier ref="addSupplier" @success="getTableData" />
</div>
</template>
@@ -100,6 +101,10 @@ export default {
this.tableData.page = 0;
this.getTableData()
},
pagesizeChange(e) {
this.tableData.size = e
this.getTableData()
},
// 分页回调
paginationChange(e) {
this.tableData.page = e - 1