|
@@ -0,0 +1,244 @@
|
|
|
+import BaseModel from '../../../core/base'
|
|
|
+import { dateFormatter, formatMoney, splitMoney } from '@jy/util'
|
|
|
+
|
|
|
+/**
|
|
|
+ * 摘要 Item 基础类
|
|
|
+ */
|
|
|
+class SummaryItem {
|
|
|
+ constructor(key, label, value) {
|
|
|
+ this.key = key
|
|
|
+ this.label = label
|
|
|
+ this.value = value || '-' // 如果为空,默认值则改为'-'
|
|
|
+ }
|
|
|
+ addKey(key, value) {
|
|
|
+ this[key] = value
|
|
|
+ }
|
|
|
+}
|
|
|
+// 联系人类
|
|
|
+class PersonTelSummaryItem extends SummaryItem {
|
|
|
+ constructor(key, label, value, tel) {
|
|
|
+ super(key, label, value)
|
|
|
+ if (tel) {
|
|
|
+ this.showMore = true
|
|
|
+ this.tel = tel
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class Unit {
|
|
|
+ constructor(name, id) {
|
|
|
+ this.name = name || '-'
|
|
|
+ this.id = id
|
|
|
+ }
|
|
|
+}
|
|
|
+class Buyer extends Unit {
|
|
|
+ constructor(name, id, { link }) {
|
|
|
+ super(name, id)
|
|
|
+ this.link = link
|
|
|
+ }
|
|
|
+}
|
|
|
+class Winner extends Unit {
|
|
|
+ constructor(name, id, { seoId, winnerPerson, winnerTel, isCandidate }) {
|
|
|
+ super(name, id)
|
|
|
+
|
|
|
+ this.seoId = seoId || ''
|
|
|
+ this.winnerPerson = winnerPerson || ''
|
|
|
+ this.winnerTel = winnerTel || ''
|
|
|
+ this.isCandidate = isCandidate
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+class SummaryModel extends BaseModel {
|
|
|
+ constructor(config) {
|
|
|
+ super(config)
|
|
|
+ }
|
|
|
+
|
|
|
+ createModel() {
|
|
|
+ return {
|
|
|
+ // 是否超前项目
|
|
|
+ isProposed: false,
|
|
|
+ // 原始数据
|
|
|
+ originMap: {},
|
|
|
+ list: [],
|
|
|
+ // 采购单位
|
|
|
+ buyers: [],
|
|
|
+ // 中标单位
|
|
|
+ winners: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ formatModel(data, isInit = false) {
|
|
|
+ const { baseInfo, abstract } = data
|
|
|
+ const isProposed = this.isProposedCheck(baseInfo?.subType)
|
|
|
+ const model = isProposed
|
|
|
+ ? this.tranSummaryOfProposed(abstract.proposed)
|
|
|
+ : this.tranSummaryOfDefault(abstract.default)
|
|
|
+ model.isProposed = isProposed
|
|
|
+ return model
|
|
|
+ }
|
|
|
+
|
|
|
+ isProposedCheck(type) {
|
|
|
+ return type === '拟建' || type === '采购意向'
|
|
|
+ }
|
|
|
+
|
|
|
+ formatTime(time) {
|
|
|
+ if (time) {
|
|
|
+ return dateFormatter(time * 1000, 'yyyy-MM-dd')
|
|
|
+ } else {
|
|
|
+ return time
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ formatMoney(m) {
|
|
|
+ return splitMoney(m, -1, true)
|
|
|
+ }
|
|
|
+
|
|
|
+ formatTel(name, tel) {
|
|
|
+ const arr = [name, tel]
|
|
|
+ return arr.filter((item) => !!item).join(' / ')
|
|
|
+ }
|
|
|
+
|
|
|
+ tranSummaryOfDefault(summary) {
|
|
|
+ const result = this.createModel()
|
|
|
+
|
|
|
+ const list = []
|
|
|
+
|
|
|
+ // 采购单位
|
|
|
+ const buyerInfo = new SummaryItem('buyer', '采购单位', summary?.buyer)
|
|
|
+ // 是否可进行跳转
|
|
|
+ buyerInfo.addKey('link', summary?.buyerPortraitShow)
|
|
|
+ list.push(buyerInfo)
|
|
|
+ result.buyers.push(
|
|
|
+ new Buyer(summary?.buyer, summary?.buyer, { link: summary?.buyerPortraitShow })
|
|
|
+ )
|
|
|
+
|
|
|
+ // 采购人/联系电话
|
|
|
+ const buyerContactInfoValue = this.formatTel(summary?.buyerPerson, summary?.buyerTel)
|
|
|
+ const buyerContactInfo = new PersonTelSummaryItem('buyerContactInfo', '采购人 / 联系电话', buyerContactInfoValue, summary?.buyerTel)
|
|
|
+ list.push(buyerContactInfo)
|
|
|
+
|
|
|
+ // 招标代理机构
|
|
|
+ list.push(
|
|
|
+ new SummaryItem('agency', '招标代理机构', summary?.agency)
|
|
|
+ )
|
|
|
+
|
|
|
+ // 代理联系人
|
|
|
+ const agencyContactInfoValue = this.formatTel(summary?.agencyPerson, summary?.agencyTel)
|
|
|
+ const agencyContactInfo = new PersonTelSummaryItem('agencyContactInfo', '代理联系人 / 联系电话', agencyContactInfoValue, summary?.agencyTel)
|
|
|
+ list.push(agencyContactInfo)
|
|
|
+
|
|
|
+ // 截止日期
|
|
|
+ list.push(
|
|
|
+ new SummaryItem('signEndTime', '报名截止日期', this.formatTime(summary?.signEndTime))
|
|
|
+ )
|
|
|
+
|
|
|
+ // 投标截止日期
|
|
|
+ list.push(
|
|
|
+ new SummaryItem('bidEndTime', '投标截止日期', this.formatTime(summary?.bidEndTime))
|
|
|
+ )
|
|
|
+
|
|
|
+ // 中标单位
|
|
|
+ if (Array.isArray(summary.winnerInfos) && summary.winnerInfos.length > 0) {
|
|
|
+ const winnerList = []
|
|
|
+ summary.winnerInfos.forEach((w, index) => {
|
|
|
+ const summaryWinner = new SummaryItem('winner', '中标单位', w.winner)
|
|
|
+ // 是否可跳转
|
|
|
+ summaryWinner.addKey('link', !!w.winnerId)
|
|
|
+ summaryWinner.addKey('id', w.winnerId)
|
|
|
+
|
|
|
+ const wContactInfoValue = this.formatTel(w?.winnerPerson, summary?.winnerTel)
|
|
|
+ const winnerContactInfo = new PersonTelSummaryItem(`winnerContactInfo-${index}`, '代理联系人 / 联系电话', wContactInfoValue, w?.winnerTel)
|
|
|
+
|
|
|
+ list.push(summaryWinner)
|
|
|
+ list.push(winnerContactInfo)
|
|
|
+
|
|
|
+ const seoId = winnerSeoId[w.winner]
|
|
|
+ winnerList.push(
|
|
|
+ new Winner('winner', '中标单位', {
|
|
|
+ seoId: seoId || '',
|
|
|
+ winnerPerson: w.winnerPerson || '',
|
|
|
+ winnerTel: w.winnerTel || '',
|
|
|
+ isCandidate: w.isCandidate || false
|
|
|
+ })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ result.winners = winnerList
|
|
|
+ }
|
|
|
+
|
|
|
+ // 中标金额
|
|
|
+ list.push(
|
|
|
+ new SummaryItem('bidAmount', '中标金额(元)', this.formatMoney(summary?.bidAmount))
|
|
|
+ )
|
|
|
+
|
|
|
+ result.list = list
|
|
|
+ result.originMap = summary
|
|
|
+
|
|
|
+ console.log(result)
|
|
|
+
|
|
|
+ return result
|
|
|
+ }
|
|
|
+
|
|
|
+ tranSummaryOfProposed(summary) {
|
|
|
+ const result = this.createModel()
|
|
|
+
|
|
|
+ const list = []
|
|
|
+
|
|
|
+ const summaryMap = {
|
|
|
+ projectName: '项目名称',
|
|
|
+ area: '省份',
|
|
|
+ buyer: '业主单位',
|
|
|
+ buyerClass: '业主类型',
|
|
|
+ totalInvestment: '总投资',
|
|
|
+ projectPeriod: '建设年限',
|
|
|
+ address: '建设地点',
|
|
|
+ approveDept: '审批机关',
|
|
|
+ approveContent: '审批事项',
|
|
|
+ approveCode: '审批代码',
|
|
|
+ approvalNumber: '批准文号',
|
|
|
+ approveTime: '审批时间',
|
|
|
+ approveStatus: '审批结果',
|
|
|
+ content: '建设内容'
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in summaryMap) {
|
|
|
+ const label = summaryMap[item]
|
|
|
+ let s = null
|
|
|
+ if (key === 'buyerClass') {
|
|
|
+ s = new SummaryItem(key, label, summary?.buyerClass === '其它' ? '' : summary?.buyerClass)
|
|
|
+ } else if (key === 'totalInvestment') {
|
|
|
+ s = new SummaryItem(key, label, formatMoney(summary[key]))
|
|
|
+ } else {
|
|
|
+ s = new SummaryItem(key, label, summary[key] || '')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (key === 'buyer') {
|
|
|
+ s.addKey('link', summary?.buyerPortraitShow) // 是否可进行跳转
|
|
|
+ result.buyers.push(
|
|
|
+ new Buyer(summary?.buyer, summary?.buyer, { link: summary?.buyerPortraitShow })
|
|
|
+ )
|
|
|
+ } else if (key === 'address') {
|
|
|
+ s.addKey('row', true)
|
|
|
+ } else if (key === 'content') {
|
|
|
+ s.addKey('row', true)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (s) {
|
|
|
+ list.push(s)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.list = list
|
|
|
+ result.originMap = summary
|
|
|
+
|
|
|
+ return result
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function useSummaryModel() {
|
|
|
+ return new SummaryModel()
|
|
|
+}
|
|
|
+
|
|
|
+export default useSummaryModel
|