|
@@ -1,46 +1,31 @@
|
|
|
<template>
|
|
|
- <div class="box">
|
|
|
- <div class="con">
|
|
|
-
|
|
|
- <div class="tab">
|
|
|
- <h1></h1>
|
|
|
- <upload-excel :on-success="handleSuccess" :before-upload="beforeUpload" />
|
|
|
- <h1 style="color: #0099ff"></h1>
|
|
|
- <ex-table :columns="columns" :table="table" :data="tableData">
|
|
|
- <el-table-column width="50" type="index" />
|
|
|
- <template #operation={scope}>
|
|
|
- <el-tooltip
|
|
|
-
|
|
|
- effect="dark"
|
|
|
- content="删除"
|
|
|
- placement="top"
|
|
|
- >
|
|
|
- <i
|
|
|
- class="el-icon-delete tb-icon"
|
|
|
- @click="del(scope)"
|
|
|
- ></i>
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </ex-table>
|
|
|
- <div class="btn">
|
|
|
- <el-button type="primary" @click="submit">提交</el-button>
|
|
|
- <el-button @click="cancel">取消</el-button>
|
|
|
+ <div class="orderImport pagePadding">
|
|
|
+ <div v-if="tableData && tableData.length > 0" class="tr" style="padding:10px 0 0 0">
|
|
|
+
|
|
|
+ <el-button @click="cancel" :size="'mini'">取消</el-button>
|
|
|
+ <el-button type="primary" @click="submit" :size="'mini'">提交</el-button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
-
|
|
|
+ <div v-else>
|
|
|
+ <upload-excel :on-success="handleSuccess" :before-upload="beforeUpload" />
|
|
|
</div>
|
|
|
-
|
|
|
+ <ex-table :columns="columns" :table="table" :data="tableData" style="margin:15px 0 0 0">
|
|
|
+ <template #operation="{ scope }">
|
|
|
+ <el-tooltip effect="dark" content="删除" placement="top">
|
|
|
+ <i class="el-icon-delete tb-icon" @click="del(scope)"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </ex-table>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import asyncRequest from "@/apis/service/orderEntry/orderImport";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
-import { province_list, city_list, county_list } from "@/assets/js/area-data";
|
|
|
import { columns } from "./columns";
|
|
|
-import { set } from 'js-cookie';
|
|
|
+
|
|
|
export default {
|
|
|
mixins: [resToken],
|
|
|
+ name: "orderImport",
|
|
|
data() {
|
|
|
return {
|
|
|
ruleForm: {
|
|
@@ -64,12 +49,10 @@ export default {
|
|
|
columns: columns,
|
|
|
|
|
|
//按钮锁
|
|
|
- btnFlag:false,
|
|
|
+ btnFlag: false,
|
|
|
};
|
|
|
},
|
|
|
- mounted(){
|
|
|
-
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
beforeUpload(file) {
|
|
|
const isLt1M = file.size / 1024 / 1024 < 1;
|
|
@@ -133,32 +116,29 @@ export default {
|
|
|
// let r = /^\+?[1-9][0-9]*$/;
|
|
|
// let tableOk = true;
|
|
|
this.ruleForm.order_addr = [];
|
|
|
- list.forEach((v1,index) => {
|
|
|
+ list.forEach((v1, index) => {
|
|
|
let b = Object.values(v1);
|
|
|
let numFlag = false;
|
|
|
-
|
|
|
- try{
|
|
|
- if(
|
|
|
- !isNaN(b[5]) && !isNaN(b[6]) && !isNaN(b[7])
|
|
|
- ){
|
|
|
|
|
|
- }else{
|
|
|
- this.$message.warning(`excel表格第${index+1}行,单价,数量,总金额必须是数字`);
|
|
|
+ try {
|
|
|
+ if (!isNaN(b[5]) && !isNaN(b[6]) && !isNaN(b[7])) {
|
|
|
+ } else {
|
|
|
+ this.$message.warning(
|
|
|
+ `excel表格第${index + 1}行,单价,数量,总金额必须是数字`
|
|
|
+ );
|
|
|
numFlag = true;
|
|
|
throw Error();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if(!Number.isInteger(Number(b[6]))){
|
|
|
- this.$message.warning(`excel表格第${index+1}行,数量必须是整数`);
|
|
|
+ if (!Number.isInteger(Number(b[6]))) {
|
|
|
+ this.$message.warning(`excel表格第${index + 1}行,数量必须是整数`);
|
|
|
numFlag = true;
|
|
|
throw Error();
|
|
|
}
|
|
|
- }catch(e){
|
|
|
-
|
|
|
+ } catch (e) {}
|
|
|
+ if (numFlag) {
|
|
|
+ return;
|
|
|
}
|
|
|
- if(numFlag){return;}
|
|
|
// let item = this.get_code(b[3], b[4], b[5]);
|
|
|
let model = {
|
|
|
platform_code: b[0] + "",
|
|
@@ -189,48 +169,52 @@ export default {
|
|
|
this.tableData = [];
|
|
|
},
|
|
|
//删除
|
|
|
- del(scope){
|
|
|
- console.log(scope.$index)
|
|
|
- this.$confirm('是否删除本条导入数据?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- this.tableData.splice(scope.$index,1)
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
+ del(scope) {
|
|
|
+ console.log(scope.$index);
|
|
|
+ this.$confirm("是否删除本条导入数据?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.tableData.splice(scope.$index, 1);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "删除成功!",
|
|
|
});
|
|
|
- }).catch(() => {
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消删除'
|
|
|
- });
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
//日期转换
|
|
|
formatDate(numb) {
|
|
|
const date = new Date(numb);
|
|
|
- var Y = date.getFullYear() + '-';
|
|
|
- var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
|
|
|
- var D = date.getDate() + ' ';
|
|
|
- // var h = date.getHours() + ':';
|
|
|
- // var m = date.getMinutes() + ':';
|
|
|
- // var s = date.getSeconds();
|
|
|
- return Y+M+D;
|
|
|
+ var Y = date.getFullYear() + "-";
|
|
|
+ var M =
|
|
|
+ (date.getMonth() + 1 < 10
|
|
|
+ ? "0" + (date.getMonth() + 1)
|
|
|
+ : date.getMonth() + 1) + "-";
|
|
|
+ var D = date.getDate() + " ";
|
|
|
+ // var h = date.getHours() + ':';
|
|
|
+ // var m = date.getMinutes() + ':';
|
|
|
+ // var s = date.getSeconds();
|
|
|
+ return Y + M + D;
|
|
|
},
|
|
|
//提交
|
|
|
async submit() {
|
|
|
- if(this.btnFlag){
|
|
|
- console.log("拦截点击")
|
|
|
+ if (this.btnFlag) {
|
|
|
+ console.log("拦截点击");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const model = {
|
|
|
list: this.tableData,
|
|
|
};
|
|
|
- if(model.list.length<=0){
|
|
|
+ if (model.list.length <= 0) {
|
|
|
this.$message.warning("导入数据不能为空");
|
|
|
return;
|
|
|
}
|
|
@@ -246,7 +230,7 @@ export default {
|
|
|
let flag = true;
|
|
|
let platform_code_arr = [];
|
|
|
model.list.forEach((item, index) => {
|
|
|
- platform_code_arr.push(item.platform_code)
|
|
|
+ platform_code_arr.push(item.platform_code);
|
|
|
//必填判断
|
|
|
if (flag) {
|
|
|
} else {
|
|
@@ -265,17 +249,20 @@ export default {
|
|
|
});
|
|
|
|
|
|
//去重锁
|
|
|
- if(platform_code_arr.length != Array.from(new Set(platform_code_arr)).length){
|
|
|
+ if (
|
|
|
+ platform_code_arr.length !=
|
|
|
+ Array.from(new Set(platform_code_arr)).length
|
|
|
+ ) {
|
|
|
this.$message.warning(`平台订单号不能重复`);
|
|
|
return;
|
|
|
}
|
|
|
- if(flag){
|
|
|
+ if (flag) {
|
|
|
//按钮锁开启
|
|
|
this.btnFlag = true;
|
|
|
- this.submitHttp(model)
|
|
|
+ this.submitHttp(model);
|
|
|
}
|
|
|
},
|
|
|
- async submitHttp(model) {
|
|
|
+ async submitHttp(model) {
|
|
|
const res = await asyncRequest.orderimport(model);
|
|
|
if (res && res.code === 0) {
|
|
|
this.$notify.success({
|
|
@@ -283,7 +270,6 @@ export default {
|
|
|
message: "",
|
|
|
});
|
|
|
this.tableData = [];
|
|
|
-
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
await this.logout();
|
|
|
} else {
|
|
@@ -299,9 +285,9 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
.box {
|
|
|
width: 100%;
|
|
|
- padding-top: 50px;
|
|
|
+ // padding-top: 50px;
|
|
|
box-sizing: border-box;
|
|
|
- height: 100vh;
|
|
|
+ // height: 100vh;
|
|
|
// overflow: hidden;
|
|
|
background: #fff;
|
|
|
}
|
|
@@ -311,7 +297,6 @@ export default {
|
|
|
background: #fff;
|
|
|
// padding: 50px;
|
|
|
box-sizing: border-box;
|
|
|
-
|
|
|
|
|
|
h1 {
|
|
|
margin-bottom: 20px;
|
|
@@ -320,14 +305,14 @@ export default {
|
|
|
color: #333;
|
|
|
}
|
|
|
}
|
|
|
-.tab{
|
|
|
- width: 100%;
|
|
|
- overflow: hidden;
|
|
|
- margin: auto;
|
|
|
- box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
|
|
|
- padding: 30px;
|
|
|
+// .tab{
|
|
|
+// width: 100%;
|
|
|
+// overflow: hidden;
|
|
|
+// margin: auto;
|
|
|
+// box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
|
|
|
+// padding: 30px;
|
|
|
|
|
|
-}
|
|
|
+// }
|
|
|
.btn {
|
|
|
width: 50%;
|
|
|
margin: 50px auto 0;
|