From ac4e2892a68bb4ef5b35e8e2e12e76d3ec3ede35 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 07 七月 2023 18:50:11 +0800 Subject: [PATCH] 2023-07-07 --- src/tabviews/custom/components/calendar/board/index.jsx | 59 +++++++++++++++++-- src/tabviews/custom/components/calendar/index.jsx | 75 +++++++++++++++++++++---- src/menu/components/calendar/index.jsx | 11 +++ src/views/login/index.jsx | 34 +++++++++++ 4 files changed, 156 insertions(+), 23 deletions(-) diff --git a/src/menu/components/calendar/index.jsx b/src/menu/components/calendar/index.jsx index e4bf1fb..00a1663 100644 --- a/src/menu/components/calendar/index.jsx +++ b/src/menu/components/calendar/index.jsx @@ -175,9 +175,9 @@ res.resetContrl = card.wrap.resetContrl || 'init' if (res.colorField && res.signs) { - res.signs = res.signs.map(item => { + res.signs = res.signs.map((item, i) => { try { - let colors = item.color.match(/\d+/g) + let colors = item.background.match(/\d+/g) if ((colors[0] * 0.299 + colors[1] * 0.578 + colors[2] * 0.114) * colors[3] < 192) { item.fontColor = '#ffffff' } else { @@ -187,6 +187,13 @@ item.fontColor = '' } + item.style = {background: item.background} + if (item.fontColor) { + item.style.color = item.fontColor + } + + item.$index = i + 1 + return item }) } diff --git a/src/tabviews/custom/components/calendar/board/index.jsx b/src/tabviews/custom/components/calendar/board/index.jsx index 911cc2d..44c208d 100644 --- a/src/tabviews/custom/components/calendar/board/index.jsx +++ b/src/tabviews/custom/components/calendar/board/index.jsx @@ -55,16 +55,53 @@ } UNSAFE_componentWillReceiveProps(nextProps) { - if (!is(fromJS(this.props.config.wrap), fromJS(nextProps.config.wrap))) { + const { datelist } = this.state + if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { this.setState({ - levels: nextProps.config.wrap.levels, - level: nextProps.config.wrap.levels[0] + datelist: this.mountdata(datelist, nextProps.data) }) } } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.state), fromJS(nextState)) + } + + mountdata = (datelist, data) => { + return fromJS(datelist).toJS().map(month => { + month.subData = [] + data.forEach(item => { + if (item.$startM <= month.time && item.$endM >= month.time) { + month.subData.push(item) + } + }) + + month.children = month.children.map(week => { + week.children = week.children.map(day => { + if (day.$disable) return day + + day.subData = [] + day.style = null + day.$level = 100 + data.forEach(item => { + if (item.$start <= day.time && item.$end >= day.time) { + day.subData.push(item) + + if (!day.style) { + day.style = item.$style + day.$level = item.$level + } else if (item.$level < day.$level) { + day.style = item.$style + day.$level = item.$level + } + } + }) + return day + }) + return week + }) + return month + }) } getNongLi = (nyear, nmonth, nday, week) => { @@ -307,7 +344,7 @@ let item = { day: _day, - time: times[0] + times[1] + _day, + time: +(times[0] + times[1] + _day), label: _day, subData: [], $disable: true, @@ -323,7 +360,7 @@ let item = { day: _day, - time: selectYear + month + _day, + time: +(selectYear + month + _day), label: i, subData: [], ...nl @@ -348,7 +385,7 @@ let item = { day: _day, - time: times[0] + times[1] + _day, + time: +(times[0] + times[1] + _day), label: i, subData: [], $disable: true, @@ -366,7 +403,7 @@ datelist.push({ month: month, - time: selectYear + month, + time: +(selectYear + month), label: monthName[month], children: _weeklist, subData: [] @@ -381,8 +418,14 @@ } yearChange = (value) => { + const { data } = this.props const { selectMonth } = this.state let datelist = this.getDateList(value) + + if (data.length > 0) { + datelist = this.mountdata(datelist, data) + } + let monthlist = datelist.filter(item => item.month === selectMonth)[0].children.filter(cell => !cell.children[0].$disable || !cell.children[6].$disable) this.setState({ selectYear: value, datelist, monthlist }) @@ -448,7 +491,7 @@ <tr key={m}> {cell.children.map((d, i) => ( <td key={i}> - <div className={'day-wrap' + (d.$disable ? ' disabled' : '')}> + <div style={d.style} className={'day-wrap' + (d.$disable ? ' disabled' : '')}> {d.label} </div> </td> diff --git a/src/tabviews/custom/components/calendar/index.jsx b/src/tabviews/custom/components/calendar/index.jsx index c9ba92b..0d7c725 100644 --- a/src/tabviews/custom/components/calendar/index.jsx +++ b/src/tabviews/custom/components/calendar/index.jsx @@ -8,12 +8,12 @@ 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 = { @@ -25,7 +25,7 @@ BID: '', // 涓婄骇ID config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: false, // 鏁版嵁鍔犺浇鐘舵�� - data: null, // 鏁版嵁 + data: [], // 鏁版嵁 search: '', year: new Date().getFullYear(), BData: '' @@ -55,6 +55,10 @@ _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, @@ -81,13 +85,19 @@ 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}) }) } } @@ -196,19 +206,24 @@ 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({ data: data, loading: false }) - + if (result.message) { if (result.ErrCode === 'Y') { Modal.success({ @@ -242,6 +257,42 @@ } } + 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 @@ -257,7 +308,7 @@ <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 } @@ -268,7 +319,7 @@ {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> ) } diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index c160a08..c37fe44 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -293,12 +293,44 @@ document.getElementsByTagName('head')[0].removeChild(JSONP) },500) }) -} + } + + // handleItem = (list) => { + // let param = list.shift() + // Object.keys(param).forEach(key => { + // if (param[key] === null) { + // param[key] = '' + // } + // }) + // Api.directRequest({ + // url: 'http://bms.kresstools.cn/oc/webapi/dostar/zsn_app_bddmsdealersm_add_upt', + // method: 'post', + // data: JSON.stringify({ + // func: 'zsn_app_bddmsdealersm_add_upt', + // userid: '', + // ...param + // }) + // }).then(res => { + // if (res.status && list.length > 0) { + // this.handleItem(list) + // } else { + // console.log(list) + // } + // }) + // } componentDidMount () { // md5("/ws/location/v1/ip?callback=callbackFunction&key=key&output=jsonp secret key") // md5("/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonpuThL4ZM3XOj642ksEQh76tyHFjh4") + // Api.directRequest({ + // url: 'http://bms.kresstools.cn/saas-mp-open-api/shop/shopStore/getAllStoreList', + // method: 'get' + // }).then(res => { + // if (res && res.code === 0 && res.data && res.data.length > 0) { + // this.handleItem(res.data) + // } + // }) setTimeout(() => { Api.delCacheConfig() }, 50) -- Gitblit v1.8.0