Commit 6071308f by gyt

fix(consignmentRecall、createConsignmentRecallOrder): 导入位置改动

parent 4fa91662
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
<div class="operation-button row verCenter"> <div class="operation-button row verCenter">
<el-button type="primary" @click="$router.push('/createConsignmentRecallOrder')">生成寄售召回单</el-button> <el-button type="primary" @click="$router.push('/createConsignmentRecallOrder')">生成寄售召回单</el-button>
<el-button type="danger" @click="popupEvent(2)">作废</el-button> <el-button type="danger" @click="popupEvent(2)">作废</el-button>
<el-upload :action="batchRecallUpload" :headers="uploadHeaders" :on-success="handleUploadSuccess" :on-error="handleUploadError" :before-upload="handleBeforeUpload" accept=".xlsx,.xls" :show-file-list="false" name="file" style="display: inline-block; margin-left: 10px;"> <!-- <el-upload :action="batchRecallUpload" :headers="uploadHeaders" :on-success="handleUploadSuccess" :on-error="handleUploadError" :before-upload="handleBeforeUpload" accept=".xlsx,.xls" :show-file-list="false" name="file" style="display: inline-block; margin-left: 10px;">
<el-button type="primary" :loading="uploadLoading">导入</el-button> <el-button type="primary" :loading="uploadLoading">导入</el-button>
</el-upload> </el-upload>
<a href="http://cloud.liexindev.net/template/批量召回模板.xlsx" download style="text-decoration: none; margin-left: 10px;"> <a href="http://cloud.liexindev.net/template/批量召回模板.xlsx" download style="text-decoration: none; margin-left: 10px;">
<el-button type="primary">下载模板</el-button> <el-button type="primary">下载模板</el-button>
</a> </a> -->
<!-- <!--
<el-button type="primary" @click="popupEvent(1)">提交审核</el-button> <el-button type="primary" @click="popupEvent(1)">提交审核</el-button>
<el-button type="danger" @click="popupEvent(3)"> 收货信息</el-button> <el-button type="danger" @click="popupEvent(3)"> 收货信息</el-button>
...@@ -120,10 +120,10 @@ ...@@ -120,10 +120,10 @@
name: "consignmentRecall", name: "consignmentRecall",
data() { data() {
return { return {
batchRecallUpload: NODE_ENVS + '/api/consignmentRecall/batchRecallUpload', // batchRecallUpload: NODE_ENVS + '/api/consignmentRecall/batchRecallUpload',
uploadHeaders: { // uploadHeaders: {
'Authorization': 'Bearer ' + Util.getCookie('token') || '' // 'Authorization': 'Bearer ' + Util.getCookie('token') || ''
}, // },
options: pcaTextArr, options: pcaTextArr,
selectedOptions: ['广东省', '深圳市', '龙岗区'], selectedOptions: ['广东省', '深圳市', '龙岗区'],
multipleSelection: [], multipleSelection: [],
...@@ -263,42 +263,42 @@ ...@@ -263,42 +263,42 @@
* @param file 上传的文件 * @param file 上传的文件
* @return {boolean} * @return {boolean}
*/ */
handleBeforeUpload(file) { // handleBeforeUpload(file) {
var isExcel = /\.(xlsx|xls)$/i.test(file.name); // var isExcel = /\.(xlsx|xls)$/i.test(file.name);
if (!isExcel) { // if (!isExcel) {
this.$message.error('仅支持上传 .xlsx 或 .xls 格式的文件'); // this.$message.error('仅支持上传 .xlsx 或 .xls 格式的文件');
return false; // return false;
} // }
this.uploadLoading = true; // this.uploadLoading = true;
return true; // return true;
}, // },
/** /**
* 导入上传成功回调 * 导入上传成功回调
* @param res 接口返回数据 * @param res 接口返回数据
*/ */
handleUploadSuccess(res) { // handleUploadSuccess(res) {
this.uploadLoading = false; // this.uploadLoading = false;
if (res.code === 0) { // if (res.code === 0) {
var { success_total = 0, fail_total = 0, fail_list } = res.data || {}; // var { success_total = 0, fail_total = 0, fail_list } = res.data || {};
var failMsg = '' // var failMsg = ''
if(fail_list.length){ // if(fail_list.length){
failMsg += `失败原因:\n`; // failMsg += `失败原因:\n`;
failMsg = fail_list.map(item => item.remark).join(';\n'); // failMsg = fail_list.map(item => item.remark).join(';\n');
} // }
this.$message.success(`导入完成,成功 ${success_total} 条,失败 ${fail_total} 条`); // this.$message.success(`导入完成,成功 ${success_total} 条,失败 ${fail_total} 条`);
failMsg && this.$alert(failMsg); // failMsg && this.$alert(failMsg);
this.getData(); // this.getData();
} else { // } else {
this.$message.error(res.msg || '导入失败'); // this.$message.error(res.msg || '导入失败');
} // }
}, // },
/** /**
* 导入上传失败回调 * 导入上传失败回调
*/ */
handleUploadError() { // handleUploadError() {
this.uploadLoading = false; // this.uploadLoading = false;
this.$message.error('导入失败,请重试'); // this.$message.error('导入失败,请重试');
}, // },
/** /**
* 弹窗事件 * 弹窗事件
*/ */
......
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
</div> </div>
<div class="xktitle" style="margin-bottom: 10px;">召回库存明细</div> <div class="xktitle" style="margin-bottom: 10px;">召回库存明细</div>
<el-button type="primary" @click="add">添加</el-button> <el-button type="primary" @click="add">添加</el-button>
<el-upload :action="batchRecallUpload" :headers="uploadHeaders" :on-success="handleUploadSuccess" :on-error="handleUploadError" :before-upload="handleBeforeUpload" accept=".xlsx,.xls" :show-file-list="false" name="file" style="display: inline-block; margin-left: 10px;">
<el-button type="primary" :loading="uploadLoading">导入</el-button>
</el-upload>
<a href="http://cloud.liexindev.net/template/批量召回模板.xlsx" download style="text-decoration: none; margin-left: 10px;">
<el-button type="primary">下载模板</el-button>
</a>
<div style="margin-top: 10px;"> <div style="margin-top: 10px;">
<el-table :data="recall_json" border max-height="500"> <el-table :data="recall_json" border max-height="500">
<el-table-column type="index" label="序号" width="50" align="center" fixed></el-table-column> <el-table-column type="index" label="序号" width="50" align="center" fixed></el-table-column>
...@@ -125,17 +131,24 @@ ...@@ -125,17 +131,24 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import Menu from "@/components/menu.vue"; import Menu from "@/components/menu.vue";
import { Autocomplete, Button, Cascader, DatePicker, Descriptions, DescriptionsItem, Dialog, Divider, Dropdown, DropdownItem, DropdownMenu, Form, FormItem, Input, InputNumber, Link, Message, MessageBox, Option, Pagination, Popover, Select, Table, TableColumn, Tag, Tooltip } from 'element-ui' import { Autocomplete, Button, Cascader, DatePicker, Descriptions, DescriptionsItem, Dialog, Divider, Dropdown, DropdownItem, DropdownMenu, Form, FormItem, Input, InputNumber, Link, Message, MessageBox, Option, Pagination, Popover, Select, Table, TableColumn, Tag, Tooltip, Upload} from 'element-ui'
import { pcaTextArr } from 'element-china-area-data' import { pcaTextArr } from 'element-china-area-data'
import { NODE_ENVS } from "@/ajax/index"
import Util from "@/tool/index.js"
Vue.prototype.$message = Message Vue.prototype.$message = Message
Vue.prototype.$confirm = MessageBox.confirm; Vue.prototype.$confirm = MessageBox.confirm;
Vue.use(Button).use(Link).use(Cascader).use(Form).use(Select).use(Option).use(Input).use(InputNumber).use(FormItem).use(Dialog).use(Tooltip).use(Autocomplete).use(Popover).use(Tag).use(Divider); Vue.use(Button).use(Link).use(Cascader).use(Form).use(Select).use(Option).use(Input).use(InputNumber).use(FormItem).use(Dialog).use(Tooltip).use(Autocomplete).use(Popover).use(Tag).use(Divider).use(Upload);
Vue.use(DatePicker).use(Dropdown).use(DropdownMenu).use(DropdownItem).use(TableColumn).use(Table).use(Pagination).use(Descriptions).use(DescriptionsItem); Vue.use(DatePicker).use(Dropdown).use(DropdownMenu).use(DropdownItem).use(TableColumn).use(Table).use(Pagination).use(Descriptions).use(DescriptionsItem);
export default { export default {
name: "createConsignmentRecallOrder", name: "createConsignmentRecallOrder",
data() { data() {
return { return {
batchRecallUpload: NODE_ENVS + '/api/consignmentRecall/batchRecallUpload',
uploadHeaders: {
'Authorization': 'Bearer ' + Util.getCookie('token') || ''
},
uploadLoading: false,
options: pcaTextArr, options: pcaTextArr,
selectedOptions: [], selectedOptions: [],
total: 0, total: 0,
...@@ -417,6 +430,47 @@ ...@@ -417,6 +430,47 @@
this.multipleSelection = val; this.multipleSelection = val;
}, },
/** /**
* 导入上传前校验,开启 loading
* @param file 上传的文件
* @return {boolean}
*/
handleBeforeUpload(file) {
var isExcel = /\.(xlsx|xls)$/i.test(file.name);
if (!isExcel) {
this.$message.error('仅支持上传 .xlsx 或 .xls 格式的文件');
return false;
}
this.uploadLoading = true;
return true;
},
/**
* 导入上传成功回调
* @param res 接口返回数据
*/
handleUploadSuccess(res) {
this.uploadLoading = false;
if (res.code === 0) {
var { success_total = 0, fail_total = 0, fail_list } = res.data || {};
var failMsg = ''
if(fail_list.length){
failMsg += `失败原因:\n`;
failMsg = fail_list.map(item => item.remark).join(';\n');
}
this.$message.success(`导入完成,成功 ${success_total} 条,失败 ${fail_total} 条`);
failMsg && this.$alert(failMsg);
this.getData();
} else {
this.$message.error(res.msg || '导入失败');
}
},
/**
* 导入上传失败回调
*/
handleUploadError() {
this.uploadLoading = false;
this.$message.error('导入失败,请重试');
},
/**
* 型号监听 * 型号监听
* @param queryString * @param queryString
* @param cb * @param cb
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment