
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list:{
      type:Array,
      value:[]
    },
    titleCol:{
      type:String,
      value:''
    },

    titleTagCol:{
      type:String,
      value:''
    },
    descCol:{
      type:String,
      value:''
    },

    priceCol:{
      type:String,
      value:''
    },
    quantityCol:{
      type:String,
      value:'' 
    },
    title:{
      type:String,
      value:''  
    },
    type:{
      type:String,
      value:''
    },
    no:{
      type:String,
      value:''
    },
    
    sumAmountCol:{
      type:String,
      value:''
    },

    sumQuantity:{
      type:String,
      value:''
    },
  },

  options: {
    multipleSlots: true
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    expandCard(e) {
      let cardList = this.data.cardList
      let index = e.currentTarget.dataset.index
      if (cardList[index]) {
        // 收缩的时候需要展示信息
        let expand = cardList[index].expand
        cardList[index].info = undefined
        if (expand) {
          let form = this.data.form
          let infoCols = e.currentTarget.dataset.item.infoCols
          if (infoCols && infoCols.length > 0) {
            let info = ''
            infoCols.forEach(it => {
              if (form[it]) {
                info += form[it] + '/'
              }
            })
            if (info.length > 0) {
              info = info.substring(0, info.length - 1);
              cardList[index].info = info
            }
          }
        }
        cardList[index].expand = !expand
        this.setData({
          cardList: cardList
        })
      }
    },
  }
})
