<template>
  <van-swipe-cell>
    <div class="XFItem-box">
      <div class="item-tip" :class="changeBq(props.data.dwlx)">{{ setDict(props.data.dwlx, props.dic.D_BZ_DWLX) }}</div>
      <div class="text">归属单位：<span class="mess">{{props.data.dwmc}}</span></div>
      <div class="text">单位名称：<span class="mess">{{props.data.ssbm}}</span></div>
      <div class="text">单位地址：<span class="mess">{{props.data.dz}}</span></div>
      <div class="text">单位分类：<span class="mess">{{ setDict(props.data.dwfl, props.dic.D_BZ_DWFL) }}</span></div>
    </div>
    <template #right>
        <van-button style="height:100%;width:60px;" type="primary" @click="gotoEdit">编辑</van-button>
        <van-button style="height:100%;width:60px;" type="danger" @click="deleteItem">删除</van-button>
    </template>
  </van-swipe-cell>
</template>

<script setup>
import { useRouter } from "vue-router";
import { setDict } from "../../../../utils/dict";
import { ref, onMounted, reactive, defineEmits,defineProps } from "vue";
const emits = defineEmits(['deletedata'])
const router = useRouter();
const props = defineProps({
  data:{
    type:Object,
    default:{}
  },
  dic:{
    type:Object,
    default:{}
  }
});

// 编辑
function gotoEdit(){
  localStorage.setItem('XF_Active',1)
  router.push({path: "/Declaration/addEditDw", query: {id:props.data.id}});
}
// 删除
function deleteItem(){
  emits('deletedata',props.data.id)
}
// 标签
function changeBq(val){
    switch(val){
        case '02':
          return 'green';
        break;
        case '01':
            return 'blue';
        break;
        default:
            return 'blue';
    }

}
</script>

<style lang="scss" scoped>
.XFItem-box {
  padding: 3vw 4vw;
  box-sizing: border-box;
  background-color: #f6fafd;
  position: relative;
.item-tip {
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 26px;
    color: #fff;
    text-align: center;
    line-height: 26px;
    font-size: 14px;
  }
  .red {
    background: url("../../../../assets/images/red.png") no-repeat;
  }
  .green {
    background: url("../../../../assets/images/green.png") no-repeat;
  }
  .blue {
    background: url("../../../../assets/images/blue.png") no-repeat;
  }
  .orange {
    background: url("../../../../assets/images/orange.png") no-repeat;
  }
  .text {
    color: #9f9f9f;
    line-height: 6vw;
    .mess {
      color: #000;
    }
  }
}
</style>