前台校验
<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>
标签:vue,visible,--,excel,校验,item,cObject,货物
From: https://www.cnblogs.com/linhan8888/p/17617042.html