import APP from '@/services'; import { getLongTypeLoginID } from '@/services/bus/login'; import { localStorageUtil } from '@/utils/tool/storage'; import moment from 'moment'; import { commonSearch_go } from '../index'; import * as type from './interface'; /** * 获取服务器时间 */ export function getServerTime(): Promise { return commonSearch_go('/Common/GetServerTime', {}) .then((res) => { const time = moment(res) .utc() .format('YYYY-MM-DD HH:mm:ss'); APP.set('systemDate', time); return 'ok'; }) .catch((err: Error) => { throw new Error('获取服务器时间数据错误:' + err.message); }); } /** * 获取所有枚举信息 * @param autoid autoid传入后则返回这个ID之后的数据;如不传则返回所有 */ export function getAllEnums(autoid?: number): Promise { const param = autoid ? { autoid } : {}; return commonSearch_go('/Common/GetAllEnums', param).catch((err: Error) => { throw new Error('查询获取所有枚举信息:' + err.message); }); } /** * 获取数据库错误信息 * @param rowNumber 如果传入rowNumber,则返回此rowNumber后的数据 */ export function queryErrorInfos(rowNumber?: string): Promise { const param = rowNumber ? { rowNumber } : {}; return commonSearch_go('/Common/QueryErrorInfos', param) .then((res) => { localStorageUtil.setItem('errorCodeInfos', res); return 'ok'; }) .catch((err: Error) => { throw new Error('查询获取所有枚举信息:' + err.message); }); } /** * 通知公告设置已读请求 * @param loginID 登录账号 * @param noticeID 通知公告ID */ export function queryNoticeReaded(noticeID: number): Promise { const param = { noticeID, loginID: Number(getLongTypeLoginID()) }; return commonSearch_go('/Common/NoticeReaded', param, 'post') .then(() => 'ok') .catch((err: Error) => { throw new Error(`通知公告设置已读请求失败:${err.message}`); }); } /** * 通知公告系统消息查询 */ export function queryNotice(): Promise { const param = { loginID: Number(getLongTypeLoginID()) }; return commonSearch_go('/Common/QueryNotice', param).catch((err: Error) => { throw new Error(`通知公告系统消息查询失败:${err.message}`); }); } /** * 获取PC交易端菜单 */ export function GetPCMenus(): Promise { const param = { loginID: Number(getLongTypeLoginID()), clientType: 0, // 终端类型,0:PC 1:Mobile }; return commonSearch_go('/Common/GetClientMenus', param) .then((res) => { APP.set('menus', res); console.log('res', res); return 'ok'; }) .catch((err: Error) => { throw new Error(`获取PC交易端菜单失败:${err.message}`); }); } /** * 查询交易端列表头信息 * @returns */ export function QueryTableDefine(): Promise { const param = { tableType: 2, // 列表类型 - 1:管理端 2:H5终端 3:移动终端 }; return commonSearch_go('/Common/QueryTableDefine', param) .then((res) => { console.log('查询交易端列表头信息', res); APP.set('tableHead', res) return res; }) .catch((err: Error) => { throw new Error(`查询交易端列表头信息:${err.message}`); }); }