| | |
| | | import SparkMD5 from 'spark-md5' |
| | | import { getPublicImage } from '@/assets/js/middleGround/tool.js' |
| | | import { |
| | | getPublicImage |
| | | } from '@/assets/js/middleGround/tool.js' |
| | | import config from './config' |
| | | // import moment from "moment"; |
| | | import moment from "moment"; |
| | | |
| | | import dps5Api from '@/assets/js/middleGround/api/dps5.js' |
| | | |
| | | |
| | | |
| | | var tool = { |
| | | secondToTime(second) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 处理订单记录 |
| | | // export function setOrderList(res) { |
| | | // // 获取当前年份的开始时间 |
| | | // let currentTimestamp = moment().startOf("year"); |
| | | // let arr = []; |
| | | // for (let i = 0; i < res.length; i++) { |
| | | // const item = res[i]; |
| | | // // 发票状态为审核中或者审核失败,将item选中状态设置选中。 |
| | | // // UI控制禁用(显示的效果为 选中并且禁用) |
| | | // if (item.invoiceInfo) { |
| | | // item.checked = true; |
| | | // } else { |
| | | // item.checked = false; |
| | | // } |
| | | // // 判断是否超出申请发票的日期 |
| | | // item.exceedingTheSpecifiedTime = moment(item.createDate).isBefore( |
| | | // currentTimestamp |
| | | // ); |
| | | // if (item.saleMethodLinks.length > 0) { |
| | | // let itemName = null; |
| | | // let itemIcon = null; |
| | | // let cmsItemList = null; |
| | | // try { |
| | | // cmsItemList = item.saleMethodLinks[0].orderSaleMethod.cmsItemList[0]; |
| | | // } catch (error) { |
| | | // cmsItemList = null; |
| | | // } |
| | | // if (cmsItemList && cmsItemList.icon) { |
| | | // itemName = cmsItemList.name; |
| | | // itemIcon = cmsItemList.icon; |
| | | // } else { |
| | | // itemName = item.saleMethodLinks[0].orderSaleMethod.product.name; |
| | | // itemIcon = item.saleMethodLinks[0].orderSaleMethod.product.icon; |
| | | // } |
| | | // item.saleMethodLinks[0].title = itemName; |
| | | // item.saleMethodLinks[0].icon = getPublicImage(itemIcon); |
| | | // } else { |
| | | // const itemIcon = require("@/assets/images/bookCity/place_img.png"); |
| | | // const saleMethodLink = []; |
| | | // const obj = { |
| | | // icon: itemIcon, |
| | | // orderSaleMethod: { |
| | | // price: item.payPrice, |
| | | // }, |
| | | // }; |
| | | // saleMethodLink.push(obj); |
| | | // item.saleMethodLinks = saleMethodLink; |
| | | // } |
| | | // if (item.state == "Success") { |
| | | // item.CustomState = "支付成功"; |
| | | // } |
| | | // if (item.state == "Cancel") { |
| | | // item.CustomState = "取消支付"; |
| | | // } |
| | | // if (item.state == "WaitPay") { |
| | | // item.CustomState = "等待支付"; |
| | | // } |
| | | // if (item.state == "WaitDeliver") { |
| | | // item.CustomState = "正在支付"; |
| | | // } |
| | | // arr.push(item); |
| | | // } |
| | | // return arr; |
| | | // } |
| | | |
| | | //处理表单提交数据 |
| | | export function worksData(res) { |
| | |
| | | obj.setDataAndFileLinkListRequest = linkList |
| | | } else if (typeof value[k] == 'object' && k == 'region') { |
| | | obj.strValue = value[k]?.join('/') |
| | | obj.setDataAndFileLinkListRequest = [{ area: value[k] }] |
| | | obj.setDataAndFileLinkListRequest = [{ |
| | | area: value[k] |
| | | }] |
| | | } else { |
| | | obj.strValue = value[k].toString() |
| | | } |
| | |
| | | |
| | | // 获取文件 |
| | | export function getPublicFile(md5, isToken) { |
| | | const { tokenKey, requestCtx } = config |
| | | const { |
| | | tokenKey, |
| | | requestCtx |
| | | } = config |
| | | let src = null |
| | | let token = localStorage.getItem(tokenKey) |
| | | if (md5) { |
| | |
| | | return src |
| | | } |
| | | |
| | | // 处理时间,用于显示音视频当前时间 |
| | | // export function realFormatSecond(time) { |
| | | // let duration = parseInt(time); |
| | | // let minute = parseInt(duration / 60); |
| | | // let sec = (duration % 60) + ""; |
| | | // let isM0 = ":"; |
| | | // if (minute == 0) { |
| | | // minute = "00"; |
| | | // } else if (minute < 10) { |
| | | // minute = "0" + minute; |
| | | // } |
| | | // if (sec.length == 1) { |
| | | // sec = "0" + sec; |
| | | // } |
| | | // return minute + isM0 + sec; |
| | | // } |
| | | |
| | | // export function parseHtml(content) { |
| | | // const tagReg = |
| | | // /<\/?div[^>]*>|<\/?span[^>]*>|<\/?table[^>]*>|<\/?th[^>]*>|<\/?thead>|<\/?tbody>|<\/?tr>|<\/?td[^>]*>|<br[^>]*>|<\/?p[^>]*>|<\/?sub>|<\/?sup>|<\/?font[^>]*>|<img[^>]*>|<\/?a[^>]*>|\n|\\n/gi; |
| | | // const escapeReg = |
| | | // /&(lt|gt|le|ge|nbsp|amp|quot|times|Alpha|Beta|Gamma|Delta|Epsilon|Zeta|Eta|Theta|Iota|Kappa|Lambda|MU|NU|Xi|Omicron|Pi|Rho|Sigma|Tau|Upsilon|Phi|Chi|Psi|Omega|alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigmaf|sigma|tau|upsilon|phi|chi|psi|omega|thetasym|upsih|piv|circ|tilde|ndash|permil|lsquo|rsquo|ldquo|rdquo|prime);/gi; |
| | | // const escapeElements = { |
| | | // lt: "<", |
| | | // gt: ">", |
| | | // le: "≤", |
| | | // ge: "≥", |
| | | // nbsp: " ", |
| | | // amp: "&", |
| | | // quot: '""', |
| | | // times: "×", |
| | | // Alpha: "Α", |
| | | // Beta: "Β", |
| | | // Gamma: "Γ", |
| | | // Delta: "Δ", |
| | | // Epsilon: "Ε", |
| | | // Zeta: "Ζ", |
| | | // Eta: "Η", |
| | | // Theta: "Θ", |
| | | // Iota: "Ι", |
| | | // Kappa: "Κ", |
| | | // Lambda: "Λ", |
| | | // Mu: "Μ", |
| | | // Nu: "Ν", |
| | | // Xi: "Ξ", |
| | | // Omicron: "Ο", |
| | | // Pi: "Π", |
| | | // Rho: "Ρ", |
| | | // Sigma: "Σ", |
| | | // Tau: "Τ", |
| | | // Upsilon: "Υ", |
| | | // Phi: "Φ", |
| | | // Chi: "Χ", |
| | | // Psi: "Ψ", |
| | | // Omega: "Ω", |
| | | // alpha: "α", |
| | | // beta: "β", |
| | | // gamma: "γ", |
| | | // delta: "δ", |
| | | // epsilon: "ε", |
| | | // zeta: "ζ", |
| | | // eta: "η", |
| | | // theta: "θ", |
| | | // iota: "ι", |
| | | // kappa: "κ", |
| | | // lambda: "λ", |
| | | // mu: "μ", |
| | | // nu: "ν", |
| | | // xi: "ξ", |
| | | // omicron: "ο", |
| | | // pi: "π", |
| | | // rho: "ρ", |
| | | // sigmaf: "ς", |
| | | // sigma: "σ", |
| | | // tau: "τ", |
| | | // upsilon: "υ", |
| | | // phi: "φ", |
| | | // chi: "χ", |
| | | // psi: "ψ", |
| | | // omega: "ω", |
| | | // thetasym: "ϑ", |
| | | // upsih: "ϒ", |
| | | // piv: "ϖ", |
| | | // circ: "ˆ", |
| | | // tilde: "˜", |
| | | // ndash: "–", |
| | | // permil: "‰", |
| | | // lsquo: "‘", |
| | | // rsquo: "’", |
| | | // ldquo: "“", |
| | | // rdquo: "”", |
| | | // prime: "′", |
| | | // }; |
| | | // const contentWithoutTag = content.replace(tagReg, ""); |
| | | // const contentWithOnlyOneSpace = contentWithoutTag.replace(/ {2,}/g, " "); |
| | | // return contentWithOnlyOneSpace.replace( |
| | | // escapeReg, |
| | | // (all, t) => escapeElements[t] |
| | | // ); |
| | | // } |
| | | |
| | | export function getCmsItem({ |
| | | path, |
| | | storeId, |
| | | repositoryId, |
| | | type, |
| | | paging, |
| | | sort, |
| | | linkTypes, |
| | | fields, |
| | | filters, |
| | | subQuery, |
| | | keyword, |
| | | itemId, |
| | | resType, |
| | | havePublishInfo, |
| | | isRightSlider, |
| | | direction, |
| | | queryParent |
| | | }) { |
| | | const query = { |
| | | AccessControl: { |
| | | Path: path, |
| | | StoreId: storeId + '', |
| | | RepositoryId: repositoryId + '', |
| | | Type: type ? type : '\\' |
| | | }, |
| | | PageQuery: paging, |
| | | SortQuery: sort ? [sort] : [], |
| | | CreateDate: [], |
| | | Description: [], |
| | | Name: [], |
| | | RefCode: [], |
| | | Type: [], |
| | | SysType: [], |
| | | TypeId: [], |
| | | State: [], |
| | | Tag: [], |
| | | LinkDepartment: [], |
| | | LinkOrg: [], |
| | | LinkInfo: [], |
| | | LinkId: [], |
| | | LinkOrder: [], |
| | | LinkParentId: [], |
| | | LinkFile: [], |
| | | LinkType: linkTypes ?? [], |
| | | LinkStore: [], |
| | | LinkRepository: [], |
| | | LinkPath: [], |
| | | LinkAppId: [], |
| | | Creator: [], |
| | | ...fields, |
| | | ...filters, |
| | | ...subQuery |
| | | }; |
| | | if (havePublishInfo) { |
| | | query['PublishInfo'] = []; |
| | | } |
| | | if (queryParent) { |
| | | query['QueryParent'] = { |
| | | ...queryParent |
| | | }; |
| | | } |
| | | if (keyword) { |
| | | delete query.Name; |
| | | query['Name*'] = [keyword]; |
| | | } |
| | | if (direction && isRightSlider) { |
| | | query['Direction'] = [direction]; |
| | | } |
| | | if (itemId) query['Id='] = [`${itemId}`]; |
| | | if (query['CreatorAndAppRole'] != null) { |
| | | delete query.Creator; |
| | | } |
| | | const body = { |
| | | query: JSON.stringify({ |
| | | Query: [{ |
| | | Q1: query |
| | | }] |
| | | }) |
| | | }; |
| | | return dps5Api.QueryCmsItem(body).then((res) => { |
| | | if (res && res.length > 0) { |
| | | const data = res[0]; |
| | | const datas = handleCmsItemListRequestData(data.datas, fields, path, storeId, repositoryId); |
| | | return { |
| | | datas, |
| | | total: data.totalCount |
| | | }; |
| | | } else { |
| | | return { |
| | | datas: [], |
| | | total: 0 |
| | | }; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | export const handleCmsItemListRequestData = (datas, fields, path, storeId, repositoryId) => { |
| | | const dataList = []; |
| | | for (let i = 0; i < datas.length; i++) { |
| | | const item = datas[i]; |
| | | const _fields = {}; |
| | | const _datas = []; |
| | | if (fields != null) { |
| | | for (let fieldKey in fields) { |
| | | // 兼容筛选条件的字段值获取,因为后台筛选和取值只能传一个,都会返回值 |
| | | fieldKey = fieldKey.replace(/[!=<>*]/g, ''); |
| | | if (item.datas[fieldKey]) { |
| | | let values = []; |
| | | if (typeof item.datas[fieldKey] == 'string') { |
| | | values = JSON.parse(item.datas[fieldKey]); |
| | | } else { |
| | | values = item.datas[fieldKey]; |
| | | } |
| | | if (values ?.length > 0) { |
| | | // 用字段名处理返回的字段值 |
| | | if (values[0].Value) { |
| | | _fields[fieldKey] = values[0].Value; |
| | | values[0].sequenceNum = values[0].SequenceNum; |
| | | } |
| | | // 兼容处理数据返回的key是CmsItemData |
| | | // if (values[0].CmsItemData) { |
| | | // _fields[fieldKey] = values[0].CmsItemData.Value; |
| | | // values[0].sequenceNum = values[0].CmsItemData.SequenceNum; |
| | | // } |
| | | |
| | | item.datas[fieldKey] = values[0]; |
| | | if (values ?.length > 1) { |
| | | const isFile = values.find((citem) => citem.FileList ?.length > 0); |
| | | const dataItems = deduplicateArray(values, 'FieldId'); |
| | | if (!isFile) { |
| | | _datas.push(dataItems[0]); |
| | | } else { |
| | | const customFile = { |
| | | customFileList: values, |
| | | name: fieldKey, |
| | | md5: _fields[fieldKey], |
| | | FieldId: values[0].FieldId, |
| | | SequenceNum: values[0].SequenceNum |
| | | }; |
| | | _datas.push(customFile); |
| | | } |
| | | } else { |
| | | _datas.push(values[0]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (item.datas.LogQuery) { |
| | | item.datas.LogQuery = JSON.parse(item.datas.LogQuery); |
| | | } |
| | | |
| | | const subDatas = {}; |
| | | if (item.subDatas) { |
| | | for (let subData of item.subDatas) { |
| | | const tag = subData.queryTag.replace('Query', ''); |
| | | subDatas[tag] = subData.datas; |
| | | } |
| | | } |
| | | dataList.push({ |
| | | ...item, |
| | | id: item.id, |
| | | name: item.datas.Name ? item.datas.Name : item.name, |
| | | icon: item.datas.Icon, |
| | | storeId: storeId, |
| | | repositoryId: repositoryId, |
| | | refCode: item.datas.RefCode === '[]' ? null : item.datas.RefCode, |
| | | state: item.datas.State, |
| | | type: item.datas.Type, |
| | | tag: item.datas.Tag, |
| | | creator: item.datas.Creator ? JSON.parse(item.datas.Creator) : undefined, |
| | | linkType: item.datas.LinkType, |
| | | childrenCount: parseInt(item.datas.ChildrenCount ?? '0'), |
| | | childrenFolderCount: parseInt(item.datas.ChildrenFolderCount ?? '0'), |
| | | childrenChannelCount: parseInt(item.datas.ChildrenChannelCount ?? '0'), |
| | | childrenCmsItemCount: parseInt(item.datas.ChildrenCmsItemCount ?? '0'), |
| | | childrenFileCount: parseInt(item.datas.ChildrenFileCount ?? '0'), |
| | | createDate: moment(item.datas.CreateDate).format('YYYY-MM-DD HH:mm:ss'), |
| | | description: item.datas.Description, |
| | | sysType: item.datas.SysType, |
| | | idPath: path + '\\' + item.id, |
| | | typeId: parseInt(item.datas.TypeId), |
| | | linkAppId: item.datas.linkAppId, |
| | | linkFile: JSON.parse(item.datas.LinkFile ?? '[]'), |
| | | PublishInfo: JSON.parse(item.datas.PublishInfo ?? '[]'), |
| | | linkInfo: item.datas.LinkInfo ? JSON.parse(item.datas.LinkInfo) : [], |
| | | linkPath: item.datas.LinkPath ?? null, |
| | | linkOrg: item.datas.LinkOrg ? JSON.parse(item.datas.LinkOrg) : [], |
| | | linkDepartment: item.datas.LinkDepartment? JSON.parse(item.datas.LinkDepartment) : [], |
| | | ..._fields, |
| | | datas: item.datas, |
| | | fieldList: _datas, |
| | | subDatas |
| | | }); |
| | | } |
| | | return dataList; |
| | | }; |
| | | |
| | | // type结构处理 |
| | | export const handleTypeList = (list) => { |
| | | for (let i = 0; i < list.length; i++) { |
| | | const type = list[i]; |
| | | try { |
| | | type.cfg = JSON.parse(type.config); |
| | | } catch (error) { |
| | | type.cfg = null; |
| | | } |
| | | const fieldRefcodeMap = {}; |
| | | const tableHeaderFieldList = []; |
| | | const isSearchFieldList = []; |
| | | const isAdvSearchFieldList = []; |
| | | const isFilterFieldList = []; |
| | | handleType({ |
| | | typeFieldList: type.typeLinkList, |
| | | fieldRefcodeMap, |
| | | tableHeaderFieldList, |
| | | isSearchFieldList, |
| | | isAdvSearchFieldList, |
| | | isFilterFieldList |
| | | }); |
| | | type.fieldRefcodeMap = fieldRefcodeMap; |
| | | type.tableHeaderFieldList = tableHeaderFieldList; |
| | | type.isSearchFieldList = isSearchFieldList; |
| | | type.isAdvSearchFieldList = isAdvSearchFieldList; |
| | | type.isFilterFieldList = isFilterFieldList; |
| | | } |
| | | |
| | | return list; |
| | | }; |
| | | |
| | | const handleType = ({ |
| | | typeFieldList, |
| | | fieldRefcodeMap, |
| | | tableHeaderFieldList, |
| | | isSearchFieldList, |
| | | isAdvSearchFieldList, |
| | | isFilterFieldList |
| | | }) => { |
| | | for (let i = 0; i < typeFieldList.length; i++) { |
| | | const item = typeFieldList[i]; |
| | | try { |
| | | item.cfg = JSON.parse(item.config); |
| | | } catch (error) { |
| | | item.cfg = null; |
| | | } |
| | | if (item.typeField) { |
| | | try { |
| | | item.typeField.cfg = JSON.parse(item.typeField.config); |
| | | } catch (error) { |
| | | item.typeField.cfg = null; |
| | | } |
| | | fieldRefcodeMap[item.typeField.refCode] = item; |
| | | } |
| | | if (item.cfg && item.cfg.isColHeader) { |
| | | tableHeaderFieldList.push(item); |
| | | } |
| | | if (item.cfg && item.cfg.isSearch) { |
| | | isSearchFieldList.push(item); |
| | | } |
| | | if (item.cfg && item.cfg.isAdvSearch) { |
| | | isAdvSearchFieldList.push(item); |
| | | } |
| | | if (item.cfg && item.cfg.isFilter) { |
| | | isFilterFieldList.push(item); |
| | | } |
| | | if (item.children && item.children.length) { |
| | | handleType({ |
| | | typeFieldList: item.children, |
| | | fieldRefcodeMap, |
| | | tableHeaderFieldList, |
| | | isSearchFieldList, |
| | | isAdvSearchFieldList, |
| | | isFilterFieldList |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | //处理树形结构 |
| | | const handleTreeData = (datas, parent, noTriggerSelect = false) => { |
| | | let parentData = {}; |
| | | if (parent) { |
| | | parentData = { ...parent, parent: null }; |
| | | } else { |
| | | parentData = null; |
| | | } |
| | | const list = []; |
| | | for (let i = 0; i < datas.length; i++) { |
| | | const data = datas[i]; |
| | | const obj = { |
| | | label: data.name, |
| | | key: parentData ? parentData.key + "_" + i : i + "", |
| | | namePath: parentData ? parentData.namePath + "\\" + data.name : data.name, |
| | | icon: data.icon, |
| | | data: data, |
| | | parent: parentData, |
| | | leaf: false, |
| | | children: [], |
| | | }; |
| | | if (data["children"] && data["children"].length) { |
| | | obj.leaf = false; |
| | | obj.children = handleTreeData( |
| | | data["children"], |
| | | { |
| | | ...data, |
| | | key: obj.key, |
| | | namePath: obj.namePath, |
| | | }, |
| | | i == 0 ? false : true // 如果有子数据处理,只有第一条数据需要展开和回调 |
| | | ); |
| | | } else { |
| | | obj.leaf = |
| | | !data["childrenChannelCount"] || data["childrenChannelCount"] == 0; |
| | | } |
| | | list.push(obj); |
| | | } |
| | | console.log(list, "list"); |
| | | return list; |
| | | }; |
| | | |
| | | |
| | | //获取资源 |
| | | |
| | | const getResourceItem = async (path,storeInfo,filters,fields) => { |
| | | const params = { |
| | | path:path.data.idPath, |
| | | storeId:storeInfo.storeId, |
| | | repositoryId:storeInfo.repositoryId, |
| | | type: "\\", |
| | | sort: { |
| | | LinkOrder: "Asc", |
| | | }, |
| | | paging: { |
| | | Start: 0, |
| | | Size: 50, |
| | | }, |
| | | filters:{...filters}, |
| | | fields:{...fields} |
| | | } |
| | | const res = await getCmsItem(params); |
| | | |
| | | return res; |
| | | } |
| | | |
| | | |
| | | export default { |
| | | ...tool, |
| | |
| | | UpdateworksDataBytool, |
| | | getPublicImage, |
| | | worksData, |
| | | getPublicFile |
| | | getCmsItem, |
| | | getPublicFile, |
| | | handleTypeList, |
| | | handleTreeData, |
| | | getResourceItem |
| | | // parseHtml, |
| | | } |
| | | } |