123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <div class="article-item" :class="{'style-for-gray': config.gray, 'style-for-table': config.table }">
- <input v-if="config.collect" @change="changeCheck($event)" @click.stop class="custom-checkbox title-text-checkbox" name="bid-list" type="checkbox" :dataid="article._id">
- <div v-if="article.site === '剑鱼信息发布平台' || article.spidercode === 'a_jyxxfbpt_gg'" class="yhfb">用户发布</div>
- <div class="a-i-con">
- <div class="content-item" @click="onClick">
- <div v-html="calcTitle" class="a-i-left ellipsis visited-hd"></div>
- <span v-if="config.gray&&article.ca_fileExists" class="haveFile">有附件</span>
- </div>
- </div>
- <div class="a-i-right">
- <div class="tags">
- <span class="tag" v-if="article.area">{{ article.area }}</span>
- <span class="tag orange" v-if="article.type">{{ article.type }}</span>
- <span class="tag green" v-if="article.buyerclass">{{ article.buyerclass }}</span>
- <span class="tag dpink" v-if="calcBudget">{{ calcBudget }}</span>
- </div>
- <div class="time-container">
- <span class="el-icon-jy-time" v-if="!config.gray"></span>
- <span class="time-text">
- <slot name="right-time">{{ dateFromNow(article.publishtime * 1000) }}</slot>
- </span>
- </div>
- <i class="icon-collect" @click.stop="collectChange($event)" v-if="config.collect" :class="{'checked': article.collection}" :dataid="article._id"></i>
- </div>
- </div>
- </template>
- <script>
- import { Tag } from 'element-ui'
- import { moneyUnit, dateFromNow, replaceKeyword } from '@/utils/'
- export default {
- name: 'article-item',
- components: {
- [Tag.name]: Tag
- },
- props: {
- index: {
- type: [String, Number],
- default: '1'
- },
- config: {
- type: Object,
- default () {
- return {
- gray: false,
- table: false,
- collect: false
- }
- }
- },
- article: {
- type: Object,
- default () {
- return {
- title: '', // 标题
- area: '', // 区域
- type: '', // 类型
- buyerclass: '', // 行业
- budget: '', // 金额
- publishtime: 0, // 时间
- matchkeys: [], // 高亮的关键词
- ca_fileExists: false
- }
- }
- }
- },
- computed: {
- calcBudget () {
- if (this.article.budget) {
- return moneyUnit(this.article.budget)
- } else {
- return this.article.budget
- }
- },
- calcTitle () {
- const hightLightedTitle = replaceKeyword(this.article.title, this.article.matchkeys, ['<span class="highlight-text">', '</span>'])
- return `${this.index}. ${hightLightedTitle}`
- }
- },
- methods: {
- dateFromNow,
- onClick () {
- this.$emit('onClick')
- },
- changeCheck (e) {
- const { _id } = this.article
- const payload = {
- id: _id,
- check: this.$querySelector(e.target).prop('checked')
- }
- this.$emit('changeCheck', payload)
- },
- collectChange (e) {
- this.$emit('onCollect', {
- item: this.article,
- event: e
- })
- }
- }
- }
- </script>
- <style>
- .custom-toast .toast-container{
- /* display: none; */
- position: fixed;
- top: 50%;
- left: 50%;
- width: auto;
- padding: 16px 32px;
- font-size: 16px;
- background: rgba(0, 0, 0, 0.65);
- border-radius: 8px;
- color: #fff;
- transform: translateX(-50%) translateY(-50%);
- z-index: 99;
- }
- /* 附件标识样式 */
- .haveFile{
- display: inline-block;
- padding:0 8px;
- margin-left: 15px;
- height: 20px;
- border-radius: 4px;
- border: 1px solid #2CB7CA;
- font-size: 12px;
- font-weight: 400;
- color: #2CB7CA;
- line-height: 18px;
- }
- </style>
- <style lang="scss" scoped>
- $border-color: #ECECEC;
- @include diy-icon('time', 20, 20);
- .article-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 22px 16px;
- border-bottom: 1px solid $border-color;
- cursor: pointer;
- &:first-of-type,
- &:border-top {
- border-top: 1px solid $border-color;
- }
- &.style-for-gray {
- .custom-checkbox {
- margin-top: 0;
- }
- .icon-collect{
- display: inline-block;
- width: 20px;
- height: 20px;
- margin-left: 6px;
- background: transparent url(https://cdn-ali.jianyu360.com/images/collect.png) center no-repeat;
- background-size: contain;
- cursor: pointer;
- vertical-align: sub;
- ::before{
- content: ''
- }
- }
- .icon-collect.checked{
- background: transparent url(https://cdn-ali.jianyu360.com/images/collected.png) center no-repeat;
- background-size: contain;
- ::before{
- content: ''
- }
- }
- .tag,
- .orange.tag,
- .green.tag,
- .dpink.tag {
- background: #f5f5fb;
- border: 1px solid #ececec;
- border-radius: 4px;
- font-size: 12px;
- font-family: Microsoft YaHei, Microsoft YaHei-Regular;
- font-weight: 400;
- text-align: center;
- color: #686868;
- line-height: 20px;
- height: 22px;
- padding: 0 8px;
- }
- }
- &.style-for-table {
- }
- .a-i-con{
- flex: 1;
- }
- .content-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .a-i-left {
- display: inline-block;
- max-width: 650px;
- }
- .a-i-right,
- .tags,
- .time-container {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .tag {
- display: flex;
- align-items: center;
- padding: 1px 6px;
- margin-right: 14px;
- color: #fff;
- font-size: 13px;
- line-height: 20px;
- background-color: #2CB7CA;
- border-radius: 3px;
- &:not(:last-of-type) {
- margin-right: 8px;
- }
- &.orange {
- background-color: #FFBA00;
- }
- &.green {
- background-color: #25C78C;
- }
- &.dpink {
- background-color: #FF878D;
- }
- }
- .time-text {
- margin-left: 6px;
- font-size: 14px;
- color: #797a7e;
- line-height: 24px;
- }
- .yhfb{
- background-color: rgba(255, 58, 32, 0.1);
- padding: 2px 12px;
- border-radius: 4px;
- line-height: 22px;
- font-size: 14px;
- color: #FF3A20;
- margin-right: 10px;
- }
- }
- </style>
|