'use strict';

/**
 *
 *
 * @author Mai
 * @date
 * @version
 */
// 台账审批流程
const ledger = (function () {
    const status = {
        uncheck: 1, // 待上报
        checking: 2, // 待审批|审批中
        checked: 3, // 审批通过
        checkNo: 4, // 审批退回
    };

    const statusString = [];
    statusString[status.uncheck] = '';
    statusString[status.checking] = '审批中';
    statusString[status.checked] = '审批完成';
    statusString[status.checkNo] = '审批退回';

    const statusClass = [];
    statusClass[status.uncheck] = '';
    statusClass[status.checking] = '';
    statusClass[status.checked] = 'text-success';
    statusClass[status.checkNo] = 'text-warning';

    // 标段概况页
    // 描述文本
    const auditString = [];
    auditString[status.uncheck] = '';
    auditString[status.checking] = '审批中';
    auditString[status.checked] = '审批完成';
    auditString[status.checkNo] = '审批退回';
    // 文字样式
    const auditStringClass = [];
    auditStringClass[status.uncheck] = '';
    auditStringClass[status.checking] = 'text-warning';
    auditStringClass[status.checked] = 'text-success';
    auditStringClass[status.checkNo] = 'text-warning';
    return { status, statusString, statusClass, auditString, auditStringClass }
})();

// 台账修订 审批流程
const revise = (function () {
    const status = {
        uncheck: 1, // 待上报
        checking: 2, // 待审批|审批中
        checked: 3, // 审批通过
        checkNo: 4, // 审批退回
    };
    const statusString = [];
    statusString[status.uncheck] = '草稿';
    statusString[status.checking] = '审批中';
    statusString[status.checked] = '完成';
    statusString[status.checkNo] = '退回';
    return { status, statusString }
})();

// 期审批流程
const stage = (function () {
    // 流程状态
    const status = {
        uncheck: 1, // 待上报
        checking: 2, // 待审批|审批中
        checked: 3, // 审批通过
        checkNo: 4, // 审批退回原报
        checkNoPre: 5, // 审批退回上一人
    };

    // 流程状态提示
    const statusString = [];
    statusString[status.uncheck] = '待上报';
    statusString[status.checking] = '审批中';
    statusString[status.checked] = '审批通过';
    statusString[status.checkNo] = '审批退回';
    statusString[status.checkNoPre] = '审批退回';

    // 流程状态样式
    const statusClass = [];
    statusClass[status.uncheck] = '';
    statusClass[status.checking] = '';
    statusClass[status.checked] = 'text-success';
    statusClass[status.checkNo] = 'text-warning';
    statusClass[status.checkNoPre] = 'text-warning';

    /**
     * 期列表，审批状态一列
      */
    // 按钮
    const statusButton = [];
    statusButton[status.uncheck] = '待上报';
    statusButton[status.checking] = '审批';
    statusButton[status.checked] = '';
    statusButton[status.checkNo] = '重新上报';
    statusButton[status.checkNoPre] = '重新审批';
    // 按钮样式
    const statusButtonClass = [];
    statusButtonClass[status.uncheck] = 'btn-primary';
    statusButtonClass[status.checking] = 'btn-success';
    statusButtonClass[status.checked] = '';
    statusButtonClass[status.checkNo] = 'btn-warning';
    statusButtonClass[status.checkNoPre] = 'btn-warning';
    // 描述文本
    const auditString = [];
    auditString[status.uncheck] = '';
    auditString[status.checking] = '审批中';
    auditString[status.checked] = '完成';
    auditString[status.checkNo] = '退回';
    auditString[status.checkNoPre] = '退回';
    // 文字样式
    const auditStringClass = [];
    auditStringClass[status.uncheck] = '';
    auditStringClass[status.checking] = 'text-warning';
    auditStringClass[status.checked] = 'text-success';
    auditStringClass[status.checkNo] = 'text-warning';
    auditStringClass[status.checkNoPre] = 'text-warning';
    /* ------------------------------------------------------- */

    /**
     * 期列表，审批进度一列
    */
    // 描述文本
    const auditProgress = [];
    auditProgress[status.uncheck] = '待上报';
    auditProgress[status.checking] = '审批中';
    auditProgress[status.checked] = '审批通过';
    auditProgress[status.checkNo] = '审批退回';
    auditProgress[status.checkNoPre] = '审批退回';
    // 样式
    const auditProgressClass = [];
    auditProgressClass[status.uncheck] = '';
    auditProgressClass[status.checking] = 'text-warning';
    auditProgressClass[status.checked] = 'text-success';
    auditProgressClass[status.checkNo] = 'text-warning';
    auditProgressClass[status.checkNoPre] = 'text-warning';
    /* ------------------------------------------------------- */

    const backType = {
        org: 1,
        pre: 2,
    };
    return { status, statusString, statusClass, statusButton, statusButtonClass, auditString, auditStringClass, auditProgress, auditProgressClass, backType, timesLen: 100 }
})();


// 变更令状态
const status = {
    uncheck: 1,     // 待上报
    checking: 2,    // 审批中
    checked: 3,     // 审批完成
    // checkNo: 4,     // 审批终止
    back: 5,        // 重新上报
    backnew: 6,     // 退回
};
const statusButton = [];
statusButton[status.uncheck] = '上报';
statusButton[status.checking] = '审批';
statusButton[status.checked] = '';
// statusButton[status.checkNo] = '';
statusButton[status.back] = '重新上报';
statusButton[status.backnew] = '审批';

const statusButtonClass = [];
statusButtonClass[status.uncheck] = 'btn-primary';
statusButtonClass[status.checking] = 'btn-success';
statusButtonClass[status.checked] = '';
// statusButtonClass[status.checkNo] = '';
statusButtonClass[status.back] = 'btn-warning';
statusButtonClass[status.backnew] = 'btn-success';

const statusString = [];
statusString[status.uncheck] = '';
statusString[status.checking] = '审批中';
statusString[status.checked] = '完成';
// statusString[status.checkNo] = '终止';
statusString[status.back] = '退回';
statusString[status.backnew] = '退回';

const statusClass = [];
statusClass[status.uncheck] = '';
statusClass[status.checking] = 'text-warning';
statusClass[status.checked] = 'text-success';
// statusClass[status.checkNo] = 'text-danger';
statusClass[status.back] = 'text-warning';
statusClass[status.backnew] = 'text-warning';

/* ------------------------------------------------------- */

// 变更令审批人状态
const auditStatus = {
    uncheck: 1,     // 待审批
    checking: 2,    // 审批中或者原报人待上报
    checked: 3,     // 审批通过或者原报人上报完成
    // checkNo: 4,     // 审批终止
    back: 5,       // 退回到原报人重新上报
    backnew: 6,    // 退回到上一个审批人
};

const auditStatusString = [];
auditStatusString[auditStatus.uncheck] = '待上报';
auditStatusString[auditStatus.checking] = '审批中';
auditStatusString[auditStatus.checked] = '审批通过';
// auditStatusString[auditStatus.checkNo] = '审批终止';
auditStatusString[auditStatus.back] = '退回';
auditStatusString[auditStatus.backnew] = '审批退回';

const auditStatusClass = [];
auditStatusClass[auditStatus.uncheck] = '';
auditStatusClass[auditStatus.checking] = 'text-warning';
auditStatusClass[auditStatus.checked] = 'text-success';
// auditStatusClass[auditStatus.checkNo] = 'text-danger';
auditStatusClass[auditStatus.back] = 'text-warning';
auditStatusClass[auditStatus.backnew] = 'text-warning';

/* ------------------------------------------------------- */

const filter = {
    status: {
        pending: 1,
        uncheck: 5,
        checking: 2,
        checked: 3,
        // checkNo: 4,
    },
    statusString: [],
};
filter.statusString[filter.status.pending] = '待处理';
filter.statusString[filter.status.uncheck] = '待上报';
filter.statusString[filter.status.checking] = '进行中';
filter.statusString[filter.status.checked] = '已完成';
// filter.statusString[filter.status.checkNo] = '终止';

module.exports = {
    ledger,
    stage,
    revise,
    flow: {
        status,
        statusString,
        statusButton,
        statusButtonClass,
        statusClass,
        auditStatus,
        auditStatusString,
        auditStatusClass,
    },
    filter,
};
