ttk-app-core
Version:
enterprise develop framework
779 lines (679 loc) • 32.1 kB
JavaScript
import React from 'react'
import { action as MetaAction, AppLoader } from 'edf-meta-engine'
import config from './config'
import { TableOperate, Select, Button, Modal, Checkbox } from 'edf-component'
import sortSearchOption from './utils/sortSearchOption'
import moment from 'moment'
import { FormDecorator } from 'edf-component'
import changeToOption from './utils/changeToOption'
import { List, fromJS } from 'immutable'
const Option = Select.Option
import { consts } from 'edf-consts'
import renderGridColumns from './utils/renderGridColumns'
import utils from 'edf-utils'
class action {
constructor(option) {
this.metaAction = option.metaAction
this.config = config.current
this.webapi = this.config.webapi
this.voucherAction = option.voucherAction
this.selectedOption = []
}
onInit = ({ component, injections }) => {
this.component = component
this.injections = injections
injections.reduce('init')
this.load()
let addEventListener = this.component.props.addEventListener
if (addEventListener) {
addEventListener('onTabFocus', ::this.onTabFocus)
}
}
onTabFocus = async (data) => {
let codeAndNameList = null
let filter = this.metaAction.gf('data.filter').toJS()
let includeSum = this.metaAction.gf('data.showOption.includeSum')
filter.includeSum = includeSum
this.metaAction.sf('data.other.loading', true)
let res = await this.webapi.assetDetailRpt.init(filter)
this.metaAction.sf('data.other.loading', false)
if (res.codeAndNameList) {
codeAndNameList = changeToOption(res.codeAndNameList, 'codeAndName', 'code')
}
let assetDetailList = this.metaAction.gf('data.assetDetailList').toJS()
res.assetDetailList = assetDetailList
res.codeAndNameList = codeAndNameList
this.injections.reduce('load', res)
}
load = () => {
this.getInitOption()
}
//小计
showOptionsChange = async (key, includeSum) => {
let filter = this.metaAction.gf('data.filter').toJS()
if(includeSum) {
filter.includeSum = includeSum
//打开小计时取消排序
if(filter.userOrderField) delete filter.userOrderField
if(filter.order) delete filter.order
this.injections.reduce('sortReduce', {
userOrderField: null,
order: null
})
}else {
filter.includeSum = false;
}
this.metaAction.sf('data.showOption.includeSum', includeSum)
this.metaAction.sf('data.other.loading', true)
let res = await this.webapi.assetDetailRpt.query(filter)
this.metaAction.sf('data.other.loading', false)
this.metaAction.sf('data.filter', fromJS(filter))
this.injections.reduce('newAssetDetailList', res)
}
componentWillUnmount = () => {
let removeEventListener = this.component.props.removeEventListener
if (removeEventListener) {
removeEventListener('onTabAdd')
}
}
// 点击刷新按钮
refreshBtnClick = async() => {
let filter = this.metaAction.gf('data.filter').toJS()
// this.sortParmas()
let includeSum = this.metaAction.gf('data.showOption.includeSum')
filter.includeSum = includeSum
this.metaAction.sf('data.other.loading', true)
const res = await this.webapi.assetDetailRpt.query(filter)
this.metaAction.sf('data.other.loading', false)
this.injections.reduce('load', res)
}
// 初始化基础信息选项
getInitOption = async() => {
this.metaAction.sf('data.other.loading', true)
const date = await this.webapi.assetDetailRpt.date()
this.metaAction.sf('data.other.loading', false)
let newObj = {}
let contextDate = date.systemDate,
currentOrg = this.metaAction.context.get("currentOrg")
if(currentOrg.periodDate && moment(currentOrg.periodDate)<=moment(date.systemDate)){
contextDate = currentOrg.periodDate
}
newObj.startBuyData = utils.moment.stringToMoment(contextDate).endOf('month').format('YYYY-MM')
newObj.endBuyData = utils.moment.stringToMoment(contextDate).endOf('month').format('YYYY-MM')
this.metaAction.sf('data.other.loading', true)
const res = await this.webapi.assetDetailRpt.init(newObj)
this.metaAction.sf('data.other.loading', false)
if( !res ){
return
}
const assetList = res.assetList
const codeAndNameList = changeToOption(res.codeAndNameList, 'codeAndName', 'cardId')
const assetProperty = changeToOption(res.assetProperty, 'name', 'id')
const assetClass = res.assetClass
const pagination = res.page
const columnDto = res.columnDto || {}
const assetDetailList = !!columnDto.columnDetails ? columnDto.columnDetails : []
const ts = columnDto.ts && columnDto.ts
const code = columnDto.code && columnDto.code
const systemDate = res.systemDate
const ifMonthDepreciation = res.ifMonthDepreciation
let params = { assetList, systemDate, codeAndNameList, assetProperty, assetClass, pagination,assetDetailList,ts,ifMonthDepreciation, code }
this.injections.reduce('initOption', {...params })
}
//获取时间选项
getNormalDateValue = () => {
const data = this.metaAction.gf('data.searchValue').toJS()
const arr = []
arr.push(data.startBuyData)
arr.push(data.endBuyData)
return arr
}
//更改期间
onPanelChange = (value) => {
let date = {
endBuyData: value[1],
startBuyData: value[0]
}
const searchValue = this.metaAction.gf('data.searchValue').toJS()
this.metaAction.sf('data.other.oldSearchValue.endBuyData', date.endBuyData.format('YYYY-MM'))
this.metaAction.sf('data.other.oldSearchValue.startBuyData',date.startBuyData.format('YYYY-MM'))
//清空时单选框也清空
const { containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
this.metaAction.sf('data.other.oldSearchValue.containNoDepreciation', fromJS([0]))
const oldSearchValue = this.metaAction.gf('data.other.oldSearchValue').toJS()
this.metaAction.sf('data.searchValue.containNoDepreciation', fromJS([0]))
this.metaAction.sf('data.searchValue.startUseData', null)
this.metaAction.sf('data.searchValue.endUseData', null)
this.metaAction.sf('data.searchValue.cardId', null)
searchValue.containNoDepreciation = [0]
searchValue.startUseData = null
searchValue.endUseData = null
searchValue.cardId = null
this.injections.reduce('searchUpdate', {...searchValue, ...date })
this.sortParmas({...searchValue, ...date })
}
// 资产下拉选实现可搜索
filterOptionSummary = (input, option) => {
if (option && option.props && option.props.label) {
return option.props.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
return true
}
/**
* current 每个月份
* pointTime 指定比较的时间
* type 'pre' 前 'next' 后
* return 返回 true 代表禁用
*/
disabledDate = (current, pointTime, type) => {
if (type == 'pre') {
if (!pointTime) {
return false
}
let currentMonth = this.transformDateToNum(current)
let pointTimeMonth = this.transformDateToNum(pointTime)
return false
} else {
let currentMonth = this.transformDateToNum(current)
let pointTimeMonth = this.transformDateToNum(pointTime)
return currentMonth < pointTimeMonth
}
}
transformDateToNum = (date) => {
if( !date ){
return 0
}
let time = date
if (typeof date == 'string') {
time = moment(date)
}
return parseInt(`${time.year()}${time.month() < 10 ? `0${time.month()}` : `${time.month()}`}`)
}
disabledDateDay = (current, pointTime, type) => {
if (type == 'pre') {
if (!pointTime) {
return false
}
let currentDate = current&¤t.format('YYYY-MM-DD')
currentDate&¤tDate.replace(/-/g,'')
let pointTimeDate = pointTime&&pointTime.format('YYYY-MM-DD')
pointTimeDate&&pointTimeDate.replace(/-/g,'')
return false
} else {
let currentDate = current&¤t.format('YYYY-MM-DD')
currentDate&¤tDate.replace(/-/g,'')
let pointTimeDate = pointTime&&pointTime.format('YYYY-MM-DD')
pointTimeDate&&pointTimeDate.replace(/-/g,'')
return currentDate < pointTimeDate
}
}
renderCheckBox = () => {
return (
<Checkbox.Group className="app-proof-of-list-accountQuery-search-checkbox">
<Checkbox value="1">包含此开始使用期间内未折旧/摊销的资产</Checkbox>
</Checkbox.Group>
)
}
// 调接口 刷新列表
sortParmas = (search, page, type) => {
// 处理搜索参数
if (!search) {
search = this.metaAction.gf('data.searchValue').toJS()
}
if (!page) {
page = this.metaAction.gf('data.pagination').toJS()
let pageObj = {}
pageObj.pageSize = page.pageSize
pageObj.currentPage = page.currentPage
page = pageObj
}
let other = this.metaAction.gf('data.other.oldSearchValue').toJS()
search.startBuyData = !!search.startBuyData ? search.startBuyData.format('YYYY-MM') : null
search.startUseData = !!search.startUseData ? search.startUseData.format('YYYY-MM-DD') : null
search.endBuyData = !!search.endBuyData ? search.endBuyData.format('YYYY-MM') : null
search.endUseData = !!search.endUseData ? search.endUseData.format('YYYY-MM-DD') : null
const newObj = {}
newObj.startBuyData = search.startBuyData
newObj.endBuyData = search.endBuyData
//以下注释 因为普通查询和高级查询没有影响 所以不需要高级查询的参数
// newObj.startUseData = search.startUseData
// newObj.endUseData = search.endUseData
// newObj.containNoDepreciation = search.containNoDepreciation.length == 0 ? false : true
// newObj.code = search.code ? search.code : null
newObj.assetPropertyIdList = search.assetPropertyIdList&&search.assetPropertyIdList.length != 0 ? search.assetPropertyIdList : null
newObj.assetClassId = search.assetClassId ? search.assetClassId : null
if(other.containNoDepreciation) {
if (other.containNoDepreciation[0] == '1') {
newObj.containNoDepreciation = true
} else {
newObj.containNoDepreciation = false
}
} else {
newObj.containNoDepreciation = false
}
this.requestData({ ...newObj, page})
}
//分页发生变化
pageChanged = (current, pageSize) => {
let page = {
'currentPage': current,
'pageSize': pageSize
}
this.sortParmas(null, page)
}
// 请求列表中的数据
requestData = async (params) => {
let includeSum = this.metaAction.gf('data.showOption.includeSum')
let page = this.metaAction.gf('data.pagination').toJS()
params.includeSum = includeSum
if (!params.page.pageSize) {
let page = this.metaAction.gf('data.pagination').toJS()
params.page.pageSize = page.pageSize
}
this.metaAction.sf('data.other.loading', true)
const res = await this.webapi.assetDetailRpt.query(params)
this.metaAction.sf('data.other.loading', false)
this.metaAction.sf(`data.filter`, fromJS(params))
this.injections.reduce('load', res)
}
// 导出
export = async() => {
let paramsObj = this.metaAction.gf(`data.filter`).toJS()
const assetDetailList = this.metaAction.gf('data.assetDetailList').toJS()
const list = this.metaAction.gf('data.list').toJS()
const columnDetails = []
assetDetailList.forEach((item) => {
if (item.isVisible) {
columnDetails.push(item.fieldName)
}
})
paramsObj.columnDetails = columnDetails
if(!list.length){
this.metaAction.toast('warning', '当前暂无数据可导出')
return
}
let includeSum = this.metaAction.gf('data.showOption.includeSum')
paramsObj.includeSum = includeSum
let res
if (paramsObj.page) delete paramsObj.page
res = await this.webapi.assetDetailRpt.export(paramsObj)
}
// 打印
print = async() => {
let paramsObj = this.metaAction.gf(`data.filter`).toJS()
const assetDetailList = this.metaAction.gf('data.assetDetailList').toJS()
const list = this.metaAction.gf('data.list').toJS()
const columnDetails = []
assetDetailList.forEach((item) => {
if (item.isVisible) {
columnDetails.push(item.fieldName)
}
})
paramsObj.columnDetails = columnDetails
if (paramsObj.page) delete paramsObj.page
if(!list.length){
this.metaAction.toast('warning', '当前没有可打印数据')
return
}
let includeSum = this.metaAction.gf('data.showOption.includeSum')
paramsObj.includeSum = includeSum
let res
res = await this.webapi.assetDetailRpt.print(paramsObj)
}
//渲染列表
tableColumns = (assetDetailList, list) => {
let other = this.metaAction.gf('data.other').toJS(),
showOption = this.metaAction.gf('data.showOption').toJS()
return renderGridColumns(assetDetailList, list, other, this.showTableSetting, this.sortChange, showOption)
}
//表格拖宽
onColumnResizeEnd = async (newColumnWidth, columnKey) => {
let columnDto = this.metaAction.gf('data.assetDetailList').toJS(),
other = this.metaAction.gf('data').toJS().other,
params = {}, columnDetails = []
columnDto.map(item=>{
if(item.isVisible) columnDetails.push({
fieldName: item.fieldName,
isVisible: item.isVisible,
width: item.fieldName == columnKey ? newColumnWidth : item.width
})
})
params.code = other.code
params.columnDetails = columnDetails
let res = await this.webapi.assetDetailRpt.batchUpdate(params)
this.injections.reduce('onColumnResizeEnd', res)
}
//栏目重置
resetTableSetting = async () => {
this.injections.reduce('update',{
path: 'data.showTableSetting',
value: false
})
const other = this.metaAction.gf('data.other').toJS()
//重置栏目
let res = await this.webapi.assetDetailRpt.reInitByUser({code: other.code})
this.load()
}
//排序发生变化
sortChange = async (key, value) => {
let params = {
'userOrderField': value == false ? null : key,
'order': value == false ? null : value
}, filter = this.metaAction.gf(`data.filter`).toJS()
//debugger
this.injections.reduce('sortReduce', params)
if(value){
filter.userOrderField = params.userOrderField
filter.order = params.order
this.metaAction.sf('data.other.loading', true)
const res = await this.webapi.assetDetailRpt.query(filter)
this.metaAction.sf('data.other.loading', false)
this.metaAction.sf(`data.filter`, fromJS(filter))
this.injections.reduce('load', res)
}
}
//高级查询查询操作
searchValueChange = async (value) => {
if(value) {
this.metaAction.sf('data.other.oldSearchValue', fromJS(value))
let option = {},
assetProperty = this.metaAction.gf('data.searchValue.assetProperty').toJS(),
assetClass = this.metaAction.gf('data.searchValue.assetClass').toJS(),
page = this.metaAction.gf('data.pagination').toJS(),
codeAndNameList = this.metaAction.gf('data.other.codeAndNameList').toJS()
if (value.cardId) option.cardId = Number(value.cardId)
this.metaAction.sf('data.searchValue.cardId', fromJS(value.cardId))
if(value.containNoDepreciation) {
if (value.containNoDepreciation[0] == '1') {
option.containNoDepreciation = true
} else {
option.containNoDepreciation = false
}
} else {
option.containNoDepreciation = false
}
const pageObj = {}
pageObj.pageSize = page.pageSize
pageObj.currentPage = page.currentPage
option.page = pageObj
if (value.startBuyData) this.metaAction.sf('data.searchValue.startBuyData', fromJS(value.startBuyData))
if (value.endBuyData) this.metaAction.sf('data.searchValue.endBuyData', fromJS(value.endBuyData))
if (value.startUseData) this.metaAction.sf('data.searchValue.startUseData', fromJS(value.startUseData))
if (value.endUseData) this.metaAction.sf('data.searchValue.endUseData', fromJS(value.endUseData))
//以下注释 因为普通查询和高级查询没有影响 所以不需要存因为普通查询不会用
// this.metaAction.sf('data.searchValue.containNoDepreciation', fromJS(value.containNoDepreciation))
// this.metaAction.sf('data.searchValue.code', fromJS(value.cardId))
this.metaAction.sf('data.form.assetProperty', fromJS(assetProperty))
this.metaAction.sf('data.form.assetClass', fromJS(assetClass))
this.getSearchAssetClass(assetProperty, assetClass, option, 1)
}
}
//高级查询取消操作
searchCancelChange = (value) => {
let assetProperty = this.metaAction.gf('data.form.assetProperty').toJS(),
assetClass = this.metaAction.gf('data.form.assetClass').toJS(),
filter = this.metaAction.gf('data.filter').toJS()
const { startBuyData, endBuyData, startUseData, endUseData, cardId, containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
const searchValue = this.metaAction.gf('data.searchValue').toJS()
let other = this.metaAction.gf('data.other').toJS()
let assetClassArr=[]
if(other.assetClassAll){
assetClassArr = other.assetClassAll.filter(item => item.assetPropertyId == assetProperty.value)
}
assetClassArr.unshift({ label: '全部', value: 0, assetPropertyId: 0 })
this.metaAction.sf(`data.other.assetClass`, fromJS(assetClassArr))
this.metaAction.sf('data.searchValue', fromJS({
...searchValue,
assetProperty,
assetClass,
startBuyData: startBuyData&&moment(startBuyData),
endBuyData: endBuyData&&moment(endBuyData),
startUseData: startUseData&&moment(startUseData),
endUseData: endUseData&&moment(endUseData),
cardId,
containNoDepreciation
}))
// this.metaAction.sf('data.searchValue.assetProperty', fromJS(assetProperty))
// this.metaAction.sf('data.searchValue.assetClass', fromJS(assetClass))
// //为了不让日期重置
// this.metaAction.sf('data.searchValue.startBuyData', startBuyData&&moment(startBuyData))
// this.metaAction.sf('data.searchValue.endBuyData', endBuyData&&moment(endBuyData))
}
//高级查询清空操作
clearValueChange = (value) => {
const startBuyData = this.metaAction.gf('data.searchValue.startBuyData')
const endBuyData = this.metaAction.gf('data.searchValue.endBuyData')
this.searchCard.clearValue()
// 清空资产分类和属性
this.metaAction.sf('data.searchValue.assetProperty', fromJS({ label: '全部', value: 0}))
this.metaAction.sf('data.searchValue.assetClass', fromJS({ label: '全部', value: 0}))
this.metaAction.sf('data.other.assetClass', fromJS([{ label: '全部', value: 0}]))
//清空时单选框也清空
const { containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
this.metaAction.sf('data.searchValue.containNoDepreciation', 0)
this.metaAction.sf('data.searchValue.startUseData', null)
this.metaAction.sf('data.searchValue.endUseData', null)
this.metaAction.sf('data.searchValue.startBuyData', null)
this.metaAction.sf('data.searchValue.endBuyData', null)
this.metaAction.sf('data.searchValue.cardId', null)
}
//资产属性切换
assetPropertyChange = async (path, option) => {
this.metaAction.sf(path, fromJS(option))
let other = this.metaAction.gf('data.other').toJS(),
assetClass = { label: '全部', value: 0, assetPropertyId: 0 },
assetClassArr, name = path.split(".")
this.metaAction.sf(`${name[0]}.${name[1]}.assetClass`, fromJS(assetClass))
if(other.assetClassAll){
assetClassArr = other.assetClassAll.filter(item => item.assetPropertyId == option.value)
}
assetClassArr.unshift(assetClass)
this.metaAction.sf(`data.other.assetClass`, fromJS(assetClassArr))
if(name[1] == 'form') {
const { containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
this.metaAction.sf('data.other.oldSearchValue.containNoDepreciation', 0)
this.metaAction.sf('data.searchValue.startUseData', null)
this.metaAction.sf('data.searchValue.endUseData', null)
this.metaAction.sf('data.searchValue.cardId', null)
this.searchCard.clearValue()
this.metaAction.sf(`data.searchValue.assetProperty`, fromJS(option))
this.metaAction.sf(`data.searchValue.assetClass`, fromJS(assetClass))
if(!option.value){
this.metaAction.sf(`data.searchValue.assetClass`, fromJS(option))
}
this.getSearchAssetClass(option, assetClass)
}
}
//资产分类切换
assetClassChange = async (path, option) => {
this.metaAction.sf(path, fromJS(option))
let list = [],
assetProperty = this.metaAction.gf('data.form.assetProperty').toJS()
let name = path.split(".")
if(name[1] == 'form') {
const { containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
this.metaAction.sf('data.other.oldSearchValue.containNoDepreciation', 0)
this.metaAction.sf('data.searchValue.startUseData', null)
this.metaAction.sf('data.searchValue.endUseData', null)
this.metaAction.sf('data.searchValue.cardId', null)
this.metaAction.sf('data.searchValue.assetClass', fromJS(option))
this.getSearchAssetClass(assetProperty, option)
}
}
//资产分类查询
getSearchAssetClass = async (assetProperty, assetClass, option, num) => {
let assetClassAll = this.metaAction.gf('data.other.assetClassAll').toJS(),
oldFilter = this.metaAction.gf('data.filter').toJS(),
filter = {}, ids = '', assetPropertyIds=[],
startBuyData = this.metaAction.gf('data.searchValue.startBuyData'),
endBuyData = this.metaAction.gf('data.searchValue.endBuyData'),
endUseData = this.metaAction.gf('data.searchValue.endUseData'),
startUseData = this.metaAction.gf('data.searchValue.startUseData')
// code = this.metaAction.gf('data.searchValue.code'),
// containNoDepreciation = this.metaAction.gf('data.searchValue.containNoDepreciation')
startBuyData = startBuyData ? startBuyData.format('YYYY-MM') : null
endBuyData = endBuyData ? endBuyData.format('YYYY-MM') : null
endUseData = endUseData ? endUseData.format('YYYY-MM-DD') : null
startUseData = startUseData ? startUseData.format('YYYY-MM-DD') : null
const { containNoDepreciation } = this.metaAction.gf('data.other.oldSearchValue').toJS()
const searchValue = this.metaAction.gf('data.searchValue').toJS()
if(option) filter = option
if(containNoDepreciation) {
if (containNoDepreciation[0] == '1') {
filter.containNoDepreciation = true
} else {
filter.containNoDepreciation = false
}
} else {
filter.containNoDepreciation = false
}
if (option && option.page) {
filter.page = option.page
}else{
if(oldFilter.page){
let pageObj = {}
pageObj.pageSize = oldFilter.page.pageSize
pageObj.currentPage = oldFilter.page.currentPage
filter.page = pageObj
}else {
const page = this.metaAction.gf('data.pagination').toJS()
let pageObj = {}
pageObj.pageSize = page.pageSize
pageObj.currentPage = page.currentPage
filter.page = pageObj
}
}
filter.page.currentPage = 1;
if(!assetProperty.value || (!assetProperty.value && !assetClass.value)){
ids = ''
assetPropertyIds=[]
}
else {
if(!assetClass.value){
let assetClassArr = assetClassAll.filter(item => item.assetPropertyId == assetProperty.value),
idsArr = []
assetClassArr.map(item => { idsArr.push(item.value) })
ids = idsArr
} else {
let idsList = []
idsList.push(assetClass.value)
ids = idsList
}
}
if (endBuyData) filter.endBuyData = endBuyData
if (startBuyData) filter.startBuyData = startBuyData
// if (num) { //高级查询
if (endUseData) filter.endUseData = endUseData
if (startUseData) filter.startUseData = startUseData
// }
//以下注释 因为普通查询和高级查询没有影响 所以不需要高级查询的参数
// if (!option) {
// if(containNoDepreciation) filter.containNoDepreciation = containNoDepreciation && containNoDepreciation.toJS().length == 0 ? false : true
// }
// if(code) filter.code = code
if(ids.length != 0) {
filter.assetClassId = ids
}
if (assetProperty.value) {
assetPropertyIds.push(Number(assetProperty.value))
if(assetPropertyIds.length != 0) {
filter.assetPropertyIdList = assetPropertyIds
}
}
if(assetProperty && assetProperty.label != '全部'){
filter.assetPropertyId = assetProperty.value
}
let includeSum = this.metaAction.gf('data.showOption.includeSum')
filter.includeSum = includeSum
this.metaAction.sf('data.other.loading', true)
this.metaAction.sf('data.searchValue.assetClassId', ids)
this.metaAction.sf('data.searchValue.assetPropertyIdList', assetPropertyIds)
this.metaAction.sf('data.searchValue.containNoDepreciation', containNoDepreciation)
let res = await this.webapi.assetDetailRpt.query(filter)
let assetDetailList = this.metaAction.gf('data.assetDetailList').toJS()
res.assetDetailList = assetDetailList
this.metaAction.sf('data.other.loading', false)
if(res) {
this.metaAction.sf(`data.filter`, fromJS(filter))
this.injections.reduce('load', res)
}
// let res
// if (num) {
// res = await this.webapi.assetDetailRpt.query(filter)
// } else {
// let codeAndNameList = null
// res = await this.webapi.assetDetailRpt.init(filter)
// if (res.codeAndNameList) {
// codeAndNameList = changeToOption(res.codeAndNameList, 'codeAndName', 'code')
// }
// res.codeAndNameList = codeAndNameList
// }
// // let res = await this.webapi.assetDetailRpt.query(filter)
// this.metaAction.sf('data.other.loading', false)
// if(res) {
// this.metaAction.sf(`data.filter`, fromJS(filter))
// this.injections.reduce('load', res)
// }
}
getSearchCard = (childrenRef) => {
this.searchCard = childrenRef
}
showTableSetting = async ({ value, data }) => {
/**
* 更新栏目
*/
this.injections.reduce('update',{
path: 'data.showTableSetting',
value: false
})
if (!value) {
let isColumnSolution = this.metaAction.gf('data.other.isColumnSolution')
if(!isColumnSolution) return
this.metaAction.sf('data.other.isColumnSolution', false)
const columnSolution = await this.webapi.assetDetailRpt.findByParam({ code: 'assetDetailList' })
if (columnSolution) {
let columnSolutionId = columnSolution.id
const ts = this.metaAction.gf('data.other.ts')
this.metaAction.sf('data.other.loading', true)
const columnDetail = await this.webapi.assetDetailRpt.updateWithDetail({
"id": columnSolutionId,
"columnDetails": this.combineColumnProp(data),
ts: ts
})
this.metaAction.sf('data.other.loading', false)
this.metaAction.sf('data.other.isColumnSolution', true)
if (columnDetail) {
this.injections.reduce('settingOptionsUpdate', { visible: value, data: columnDetail.columnDetails })
}
}else{
this.metaAction.sf('data.other.isColumnSolution', true)
}
}
else {
this.injections.reduce('tableSettingVisible', { value, data: data })
}
}
closeTableSetting = () => {
this.injections.reduce('tableSettingVisible', { value: false })
}
combineColumnProp = (data) => {
if (!data) return []
let newDataArray = []
data.forEach((ele, index) => {
newDataArray.push({
"isVisible": ele.isVisible,
"id": ele.id,
'ts': ele.ts
})
})
return newDataArray
}
}
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
}