UNPKG

ttk-app-core

Version:
1,214 lines (1,110 loc) 42.9 kB
import React from 'react' import { action as MetaAction, AppLoader } from 'edf-meta-engine' import { TableOperate, Select, Button, Modal, Icon ,PrintOption, FormDecorator} from 'edf-component' import utils from 'edf-utils' import sortSearchOption from './utils/sortSearchOption' import moment from 'moment' import SortProof from './components/SortProof' import config from './config' const Option = Select.Option import { consts } from 'edf-consts' import table from '../../../component/components/table/table'; const VOUCHERSTATUS_NotApprove = '1000020001', // 单据状态: 1000020001: 未审核 VOUCHERSTATUS_Approved = '1000020002', // 单据状态: 1000020002: 已审核 VOUCHERSTATUS_Rejected = '1000020003' // 单据状态: 1000020003: 已驳回 class action { constructor(option) { this.metaAction = option.metaAction this.config = config.current this.webapi = this.config.webapi this.voucherAction = option.voucherAction } onInit = ({ component, injections }) => { this.component = component this.injections = injections let addEventListener = this.component.props.addEventListener this.changeSipmleDate = false if (addEventListener) { addEventListener('onTabFocus', :: this.onTabFocus) } injections.reduce('init') if( this.component.props.initSearchValue ){ this.linkInPage(this.component.props.initSearchValue) }else{ this.load() } } onTabFocus = async (params) => { if( params.initSearchValue ){ this.linkInPage(params.initSearchValue) }else{ await this.initDate() this.sortParmas() } // this.showPickerDidMount() } linkInPage = (initSearchValue) => { const { accountId, //--科目ID endCode, //--终止凭证号 startCode, //--起始凭证号 date_end, //期间终止 date_start, //期间起始 docIds, //--凭证ID列表 summary, //--摘要 voucherState, //--单据状态 sourceVoucherTypeId, //--单据类型 -- 单据来源 simpleCondition //简单查询 } = initSearchValue this.injections.reduce('update', { path: 'data.searchValue', value: { accountId, //--科目ID endCode, //--终止凭证号 startCode, //--起始凭证号 date_end, //期间终止 date_start, //期间起始 docIds, //--凭证ID列表 summary, //--摘要 voucherState, //--单据状态 sourceVoucherTypeId, //--单据类型 -- 单据来源 simpleCondition, //简单查询 } }) this.sortParmas(null, null, null, 'init', true) } componentDidMount = () => { this.onResize() // this.showPickerDidMount() const win = window if (win.addEventListener) { win.addEventListener('resize', this.onResize, false) } else if (win.attachEvent) { win.attachEvent('onresize', this.onResize) } else { win.onresize = this.onResize } } getTableScroll = () => { try{ let tableOption = this.metaAction.gf('data.tableOption').toJS() let dom = document.getElementsByClassName('ttk-table-app-list-Body')[0] let tableDom if( !dom ){ return } if( tableOption.y ){ tableDom = dom.getElementsByClassName('ant-table-fixed')[1] }else{ tableDom = dom.getElementsByClassName('ant-table-fixed')[0] } if( tableDom && dom ) { let num = dom.offsetHeight - tableDom.offsetHeight // console.log(num, tableOption.y, dom.offsetHeight, tableDom.offsetHeight) console.log( num ) if( (num-30) > 0 && tableOption.y){ delete tableOption.y this.injections.reduce('update', { path: 'data.tableOption', value: tableOption }) }else if( num < 0 && !tableOption.y){ const width = dom.offsetWidth const height = dom.offsetHeight this.injections.reduce('setTableOption', { ...tableOption, y: height - 41, containerWidth: width - 20 }) } } // setTimeout(()=>{ // this.onResize() // },2000) }catch(err){ console.log(err) } } onResize = (type) => { let keyRandom = Math.floor(Math.random() * 10000) this.keyRandom = keyRandom const tableOption = this.metaAction.gf('data.tableOption').toJS() setTimeout(() => { if (this.keyRandom == keyRandom) { let dom = document.getElementsByClassName('ttk-table-app-list-Body')[0] if (!dom) { if( type ){ return } setTimeout(() => { this.onResize() }, 20) } else { let tableOption = this.metaAction.gf('data.tableOption').toJS() const width = dom.offsetWidth const height = dom.offsetHeight this.injections.reduce('setTableOption', { ...tableOption, y: height - 41, containerWidth: width - 20 }) } } }, 100) } refreshBtnClick = () => { this.sortParmas() } getColumnsItem = (type) => { const data = this.metaAction.gf('data').toJS() const columns = [{ title: { name: 'sort', component: 'TableSort', sortOrder: data.sort.userOrderField == "voucherDate" ? data.sort.order : null, handleClick: (e) => { this.sortChange("voucherDate", e) }, title: '日期' }, dataIndex: 'voucherDate', key: 'voucherDate', className: 'table_center', render: this.rowSpan }, { title: { name: 'sort', component: 'TableSort', sortOrder: data.sort.userOrderField == "docCode" ? data.sort.order : null, handleClick: (e) => { this.sortChange("docCode", e) }, title: '账单序号' }, className: 'table_center', dataIndex: 'docTypeAndCode', key: 'docTypeAndCode', render: this.rowSpan2 }] return columns.find(item => { return item.dataIndex == type }) // return columns } needAlignType = (key) => { const right = ['amountSum', 'origAmount', 'amountDr', 'price', 'amountCr'] const left = ['summary', 'accountCodeName', 'currencyAndExchangeRate', 'sourceVoucherCode', 'creator', 'auditor'] const center = ['quantity', 'attachedNum', 'voucherStateName', 'unitName' ] let className = right.includes(key) ? 'right' : left.includes(key) ? 'left' : 'center' return className } renderColumns = () => { const tableSetting = this.metaAction.gf('data.other.columnDto').toJS() const tableOption = this.metaAction.gf('data.tableOption').toJS() const arr = [] tableSetting.forEach(data => { let item = this.getColumnsItem(data.fieldName) if (!data.isVisible) { return } if (item) { arr.push(item) } else if(data.isHeader == true) { arr.push({ title: data.caption, key: data.fieldName, className: `table_td_align_${this.needAlignType(data.fieldName)}`, dataIndex: data.fieldName, render: (text, record, index) => this.rowSpan(text, record, index, data.fieldName) }) }else{ if( data.fieldName == 'accountCodeName' ){ arr.push({ title: data.caption, key: data.fieldName, dataIndex: data.fieldName, className: `table_td_align_${this.needAlignType(data.fieldName)}`, render: this.normalTdRender2 }) }else{ arr.push({ title: data.caption, key: data.fieldName, className: `table_td_align_${this.needAlignType(data.fieldName)}`, dataIndex: data.fieldName, render: (text, record, index) => this.normalTdRender(text, record, index, data.fieldName) }) } } }) arr.push({ title: ( <Icon name="columnset" fontFamily='edficon' className='ttk-table-app-list-columnset' type="youcezhankailanmushezhi" onClick={() => this.showTableSetting({ value: true })} /> ), key: 'voucherState', dataIndex: 'voucherState', fixed: 'right', className: 'table_fixed_width', //componet: 'TableOperate', width: 70, render: (text, record, index) => this.operateCol(text, record, index) }) return arr } transformThoundsNumber = (text, key) => { const arr = ['amountCr', 'amountDr', 'origAmount', 'price', 'amountSum'] // text = -0.01 if( arr.includes(key) ){ if( !text || parseFloat(text) == 0 || isNaN(parseInt(text)) ){ return '' } if( key == 'price'){ return utils.number.format(text, 6) }else{ return utils.number.format(text, 2) } }else{ return text } } normalTdRender = (text, record, index, key) => { return <span className="ttk-table-app-list-td-con" title={this.transformThoundsNumber(text, key)}>{this.transformThoundsNumber(text, key)}</span> } normalTdRender2 = (text) => { return <span title={text} className="ttk-table-app-list-td-con" title={text}>{text}</span> } // 设置表格固定高度 // renderDid = ()=>{ // try{ // let container = document.getElementsByClassName('ttk-table-app-list')[0].offsetHeight // let footer = document.getElementsByClassName('ttk-table-app-list-footer')[0].offsetHeight // let header = document.getElementsByClassName('mk-search')[0].offsetHeight // let tableHeader = document.getElementsByClassName('ant-table-header')[0].offsetHeight // // 20是padding值 // let height = container - header - footer - tableHeader - 20 // let prevHeight = this.metaAction.gf('data.tableOption.y') // if( prevHeight == height ){ // return // } // // this.injections.reduce('setTableScroll', height) // }catch(err){ // // console.log(err) dom 没有发现时会报错 // } // } getNormalSearchValue = () => { const data = this.metaAction.gf('data.searchValue').toJS() let date = [data.date_start, data.date_end] return { date, simpleCondition: data.simpleCondition } } combineColumnProp = (data) => { if (!data) return [] let newDataArray = [] data.forEach((ele, index) => { newDataArray.push({ "isVisible": ele.isVisible, "id": ele.id }) }) return newDataArray } closeTableSetting = () => { this.injections.reduce('tableSettingVisible', { value: false }) } showTableSetting = async ({ value, data }) => { /** * 更新栏目 */ this.injections.reduce('update',{ path: 'data.showTableSetting', value: false }) const preData = this.metaAction.gf('data.other.columnDto') if (value === false) { this.injections.reduce('update', { path: 'data.other.columnDto', value: data }) const columnSolution = await this.webapi.docManage.findByParam({ code: 'docList' }) if (columnSolution) { let columnSolutionId = columnSolution.id // const ts = this.metaAction.gf('data.other.ts') const columnDetail = await this.webapi.docManage.updateWithDetail({ "id": columnSolutionId, "columnDetails": this.combineColumnProp(data) }) if (columnDetail) { this.injections.reduce('settingOptionsUpdate', { visible: value, data: columnDetail.columnDetails }) }else{ this.metaAction.sf('data.other.columnDto', preData) } }else{ this.metaAction.sf('data.other.columnDto', preData) } } else { this.injections.reduce('tableSettingVisible', { value, data: data }) } } load = () => { const { enabledMonth, enabledYear} = this.metaAction.context.get('currentOrg') if( enabledMonth && enabledYear ){ this.injections.reduce('update', { path: 'data.other.enableddate', value: utils.date.transformMomentDate(`${enabledYear}-${enabledMonth}`) }) } // this.initDate(`${enabledYear}-${enabledMonth}`) this.sortParmas(null, null, null, 'init') // 获取禁用时间 } //初始化选择时间 initDate = async () => { const changeSipmleDate = this.changeSipmleDate if( !changeSipmleDate ){ const res = await this.webapi.docManage.getDisplayDate() this.injections.reduce('updateArr',[ { path: 'data.searchValue.date_start', value: utils.date.transformMomentDate(res.DisplayDate) }, { path: 'data.searchValue.date_end', value: utils.date.transformMomentDate(res.DisplayDate) } ]) } return // let enableDate = utils.date.transformMomentDate(enableddate) // let chu = moment().startOf('month') // let now = moment() // let date_start = this.transformDateToNum(enableDate) < this.transformDateToNum(chu) ? chu : enableDate // let date_end = this.transformDateToNum(enableDate) < this.transformDateToNum(now) ? now : enableDate // this.injections.reduce('updateArr', [{ // path: 'data.searchValue.date_end', // value: date_end // },{ // path: 'data.searchValue.date_start', // value: date_start // }]) } // 高级搜索确定是简单搜索条件清除 searchValueChange = (value) => { let prevValue = this.metaAction.gf('data.searchValue').toJS() //时间是必填项不可清空 if (!value.date_end) { value.date_end = moment().endOf('month') //期间终止 } if (!value.date_start) { value.date_start = moment().startOf('month') //期间开始 } this.injections.reduce('searchUpdate', { ...prevValue, ...value, simpleCondition: null }) const pages = this.metaAction.gf('data.pagination').toJS() this.sortParmas({ ...prevValue, ...value, simpleCondition: null }, { ...pages, 'currentPage': 1 }) console.log('触发高级搜索') this.changeSipmleDate = true } sortParmas = (search, pages, order, type, noInitDate) => { // 处理搜索参数 if (!search) { search = this.metaAction.gf('data.searchValue').toJS() } if (!pages) { pages = this.metaAction.gf('data.pagination').toJS() } if (!order) { order = this.metaAction.gf('data.sort').toJS() } const changeData = { 'date_start': { 'startYear': (data) => data ? data.year() : null, 'startPeriod': (data) => data ? data.month() + 1 : null }, 'date_end': { 'endYear': (data) => data ? data.year() : null, 'endPeriod': (data) => data ? data.month() + 1 : null } } const searchValue = sortSearchOption(search, changeData) const page = sortSearchOption(pages, null, ['total', 'totalCount', 'totalPage']) // 简单查询没有值得情况下穿null不要穿'' if (searchValue.simpleCondition === '') { searchValue.simpleCondition = null } if( searchValue.endCode === '' ){ searchValue.endCode = null } if( searchValue.startCode === '' ) { searchValue.startCode = null } if (type == 'get') { return { ...searchValue, page, ...order } } if (type == 'init') { this.initData({ ...searchValue, page, ...order }, noInitDate) } else { this.requestData({ ...searchValue, page, ...order }) } } requestData = async (params) => { let loading = this.metaAction.gf('data.loading') if(!loading){ this.injections.reduce('tableLoading', true) } const response = await this.webapi.docManage.query(params) this.injections.reduce('tableLoading', false) this.injections.reduce('load', { response }) setTimeout(()=>{ this.getTableScroll() }, 100) } initData = async (params, noInitDate) => { const response = await this.webapi.docManage.init(params) this.injections.reduce('tableLoading', false) this.injections.reduce('load', { response , noInitDate}) this.metaAction.sf('data.tableKey', Math.random()) setTimeout(()=>{ this.getTableScroll() }, 100) } //排序发生变化 sortChange = (key, value) => { let params = { 'userOrderField': value == false ? null : key, 'order': value == false ? null : value } const pages = this.metaAction.gf('data.pagination').toJS() this.sortParmas(null, { ...pages, 'currentPage': 1 }, params) this.injections.reduce('sortReduce', params) } //分页发生变化 pageChanged = (current, pageSize) => { let page = this.metaAction.gf('data.pagination').toJS() const len = this.metaAction.gf('data.list').toJS().length if( pageSize ) { page = { ...page, 'currentPage': len == 0 ? 1 : current, 'pageSize': pageSize } }else { page = { ...page, 'currentPage': len == 0 ? 1 : current } } this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue: [], selectedOption: [] } }) // this.load({ current, pageSize }) this.sortParmas(null, page) } getChildVoucherItems = () => { } // 指定table 以什么字段作为key值 renderRowKey = (record) => { return record.docId } tableOnchange = async (pagination, filters, sorter) => { // const { columnKey, order } = sorter // const response = await this.webapi.report.query(sorter) // this.injections.reduce('tableOnchange', response.value.details) } rowSelection = (text, row, index) => { return undefined } checkboxChange = (arr, itemArr) => { let newArr = [] arr.forEach(item => { if( item ){ newArr.push(item) } }) let newItemArr = [] itemArr.map(item => { if( item ){ newItemArr.push(item) } }) this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue: newArr, selectedOption: newItemArr } }) this.selectedOption = newItemArr } moreActionOpeate = (e) => { this[e.key] && this[e.key]() } delTableItemClick = async () => { const selectedOption = this.metaAction.gf('data.tableCheckbox.selectedOption').toJS() if (selectedOption.length == 0) { this.metaAction.toast('error', '请选择您要删除的数据!') return } const ret = await this.metaAction.modal('confirm', { title: '删除凭证', content: '确定删除所选凭证?' }) console.log(ret) if( !ret ){ return } let mapData = new Map() // 去下重复 (以防万一) selectedOption.forEach(item => { if (!mapData.has(item.docId)) { mapData.set(item.docId, { docId: item.docId, ts: item.ts }) } }) let data = [] for (let value of mapData.values()) { data.push(value) } const res = await this.webapi.docManage.delProof(data) if (res.allSuccess) { this.metaAction.toast('success', '删除成功!') } else { this.metaAction.toast('error', `${res.msg}`) } this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue: [], selectedOption: [] } }) // 重新请求列表数据 this.sortParmas() } // 审核 auditClick = async () => { const selectedOption = this.getNewData() if (selectedOption.length == 0) { this.metaAction.toast('error', '请选择您要审核的数据!') return } let flag = false let data = selectedOption.map(item => { if( item.voucherState != VOUCHERSTATUS_Approved ){ flag = true } return { docId: item.docId, ts: item.ts } }) if( !flag ){ return this.metaAction.toast('warn', '当前没有可审核数据!') } const res = await this.webapi.docManage.auditProof(this.delRepeat(data, 'docId')) this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue: [], selectedOption: [] } }) // 重新请求列表数据 this.sortParmas() } getNewData = () => { const checkboxValue = this.metaAction.gf('data.tableCheckbox.checkboxValue').toJS() const list = this.metaAction.gf('data.list').toJS() let arr = [] list.map(item => { if ( checkboxValue.includes(item.docId) ){ arr.push(item) } }) return arr } //凭证去重 delRepeat = (data, code) => { const arr = new Map() data.map(item => { if (!arr.has(item[code])) { arr.set(item[code], item) } }) const sum = [] for (let value of arr.values()) { sum.push(value) } return sum } //提交整理凭证信息信息 submitSortProof = async (form, target) => { const data = form.getValue() let params = { year: data.date.year(), period: data.date.month() + 1, reorganizeType: data.radio } const res = await this.webapi.docManage.reorganizeDocCode(params) this.sortParmas() return this.metaAction.toast('success', '整理凭证号成功!') } //整理凭证号 sortProofClick = () => { let _this = this const { date_end } = this.metaAction.gf('data.searchValue').toJS() this.metaAction.modal('show', { title: '整理凭证号', width: 320, iconType: null, className: 'mk-ttk-table-app-list-modal-container', children: <SortProof time={date_end} callBack={ _this.submitSortProof } />, footer: null }) } //反审核 versaAuditClick = async () => { const selectedOption = this.getNewData() if (selectedOption.length == 0) { this.metaAction.toast('error', '请选择您要反审核的数据!') return } let flag = false let data = selectedOption.map(item => { if( item.voucherState == VOUCHERSTATUS_Approved ){ flag = true } return { docId: item.docId, ts: item.ts } }) if( !flag ){ return this.metaAction.toast('warn', '当前没有反审核的数据!') } const res = await this.webapi.docManage.unAuditBatch(this.delRepeat(data, 'docId')) this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue: [], selectedOption: [] } }) // 重新请求列表数据 this.sortParmas() } insertProofConfirm = (item) => { this.component.props.setPortalContent && this.component.props.setPortalContent( '填制凭证', 'app-proof-of-charge', { initData: { code: item.docCode, voucherDate: item.voucherDate } } ) } getInsertItem = () => { const checkboxValue = this.metaAction.gf('data.tableCheckbox.checkboxValue').toJS() const list = this.metaAction.gf('data.list').toJS() let index = list.find(item => { return checkboxValue.includes(item.docId) }) return index } delDocId = async (docId, ts) => { const res = await this.webapi.docManage.delSingleDocId({ docId, ts }) if (res) { this.metaAction.toast('success', '删除成功') } let { checkboxValue, selectedOption } = this.metaAction.gf('data.tableCheckbox').toJS() checkboxValue = checkboxValue.filter(item => item != docId) selectedOption = selectedOption.filter(item => item.docId != docId) this.injections.reduce('update', { path: 'data.tableCheckbox', value: { checkboxValue:checkboxValue, selectedOption: selectedOption } }) console.log(checkboxValue, selectedOption) this.sortParmas() } // delModal = async (docId, ts) => { const _this = this const ret = await this.metaAction.modal('confirm', { title: '删除', content: '你确定要删除吗?', onOk() { return _this.delDocId(docId, ts) }, onCancel() { } }) if (ret) { console.log(ret) } } openMoreContent = async (docId, edit) => { this.metaAction.toast('warn', '功能暂未实现!') } operateCol = (text, record, index) => { const { voucherState, docId } = record const num = this.calcRowSpan(docId, 'docId', index) const obj = { children: ( // <span className="table-needDel2" data-rol={num} data-sign={docId}> <span> <TableOperate viewClick={() => this.openMoreContent(docId, false)} editClick={() => this.openMoreContent(docId, false)} deleteClick={() => this.delModal(docId, record.ts)} status={voucherState == VOUCHERSTATUS_Approved ? 1 : 2} /> </span> ), props: { rowSpan: num, }, } return obj } componentWillUnmount = () => { if( this.dateDom ) { this.dateDom.removeEventListener('click', this.rangePickerClick) } if (this.props && this.props.isFix === true) return const win = window if (win.removeEventListener) { win.removeEventListener('resize', this.onResize, false) } else if (win.detachEvent) { win.detachEvent('onresize', this.onResize) } else { win.onresize = undefined } } rangePickerClick = () => { this.injections.reduce('update', { path: 'data.showPicker', value: true }) } normalSearchDateChange = (value) => { console.log('简单时间搜索') this.changeSipmleDate = true } // showPickerDidMount = () => { // this.dateDom = document.getElementsByClassName('ttk-table-app-list-date-picker')[0] // if( !this.dateDom ) { // setTimeout(()=>{ // this.showPickerDidMount() // }, 50) // return // } // this.dateDom.addEventListener('click', this.rangePickerClick, false) // } normalSearchChange = (path, value, initSearchValue, type) => { // this.injections.reduce('normalSearchChange', { path, value }) let params = this.metaAction.gf('data.searchValue').toJS() if (initSearchValue) { params = { ...params, ...initSearchValue } } if (path == 'date') { params.date_start = value[0] params.date_end = value[1] } else { params[path] = value } this.injections.reduce('searchUpdate', params) const pages = this.metaAction.gf('data.pagination').toJS() this.sortParmas(params, { ...pages, 'currentPage': 1 }) console.log('简单搜索') this.changeSipmleDate = true } rowSpan2 = (text, row, index) => { const num = this.calcRowSpan(row.docId, 'docId', index) const obj = { children: ( <span className="ttk-table-app-list-td-con"> <a href="javascript:;" onClick={() => this.openMoreContent(row.docId, false)} className="table-needDel" title={text} data-rol={num}> {text} </a> </span> ), props: { rowSpan: num, }, } return obj } rowSpan = (text, row, index, key) => { const obj = { children: <span className="ttk-table-app-list-td-con"><span title={this.transformThoundsNumber(text, key)}>{this.transformThoundsNumber(text, key)}</span></span>, props: { rowSpan: this.calcRowSpan(row.docId, 'docId', index), }, } return obj } isTotalRow = async (rowIndex) => { } export = async () => { const params = this.sortParmas(null, null, null, 'get') const list = this.metaAction.gf('data.list').toJS() if( list.length == 0 ){ this.metaAction.toast('warn', '当前没有可导出数据!') return } params.docIdsStr = this.getPrintDocId() this.metaAction.toast('warn', '功能暂未实现!') // await this.webapi.docManage.export(params) // /* // const res = await new Promise((reslove, reject) => { // setTimeout(() => { // reslove('导出成功!') // }, 500) // })*/ // this.metaAction.toast('success', '导出成功!') } print = async () => { let ret, form let _this = this const list = this.metaAction.gf('data.list').toJS() if( list.length == 0 ){ this.metaAction.toast('warn', '当前没有可打印数据!') return } const { height, maxLineNum, printAuxAccCalc, type, width } = await this.webapi.docManage.getPrintConfig() this.metaAction.modal('show', { title: '打印', width: 400, footer: null, iconType: null, okText: '打印', className: 'mk-ttk-table-app-list-modal-container', // footer: null, children: <PrintOption height={height} maxLineNum={maxLineNum} printAuxAccCalc={printAuxAccCalc} type={type} width={width} callBack={ _this.submitPrintOption } /> }) } getPrintDocId = () => { const selectedOption = this.metaAction.gf('data.tableCheckbox.selectedOption').toJS() if (selectedOption.length == 0) { return '' } let arr = selectedOption.map(item => { return item.docId }) console.log(arr) return arr.join(',') } submitPrintOption = async (form, target) => { // debugger this.metaAction.toast('warn', '功能暂未实现!') // let params = this.sortParmas(null, null, null, 'get') // delete params.page // let option = { // "type": parseInt(form.state.value), // "printAuxAccCalc": form.state.printAccountChecked, // "docIdsStr": this.getPrintDocId() // } // if(form.state.value == "0"){ // Object.assign(option,{"maxLineNum": form.state.pageSize},params) // }else if(form.state.value == "2"){ // Object.assign(option,{"height": form.state.height, "width": form.state.width},params) // }else { // Object.assign(option,params) // } // let res = await this.webapi.docManage.print(option) } calcRowSpan(text, columnKey, currentRowIndex) { const list = this.metaAction.gf('data.list') if (!list) return const rowCount = list.size if (rowCount == 0 || rowCount == 1) return 1 if (currentRowIndex > 0 && currentRowIndex <= rowCount && text == list.getIn([currentRowIndex - 1, columnKey])) { return 0 } let rowSpan = 1 for (let i = currentRowIndex + 1; i < rowCount; i++) { if (text == list.getIn([i, columnKey])) rowSpan++ else break } return rowSpan } checkSearchValue = (value, form) => { let flagCode = this.checkSearchValueCode(value, form) return flagCode } checkSearchValueCode = (value, form) => { const { endCode, startCode } = value if (!endCode && !startCode) { return true } if ((!endCode && startCode)) { let startCodeNum = parseInt(value.startCode ? value.startCode : 0 ) if( isNaN(startCodeNum) || startCodeNum > 9999 ){ form.setFields({ startCode: { errors: [new Error('请输入正确的凭证号')], } }) return false } form.setFields({ startCode: { value: this.fillZero(startCodeNum), errors: null, }, endCode: { value: this.fillZero(9999), errors: null, } }) value.startCode = this.fillZero(startCodeNum) value.endCode = this.fillZero(9999) return true // if (!endCode) { // form.setFields({ // endCode: { // value: null, // errors: [new Error('请输入正确的凭证号')], // } // }) // return false // } else if (!startCode) { // form.setFields({ // startCode: { // value: null, // errors: [new Error('请输入正确的凭证号')], // } // }) // return false // } } else { let startCodeNum = parseInt(value.startCode ? value.startCode : 0 ) let endCodeNum = parseInt(value.endCode) let flag = true if (isNaN(startCodeNum) || startCodeNum > 9999) { flag = false form.setFields({ startCode: { errors: [new Error('请输入正确的凭证号')], } }) } if (isNaN(endCodeNum) || endCodeNum > 9999) { flag = false form.setFields({ endCode: { errors: [new Error('请输入正确的凭证号')], } }) } if (flag) { form.setFields({ startCode: { value: endCodeNum > startCodeNum ? this.fillZero(startCodeNum) : this.fillZero(endCodeNum), errors: null, }, endCode: { value: endCodeNum > startCodeNum ? this.fillZero(endCodeNum) : this.fillZero(startCodeNum), errors: null, } }) value.startCode = endCodeNum > startCodeNum ? this.fillZero(startCodeNum) : this.fillZero(endCodeNum) value.endCode = endCodeNum > startCodeNum ? this.fillZero(endCodeNum) : this.fillZero(startCodeNum) } return flag } return true } fillZero = (a) => { let num = a.toString() let length = num.length let x = 4 - length const zero = '0' return `${zero.repeat(x)}${num}` } /** * current 每个月份 * pointTime 指定比较的时间 * type 'pre' 前 'next' 后 * return 返回 true 代表禁用 */ disabledDate = (current, pointTime, type) => { const enableddate = this.metaAction.gf('data.other.enableddate') // const enableddateNum = this.transformDateToNum(enableddate) if (type == 'pre') { let currentMonth = this.transformDateToNum(current) let pointTimeMonth = this.transformDateToNum(pointTime) let enableddateMonth = this.transformDateToNum(enableddate) return currentMonth > pointTimeMonth || currentMonth<enableddateMonth } else { let currentMonth = this.transformDateToNum(current) let pointTimeMonth = this.transformDateToNum(pointTime) let enableddateMonth = this.transformDateToNum(enableddate) return currentMonth < pointTimeMonth || currentMonth<enableddateMonth } } transformDateToNum = (date) => { let time = date if (typeof date == 'string') { time = utils.date.transformMomentDate(date) } return parseInt(`${time.year()}${time.month() < 10 ? `0${time.month()}` : `${time.month()}`}`) } disabledRangePicker = (current) => { const { enabledMonth, enabledYear} = this.metaAction.context.get('currentOrg') return true } // normalSelectDate = () => { // const showPicker = this.metaAction.gf('data.showPicker') // if( showPicker ){ // this.injections.reduce('update',{ // path: 'data.showPicker', // value: false // }) // } // const params = this.metaAction.gf('data.searchValue').toJS() // this.injections.reduce('searchUpdate', params) // const pages = this.metaAction.gf('data.pagination').toJS() // this.sortParmas(params, { ...pages, 'currentPage': 1 }) // } // renderDatePickerExtraFooter = () => { // return ( // <Button type="primary" style={{ float: 'right' }} size='small' onClick={this.normalSelectDate}>确定</Button> // ) // } filterOptionSummary = (input, option) => { if (option && option.props && option.props.label) { return option.props.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 } return true } } export default function creator(option) { const metaAction = new MetaAction(option), voucherAction = FormDecorator.actionCreator({ ...option, metaAction }), o = new action({ ...option, metaAction, voucherAction }), ret = { ...metaAction, ...voucherAction, ...o } metaAction.config({ metaHandlers: ret }) return ret }