12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202 |
- <!doctype html>
- <html>
- <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">
- <meta name="format-detection"content="telephone=no">
- <title>添加记录</title>
- <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
- <link rel="stylesheet" href="../../css/select.css">
- <style media="screen">
- body,html{
- margin: 0;
- background: #fff;
- }
- *{
- box-sizing: border-box;
- }
- .recode-warp{
- margin-top: 10px;
- }
- .col>label{
- color: #333;
- font-size: 16px;
- padding: 15px 0 ;
- position: relative;
- padding-left: 15px;
- width: 100%;
- }
- .col>label:before{
- content: '';
- position: absolute;
- top: 13px;
- left: 0;
- width: 3px;
- height: 26px;
- background: #009fe8;
- }
- .col>label:after{
- content: '';
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 1px;
- background: #ECF0F1;
- }
- .recode-warp{
- padding: 5px 10px;
- }
- .input-recode{
- position: relative;
- }
- .title{
- font-size: 16px;
- color: #333;
- font-weight: normal;
- margin-bottom: 10px;
- }
- .title span{
- color: red;
- }
- .input-recode .input{
- margin: 0;
- height: 45px;
- border: 1px solid #e1e5e9;
- background: #ffffff;
- font-size: 14px;
- width: 100%;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- padding-left: 15px;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- color: #333;
- }
- .modula:not(:first-child){
- margin-top: 18px;
- }
- .ico{
- display: block;
- position: absolute;
- top: 16px;
- right: 8px;
- width: 18px;
- height: 13px;
- background: url(../../icon/ico.png) no-repeat;
- background-size: cover;
- }
- /*录音*/
- .input-recode audio{
- width: 100%;
- }
- .upload-btn{
- width: 100px;
- height: 33px;
- background: url(../../icon/mp3.jpg);
- background-size: cover;
- display: block;
- cursor: pointer;
- }
- .del-btn{
- display: none;
- width: 60px;
- height: 30px;
- line-height: 30px;
- text-align: center;
- color: #fff;
- background: #07c160;
- border-radius: 3px;
- font-size: 14px;
- margin-bottom: 10px;
- }
- /*文件*/
- .file-items{
- border: 1px dashed #D9D9D9;
- padding: 10px 10px 0 10px;
- display: flex;
- justify-content: flex-start;
- flex-wrap: wrap;
- box-sizing: border-box;
- }
- .file-width{
- width: 33.3333333%;
- box-sizing: border-box;
- font-size: 14px;
- color: #333;
- margin-bottom: 10px;
- }
- .file-item{
- text-align: center;
- }
- .file-item img{
- width: 35px;
- height: 35px;
- margin-bottom: 5px;
- }
- .file-item p{
- padding: 0 5px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- height: auto;
- }
- .upload img{
- width: 80px;
- height: 80px;
- margin-left: 15px;
- }
- /*图片*/
- .img-item{
- text-align: center;
- }
- .img-item img{
- width: 80px;
- height: 80px;
- border-radius: 3px;
- object-fit: cover;
- }
- .img-items .upload{
- text-align: center;
- }
- .img-items .upload img{
- width: 80px;
- height: 80px;
- margin: 0;
- }
- /*视频*/
- .upload-btn1{
- width: 100px;
- height: 33px;
- background: url(../../icon/vedio.png);
- background-size: cover;
- display: block;
- cursor: pointer;
- }
- .submit-btn{
- width: 100%;
- font-size: 18px;
- background: #009fe8;
- height: 55px;
- line-height: 55px;
- letter-spacing: 5px;
- color: #fff;
- border-radius: 3px;
- margin-top: 20px;
- margin-bottom: 20px;
- }
- /*检查项*/
- .radio-wrap{
- font-size: 14px;
- display: flex;
- justify-content: flex-start;
- flex-wrap: wrap;
- padding-top: 10px;
- }
- .radio-wrap label{
- margin-right: 10px;
- padding: 5px 0;
- }
- .radio-wrap label input{
- margin-right: 10px;
- }
- /*position*/
- .flex-start{
- display: flex;
- justify-content: space-between;
- white-space: nowrap;
- align-items: center;
- }
- .flex-space{
- display: flex;
- justify-content: space-between;
- white-space: nowrap;
- align-items: center;
- }
- .ico-map{
- width: 25px;
- height: 25px;
- background: url("../../icon/position.png") no-repeat;
- background-position: center;
- background-size: cover;
- }
- .position{
- padding: 5px 0;
- padding-left: 15px;
- padding-right: 10px;
- border-radius: 50px;
- background: #F0F0F0;
- font-size: 14px;
- margin-top:10px;
- }
- .map1{
- color: #009FE8;
- margin-bottom: 5px;
- }
- .again{
- color: #6C6F74;
- }
- .map-name {
- width: 78%;
- }
- .names{
- width: 85%;
- white-space: normal;
- }
- #position_warp{
- padding: 0 10px;
- }
- .textarea{
- height: 45px;
- line-height: 1.5;
- }
- </style>
- </head>
- <body>
- <div id="position_warp"></div>
- <div class="recode-warp" id="recode_warp"></div>
- </body>
- </html>
- <script type="text/template" id="recodeTemplate">
- <!-- 是否开启定位 -->
- {{?it.position == true}}
- {{=getLonLat(false)}}
- {{?}}
- <!-- 状态-->
- {{?it.recordStatusList != "" && it.recordStatusList != null}}
- {{ for(var i= 0;i<it.recordStatusList.length;i++) { }}
- <div class="modula state">
- <label class="title isOptionals" isOptional="true">
- <span>*</span>
- {{=it.recordStatusList[i].statusContent}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" placeholder="请选择{{=it.recordStatusList[i].statusContent}}" statusId="{{=it.recordStatusList[i].statusId}}" class="isOptional input moreStatusA" id="moreStatus{{=it.recordStatusList[i].id}}" readonly>
- <i class="ico"></i>
- </div>
- </div>
- {{?it.recordStatusList[i].choseType === 'checkbox'}}
- {{=statusCheckbox('moreStatus'+it.recordStatusList[i].id,it.recordStatusList[i].statusItemList,it.recordStatusList[i].statusContent)}}
- {{??}}
- {{=statusRadio('moreStatus'+it.recordStatusList[i].id,it.recordStatusList[i].statusItemList,it.recordStatusList[i].statusContent)}}
- {{?}}
- {{ } }}
- {{??it.statusName !=""}}
- <div class="modula state">
- <label class="title isOptionals" isOptional="true">
- <span>*</span>
- {{=it.statusName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" placeholder="请输入{{=it.statusName}}" class="isOptional input statusContent">
- </div>
- </div>
- {{?}}
- <!-- 记录项 -->
- {{ for(var key in it.inputList) { }}
- <div class="col">
- <label style="display:{{=key==""?'none':'block'}}">{{=key}}</label>
- <div class="content" style="padding-top:15px;">
- {{ for(var i=0;i<it.inputList[key].length;i++) { }}
- {{?it.inputList[key][i].inputType === 'text'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <textarea oninput="Oninput(this)" placeholder="请输入{{=it.inputList[key][i].inputName}}" style="padding: 10px 15px" recordTrem-id="{{=it.inputList[key][i].id}}" class="isOptional input recordTrems textarea"></textarea>
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'date_auto'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" readonly value="{{=getYearMonthDate()}}" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'dateTime_auto'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" readonly value="{{=getYearMonthDateTime()}}" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'text_phone'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="tel" placeholder="请填写手机号" value="{{=JSON.parse($api.getStorage('data')).data.user.mobile == null?'':JSON.parse($api.getStorage('data')).data.user.mobile}}" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'text_id'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" placeholder="请填写身份证号" value="{{=JSON.parse($api.getStorage('data')).data.user.identity_card == null?'':JSON.parse($api.getStorage('data')).data.user.identity_card }}" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'company_auto'}}
- <div class="modula text">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" readonly value="{{=JSON.parse($api.getStorage('data')).data.user.section}}" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'dateTime'}}
- <div class="modula date-time">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="datetime-local" data-datetime="true" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'date'}}
- <div class="modula date">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="date" class="isOptional input recordTrems" recordTrem-id="{{=it.inputList[key][i].id}}">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'file'}}
- <div class="modula file-warp">
- <label class="title" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode file-items fileList_warp" recordTrem-id="{{=it.inputList[key][i].id}}">
- <div class="upload file-width" onclick="browseFile(this,'file')">
- <img src="../../image/upload.png" alt="">
- </div>
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'mp3'}}
- <div class="modula audio-warp">
- <h4 class="title" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </h4>
- <div class="text-input input-recode mp3_wrap" recordTrem-id="{{=it.inputList[key][i].id}}">
- <div class="upload-audio">
- <span class="upload-btn" onclick="browseFile(this,'mp3')"></span>
- <button type="button" class="del-btn hide" onclick="delAudio(this)">删除</button>
- </div>
- <div class="audio-content">
- </div>
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'number'}}
- <div class="modula number">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="number" placeholder="请输入{{=it.inputList[key][i].inputName}}" recordTrem-id="{{=it.inputList[key][i].id}}" class="isOptional input recordTrems">
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'photo'}}
- <div class="modula img-warp">
- <label class="title" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode file-items img-items photoFile" isOptional="{{=it.inputList[key][i].isOptional}}" recordTrem-id="{{=it.inputList[key][i].id}}">
- <div class="upload file-width" onclick="uploadImg('{{=it.inputList[key][i].businessType}}',this)">
- <img src="../../image/upload.png" alt="">
- </div>
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'radio'}}
- <div class="modula radio">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" placeholder="请选择" class="isOptional input changeInput" recordTrem-id="{{=it.inputList[key][i].id}}" id="radio{{=i}}" readonly>
- <i class="ico"></i>
- </div>
- </div>
- {{=radioRecord('radio'+i,it.inputList[key][i].inputItemList)}}
- {{??it.inputList[key][i].inputType === 'video'}}
- <div class="modula vedio-warp">
- <h4 class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </h4>
- <div class="text-input input-recode mp4_wrap" recordTrem-id="{{=it.inputList[key][i].id}}">
- <div class="upload-audio">
- <span class="upload-btn1" onclick="browseFile(this,'mp4')"></span>
- <button type="button" class="del-btn hide" onclick="delVedio(this)">删除</button>
- </div>
- <div class="audio-content">
- </div>
- </div>
- </div>
- {{??it.inputList[key][i].inputType === 'checkbox'}}
- <div class="modula checkbox">
- <label class="title isOptionals" isOptional="{{=it.inputList[key][i].isOptional}}">
- <span style="display:{{=it.inputList[key][i].isOptional== true?'inline-block':'none'}}">*</span>
- {{=it.inputList[key][i].inputName}}:
- </label>
- <div class="text-input input-recode">
- <input type="text" placeholder="请选择" class="isOptional input changeInput" recordTrem-id="{{=it.inputList[key][i].id}}" id="checkbox{{=i}}" readonly>
- <i class="ico"></i>
- </div>
- </div>
- {{=checkboxRecord('checkbox'+i,it.inputList[key][i].inputItemList)}}
- {{?}}
- {{ } }}
- </div>
- </div>
- {{ } }}
- <!-- 检查项 -->
- {{?it.checkItemList != ""}}
- {{ for(var i= 0;i<it.checkItemList.length;i++) { }}
- <div class="modula checkbox-term">
- <label class="title" style="margin-bottom: 0">
- {{=it.checkItemList[i].group.groupName}}:
- </label>
- <div class="radio-wrap">
- {{?it.checkItemList[i].group.checkType == 'radio'}}
- {{ for(var t=0;t<it.checkItemList[i].checkItemList.length;t++) { }}
- <label>
- <input class="aui-radio checked" type="radio" value="{{=it.checkItemList[i].checkItemList[t].id}}" name="{{=it.checkItemList[i].group.groupName}}">
- {{=it.checkItemList[i].checkItemList[t].itemValue}}
- </label>
- {{ } }}
- {{??}}
- {{ for(var t=0;t<it.checkItemList[i].checkItemList.length;t++) { }}
- <label>
- <input class="aui-checkbox checked" type="checkbox" value="{{=it.checkItemList[i].checkItemList[t].id}}" name="{{=it.checkItemList[i].group.groupName}}">
- {{=it.checkItemList[i].checkItemList[t].itemValue}}
- </label>
- {{ } }}
- {{?}}
- </div>
- </div>
- {{ } }}
- {{?}}
- <button type="button" name="button" class="submit-btn" onclick="submitRecode()">提交记录</button>
- </script>
- <script type="text/template" id="mapTemplate">
- <div class="position flex-space">
- <div class="map-name flex-start">
- <i class="ico-map"></i>
- <div class="names">
- <p class="map1">{{=it.address}}</p>
- </div>
- </div>
- <p class="again" onclick="getLonLat(true)">重新定位</p>
- </div>
- </script>
- <script type="text/javascript" src="../../script/api.js"></script>
- <script type="text/javascript" src="../../script/doT.min.js"></script>
- <script type="text/javascript" src="../../script/zepto.js"></script>
- <script type="text/javascript" src="../../script/select.js"></script>
- <script src="../../script/config.js" charset="utf-8"></script>
- <script type="text/javascript">
- var imgarr = [], UIAlbumBrowser= "";
- var pageId="", pageRecordParentId= "", recordParentId= "",
- templateId="", templateName="",departmentId="",userId= "",userName= "";
- var i = 0;
- apiready = function () {
- UIAlbumBrowser = api.require('UIAlbumBrowser');
- pageId = api.pageParam.pageId
- departmentId = api.pageParam.organizationIds
- userId= api.pageParam.createBy
- userName= api.pageParam.createName
- recordParentId= api.pageParam.recordTrueID
- recodeContent(api.pageParam.pageId, api.pageParam.pageRecordId)
- }
- // 记录模版内容
- function recodeContent(id,recodeId) {
- var param={
- pageId:id,
- pageRecordId:recodeId,
- recordParentId:recordParentId,
- }
- $http.requestShowProgress(UrlRouter.getInspection,'get',param)
- .then(ret=>{
- if (ret.code === '200') {
- pageRecordParentId = ret.data.parentId;
- templateId = ret.data.recordTemplate.id
- templateName = ret.data.recordTemplate.templateName
- $apis.html(recode_warp, '#recodeTemplate',ret.data.recordTemplate);
- }
- }).catch(err=>{})
- }
- // 录音
- // 删除录音
- function delAudio(that) {
- $(that).hide();
- $(that).parent().find('.upload-btn').show();
- $(that).parent().parent().find('audio').remove();
- }
- // 视频
- // 删除视频
- function delVedio(that) {
- $(that).hide();
- $(that).parent().find('.upload-btn1').show();
- $(that).parent().parent().find('video').remove();
- }
- // 状态
- function checkbox(el,list,titles) {
- var itmes = {title:'',value:''},itmesArray = [];
- for (var j= 0;j<list.length;j++) {
- itmes = {};
- itmes.title = list[j].statusContent;
- itmes.value = list[j].id;
- itmesArray.push(itmes)
- }
- setTimeout(function () {
- $('#'+el).select({
- title: titles,
- multi: true,
- items: itmesArray
- });
- },1000)
- return ''
- }
- // 记录项多选-单选
- function checkboxRecord(el,list) {
- var itmes = {title:'',value:''},itmesArray = [],idArray=[],titleArray=[];
- for (var j= 0;j<list.length;j++) {
- itmes = {};
- if (list[j].isDefault === true) {
- titleArray.push(list[j].itemValue)
- idArray.push(list[j].id)
- }
- itmes.title = list[j].itemValue;
- itmes.value = list[j].id;
- itmesArray.push(itmes)
- }
- setTimeout(function () {
- $("#"+el).select({
- multi: true,
- items: itmesArray
- });
- $("#"+el).attr("data-values",idArray.join(','))
- $("#"+el).attr("value",titleArray.join(','))
- },1000)
- return ''
- }
- function radioRecord(el,list) {
- var itmes = {title:'',value:''},itmesArray = [],idArray=[],titleArray=[];
- for (var j= 0;j<list.length;j++) {
- itmes = {};
- if (list[j].isDefault === true) {
- titleArray.push(list[j].itemValue)
- idArray.push(list[j].id)
- }
- itmes.title = list[j].itemValue;
- itmes.value = list[j].id;
- itmesArray.push(itmes)
- }
- setTimeout(function () {
- $("#"+el).select({
- multi: false,
- items: itmesArray
- });
- $("#"+el).attr("data-values",idArray.join(','))
- $("#"+el).attr("value",titleArray.join(','))
- },1000)
- return ''
- }
- //状态
- // 多选
- function statusCheckbox(el,list,titles) {
- var itmes = {title:'',value:''},itmesArray = [];
- for (var j= 0;j<list.length;j++) {
- itmes = {};
- itmes.title = list[j].statusContent;
- itmes.value = list[j].id;
- itmesArray.push(itmes)
- }
- setTimeout(function () {
- $("#"+el).select({
- title: titles,
- multi: true,
- items: itmesArray
- });
- },1000)
- return ''
- }
- // 单选
- function statusRadio(el,list,titles) {
- var itmes = {title:'',value:''},itmesArray = [];
- for (var j= 0;j<list.length;j++) {
- itmes = {};
- itmes.title = list[j].statusContent;
- itmes.value = list[j].id;
- itmesArray.push(itmes)
- }
- setTimeout(function () {
- $("#"+el).select({
- title: titles,
- multi: false,
- items: itmesArray
- });
- },1000)
- return ''
- }
- // 上传图片
- function uploadImg(type,that) {
- if (type == 'remote') {
- api.getPicture({
- sourceType: 'camera'
- }, function(ret, err){
- if(ret && ret.data!=""){
- uploadHead(ret.data,that);
- }
- });
- }else {
- 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(ret.data,that);
- }
- });
- }else {
- type = 'album';
- // 支持多图片上传,UIAlbumBrowser模块获取图片路径
- changeImageUrl(that)
- }
- }
- });
- }
- }
- // upload img
- function uploadHead(imgUrl,that){
- $http.fileUploadRequest(UrlRouter.uploadFile,'post',{file:imgUrl})
- .then(ret=>{
- if(ret.code === '200'){
- var html = `<div class="img-item file-width" img-Url="${ret.data.fullURL}">
- <img src="${ret.data.fullURL}" alt="">
- </div>`;
- $api.append(that.parentNode,html);
- api.toast({
- msg: '上传成功',
- duration: 2000,
- location: 'top'
- });
- }else {
- api.toast({
- msg: '上传失败',
- duration: 2000,
- location: 'top'
- });
- }
- })
- .catch(err=>{
- api.toast({
- msg: '网络错误',
- duration: 2000,
- location: 'top'
- });
- })
- }
- // 获取相册图片路径
- function changeImageUrl(el) {
- 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: {
- w: 100,
- h: 100
- }
- },
- animation: true,
- }, function(ret) {
- if (ret.eventType == 'nextStep') {
- UIAlbumBrowser.closePicker();
- if (ret.list && ret.list.length > 0) {
- imgarr = ret.list;
- // 转换缩略图路径 ios
- UIAlbumBrowser_transPath(el);
- }
- }
- if (ret.originalPath && ret.originalPath.length > 0) {
- uploadHead(ret.originalPath,el)
- }
- });
- }
- // 转换缩略图路径 ios
- function UIAlbumBrowser_transPath(el) {
- UIAlbumBrowser.transPath({
- path: imgarr[i].path
- }, function(ret, err) {
- if (ret) {
- i++;
- if (i < imgarr.length) {
- UIAlbumBrowser_transPath(el);
- } else {
- i = 0;
- }
- uploadHead(ret.path,el)
- }
- });
- }
- // 上传文件
- // 浏览手机文件夹,获取文件路径
- function browseFile(el,type) {
- var fileBrowser = api.require('fileBrowser');
- fileBrowser.open(function(ret) {
- if (ret) {
- var type = ret.name.substring(ret.name.lastIndexOf('.'))
- if (
- type === '.xls' ||
- type === '.ppt' ||
- type === '.pptx' ||
- type === '.xlsx' ||
- type === '.doc' ||
- type === '.docx' ||
- type === '.zip' ||
- type === '.rar' ||
- type === '.pdf'
- ) {
- setTimeout(function () {
- uploadFile(el,ret.url)
- },500)
- }else if (type === '.mp3') {
- setTimeout(function () {
- uploadAudio(el,ret.url)
- },500)
- }else if(type === '.mp4'){
- setTimeout(function () {
- uploadVedio(el,ret.url)
- },500)
- }else {
- alert('选择文件格式不正确');
- }
- }
- });
- fileBrowser.skin({
- skin:1
- });
- }
- // 上传文件
- function uploadFile(el,fileUrl) {
- $http.fileUploadRequest(UrlRouter.uploadFile,'post',{file:fileUrl})
- .then(ret=>{
- if(ret.code === '200'){
- 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'
- ){
- var html = `<div class="file-item file-width" file-Url="${ret.data.fullURL}" file-Name="${ret.data.fileName}">
- <img src="../../icon/${ret.data.fullURL.substr(ret.data.fullURL.length-3,3)}.png"/>
- <p>${ret.data.fileName}</p>
- </div>`;
- $api.append(el.parentNode,html);
- }else {
- api.toast({
- msg: '文件格式不对',
- duration: 2000,
- location: 'top'
- });
- }
- }else {
- api.toast({
- msg: '上传失败',
- duration: 2000,
- location: 'top'
- });
- }
- })
- .catch(err=>{
- api.toast({
- msg: '网络错误',
- duration: 2000,
- location: 'top'
- });
- })
- }
- // 上传音频
- function uploadAudio(el,fileUrl) {
- $http.fileUploadRequest(UrlRouter.uploadFile,'post',{file:fileUrl})
- .then(ret=>{
- if(ret.code === '200'){
- api.toast({
- msg: '上传成功',
- duration: 2000,
- location: 'top'
- });
- var fileType = ret.data.fileExt;
- if (
- fileType == 'm4a' ||
- fileType == 'mp3' ||
- fileType == 'amr' ||
- fileType == 'AMR' ||
- fileType == 'WAV' ||
- fileType == 'wav' ||
- fileType == 'AWB' ||
- fileType == 'awb'
- ){
- $(el).hide();
- $(el).parent().find('.del-btn').show();
- var html = `<audio src="${ret.data.fullURL}" controls></audio>`;
- $(el).parent().parent().find('.audio-content').html(html)
- }else {
- api.toast({
- msg: '音频格式不对',
- duration: 2000,
- location: 'top'
- });
- }
- }else {
- api.toast({
- msg: '上传失败',
- duration: 2000,
- location: 'top'
- });
- }
- })
- .catch(err=>{
- api.toast({
- msg: '网络错误',
- duration: 2000,
- location: 'top'
- });
- })
- }
- // 上传视频
- function uploadVedio(el,fileUrl) {
- $http.fileUploadRequest(UrlRouter.uploadFile,'post',{file:fileUrl})
- .then(ret=>{
- if(ret.code === '200'){
- api.toast({
- msg: '上传成功',
- duration: 2000,
- location: 'top'
- });
- var fileType = ret.data.fileExt;
- if (
- fileType == 'mp4' ||
- fileType == 'avi' ||
- fileType == 'wmv' ||
- fileType == '3gp' ||
- fileType == 'mkv' ||
- fileType == 'flv' ||
- fileType == 'rmvb'
- ){
- $(el).hide();
- $(el).parent().find('.del-btn').show();
- var html = `<video controls="controls" style="width: 100%;height: 200px;">
- <source src="${ret.data.fullURL}">
- 当前不支持播放该视频
- </video>`;
- $(el).parent().parent().find('.audio-content').html(html)
- }else {
- api.toast({
- msg: '视频格式不对',
- duration: 2000,
- location: 'top'
- });
- }
- }else {
- api.toast({
- msg: '上传失败',
- duration: 2000,
- location: 'top'
- });
- }
- })
- .catch(err=>{
- api.toast({
- msg: '网络错误',
- duration: 2000,
- location: 'top'
- });
- })
- }
- //提交
- function mvalidate() {
- var isOptionals = $('.isOptionals')
- var opnum=0,eachnum=0;
- isOptionals.each(function (index) {
- if ($(this).attr('isOptional') == 'true'){
- ++opnum;
- }
- if ($(this).attr('isOptional') == 'true' && $(this).parent().find('.isOptional').val() !== "") {
- ++eachnum
- }
- })
- if (opnum == eachnum) {
- return true;
- }else {
- return false;
- }
- }
- function submitRecode() {
- if (mvalidate()) {
- var inutItme =[],recordTrems = $('.recordTrems'),inputObj = {inputId:'',inputValue:''},changeInput = $('.changeInput');
- //6.图片
- var photoFile = $('.photoFile'),photoArray = [];
- var isOptional = true
- photoFile.each(function () {
- inputObj = {};
- photoArray =[];
- inputObj.inputId = $(this).attr('recordTrem-id');
- var photoList = $(this).find('.img-item');
- photoList.each(function () {
- photoArray.push($(this).attr('img-Url'));
- });
- inputObj.inputValue = photoArray.join(',');
- if ($(this).attr('isOptional') === "true" && inputObj.inputValue =="") {
- isOptional = false
- }
- inutItme.push(inputObj);
- });
- if (isOptional === false) {
- return api.toast({
- msg: '请上传带*号的图片',
- duration: 2000,
- location: 'bottom'
- });
- }
- api.showProgress({
- title: '',
- text: '提交中...',
- modal: true
- });
- // 检查项
- var inspectTremA = $('.checked'),checkItemArray = [];
- var obj = {checkItemId:'',instanceValue:''}
- for (var i = 0; i < inspectTremA.length; i++) {
- obj = {}
- if (inspectTremA[i].checked) {
- obj.checkItemId = inspectTremA[i].value
- obj.instanceValue = true;
- checkItemArray.push(obj)
- }
- }
- // 记录项
- //// 1.文本, 时间,日期,数字
- recordTrems.each(function () {
- inputObj = {};
- var inputValue = $(this).val(),
- inputId = $(this).attr('recordTrem-id'),
- datetime = $(this).attr('data-datetime');;
- if (datetime) {
- inputObj.inputId = inputId;
- inputObj.inputValue = inputValue.replace("T"," ");
- }else {
- inputObj.inputId = inputId;
- inputObj.inputValue = inputValue;
- }
- inutItme.push(inputObj);
- });
- //2.多选,单选
- changeInput.each(function () {
- inputObj = {};
- inputObj.inputId = $(this).attr('recordTrem-id');
- inputObj.inputValue = $(this).attr('data-values');
- inutItme.push(inputObj);
- });
- //3.录音
- var mp3_wrap = $('.mp3_wrap');
- mp3_wrap.each(function () {
- inputObj = {};
- inputObj.inputId = $(this).attr('recordTrem-id');
- inputObj.inputValue = $(this).find('audio').attr('src');
- inutItme.push(inputObj);
- });
- //4.视频
- var mp4_wrap = $('.mp4_wrap');
- mp4_wrap.each(function () {
- inputObj = {};
- inputObj.inputId = $(this).attr('recordTrem-id');
- inputObj.inputValue = $(this).find('video>source').attr('src');
- inutItme.push(inputObj);
- });
- //5.文件
- var fileList_warp = $('.fileList_warp'),fileArray = [],fileName = [],num = 0;
- fileList_warp.each(function (index) {
- inputObj = {};
- fileArray= [];
- inputObj.inputId = $(this).attr('recordTrem-id');
- var fileList = $(this).find('.file-item');
- fileList.each(function () {
- fileArray.push($(this).attr('file-Url')+"-"+$(this).attr('file-Name'));
- });
- inputObj.inputValue = fileArray.join(',');
- inutItme.push(inputObj);
- });
- // 状态项
- // 状态
- var moreStatusA = $('.moreStatusA'),statusA = [],statusObj = {statusId:"",statusValue:''};
- moreStatusA.each(function () {
- statusObj = {};
- statusObj.statusId = $(this).attr('statusId');
- statusObj.statusValue = $(this).attr('data-values');
- statusA.push(statusObj);
- });
- var filterl= inutItme.filter(function (item) {
- if (item.inputValue != undefined){
- return item.inputValue !=""
- }
- });
- var param= {
- checkItems: checkItemArray,
- createBy: userId,
- createName: userName,
- inputs:filterl,
- pageId:pageId,
- pageRecordParentId:pageRecordParentId,
- recordParentId:recordParentId,
- status:statusA.length !=0? statusA : [],
- statusContent:$('.statusContent').val(),
- templateId:templateId,
- templateName:templateName,
- departmentId:departmentId,
- spName:spName,
- lng:lon,
- lat:lat
- }
- $.ajax({
- url: UrlRouter.addRecordInstance,
- type: 'post',
- contentType:'application/json;charset=UTF-8',
- dataType: 'json',
- data: JSON.stringify(param),
- success: function (ret) {
- if(ret.code === '200') {
- $('.submit-btn').attr('disabled','disabled')
- api.hideProgress()
- $event.openTabLayout('recodeDetails'+Math.random(),'recodeDetails','记录详情',{recordParentId:ret.data});
- }else if (ret.code == 422) {
- api.hideProgress()
- api.alert({
- title: '提示',
- msg: '请填写记录项',
- });
- }
- },
- error:function (err) {
- api.hideProgress()
- api.toast({
- msg: err,
- duration: 3000,
- location: 'top'
- });
- }
- })
- }else {
- api.toast({
- msg: '请填写带*号的内容!',
- duration: 3000,
- location: 'top'
- });
- }
- }
- // 定位初始化
- var spName = '',lon='',lat='';
- function getLonLat(flag) {
- if (flag) {
- api.showProgress({
- title: '提示',
- text: '定位中...',
- });
- }
- var aMap = api.require('aMap');
- aMap.getLocation(function(ret, err) {
- if (ret.status) {
- api.hideProgress();
- lon= ret.lon; lat=ret.lat;
- aMap.getNameFromCoords({
- lon: ret.lon,
- lat: ret.lat
- }, function(ret, err) {
- if (ret.status) {
- spName = ret.address
- $apis.html(position_warp, '#mapTemplate',ret);
- } else {
- api.toast({
- msg: '请打开手机定位',
- duration: 2000,
- location: 'top'
- });
- }
- });
- } else {
- api.hideProgress();
- api.toast({
- msg: '定位失败请重新定位',
- duration: 2000,
- location: 'top'
- });
- }
- });
- return '';
- }
- // textarea根据文字多少自适应高度
- function Oninput(that) {
- $(that).height(that.scrollHeight);
- }
- </script>
|