diff --git a/src/pages/20181112o4/src/components/app.css b/src/pages/20181112o4/src/components/app.css index 07b344f..fc944b9 100644 --- a/src/pages/20181112o4/src/components/app.css +++ b/src/pages/20181112o4/src/components/app.css @@ -1,14 +1,50 @@ .app { width: 100%; height: 100%; - font-size: 16px; + font-size: 12px; + color: #333; + display: flex; + flex-direction: column; +} + +.seats { + width: 100%; + height: 500px; display: flex; justify-content: space-around; } +.ctrol { + flex: 1; + display: flex; + justify-content: stretch; +} + +.btn-box { + flex: 1; + display: flex; + flex-direction: column; + justify-content:center; +} + +.btn { + width: 100px; + height: 30px; +} + +.record { + flex: 10; + overflow-y: auto; +} + .group { height: 100%; flex: 1; + border: #666 solid 1px; + display: flex; + flex-direction: column; + justify-content: space-around; + border-radius: 10px; } .row { @@ -17,7 +53,14 @@ } .item { - width: 10px; - height: 10px; + display: inline-block; + min-width: 40px; + padding: 2px 0; + text-align: center; background-color: lightgreen; + border-radius: 5px; } + +.disable { + background-color: #ccc; +} \ No newline at end of file diff --git a/src/pages/20181112o4/src/components/app.js b/src/pages/20181112o4/src/components/app.js index b2aa8c6..05975d7 100644 --- a/src/pages/20181112o4/src/components/app.js +++ b/src/pages/20181112o4/src/components/app.js @@ -7,16 +7,21 @@ class App extends Component { constructor () { super(); + this.element = null; this.front = 2; this.back = 10; this.gap = 2; this.group = 4; this.lines = (this.back - this.front) / this.gap; - + this.seats = []; + this.record = []; this.state = { - seatList:[] - } + seatList: this.seats, + record: this.record + }; + + this.handleClickBtn = this.handleClickBtn.bind(this); } groupName(g) { @@ -39,37 +44,165 @@ class App extends Component { } componentDidMount() { - let list = []; + let index = 0; for (let g = 0; g < this.group; g++) { for (let line = this.lines; line >= 0; line--) { for (let seat = 0; seat < (this.back - this.gap * (this.lines - line)); seat++) { - list.push({ - group: this.groupName(g), + let item = { + index:index++, + group: g, + groupName: this.groupName(g), number: seat, row: line, disable:false - }); + }; + this.seats.push(item); + //console.log(item) } }; } + this.setState({ - seatList:list - }); - - console.log(list) + seatList: this.seats + }) + //console.log(this.state.seatList) } - renderSeat() { + componentDidUpdate() { + if(this.element) { + this.element.scrollTop = this.element.scrollHeight; + } + } + + renderItem(array) { + let notes = []; + array.forEach((value) => { + notes.push({value.groupName + value.row + '-' + value.number}) + }); + return notes; + } + + renderRow(array) { + let notes = []; + for (let row = this.lines; row >= 0; row--) { + let rowItems = array.filter((item) => { + return item.row == row; + }); + notes.push(
{'本次抽取'+ data.length +'个座位,随机到'+ data.place.groupName + '区第' + data.place.row + '排'}
); + }else{ + notes.push({'本次抽取'+ data.length +'个座位,随机到'+ data.place.groupName + '区第' + data.place.row + '排,但剩余的连号位置不足!'}
); + } + }); + return notes; + } + + begin() { + let length = this.randomInput(); + let seat = this.randomSeat(); + let data = this.selectSeats(seat, length); + let selects = data.list; + this.record = this.record.concat(data); + if(data.result && selects instanceof Array && selects.length > 0) { + this.setSeats(selects); + } + this.setState({ + record: this.record + }) + } + + handleClickBtn() { + this.begin(); } render() { return (