<!DOCTYPE HTML>
<html class="mask">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" href="../../css/style.css">
    <link rel="stylesheet" href="../../css/projeck.css">
    <style>
        body {
            background: #009fe8;
        }

        .hidden {
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        .api_layout {
            width: 95%;
            margin: 10px;
            background: #fff;
            border-radius: 5px;
        }

        .column-row-container {
            margin: 10px;
        }

        .column {
            margin-bottom: 10px;
        }

        .column:first-child {
            /*padding-top: 10px;*/
        }

        .column-title {
            display: block;
            font-size: 15px;
            color: #97a3b4;
            margin-bottom: 10px;
        }

        input::placeholder {
            font-size: 14px;
            color: #bdc3c7;
        }

        .api_layout .font-s {
            font-size: 14px;
        }

        .api_layout .input-s {
            height: 45px;
            border: 1px solid #ebebeb;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            padding-left: 10px;
        }
        /*#person-name {
          margin-top: 10px;
          display: none;
        }*/

        #person-name-container {
            height: 43px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border: solid 1px #97a3b4;
            border-radius: 5px;
            display: none;
        }

        .column-input {
            border: none;
            padding-left: 15px;
            padding-top: 12px
        }

        .person-search-btn {
            display: block;
            height: 100%;
            width: 50px;
            background: #009FE8;
            border: none
        }

        .aui-list-item-input1 {
            position: relative;
        }

        .aui-list-item-input1:after {
            content: "";
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-bottom: 5px solid #b3c0ce;
            -webkit-transform-origin: 5px 2.5px;
            transform-origin: 5px 2.5px;
            -webkit-transition: all .5s ease;
            transition: all .5s ease;
            position: absolute;
            right: 10px;
            top: 18px;
            -webkit-transform: rotate(180deg);
            transform: rotate(180deg);
        }

        .column-textarea {
            border: 1px solid #97a3b4;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            padding: 10px;
            height: 160px;
        }

        .column-textarea::placeholder {
            font-size: 14px;
            color: #333;
        }

        .aui-row {
            border: 1px dashed #c8d2de;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            padding: 10px;
        }

        .technological-process {
            margin-top: 10px;
            display: flex;
            justify-content: flex-start;
            flex-wrap: wrap;
        }

        .technologicals {
            margin-bottom: 20px;
        }

        .aui-list-item-input label {
            font-size: 14px;
            height: 21px;
            display: inline-block;
            line-height: 22px;
            margin-right: 5px;
        }

        .aui-list-item-input label:last-child {
            margin-right: 0;
        }

        .uploadImg .imgParent {
            padding: 15px;
        }

        .imgParent img {
            width: 79px;
            height: 79px;
        }

        .imgParents img {
            width: 104px;
            height: 104px;
            object-fit: cover;
            border-radius: 3px;
        }

        .aui-toast-content {
            font-size: 16px;
        }

        .delImg {
            width: 15px;
            height: 15px;
            line-height: 15px;
            position: absolute;
            top: -5px;
            left: -5px;
            border: 1px solid red;
            border-radius: 50%;
            color: red;
            font-size: 12px;
            font-weight: bold;
            text-align: center;
        }

        .fileList img {
            width: 35px;
            height: 35px;
            margin: auto;
            margin-top: 8px;
        }

        .fileList .uploadFiles {
            padding: 15px;
        }

        .uploadFiles img {
            width: auto;
            height: auto;
            margin-top: 0;
        }

        .aui-col-xs-4 span {
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            padding: 0 3px;
            height: 48px;
            text-align: center;
            margin: 5px 0;
            font-size: 15px;
        }

        .node-content {
            width: 100%;
            display: flex;
            justify-content: space-between;
            flex-wrap: nowrap;
            margin-bottom: 10px;
        }

        .node-name {
            width: 35%;
        }

        .node-personal {
            width: 65%;
            display: -webkit-box;
            justify-items: flex-start;
            align-items: center;
            align-content: center;
            flex-wrap: wrap;
            line-height: normal;
        }

        .personal-name {
            display: inline-block;
            font-size: 13px;
            padding: 4px 3px;
            background: #009fe8;
            color: #fff;
            border-radius: 2px;
            margin-left: 5px;
            margin-bottom: 5px;
            position: relative;
        }

        .addNode-name {
            padding: 5px 5px;
            background: #009fe8;
            font-size: 16px;
            color: #fff;
            font-weight: bold;
            text-align: center;
            display: inline-block;
            border-radius: 2px;
            margin-left: 5px;
        }

        .aui-btn-block {
            font-size: 18px;
            height: 40px;
            line-height: 40px;
        }

        .ico-loading {
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            width: 35px;
            height: 35px;
            background: url("../../icon/loading.gif") no-repeat;
            background-size: cover;
            background-position: center;
        }

        .loading {
            position: absolute;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, .3);
            top: 0;
            left: 0;
        }

        .aui-radio,
        .aui-checkbox {
            position: relative;
            top: 3px;
        }

        .selectTitle {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sure-btn {
            /*padding: 5px;*/
            padding: 3px 5px 0 5px;
            border-radius: 3px;
            color: #fff;
            background: #009fe8;
            font-size: 14px;
        }

        /*.department-list-name option{
            height: 40px;
            -webkit-appearance: none;
            appearance: none;
            border: none;
            font-size: 18px;
            padding: 0px 10px;
            display: block;
            width: 100%;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            background-color: #FFFFFF;
            color: red;
            border-radius: 4px;
        }*/

        .template_my_record{
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 10px 0 0 10px;
        }
        .template_name{
          font-size: 20px;
          font-weight: bold;
          color: #009FE8;
        }
    </style>
</head>

<body class="mask">
    <div class="api_layout" id="column_row">
      <div class="template_my_record">
        <div class="template_name"></div>
      </div>
    </div>
    </div>
    <!--添加审核人员-->
    <div class="api_layout_box hide">
        <div class="box_m">
            <div class="api_box">
                <div class="selectTitle after-border relative">
                    <h3 class="h3">选择审批人</h3>
                    <div class="sure-btn" onclick="closesss()">确认</div>
                </div>
                <div class="aui-list-item-input relative">
                    <select class="column-select input-s font-s"  id="department-list-name" onchange="getApproList($api.val(this))">
                    <option value="0">请选择部门</option>
                </select>
                    <!-- 根据姓名查人员 -->
                    <!-- <div id="person-name-container">
                        <input class="column-input" id='person-value' oninput="searchPersonName(this)" placeholder="请输入人员姓名" />
                    </div> -->
                </div>
            </div>
            <!-- 人员列表 -->
            <ul class="column" id="personal_List" style="margin-bottom: 0">

            </ul>
            <div class="loading hide">
                确认
                <!-- <i class="ico-loading"></i> -->
            </div>
        </div>
    </div>
    <!--*****-->
</body>
<script type="text/template" id="template">
    <div class="column-row-container">
        <div class="column-row">
            {{ for (var i = 0;i
            <it.length;i++) { }} {{? it[i].type=='input' || it[i].mold}} {{? it[i].mold=='date' }} <div class="column">
                <label class="column-title">{{=it[i].label}}：</label>
                <input type="date" name="{{=it[i].name}}" value="" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s time" style="line-height: 41px">
        </div>
        {{?? it[i].mold == 'num'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="number" name="{{=it[i].name}}" value="" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s">
        </div>
        {{?? it[i].mold == 'name'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="text" name="{{=it[i].name}}" readonly value="{{=JSON.parse($api.getStorage('data')).data.user.name}}" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s">
        </div>
        {{?? it[i].mold == 'section'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="text" name="{{=it[i].name}}" readonly value="{{=JSON.parse($api.getStorage('data')).data.user.section}}" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s">
        </div>
        {{?? it[i].mold == 'phone'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="number" name="{{=it[i].name}}" value="{{=JSON.parse($api.getStorage('data')).data.user.mobile}}" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s">
        </div>
        {{?? it[i].mold == 'datetime'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="datetime-local" name="{{=it[i].name}}" value="" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s" style="line-height: 41px">
        </div>
        {{??}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <input type="text" name="{{=it[i].name}}" value="" placeholder="请输入{{=it[i].label}}" class="inputBox colimn-input input-s font-s">
        </div>
        {{?}} {{?? it[i].type == 'radio'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <div class="radioName" name="{{=it[i].name}}" data-info>
                {{ for(var j=0;j
                <it[i].select.length;j++) { }} <label><input class="aui-radio" type="radio" name="{{=it[i].name}}" value="{{=it[i].select[j]}}" onchange="radioFun(this)">{{=it[i].select[j]}}</label>
                    {{ } }}
            </div>
        </div>
        {{?? it[i].type == 'checkbox'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <div class="checkboxName" name={{=it[i].name}} data-info>
                {{ for(var j=0;j
                <it[i].select.length;j++) { }} <label><input class="aui-checkbox" type="checkbox" name="{{=it[i].name}}" value="{{=it[i].select[j]}}" onchange="checkboxFun(this)">{{=it[i].select[j]}}</label>
                    {{ } }}
            </div>
        </div>
        {{?? it[i].type == 'textarea'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <textarea name="{{=it[i].name}}" rows="8" cols="80" class="column-textarea font-s column-textarea1" placeholder="请输入{{=it[i].label}}"></textarea>
        </div>
        {{?? it[i].type == 'select'}}
        <div class="column">
            <label class="column-title">选择：</label>
            <div class="aui-list-item-input1">
                <select class="input-select font-s input-s" name="{{=it[i].name}}">
                      <option value="">请选择</option>
                      {{ for(var j=0;j<it[i].select.length;j++) { }}
                          <option value="{{=it[i].select[j]}}">{{=it[i].select[j]}}</option>
                      {{ } }}
                  </select>
            </div>
        </div>
        {{?? it[i].type == 'images'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <div class="aui-row aui-row-padded uploadImg" data-info name="{{=it[i].name}}">
                <div class="aui-col-xs-4 imgParent" onclick="actionSheetFun(this, '{{=it[i].name}}')" data-url='{{=it[i].url}}'>
                    <img src="../../image/upload.png" />
                </div>
            </div>
        </div>
        {{?? it[i].type == 'files'}}
        <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
            <div class="aui-row aui-row-padded fileList" data-info name="{{=it[i].name}}">
                <div class="aui-col-xs-4 uploadFiles" onclick="browseFile(this,'{{=it[i].name}}')" data-url='{{=it[i].url}}'>
                    <img src="../../image/upload.png" />
                </div>
            </div>
        </div>
        <!-- <div class="column">
            <label class="column-title">{{=it[i].label}}：</label>
        </div> -->
        {{?}} {{ } }}
    </div>
    <div class="technologicals" id="technologicals">

    </div>
    <div class="aui-btn aui-btn-info aui-btn-block" onclick="submitInfo()">
        提交
    </div>
    <div style="width: 100%; height: 10px;"></div>
    </div>
</script>
<script type="text/template" id="templateApply">
    <label class="column-title">固定审批流程：(双击可删除已选定的审批人)</label>
    <div class="technological-process">
        {{ for(var i=0;i < it.length; i++) { }}
          <div class="node-content">
              <span class="node-name">{{=it[i]}}：</span>
              <div class="node-personal" flowName='{{=it[i]}}' jobIDs="">
                  <i class="aui-iconfont aui-icon-plus addNode-name" onclick="approValPesonal(this)"></i>
              </div>
          </div>
        {{ } }}
    </div>
</script>
<!-- 部门人员 -->
<script type="text/template" id="getApproList">
    {{ for (var i = 0;i
    <it.length;i++) { }} <li class="after-border relative">
        <label class="remember-me-label flex-space">
          <div class="flex-start">
              <img src="" onerror=javascript:this.src="http://jiewei-icon.oss-cn-beijing.aliyuncs.com/icon/default-avatar.png" class="api_leader_head">
              <div>
                  <p class="name font-s">{{=it[i].name}}</p>
                  <p class="del font-s">{{=it[i].section_fullname}}</p>
              </div>
          </div>
          <div class="remember-password-container">
              <div class="remember-password-content">
                  <input type="checkbox" class='checkbox' onchange="addApproValPesonal(this)" {{=personals.length>0?(it[i].staff_num == personals[i]?'checked':''):''}} value="{{=it[i].staff_num}}" name="{{=it[i].name}}">
                  <span></span>
              </div>
          </div>
      </label>
        </li>
        {{ } }}
</script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script src="../../script/zepto.js" charset="utf-8"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript">
    var toast = new auiToast(),
        token;
    var UIAlbumBrowser;
    var i = 0;
    var imgarr = [];
    var id = "",
        addNodeThis = '',
        personals = '',
        titleName;
    var departmentPerson = []
    apiready = function() {
        var info = $api.getStorage('data');
        token = JSON.parse(info).data.access_token;
        id = api.pageParam.id;
        getApplyDe(api.pageParam.id, token);
        UIAlbumBrowser = api.require('UIAlbumBrowser');
    };

    function getApplyDe(id, token) {
        var headers = {
            "Authorization": "Bearer " + token
        };
        $http.fnReuestDataNologing(UrlRouter.getApplyD + id, headers, 'get', '', function(ret, err) {
            if (ret.code === 0) {
                toast.hide();
                $apis.append(column_row, '#template', ret.data.form);
                titleName = ret.data.title
                $api.append($api.dom('.template_name'), titleName);
                $apis.append(technologicals, '#templateApply', ret.data.flow);
            }
        })
    }
    // open审核人员
    var ruleTop = '';

    function approValPesonal(that) {
        addNodeThis = that;
        $('.api_layout_box').show();
        $('.mask').addClass('hidden');
        ruleTop = $(addNodeThis).offset().top;
        $apis.html(personal_List, '#getApproList', '');
        getDep() //调用部门接口
    }
    // 添加审核人员
    function addApproValPesonal(that) {
        var personal_name = $(addNodeThis).parent().find('.personal-name');
        var name = $api.attr(that, 'name'),
            ID = $api.val(that),
            IDS = [];
        if (that.checked) {
            $api.prepend(addNodeThis.parentNode, `<sapn class="personal-name" jobId="${ID}" ondblclick="this.remove()">${name}</span>`);
            $(addNodeThis).parent().attr('jobIDs', IDS.push(ID))
        } else {
            $(addNodeThis).parent().find('[jobid*="' + ID + '"]').remove()
        }
    }

    function closesss() {
        $api.css($api.byId('person-name-container'), 'display: none');
        $api.css($api.byId('department-list-name'), 'display: block');
        // $api.css($api.byId('aui-list-item-input1'), 'display: none');
        $('.api_layout_box').hide()
        $('.mask').removeClass('hidden')
        $("body,html").scrollTop(ruleTop);
    }
    // 上传图片
    var headImg;

    function actionSheetFun(el, name) {
        api.actionSheet({
            title: '选择',
            cancelTitle: '取消',
            buttons: ['相机', '相册']
        }, function(ret, err) {
            if (ret.buttonIndex != 3) {
                var type = 'camera';
                if (ret.buttonIndex == 1) {
                    type = 'camera';
                    api.getPicture({
                        sourceType: type
                    }, function(ret, err) {
                        if (ret && ret.data != "") {
                            uploadHead(el, ret.data, name);
                        }
                    });
                } else {
                    type = 'album';
                    // 支持多图片上传，UIAlbumBrowser模块获取图片路径
                    changeImageUrl(el, name)
                }
            }
        });
    }
    // upload img
    function uploadHead(el, imgUrl, name) {
        var uploadUrl = $api.attr(el, 'data-url');
        toast.loading({
            title: "上传中",
            duration: 2000
        });
        api.ajax({
            url: urlphp + uploadUrl,
            method: 'post',
            headers: {
                "Authorization": "Bearer " + token,
            },
            data: {
                files: {
                    image: imgUrl
                }
            }
        }, function(ret, err) {
            if (ret) {
                toast.hide();
                if (ret.code === 0) {
                    var html =
                        `<div class="aui-col-xs-4 imgParents" data-imgUrl="${ret.data.path}" data-imgName="${ret.data.imageName}" name="${name}">
                                <i class="delImg aui-iconfont aui-icon-close" onclick="this.parentNode.remove()"></i>
                                <img src="${ret.data.path}"/>
                             </div>`;
                    $api.append(el.parentNode, html);
                    api.toast({
                        msg: '上传成功',
                        duration: 2000,
                        location: 'top'
                    });
                } else {
                    api.toast({
                        msg: '上传失败',
                        duration: 2000,
                        location: 'top'
                    });
                }
            } else {
                toast.hide();
                api.toast({
                    msg: '网络错误',
                    duration: 2000,
                    location: 'top'
                });
            }
        });

    }
    // radio
    function radioFun(el) {
        var value = el.value;
        if (el.checked) {
            el.parentNode.parentNode.setAttribute('data-info', value);
        }
    }
    // chexkbox
    function checkboxFun(el) {
        var value = el.value;
        if (el.checked) {
            var getAttribute = el.parentNode.parentNode.getAttribute('data-info').split(',');
            getAttribute.push(value);
            el.parentNode.parentNode.setAttribute('data-info', getAttribute);
        } else {
            var getAttribute = el.parentNode.parentNode.getAttribute('data-info').split(',');
            getAttribute.remove(value);
            el.parentNode.parentNode.setAttribute('data-info', getAttribute);
        }
    }
    // 选择图片库路径
    function changeImageUrl(el, name) {
        UIAlbumBrowser.imagePicker({
            max: 9,
            styles: {
                bg: '#000000',
                //cameraImg: 'widget://res/cameraImg.png',
                mark: {
                    position: 'top_right',
                    size: 20
                },
                nav: {
                    bg: '#000000',
                    cancelColor: '#fff',
                    cancelSize: 16,
                    nextStepColor: '#7fff00',
                    nextStepSize: 16
                },
                thumbnail: { //（可选项）返回的缩略图配置，**建议本图片不要设置过大** 若已有缩略图，则使用已有的缩略图。若要重新生成缩略图，可先调用清除缓存接口api.clearCache()。
                    w: 100, //（可选项）数字类型；返回的缩略图的宽；默认：原图的宽度
                    h: 100 //（可选项）数字类型；返回的缩略图的宽；默认：原图的高度
                }
            },
            animation: true,
        }, function(ret) {
            if (ret.eventType == 'nextStep') {
                if (ret.list && ret.list.length > 0) {
                    imgarr = ret.list;
                    UIAlbumBrowser_transPath(el, name);
                }
                UIAlbumBrowser.closePicker();
            }
            if (ret.originalPath && ret.originalPath.length > 0) {
                uploadHead(el, ret.originalPath, name)
            }
        });
    }
    // 转换缩略图路径 ios
    function UIAlbumBrowser_transPath(el, name) {
        UIAlbumBrowser.transPath({
            path: imgarr[i].path
        }, function(ret, err) {
            if (ret) {
                i++;
                if (i < imgarr.length) {
                    UIAlbumBrowser_transPath(el, name);
                } else {
                    i = 0;
                }
                uploadHead(el, ret.path, name)
            }
        });
    }
    // 上传文件
    function uploadFile(el, fileUrl, name) {
        var uploadUrl = $api.attr(el, 'data-url');
        api.ajax({
            url: urlphp + uploadUrl,
            method: 'post',
            headers: {
                "Authorization": "Bearer " + token,
            },
            data: {
                files: {
                    file: fileUrl
                }
            }
        }, function(ret, err) {
            if (ret) {
                toast.hide();
                if (ret.code === 0) {
                    api.toast({
                        msg: '上传成功',
                        duration: 2000,
                        location: 'top'
                    });
                    var fileType = ret.data.fileName.substr(ret.data.fileName.length - 3, 3);
                    if (
                        fileType == 'ppt' ||
                        fileType == 'ptx' ||
                        fileType == 'lsx' ||
                        fileType == 'xls' ||
                        fileType == 'doc' ||
                        fileType == 'ocx' ||
                        fileType == 'zip' ||
                        fileType == 'rar' ||
                        fileType == 'pdf' ||
                        fileType == 'jpg' ||
                        fileType == 'jpeg' ||
                        fileType == 'png' ||
                        fileType == 'gif'
                    ) {
                        var html =
                            `<div class="aui-col-xs-4 fileCol" data-fileUrl="${ret.data.path}" data-fileName="${ret.data.fileName}" name="${name}">
                                 <i class="delImg aui-iconfont aui-icon-close" onclick="this.parentNode.remove()"></i>
                                 <img src="../../icon/${ret.data.path.substr(ret.data.path.length-3,3)}.png"/>
                                 <span>${ret.data.fileName}</span>
                             </div>`;
                        var getAttribute = el.parentNode.getAttribute('data-info');
                        var dataInfo = getAttribute + ',,' + JSON.stringify(ret.data)
                        el.parentNode.setAttribute('data-info', dataInfo);
                        $api.append(el.parentNode, html);
                    } else {
                        api.toast({
                            msg: '文件格式不对',
                            duration: 2000,
                            location: 'top'
                        });
                    }
                } else {
                    api.toast({
                        msg: '上传失败',
                        duration: 2000,
                        location: 'top'
                    });
                }
            } else {
                toast.hide();
                api.toast({
                    msg: '网络错误',
                    duration: 2000,
                    location: 'top'
                });
            }
        });
    }
    // 浏览手机文件夹,获取文件路径
    function browseFile(el, name) {
        var selectFile = api.require('selectFile');
        selectFile.open(function(ret, err) {
            if (ret.status) {
                uploadFile(el, ret.path, name)
            } else {
                alert('选择文件不存在');
            }
        });
    }
    // 提交工单信息
    function submitInfo() {
        var headers = {
            "Authorization": "Bearer " + token
        };
        var inputBoxArray = [],
            inputBoxObject = {
                id: id,
                hadFlow: [],
                imgAtlas: [],
                fileAtlas: []
            },
            inputBox = $api.domAll('.inputBox'),
            inputSelect = $api.domAll('.input-select'),
            checkboxName = document.querySelectorAll('.checkboxName'),
            radioName = $api.domAll('.radioName'),
            uploadImg = $api.domAll('.uploadImg'),
            imgParents = $api.domAll('.imgParents'),
            fileCol = $api.domAll('.fileCol'),
            fileList = $api.domAll('.fileList'),
            columnTextarea = $api.domAll('.column-textarea');
        // 文本框
        for (var i = 0; i < inputBox.length; i++) {
            var key = $api.attr(inputBox[i], 'name'),
                value = $api.val(inputBox[i]);
            inputBoxObject[key] = value
        }
        // 文本域
        for (var i = 0; i < columnTextarea.length; i++) {
            var key = $api.attr(columnTextarea[i], 'name'),
                value = $api.val(columnTextarea[i]);
            inputBoxObject[key] = value
        }
        // 下拉选择
        for (var j = 0; j < inputSelect.length; j++) {
            var key = $api.attr(inputSelect[j], 'name'),
                value = $api.val(inputSelect[j]);
            inputBoxObject[key] = value;
        }
        // 单选
        for (var k = 0; k < radioName.length; k++) {
            var val = $api.attr(radioName[k], 'data-info'),
                key = $api.attr(radioName[k], 'name');
            inputBoxObject[key] = val;
        }
        // 多选
        for (var t = 0; t < checkboxName.length; t++) {
            var value = checkboxName[t].getAttribute('data-info'),
                key = checkboxName[t].getAttribute('name');
            inputBoxObject[key] = value.split(',').slice(1).join(',');
        }
        // img集合
        var imgAtlas = {},
            imgAtlasArray = []
        for (var i = 0; i < imgParents.length; i++) {
            imgAtlas = {}
            var imgUrl = $api.attr(imgParents[i], 'data-imgUrl'),
                imgName = $api.attr(imgParents[i], 'data-imgName'),
                name = $api.attr(imgParents[i], 'name');
            imgAtlas.path = imgUrl
            imgAtlas.imageName = imgName
            imgAtlas.name = name
            imgAtlasArray.push(imgAtlas)
        }
        //file集合
        var fileAtlas = {},
            fileAtlasArray = []
        for (var i = 0; i < fileCol.length; i++) {
            fileAtlas = {}
            var fileUrl = $api.attr(fileCol[i], 'data-fileUrl'),
                fileName = $api.attr(fileCol[i], 'data-fileName'),
                name = $api.attr(fileCol[i], 'name');
            fileAtlas.path = fileUrl
            fileAtlas.fileName = fileName
            fileAtlas.name = name
            fileAtlasArray.push(fileAtlas)
        }
        // 审批人员
        var node_personal = $('.node-personal')
        var hadFlows = {};
        node_personal.each(function(index) {
            var hadFlows1 = [];
            var personal_names = $(this).find('.personal-name')
            var key = $(this).attr('flowName')
            for (var i = 0; i < personal_names.length; i++) {
                hadFlows1.push($(personal_names[i]).attr('jobId'))
            }
            hadFlows[key] = hadFlows1.join(',')
        });
        inputBoxObject.imgAtlas = imgAtlasArray
        inputBoxObject.fileAtlas = fileAtlasArray
        inputBoxObject.hadFlow = hadFlows
        inputBoxArray.push(inputBoxObject)
        var hadFlowLength = Object.keys(inputBoxObject.hadFlow).length;
        // console.log(JSON.stringify(inputBoxObject));
        if (hadFlowLength > 0) {
            $http.fnReuestDataJSON(UrlRouter.submitApply, headers, 'post', inputBoxObject, function(ret, err) {
                if (ret.code === 0) {
                    api.toast({
                        msg: '提交成功',
                        duration: 2000,
                        location: 'top'
                    });
                    setTimeout(function() {
                        $event.openWin('myWordeOrder_win', 'myWordeOrder_win', '', '');
                    }, 100)
                } else if (ret.code == 1) {
                    api.toast({
                        msg: ret.message,
                        duration: 2000,
                        location: 'bottom'
                    });
                    toast.hide();
                }
            })
        } else {
            api.toast({
                msg: '请选择审批人',
                duration: 2000,
                location: 'top'
            });
        }
    };
    // 获取部门
    function getDep() {
        var headers = {
            "Authorization": "Bearer " + token
        };
        $http.fnReuestDataNologing(UrlRouter.getAlllist, headers, 'get', '', function(ret, err) {
            var html = ''
            for (var i = 0; i < ret.data.length; i++) {
                if (i == 0) {
                    html += `<option value="0">请选择部门</option>`
                }
                html += `<option value="${ret.data[i].id}">${ret.data[i].title}</option>`
            }
            $api.html($api.dom('.column-select'), html)
        })
    }
    // 获取人员列表
    function getApproList(id) {
        if (id) {
            $api.css($api.byId('person-name-container'), 'display: block');
            // $api.css($api.byId('department-list-name'), 'display: none');
        }
        $api.removeCls($api.dom('.loading'), 'hide');
        $apis.html(personal_List, '#getApproList', '');
        var headers = {
            "Authorization": "Bearer " + token
        };

        $http.fnReuestDataNologing(UrlRouter.getPersonalList, headers, 'post', {
            id: id
        }, function(ret, err) {
            if (ret.code === 0) {
                $api.addCls($api.dom('.loading'), 'hide');
                $apis.html(personal_List, '#getApproList', ret.data);
                departmentPerson = ret.data
            }
        })
    }
    // // 搜索部门下的人员姓名
    // function searchPersonName(value) {
    //     let personValue = $api.val($api.byId('person-value'));
    //     let newDepartMentPerson = departmentPerson.filter(function(item) {
    //         return item.name.includes(`${personValue}`)
    //     })
    //     $apis.html(personal_List, '#getApproList', newDepartMentPerson);
    // }
</script>

</html>
