From 50b1b07bfa382c3f19c6b23f1cff4dfa50294f07 Mon Sep 17 00:00:00 2001 From: 石广澎 <shiguangpeng@163.com> Date: 星期四, 30 十一月 2023 10:58:38 +0800 Subject: [PATCH] feat: 库存管理 增加加载状态 --- admin-web/src/views/stock/accessStock/outbound/edit.vue | 49 +++++++++++++++++++++++++++---------------------- 1 files changed, 27 insertions(+), 22 deletions(-) diff --git a/admin-web/src/views/stock/accessStock/outbound/edit.vue b/admin-web/src/views/stock/accessStock/outbound/edit.vue index 1521f03..e7d1cd4 100644 --- a/admin-web/src/views/stock/accessStock/outbound/edit.vue +++ b/admin-web/src/views/stock/accessStock/outbound/edit.vue @@ -1,6 +1,6 @@ <template> <win-md class="stock-edit" :title="`${setting.title}鍑哄簱`" @close="close" :width="'800px'"> - <el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px"> + <el-form v-loading="loading" class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px"> <div class="main-w"> <el-row :gutter="24" class="headerHeight"> <el-col :span="12"> @@ -169,24 +169,19 @@ </el-form> <div slot="footer" align="center" class="dialog-footer"> <my-button name="鍙栨秷" site="form" @click="close" /> - <my-button name="淇濆瓨" site="form" @click="handleSubmit" /> + <el-button name="淇濆瓨" type="primary" size="medium" :loading="btnloading" @click="handleSubmit">淇濆瓨</el-button> </div> </win-md> </template> <script> -import { - goodsTemplate, - goodsModel, - selectTenantWarehouse, - warehouseSelectNumber, -} from '@/api/baseSetting/finsystenant'; -import { outputAdd } from '@/api/stock/accessStock'; -import { getTree } from '@/api/foudation/classification'; +import {goodsModel, goodsTemplate, selectTenantWarehouse, warehouseSelectNumber,} from '@/api/baseSetting/finsystenant'; +import {outputAdd} from '@/api/stock/accessStock'; +import {getTree} from '@/api/foudation/classification'; import MyButton from '@/components/myButton/myButton'; import winMd from '@/components/win/win-md'; import upload from '@/components/upload/index'; -import { getUploadUrl } from '@/utils/base'; -import { mapGetters } from 'vuex'; +import {getUploadUrl} from '@/utils/base'; +import {mapGetters} from 'vuex'; export default { components: { MyButton, winMd, upload }, @@ -210,7 +205,8 @@ callback(); }; return { - loading: false, + loading: true, + btnloading: false, warehouseOptions: [], // 鍑哄簱浠撳簱鍒楄〃 categoryOptions: [], // 鐗╁搧鍒嗙被鍒楄〃 modelList: [], //鍨嬪彿鍒楄〃 @@ -268,17 +264,18 @@ }, methods: { async init() { - this.getWarehouseList(); - this.getgoodsTemplate(); - this.getgoodsModel(); + await this.getWarehouseList(); + await this.getgoodsTemplate(); + await this.getgoodsModel(); // 鑾峰彇鐗╁搧鍒嗙被鍒楄〃 const treeRes = await getTree(); this.categoryOptions = this.removeEmptyChildren(treeRes); + this.loading = false }, // 鑾峰彇鍑哄簱浠撳簱鍒楄〃 - getWarehouseList() { - selectTenantWarehouse({ agencyId: this.userInfo.tenantId }) + async getWarehouseList() { + await selectTenantWarehouse({ agencyId: this.userInfo.tenantId }) .then((res) => { this.warehouseOptions = res; if (res.length) { @@ -306,8 +303,8 @@ }, // 鑾峰彇鐗╁搧鍚嶇О鍒楄〃 - getgoodsTemplate(id, index) { - goodsTemplate({ categoryId: id || '' }).then((res) => { + async getgoodsTemplate(id, index) { + await goodsTemplate({ categoryId: id || '' }).then((res) => { if (index || index == 0) { this.$set(this.formData.goods[index], 'goodsOptions', res); } else { @@ -317,8 +314,8 @@ }, // 瑙勬牸鍨嬪彿 - getgoodsModel(id, index) { - goodsModel({ goodsTemplatesId: id || '' }).then((res) => { + async getgoodsModel(id, index) { + await goodsModel({ goodsTemplatesId: id || '' }).then((res) => { if (index || index == 0) { this.$set(this.formData.goods[index], 'modelsOptions', res); } else { @@ -432,19 +429,27 @@ handleSubmit() { this.$refs['ruleForm'].validate((valid) => { if (valid) { + if (this.loading) return + this.loading = true; + this.btnloading = true; console.log('this.formData', this.formData); outputAdd(this.formData) .then((res) => { this.$message.success('淇濆瓨鎴愬姛锛�'); + this.btnloading = false; + this.loading = false; this.close(); this.$emit('search'); }) .catch((err) => { console.log('edit err', err); + this.btnloading = false; + this.loading = false; this.$message.error('淇濆瓨澶辫触'); }); } else { this.$message.error('鏍¢獙鏈�氳繃锛岃妫�鏌ャ��'); + this.btnloading = false; } }); }, -- Gitblit v1.9.1