/**procurementDetail
  // author：zhangyy
  // time:2023-03-23
  // desc:采购需求详情
*/
<template>
  <div class="procurementDetail">

    <Button @click="$router.go(-1)">返回</Button>
    <Divider orientation="left"><b>采购信息</b></Divider>
    <DescriptionList :col="1" style="margin:30px 60px" :gutter="40">
      <Description term="采购牛只类别:">
        {{ newContentForm.classifyOneName}}/{{newContentForm.classifyTwoName }}/{{newContentForm.classifyThreeName  }}
      </Description>
      <Description term="意向采购单价:">
        <Numeral :value="newContentForm.buyPrice" format="0,0.00" style="color:#D64E47; font-weight:bold;">
          <template #suffix>
            <strong>{{newContentForm.priceUnitCode == 1? '元/头':(newContentForm.priceUnitCode == 2?"元/公斤":'元/斤' )}}</strong>
          </template>
        </Numeral>
      </Description>
      <Description term="采购数量:">
        {{ newContentForm.buyCount}} {{newContentForm.countUnitCode == 1? '头':(newContentForm.countUnitCode == 2?"公斤":'斤' )}}
      </Description>
      <Description term="牛只重量:">
        <Tag color="blue" v-for="(item,index) in newContentForm.weightList" :key="index">{{item}} </Tag>
      </Description>
      <Description term="牛只膘情:">
        <Tag color="#B62D4A" v-for="(item,index) in newContentForm.fat" :key="index">{{item}} </Tag>
      </Description>
      <Description term="采购地区:">
        <Icon type="md-pin" color="#2db7f5" /> 
        {{ newContentForm.province}}-{{ newContentForm.city}}-{{newContentForm.area}}
      </Description>
      <Description term="采购要求:">
        <div v-html="newContentForm.buyContent" class="content_box"></div>
      </Description>
    </DescriptionList>
  </div>
</template>

<script>
import { Message} from 'view-ui-plus'
import { defineComponent, reactive,getCurrentInstance,onMounted,ref} from 'vue'
import router from '@/router'
import {cow} from '@/request/api'

export default defineComponent({
  components:{
  },
  setup() {
    let newContentForm = ref({})

    async function getNeedsDetail(id){
        const params = {
          id:id
        }
        await cow.getCattleBuyDemandById(params).then(res =>{
            if (res.code == 101) {
                res.data.fat = []
                res.data.fat = res.data.fatInfo.split(",");
                res.data.weightList = []
                let arr = res.data.weight.split(",");
                arr.forEach(e=>{
                    res.data.weightList.push(e.replace(/\"/g, "").replace(/\[/g, "").replace(/\]/g, ""))
                });
                newContentForm.value = res.data
            }else{
                Message.error(res.message)
            }
        })
    }

    onMounted(async()=>{
      await getNeedsDetail(router.currentRoute.value.query.id)  //获取采购需求
    })

    return {
      newContentForm,getNeedsDetail
    }
  },
  methods: {
    
  },
})
</script>

<style lang="scss" scoped>
.procurementDetail{
  padding: 1em;
}
</style>
<style lang="scss">
.procurementDetail{
  .content_box{
    width: 90%;
    img{width: 100%;}
    video{width: 100%;}
  }
  .ivu-description-term{
    font-weight: 550;
  }
  .ivu-description-detail{
    padding-left: 2em;
  }
}
</style>