123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import BaseModel from '../../../core/base'
- import { dateFormatter, formatMoney } from '@jy/util'
- class CommonContentModel extends BaseModel {
- constructor(config) {
- super(config)
- }
- createModel() {
- const contentModel = {
- id: '',
- title: '',
- // 项目信息
- projectName: '',
- projectCode: '',
- // 高亮词组
- keys: [],
- tags: [],
- time: '',
- // 计算信息
- isSelfSite: false,
- // TDK
- tdk: {
- title: '',
- keywords: '',
- description: ''
- }
- }
- return contentModel
- }
- formatModel(data, isInit = false) {
- const result = this.createModel()
- const { baseInfo } = data
- result.id = baseInfo.id
- result.title = baseInfo.title
- result.projectName = baseInfo?.projectName
- result.projectCode = baseInfo?.projectCode
- result.isSelfSite = baseInfo?.site === '剑鱼信息发布平台'
- result.time = baseInfo?.publishTime
- ? dateFormatter(baseInfo.publishTime * 1000, 'yyyy-MM-dd')
- : ''
- // TDK
- result.tdk.title = baseInfo.title
- result.tdk.description = baseInfo?.description
- result.tdk.keywords = baseInfo?.keywords
- // Tags
- result.tags = this.tranTags(data)
- return result
- }
- tranTags(data) {
- const { baseInfo } = data
- const defaultURL = 'javascript:volid(0);'
- const area = [baseInfo?.area, baseInfo?.city, baseInfo?.district]
- .filter((v) => v)
- .join('-')
- const typeItem = {
- label: baseInfo?.topType,
- link: defaultURL
- }
- if (baseInfo?.subType) {
- typeItem.label = baseInfo.subType
- typeItem.link = baseInfo?.subTypeUrl
- }
- const amountItem = {
- label: formatMoney(baseInfo?.bidAmount ?? baseInfo?.budget ?? ''),
- link: defaultURL
- }
- const tags = [
- // 地区
- {
- label: area,
- link: baseInfo?.areaUrl || defaultURL
- },
- // type
- typeItem,
- // buyer_class
- {
- label: baseInfo?.buyerClass,
- link: defaultURL
- },
- // amount
- amountItem
- ].filter((v) => v.label)
- return tags
- }
- }
- function useCommonContentModel() {
- return new CommonContentModel()
- }
- export default useCommonContentModel
|