123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- import Api from "../../model/api";
- //TODO 待优化 FIXME DEFAULT IGNORE
- const app = getApp();
- Page({
- data: {
- partNull: false,
- nullDataText: '学员手册未配置',
- nullDataArr: ['封皮未配置', '目录前页未配置', '学院简介未配置', '日程安排未配置', '座位图未配置', '学员名单未配置', '培训项目组成员名单未配置', '临时党支部委员会委员未配置', '授课教师简介未配置', '中共中央组织部关于在干部教育培训中进一步加强学院管理的规定未配置', '学员须知未配置', '学院位置区域图未配置'],
- list: [],
- nullArr: [],
- active: 0,
- STUDENT_JOBS: {
- "2": "书记",
- "3": "组织",
- "4": "宣传"
- },
- up: true,
- down: true,
- teamId: ''
- },
- async onLoad(options) {
- let teamId = options.teamId;
- let index = parseInt(options.index);
- this.data.teamId = teamId;
- let res = await Api.getBook({
- teamId: this.data.teamId
- });
- if (res.rows.length != 0) {
- this.setData({
- list: res.rows,
- partNull: false,
- })
- console.log(res.rows)
- res.rows.map(item => {
- this.data.nullArr.push(false)
- })
- this.setData({
- nullArr: this.data.nullArr
- })
- console.log(this.data.nullArr)
- if (res.rows[0].manualUrl) {
- this.getDataByIndex(res.rows[0].manualUrl);
- } else {
- let index = 'nullArr[0]'
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[0]
- })
- console.log(this.data.nullArr)
- }
- } else {
- this.setData({
- partNull: true,
- up: false,
- down: false,
- })
- }
- this.data.active = index - 1;
- this.next();
- },
- async getDataByIndex(index) {
- console.log(index)
- console.log(this.data.active)
- let res = await Api.getStudentBookByIndex(index);
- if (this.data.active == 0 || this.data.active == 11) {
- res.data.configContent = res.data.configContent.replace(/width\s*:\s*[0-9]+px/g, 'width:100%');
- res.data.configContent = res.data.configContent.replace(/<([\/]?)(center)((:?\s*)(:?[^>]*)(:?\s*))>/g, '<$1div$3>');
- res.data.configContent = res.data.configContent.replace(/\<img/gi, '<img class="rich-img" ');
- }
- if (this.data.active == 1 || this.data.active == 2 || this.data.active == 10) {
- res.data.configContent = res.data.configContent.replace(/\<p/gi, '<P class="rich-p" ');
- }
- this.data.list[this.data.active].manualContent = res.data.configContent;
- this.setData({
- list: this.data.list
- })
- },
- pre(e) {
- this.setData({
- active: this.data.active - 1
- })
- if (this.data.nullArr[this.data.active]) {
- this.setData({
- partNull: true,
- nullDataText: this.data.nullDataArr[this.data.active]
- })
- } else {
- this.setData({
- partNull: false
- })
- }
- },
- async next(e) {
- this.setData({
- active: this.data.active + 1
- })
- if (this.data.active == 1) {
- if (this.data.list[1].manualUrl) {
- this.getDataByIndex(this.data.list[1].manualUrl)
- this.setData({
- partNull: false
- })
- } else {
- let index = 'nullArr[1]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[1]
- })
- }
- }
- if (this.data.active == 2) {
- if (this.data.list[2].manualUrl) {
- this.getDataByIndex(this.data.list[2].manualUrl)
- this.setData({
- partNull: false
- })
- } else {
- let index = 'nullArr[2]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[2]
- })
- }
- }
- if (this.data.active == 3) {
- let res = await Api.studentBookSchedule({
- teamId: this.data.teamId
- });
- if (res.rows) {
- this.data.list[this.data.active].manualContent = res.rows;
- this.setData({
- partNull: false,
- list: this.data.list
- })
- } else {
- let index = 'nullArr[3]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[3]
- })
- }
- }
- if (this.data.active == 4) {
- if (this.data.list[4].manualUrl) {
- let res = await Api.studentBookSeat(this.data.list[4].manualUrl);
- console.log(res, '我是座位图')
- this.data.list[this.data.active].manualContent = res.data;
- this.setData({
- partNull: false,
- list: this.data.list
- })
- } else {
- let index = 'nullArr[4]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[4]
- })
- }
- }
- if (this.data.active == 5) {
- let res = await Api.studentBookLists({
- teamId: this.data.teamId
- });
- console.log(res, '我是学员名单')
- if (res.data) {
- let newArr = res.data.filter(item => item.groupName !== '未分组');
- newArr.shift();
- this.data.list[this.data.active].manualContent = newArr;
- this.setData({
- partNull: false,
- list: this.data.list
- })
- } else {
- let index = 'nullArr[5]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[5]
- })
- }
- }
- if (this.data.active == 6 || this.data.active == 7) {
- let res = await Api.studentBookGroups(this.data.teamId);
- console.log(res, '我是项目组+党支部委员成员名单')
- let jobs = []
- res.data.teamStuJobList.map(item => {
- let key2 = this.data.STUDENT_JOBS[Object.keys(item)]
- let value2 = Object.values(item)
- if (key2 == '书记') {
- jobs.push({
- name: '书记',
- value: value2[0]
- })
- }
- if (key2 == '组织') {
- jobs.push({
- name: '组织',
- value: value2[0]
- })
- }
- if (key2 == '宣传') {
- jobs.push({
- name: '宣传',
- value: value2[0]
- })
- }
- })
- let data = [];
- if (this.data.active == 6) {
- if (res.data.itemLeadesName || res.data.subLedaersName || res.data.itemAssistantsName || res.data.teamDirectorList || res.data.teamStuJobList) {
- data.push(res.data.itemLeadesName, res.data.subLedaersName, res.data.itemAssistantsName, res.data.teamDirectorList, res.data.teamStuJobList)
- } else {
- let index = 'nullArr[6]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[6]
- })
- }
- } else {
- if (res.data.teamStuJobList.length > 0) {
- data.push(res.data.itemLeadesName, res.data.subLedaersName, res.data.itemAssistantsName, res.data.teamDirectorList, jobs)
- } else {
- let index = 'nullArr[7]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[7]
- })
- }
- }
- this.data.list[this.data.active].manualContent = data;
- this.setData({
- list: this.data.list
- })
- }
- if (this.data.active == 8) {
- console.log(this.data.list, 'xxxxxxxxxxx')
- if (this.data.list[8].manualUrl) {
- let res = await Api.studentBookTeacher(this.data.list[8].manualContent);
- this.data.list[this.data.active].manualContent = res.data;
- this.setData({
- list: this.data.list,
- partNull: false,
- })
- } else {
- let index = 'nullArr[8]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[8]
- })
- }
- }
- if (this.data.active == 9) {
- if (this.data.list[9].manualUrl) {
- this.getDataByIndex(this.data.list[9].manualUrl)
- this.setData({
- partNull: false,
- })
- } else {
- let index = 'nullArr[9]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[9]
- })
- }
- }
- if (this.data.active == 10) {
- if (this.data.list[10].manualUrl) {
- this.getDataByIndex(this.data.list[10].manualUrl)
- this.setData({
- partNull: false,
- })
- } else {
- let index = 'nullArr[10]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[10]
- })
- }
- }
- if (this.data.active == 11) {
- if (this.data.list[11].manualUrl) {
- this.getDataByIndex(this.data.list[11].manualUrl)
- this.setData({
- partNull: false,
- })
- } else {
- let index = 'nullArr[10]';
- this.setData({
- [index]: true,
- partNull: true,
- nullDataText: this.data.nullDataArr[11]
- })
- }
- }
- },
- });
|