<template>
  <a-card size="small" :bordered="false" class="systemSettingsList-wrap" :style="{height:conHeight+'px'}">
    <a-spin :spinning="spinning" tip="Loading...">
      <div ref="contentBox">
        <a-row :gutter="16">
          <a-col class="gutter-row" :span="12">
            产品报价，箭冠产品优先获取自定义车主价和终端价
          </a-col>
          <a-col class="gutter-row" :span="12">
            <a-radio-group v-model="priceValue" @change="handleQty">
              <a-radio :value="1">
                启用
              </a-radio>
              <a-radio :value="2">
                禁用
              </a-radio>
            </a-radio-group>
          </a-col>
          <a-col class="priceDesc" :span="24">
            箭冠产品优先获取自定义车主价和终端价启用后，自定义车主价和终端价存在时，产品报价列表将优先显示自定义价格，自定义车主价和终端价不存在时，获取箭冠建议价。
          </a-col>
        </a-row>
        <a-row :gutter="16">
          <a-col class="gutter-row" :span="12">
            销售下单时，是否显示产品库存为0的产品信息
          </a-col>
          <a-col class="gutter-row" :span="12">
            <a-radio-group v-model="qtyValue" @change="handleQty">
              <a-radio :value="1">
                显示
              </a-radio>
              <a-radio :value="2">
                隐藏
              </a-radio>
            </a-radio-group>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col class="gutter-row" :span="12">
            销售下单时，是否显示废品仓的产品信息
          </a-col>
          <a-col class="gutter-row" :span="12">
            <a-radio-group v-model="wasteInfoValue" @change="handleWasteInfo">
              <a-radio :value="1">
                显示
              </a-radio>
              <a-radio :value="2">
                隐藏
              </a-radio>
            </a-radio-group>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col class="gutter-row" :span="12">
            库存预警，是否包含废品库数量
          </a-col>
          <a-col class="gutter-row" :span="12">
            <a-radio-group v-model="wasteNumValue" @change="handleWasteNum">
              <a-radio :value="1">
                包含
              </a-radio>
              <a-radio :value="2">
                不包含
              </a-radio>
            </a-radio-group>
          </a-col>
        </a-row>
      </div>
    </a-spin>
  </a-card>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
export default {
  name: 'SystemSettingsList',
  mixins: [commonMixin],
  data () {
    return {
      spinning: false,
      priceValue: 2,
      qtyValue: 1,
      wasteInfoValue: 1,
      wasteNumValue: 1,
      conHeight: '100%'
    }
  },
  methods: {
    getData () {
      this.spinning = true
      noticeUserBizQuery().then(res => {
        const data = res.data
        if (res.status == 200) {
          const no = 0
          for (var i = 0; i < data.length; i++) {
            data[i].no = no + i + 1
            const key = ['tempOrderFlag', 'shelfReplenishFlag', 'shelfOrderFlag', 'shelfWarnFlag', 'allFlag']
            const ret = []
            key.map(item => {
              if (data[i][item] == 1) {
                ret.push(1)
              }
            })
            data[i].allFlag = ret.length == 4 ? 1 : 0
          }
        }
        this.loadData = data
        this.spinning = false
      })
    },
    pageInit () {
      const _this = this
      this.$nextTick(() => { // 页面渲染完成后的回调
        _this.setTableH()
      })
    },
    setTableH () {
      this.conHeight = window.innerHeight - 86.5
    },
    handleQty () {},
    handleWasteInfo () {},
    handleWasteNum () {}
  },
  watch: {
    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时，需同时更改表格高度
      this.setTableH()
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.pageInit()
      // this.getData()
    }
  },
  activated () {
    // 如果是新页签打开，则重置当前页面
    if (this.$store.state.app.isNewTab) {
      this.pageInit()
      // this.getData()
    }
  }
}
</script>
<style lang="less" scoped>
  .systemSettingsList-wrap{
    .ant-row{
      padding:23px 10px;
      border-bottom: 1px solid #e0e0e0;
      .priceDesc{
        color:gray;
        margin-top:10px;
      }
    }
  }

</style>
