
<template>
  <div>
    <el-button type="primary" @click="test1()">主要按钮</el-button>
    {{ this.asnDetailFrom }}
  </div>
</template>
<script>
import { getObjectClearData } from '@/utils/commonUtils'

export default {
  name: 'JiangKunTest',
  data() {
    return {
      asnDetailFrom: {
        id: null,
        asn: null,
        item: null,
        stock: null,
        lineNo: null,
        po: null,
        status: 'OPEN',
        point: null,
        orderQty: 0,
        receivedQty: 0,
        moveQty: 0,
        putQty: 0,
        weight: 0,
        volume: 0,
        remark: ["null","dskapdjapo"],
        propC1: {  putQty: 0,
          weight: ["null","dskapdjapo"],
          volume: 0},
        propC2: { },
        propC3: null,
        propC4: null,
        propC5: null,
        propC6: null,
        propD1: null,
        propD2: null,
        deptId: null,
        sourceName: null,
        sourceId: null,
        createBy: null,
        updateBy: null,
        createTime: null,
        updateTime: null
      }
    }
  },
  methods:{
    test1(){
      this.asnDetailFrom = getObjectClearData(this.asnDetailFrom);
    },
    clearAll(obj){
      const data_ = obj
      Object.keys(obj).forEach(key => {
        switch (toString.call(obj[key])) {
          case '[object String]':
            data_[key] = null
            break
          case '[object Number]':
            data_[key] = 0
            break
          case '[object Array]':
            data_[key] = []
            break
          case '[object Object]':
            data_[key] = this.clearAll(obj[key])
            break
          case '[object Boolean]':
            data_[key] = false
            break
          case 'undefined':
            data_[key] = null
            break
          case '[object Null]':
            data_[key] = null
            break
          case '[object Date]':
            data_[key] = new Date()
            break
          case '[object Map]':
            data_[key] = new Map()
            break
          case '[object WeakSet]':
            //   WeakSet 是一个构造函数，可以接受一个数组或类似数组的对象作为参数 ,可以使用new命令，创建 WeakSet 数据结构。
            data_[key] = new WeakSet()
            break
          default:
            // [object Function] toString.call(function(){})
            data_[key] = null
        }
      })
      return data_
    }
  }
}
</script>



<style scoped>

</style>
