vue excel导入 补充校验
前台校验
<template>
<div>
<el-dialog
:title="'校验'"
:close-on-click-modal="false"
append-to-body :before-close="handleClose"
v-if="visible" :visible.sync="visible" top="5vh" width="1048px">
<!-- <el-table-->
<!-- :data="tableData" style="width: 100%">-->
<!-- <el-table-column prop="date" label="日期" width="180"> </el-table-column>-->
<!-- <el-table-column prop="name" label="姓名" width="180"> </el-table-column>-->
<!-- <el-table-column prop="address" label="地址"></el-table-column>-->
<!-- </el-table>-->
<el-table border v-if="cObject.header.length" :data="cObject.results" style="width: 100%">
<el-table-column type="index" width="50" :index="indexMethod"></el-table-column>
<el-table-column
v-for="(item, key) in cObject.header"
:prop="item"
:label="item"
:key="key"
width="180"
>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
import { validatenull } from "@/util/validate"
export default {
name: "goodsImportSee",
data(){
return{
visible: false,
cObject: null,
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}]
}
},
methods:{
init(param) {
this.visible = true
this.cObject = JSON.parse(JSON.stringify(param))
for(let item of this.cObject.results){
if(validatenull(item["货物编码"])){
item["货物编码"]="校验:货物编码不能为空!"
}
if(validatenull(item["货物名称"])){
item["货物名称"]="校验:货物名称不能为空!"
}
}
// console.log(this.cObject)
},
handleClose(){
this.visible = false
this.$nextTick(()=>{
// this.$refs.dataForm.resetFields();
})
},
indexMethod(index) {
return index + 2;
}
}
}
</script>
<style scoped>
</style>
/**
* 货物导入
**/
@PostMapping("/imOverseaGoods")
@Inner(false)
public R importCustomerInfo(@RequestBody Map<String, Object> map, BindingResult bindingResult) {
JSONArray headerKey = JSONUtil.parseArray(map.get("header").toString());
JSONArray jContent = JSONUtil.parseArray(map.get("results").toString());
List<Map> lstMap = JSONUtil.toList(jContent, Map.class);
int iIndex = 1;
for(Map<String,Object> mp: lstMap){
String sName = mp.get("姓名").toString();
iIndex ++;
}
String sSql = "";
return R.ok();
//return customerInfoService.importCustomerInfo(voList, bindingResult);
}
择善人而交,择善书而读,择善言而听,择善行而从。