| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import CalendarBoard from './board' |
| | | import './index.scss' |
| | | |
| | | const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) |
| | | const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) |
| | | const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton')) |
| | | const CalendarBoard = asyncComponent(() => import('./board')) |
| | | |
| | | class NormalCalendar extends Component { |
| | | static propTpyes = { |
| | |
| | | BID: '', // 上级ID |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | data: null, // 数据 |
| | | data: [], // 数据 |
| | | search: '', |
| | | year: new Date().getFullYear(), |
| | | BData: '' |
| | |
| | | _config.setting.$re_year = true |
| | | } |
| | | |
| | | if (_config.wrap.colorField && (!_config.wrap.signs || _config.wrap.signs.length === 0)) { |
| | | _config.wrap.colorField = '' |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BData ? (BData.$BID || '') : '', |
| | | BData: BData, |
| | |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | this.setState({data: res.map((item, index) => { |
| | | let data = [] |
| | | res.forEach((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | return item |
| | | })}) |
| | | let pass = this.resetLine(item) |
| | | |
| | | if (pass) { |
| | | data.push(item) |
| | | } |
| | | }) |
| | | |
| | | this.setState({data: data}) |
| | | }) |
| | | } |
| | | } |
| | |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | } |
| | | |
| | | let data = result.data.map((item, index) => { |
| | | let data = [] |
| | | result.data.forEach((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | |
| | | return item |
| | | let pass = this.resetLine(item) |
| | | |
| | | if (pass) { |
| | | data.push(item) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | |
| | | } |
| | | } |
| | | |
| | | resetLine = (item) => { |
| | | const { config: { wrap } } = this.state |
| | | |
| | | let startTime = item[wrap.timeField] || '' |
| | | let endTime = item[wrap.endField || wrap.timeField] || '' |
| | | |
| | | item.$message = item[wrap.remarkField] |
| | | |
| | | if (!/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(startTime)) return false |
| | | if (!/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(endTime)) return false |
| | | if (!item.$message) return false |
| | | |
| | | if (wrap.colorField) { |
| | | let sign = item[wrap.colorField] || '' |
| | | |
| | | wrap.signs.forEach(cell => { |
| | | if (cell.sign !== sign) return |
| | | |
| | | item.$style = cell.style |
| | | item.$color = cell.background |
| | | item.$level = cell.$index |
| | | }) |
| | | } |
| | | |
| | | let equal = endTime.substr(0, 4) === startTime.substr(0, 4) |
| | | |
| | | item.$startM = +(startTime.substr(0, 4) + startTime.substr(5, 2)) |
| | | item.$endM = +(endTime.substr(0, 4) + endTime.substr(5, 2)) |
| | | item.$start = +(startTime.substr(0, 4) + startTime.substr(5, 2) + startTime.substr(8, 2)) |
| | | item.$end = +(endTime.substr(0, 4) + endTime.substr(5, 2) + endTime.substr(8, 2)) |
| | | item.$startTime = equal ? `${startTime.substr(5, 2)}-${startTime.substr(8, 2)}` : `${startTime.substr(0, 4)}-${startTime.substr(5, 2)}-${startTime.substr(8, 2)}` |
| | | item.$endTime = equal ? `${endTime.substr(5, 2)}-${endTime.substr(8, 2)}` : `${endTime.substr(0, 4)}-${endTime.substr(5, 2)}-${endTime.substr(8, 2)}` |
| | | |
| | | return true |
| | | } |
| | | |
| | | refreshbysearch = (searches) => { |
| | | this.setState({ |
| | | search: searches |
| | |
| | | <div className="normal-calendar-box" id={'anchor' + config.uuid} style={{...config.style}}> |
| | | {loading ? |
| | | <div className="loading-mask"> |
| | | {data ? <div className="ant-spin-blur"></div> : null} |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | </div> : null |
| | | } |
| | |
| | | {config.action[0] ? |
| | | <PopupButton disabled={false} BID={BID} btn={config.action[0]} BData={BData} setting={config.setting} selectedData={[]}/> : null |
| | | } |
| | | <CalendarBoard config={config} /> |
| | | <CalendarBoard config={config} data={data}/> |
| | | </div> |
| | | ) |
| | | } |