/* * @Author: lixiong * @Date: 2019-08-21 14:35:07 * @Last Modified by: zheng * @Last Modified time: 2021-06-09 09:52:31 */ /** * 贷款申请查询 */ import ApiModel from '@dreamSend/serve/core/ApiModel' import * as dayjs from 'dayjs' // 表单信息 const formList = [ { type: 'input', label: '手机号', value: '', name: 'phoneNo', rules: [{ maxLength: 11 }] }, { type: 'input', label: '短信-模糊查询', value: '', name: 'tempContent' }, { type: 'select', label: '提供商状态', value: '', options: [], name: 'dealStatus', attrs: ['collapse-tags', 'filterable', 'clearable'] }, { type: 'select', label: '渠道', value: '', options: [], name: 'channelCode', attrs: ['collapse-tags', 'filterable', 'clearable'] }, { type: 'input', label: '模板编号', value: '', name: 'tempNo' }, { type: 'dateRange', label: '请求时间', value: [], name: 'planLendDate', names: ['startTime', 'endTime'] }, { type: 'input', label: '申请编号', value: '', name: 'applyNo' }, { type: 'input', label: '请求流水号', value: '', name: 'reqNo' }, { type: 'input', label: '业务单号', value: '', name: 'busiNo' }, ] // 表格信息 const tableList = [ { prop: "applyNo", label: "申请编号", width: "220px", // fixed: true, // type: "link" // link, button, buttons }, { prop: 'createdAt', label: '请求时间', width: '160px' }, { prop: 'phoneNo', label: '手机号', width: '120px' }, { prop: 'tempContent', label: '短信内容', width: '250px', showTooltip: true }, { prop: 'channerName', label: '渠道', width: '80px' }, { prop: 'tempNo', label: '模板编号', width: '200px' }, { prop: 'statusName', label: '提交状态', width: '80px' }, { prop: 'dealDesc', label: '提供商状态', width: '100px' }, { prop: 'dealTime', label: '处理时间', width: '160px' }, { prop: 'elapsedTime', label: '耗时', width: '60px' }, { prop: "lastAction", label: "操作管理", width: "170px", type: "buttons", fixed: "right" } ] export default options => { // 接口地址,required const api = '/admin/sms/Info' return new ApiModel({ api, formList, tableList, request(params) { return this.get(params) }, computedItem(item) { // 表格部分字段特殊处理 let { createdAt, dealTime, status } = item const createdAtN = dayjs(createdAt).format('YYYY-MM-DD HH:mm:ss') const dealTimeN = dayjs(dealTime).format('YYYY-MM-DD HH:mm:ss') let seconds = dayjs(dealTime).diff(dayjs(createdAt),"seconds") || 0 let returnTime = ''; if(60<=seconds&&seconds<3600){//转为分钟 returnTime = Math.round(seconds / 60)+'分'+seconds%60+'秒'; }else if(3600<=seconds&&seconds<86400){//转为小时 returnTime = Math.floor(seconds / 3600)+'小时'+Math.floor(seconds%3600/60)+'分'+Math.floor(seconds%60)+'秒'; }else if(86400<=seconds){//转为天 returnTime = Math.floor(seconds/86400)+'天'+Math.floor(seconds%86400/3600)+'小时'+Math.floor(seconds%3600/60)+'分'+Math.floor(seconds%60)+'秒'; }else{ returnTime = seconds+'秒'; } const statusArr = {"1":"落地","2":"处理中","3":"成功","4":"失败"}; const statusName = statusArr[status] return {...item, createdAt: createdAtN, dealTime: dealTimeN, elapsedTime: returnTime, statusName} }, computedValue(val, name, list) { // 表单部分字段特殊处理(这里为:多选项按接口要求转换为拼接字符串) const { formList } = this if (typeof list === 'undefined') { list = [...formList] } if ( formList.some( ({ attrs = [], name: findName }) => attrs.includes('multiple') && findName === name ) ) { return Array.isArray(val) ? val.join(',') : val } return val } // computedValues(values = {}) { // const { formList } = this // return Object.keys(values).reduce((pre, curr) => { // // let { name, value } = curr // let value = values[curr] // const findItem = formList.find( // item => // item.name === curr && // (Array.isArray(item.attrs) && item.attrs.includes('multiple')) // ) // if (findItem && Array.isArray(value)) { // value = value.join(',') // } // pre[curr] = value // return pre // }, {}) // } }) }