index.vue 153 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095
  1. <template>
  2. <div class="editClss">
  3. <van-nav-bar :title="substitute ? '代填日报' : '填写日报'" left-text="返回" @click-left="back" fixed left-arrow />
  4. <van-form class="login_form" ref="loginForm">
  5. <div>
  6. <van-field readonly clickable right-icon="arrow" v-if="substitute"
  7. :value="fillingAgent.name" :label="'代填人员'" placeholder="请选择代填人员"
  8. @click="auditorShow = true">
  9. <template #input>
  10. <span v-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  11. :openid='fillingAgent.name'></TranslationOpenDataText></span>
  12. <span v-else>{{ fillingAgent.name }}</span>
  13. </template>
  14. </van-field>
  15. <van-cell >
  16. <van-field style="padding:0px" readonly clickable name="datetimePicker" :value="form.createDate" label="时间选择"
  17. placeholder="点击选择时间" @click="showPicker = true" :rules="rules.createDate" >
  18. </van-field>
  19. <template #right-icon>
  20. <!--先开放几家,试一下-->
  21. <span style="color:#20a0ff;" @click="getAIReport()" v-if="!substitute && !hasWrittenReport && (user.companyId==10||user.companyId==7||user.companyId==7030)">智能填报</span>
  22. </template>
  23. </van-cell>
  24. <van-cell>
  25. <template #default>
  26. <div class="attendanceRecord">
  27. <template v-if="user.timeType.syncDingding == 1 || user.timeType.syncCorpwxTime == 1">
  28. <span>打卡:</span>
  29. <span v-if="!report.time">暂无考勤记录</span>
  30. <span v-else>{{ report.time.startTime }}-{{ report.time.endTime }}, 工作{{
  31. report.time.workHours }}h
  32. <span v-if="report.time.askLeaveTime">|&nbsp;请假{{ report.time.askLeaveTime
  33. }}h</span>
  34. <span v-if="report.time.otTime" style="color:#DAA520;">|&nbsp;加班{{ report.time.otTime
  35. }}h</span></span>
  36. </template>
  37. <span style="margin-left:5px">总填报:</span>
  38. <span>{{ totalReportHours }}h</span>
  39. </div>
  40. </template>
  41. <template #right-icon>
  42. <van-button icon="replay" native-type="button" type="default" size="mini"
  43. style="height:0.6rem;padding:0 0.16667rem;" :loading="cardRefLoading" loading-size="0.26667rem"
  44. @click.stop.native="cardtimeRefresh(form.createDate)"
  45. v-if="!substitute && user.timeType.syncCorpwxTime == 1 && (user.timeType.syncDingding == 1 || user.timeType.syncCorpwxTime == 1)"></van-button>
  46. </template>
  47. </van-cell>
  48. <!-- <div v-if="report.time" class="attendanceRecord">
  49. <i class="iconfont firerock-icondakajilu" style="font-size:0.35rem;margin-right:0.12rem"></i>
  50. <span v-if="user.timeType.syncDingding==1&&!report.time">暂无考勤记录</span>
  51. <span v-else>{{report.time.startTime}}-{{report.time.endTime}}, {{report.time.workHours}}小时</span>
  52. </div> -->
  53. </div>
  54. <van-popup v-model="showPicker" position="bottom">
  55. <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate"
  56. @confirm="changeTime" @cancel="showPicker = false" />
  57. </van-popup>
  58. <van-cell title="总时长(h)" v-if="reportTimeType.type == 3">
  59. <template>
  60. <van-stepper :disabled="(!canEdit || user.timeType.lockWorktime == 1) && !isWeekend"
  61. v-model="reportTimeType.allday" @change="changeAllTime" min="0.5" max="12" step="0.5"
  62. :decimal-length="1" />
  63. </template>
  64. </van-cell>
  65. <!-- <van-cell title="待分配时长" :value="report.time + 'h'" size="large"></van-cell> -->
  66. <div class="form_domains" v-for="(item, index) in form.domains" :key="item.id">
  67. <div style="float:right;margin-top:10px;margin-right:10px;">
  68. <!-- <van-tag v-if="canEdit&&item.projectName.length>0" color="#fff"
  69. @click="copyProject(index)" style="border: 1px solid #20a0ff;padding:5px;"
  70. icon="plus" type="default" ><span style="color:#666;padding: 0 5px;">复制项目</span></van-tag> -->
  71. <van-tag v-if="(index > 0 || form.domains.length > 1) && item.canEdit" color="#fff"
  72. @click="delPro(index)" style="border: 1px solid #ff0000;padding:5px;margin-left:10px;" icon="plus"
  73. type="default"><span style="color:#666;padding: 0 5px;">删除</span></van-tag>
  74. </div>
  75. <!-- <van-icon v-if="index>0&&canEdit" class="form_del" name="delete" @click="delPro(index)" /> -->
  76. <van-cell-group :title="(user.companyId == 781 ? '任务' : '项目') + (index + 1)">
  77. <van-field readonly name="userReportDeptName" v-if="user.timeType.userWithMultiDept == 1 && userReportDeptList.length > 0"
  78. :value="item.userReportDeptName" :label="'填报部门'" placeholder="请选择部门" :disabled="!item.canEdit" @click="selectDeptPopup(index, item)">
  79. <template #input>
  80. <TranslationOpenDataText type='departmentName' :openid='item.userReportDeptName'></TranslationOpenDataText>
  81. </template>
  82. </van-field>
  83. <!-- <div>请选择投入项目</div> -->
  84. <van-field readonly name="projectId" clickable :value="item.projectName" type="textarea" autosize
  85. :label="user.companyId == 781 ? '工作任务' : '投入项目'" :disabled="!item.canEdit" rows="1"
  86. :placeholder="user.companyId == 781 ? '请选择工作任务' : '请选择项目'" @click="clickPicker(index, item)"
  87. :rules="[{ required: true, message: user.companyId == 781 ? '请选择任务' : '请选择项目' }]" />
  88. <!--昱众不显示子项目-->
  89. <van-field readonly name="subProjectId" :disabled="!item.canEdit"
  90. v-if="user.companyId != yuzhongCompId && item.subProjectList != null && item.subProjectList.length > 0 && user.timeType.mainProjectState != 1"
  91. clickable :value="item.subProjectName" label="子项目" placeholder="请选择子项目"
  92. @click="clickPickSubProject(index, item)" />
  93. <van-popup v-model="item.showPickerSubProject" position="bottom">
  94. <van-picker show-toolbar :columns="item.subProjectList" value-key="name" @confirm="choseSubProject"
  95. @cancel="item.showPickerSubProject = false; $forceUpdate();" />
  96. </van-popup>
  97. <van-field readonly name="extraField1" v-if="user.companyId == yuzhongCompId" clickable
  98. :value="item.extraField1Name" label="角色选择" placeholder="请选择担任的角色" :disabled="!item.canEdit"
  99. @click="clickPickProjectRole(index, item)" />
  100. <van-popup v-model="item.showPickerRole" position="bottom">
  101. <van-picker show-toolbar :columns="roleList" value-key="label" @confirm="choseRole"
  102. @cancel="item.showPickerRole = false; $forceUpdate();" />
  103. </van-popup>
  104. <!--任务分组 -->
  105. <van-field readonly name="groupId" :disabled="!item.canEdit"
  106. v-if="user.company.packageProject == 1 && item.taskGroups != null && item.taskGroups.length > 0 && (user.company.nonProjectSimple==0 || (user.company.nonProjectSimple==1&& (item.projectId && projectss.filter(p => p.id == item.projectId)[0].isPublic!=1)))"
  107. clickable :rules="[{ required: user.companyId == 3092 ? true : false, message: '请选择任务分组' }]"
  108. :value="item.groupName" label="任务分组" placeholder="请选择任务分组"
  109. @click="clickPickTaskGroup(index, item)" />
  110. <!-- <van-popup v-model="item.showPickerTaskGroup" position="bottom">
  111. <van-picker show-toolbar :columns="item.taskGroups" value-key="name" @confirm="choseTaskGroup"
  112. @cancel="item.showPickerTaskGroup = false; $forceUpdate();" />
  113. </van-popup> -->
  114. <van-popup v-model="item.showPickerTaskGroup" position="bottom" :style="{ height: '80vh' }" @click-overlay="item.showPickerTaskGroup = false;$forceUpdate();">
  115. <div class="groupingSelection">
  116. <div v-for="(taskItem, taskIndex) in item.taskGroups" :key="taskIndex" class="groupingSelectionItem" @click="choseTaskGroup(taskItem, taskIndex)">
  117. {{ taskItem.name }}
  118. </div>
  119. </div>
  120. </van-popup>
  121. <!--工作职责-->
  122. <van-field readonly name="extraField2" v-if="user.companyId == yuzhongCompId" clickable
  123. :value="item.extraField2Name" label="工作职责" placeholder="请选择工作职责" :disabled="!item.canEdit"
  124. @click="clickPickRespon(index, item)" />
  125. <van-popup v-model="item.showPickerRespon" position="bottom">
  126. <van-picker show-toolbar :columns="item.filteredRespList" value-key="jobRespon"
  127. @confirm="onResponseChosen" @cancel="item.showPickerRespon = false; $forceUpdate();" />
  128. </van-popup>
  129. <!--工作内容-->
  130. <van-field readonly name="extraField3" v-if="user.companyId == yuzhongCompId" clickable
  131. :value="item.extraField3Name" label="工作内容" placeholder="请选择工作内容" :disabled="!item.canEdit"
  132. @click="clickPickWorkContent(index, item)" />
  133. <van-popup v-model="item.showPickerWorkContent" position="bottom">
  134. <van-picker show-toolbar :columns="item.workContentList" value-key="workContext"
  135. @confirm="choseWorkContent" @cancel="item.showPickerWorkContent = false; $forceUpdate();" />
  136. </van-popup>
  137. <!--任务阶段 -->
  138. <van-field readonly name="stage" :disabled="!item.canEdit"
  139. v-if="user.companyId != yuzhongCompId && user.company.packageProject == 1 && !user.timeType.hideStages && item.stages != null && item.stages.length > 0"
  140. clickable :value="item.stage" label="投入阶段" placeholder="请选择投入阶段"
  141. @click="clickPickStage(index, item)" />
  142. <van-popup v-model="item.showPickerStage" position="bottom">
  143. <van-picker show-toolbar :columns="item.stages" value-key="stagesName" @confirm="choseStage"
  144. @cancel="item.showPickerStage = false; $forceUpdate();" />
  145. </van-popup>
  146. <!-- 预算来源 -->
  147. <van-field readonly name="basecostId" :disabled="!item.canEdit"
  148. v-if="user.company.packageProject == 1 && reportBasecostList && reportBasecostList.length > 0"
  149. :value="item.basecostName" label="预算来源" placeholder="请选择预算来源"
  150. @click="clickPickCostId(index, item)" />
  151. <van-popup v-model="item.showPickerCostId" position="bottom">
  152. <van-picker show-toolbar :columns="reportBasecostList" value-key="name" @confirm="choseCostId"
  153. @cancel="item.showPickerCostId = false; $forceUpdate();" />
  154. </van-popup>
  155. <!-- 审核人 -->
  156. <template v-if="user.timeType.reportAuditType != 3">
  157. <van-field readonly name="projectAuditorId" :disabled="!item.canEdit"
  158. v-if="item.auditUserList != null && item.auditUserList.length > 0" clickable
  159. :value="item.projectAuditorName" :label="user.companyId == 781 ? '审核人' : '项目审核人'"
  160. placeholder="请选择审核人" @click="clickPickAuditor(index, item)">
  161. <template #input>
  162. <span v-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  163. :openid='item.projectAuditorName'></TranslationOpenDataText></span>
  164. <span v-else>{{ item.projectAuditorName }}</span>
  165. </template>
  166. </van-field>
  167. <van-popup v-model="item.showPickerAuditor" position="bottom">
  168. <van-picker show-toolbar :columns="item.auditUserList" value-key="auditorName"
  169. @confirm="choseAuditor" @cancel="item.showPickerAuditor = false; $forceUpdate();">
  170. <template #option="item">
  171. <span v-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  172. :openid='item.auditorName'></TranslationOpenDataText></span>
  173. <span v-else>{{ item.auditorName }}</span>
  174. </template>
  175. </van-picker>
  176. </van-popup>
  177. </template>
  178. <!-- 自选审批人 -->
  179. <template v-if="user.timeType.reportAuditType == 3">
  180. <van-field readonly clickable label="第一审核人" :disabled="!item.canEdit" @click="auditorClick(index, 'auditorFirst')">
  181. <template #input>
  182. <span v-if="!item.auditorFirst"></span>
  183. <span v-else-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  184. :openid='item.auditorFirst.name'></TranslationOpenDataText></span>
  185. <span v-else>{{ item.auditorFirst.name }}</span>
  186. </template>
  187. </van-field>
  188. <van-field readonly clickable label="第二审核人" :disabled="!item.canEdit" @click="auditorClick(index, 'auditorSec')"
  189. v-if="user.timeType.auditLevel > 1">
  190. <template #input>
  191. <span v-if="!item.auditorSec"></span>
  192. <span v-else-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  193. :openid='item.auditorSec.name'></TranslationOpenDataText></span>
  194. <span v-else>{{ item.auditorSec.name }}</span>
  195. </template>
  196. </van-field>
  197. <van-field readonly clickable label="第三审核人" :disabled="!item.canEdit" @click="auditorClick(index, 'auditorThird')"
  198. v-if="user.timeType.auditLevel > 2">
  199. <template #input>
  200. <span v-if="!item.auditorThird"></span>
  201. <span v-else-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  202. :openid='item.auditorThird.name'></TranslationOpenDataText></span>
  203. <span v-else>{{ item.auditorThird.name }}</span>
  204. </template>
  205. </van-field>
  206. <van-field readonly clickable label="抄送人" @click="auditorClick(index, 'ccUserid')">
  207. <template #input>
  208. <span v-if="!item.ccUserid"></span>
  209. <span v-else-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  210. :openid='item.ccUserid.name'></TranslationOpenDataText></span>
  211. <span v-else>{{ item.ccUserid.name }}</span>
  212. </template>
  213. </van-field>
  214. </template>
  215. <!-- 选人 -->
  216. <van-popup v-model="auditorShow" position="bottom">
  217. <van-search v-model="auditor.searchText" placeholder="输入员工姓名搜索" @search="onSearch"
  218. v-if="user.userNameNeedTranslate != '1'"></van-search>
  219. <div style="minHeight:300px;">
  220. <van-radio-group v-model="auditor.item">
  221. <van-radio v-for="uitem in auditor.searchList" :key="uitem.id" :name="uitem"
  222. style="padding:10px">
  223. <span v-if="user.userNameNeedTranslate == '1'"><TranslationOpenDataText type='userName'
  224. :openid='uitem.name'></TranslationOpenDataText></span>
  225. <span v-else>{{ uitem.name ? uitem.name : '' }}</span>
  226. </van-radio>
  227. </van-radio-group>
  228. <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;"
  229. @click="searchAuditor()">确定</van-button>
  230. </div>
  231. </van-popup>
  232. <!-- 相关维度 -->
  233. <van-field :value="item.weiduName" v-if="item.projectId && user.timeType.customDegreeActive == 1"
  234. readonly name="id" clickable :label="user.timeType.customDegreeName" placeholder="请选择"
  235. @click="clickPickers(index, item)" :disabled="!item.canEdit" />
  236. <!-- <van-popup v-model="item.showPickDegree" position="bottom">
  237. <van-picker show-toolbar :columns="item.wuduList" value-key="name" @confirm="choseProjects"
  238. @cancel="item.showPickDegree = false; $forceUpdate()" />
  239. </van-popup> -->
  240. <van-popup v-model="item.showPickDegree" position="bottom">
  241. <div class="chooseSomeone">
  242. <div class="chooseSomeoneFlex1">
  243. <!-- 复选 -->
  244. <van-radio-group v-model="item.radioPickDegree" v-if="!user.timeType.customDegreeMultiple">
  245. <van-radio v-for="uitem in item.wuduList" :key="uitem.id" :name="uitem" style="padding:10px">
  246. {{ uitem.name ? uitem.name : '' }}
  247. </van-radio>
  248. </van-radio-group>
  249. <!-- 多选 -->
  250. <van-checkbox-group v-model="item.radioPickDegree" v-else>
  251. <van-checkbox v-for="uitem in item.wuduList" :key="uitem.id" :name="uitem" style="padding:10px">
  252. {{ uitem.name ? uitem.name : '' }}
  253. </van-checkbox>
  254. </van-checkbox-group>
  255. </div>
  256. <van-button @click="choseProjects(item.radioPickDegree)">
  257. 确定
  258. </van-button>
  259. </div>
  260. </van-popup>
  261. <!-- 自定义数值 -->
  262. <van-field v-if="user.timeType.customDataActive == 1" type="number" :disabled="!item.canEdit"
  263. v-model="item.customData" :label="user.timeType.customDataName" placeholder="请输入数字"
  264. :rules="user.timeType.customDataStatus == 1 ? [{ required: true, message: '请输入' + user.timeType.customDataName }] : []"></van-field>
  265. <!-- 自定义文本 -->
  266. <van-field v-if="user.timeType.customTextActive == 1" :disabled="!item.canEdit"
  267. v-model="item.customText" :label="user.timeType.customTextName" placeholder="请输入" maxlength="1000"
  268. :rules="user.timeType.customTextStatus ? [{ required: true, message: '请选择' + user.timeType.customTextName }] : []"
  269. rows="2" type="textarea" show-word-limit autosize></van-field>
  270. <van-cell title="专业进度" v-if="user.company.packageEngineering == 1">
  271. </van-cell>
  272. <van-field :disabled="!item.canEdit" type="number" :name="'progress_' + pItem.professionId"
  273. input-align="right" v-for="pItem in item.professionProgress" :key="pItem.professionId"
  274. :label="'-- ' + pItem.professionName">
  275. <template slot="input">
  276. <van-stepper v-model="pItem.progress" integer min="0" max="100" />%
  277. </template>
  278. </van-field>
  279. <van-field v-if="user.company.packageProject == 1 && !user.timeType.hideTask && (user.company.nonProjectSimple==0 || (user.company.nonProjectSimple==1&& (item.projectId && projectss.filter(p => p.id == item.projectId)[0].isPublic!=1)))" readonly name="taskId" :value="item.taskName"
  280. :rules="[{ required: reportTimeType.taskRequired? true : false, message: '请选择任务/里程碑' }]" label="任务/里程碑" :disabled="!item.canEdit"
  281. placeholder="请选择任务/里程碑" @click="clickPickerTask(index, item)"></van-field>
  282. <van-field v-if="user.companyId == 3092" readonly name="sapServiceId" :value="item.sapServiceName"
  283. :rules="[{ required: true, message: '请选择服务' }]" label="服务" placeholder="请选择服务"
  284. @click="clickPickerService(index, item)"></van-field>
  285. <van-field name="taskFinish" label="是否已完成" v-if="item.taskId != null">
  286. <template #input>
  287. <van-checkbox :disabled="!item.canEdit" v-model="item.taskFinish"
  288. shape="square">已完成</van-checkbox>
  289. </template>
  290. </van-field>
  291. <van-popup v-model="item.showPickerTask" position="bottom">
  292. <van-picker show-toolbar :columns="item.taskList" value-key="taskName" @confirm="choseTask"
  293. @cancel="item.showPickerTask = false; $forceUpdate()" />
  294. </van-popup>
  295. <van-popup v-model="item.showPickerService" position="bottom">
  296. <van-picker show-toolbar :columns="item.serviceList" value-key="serviceName" @confirm="choseService"
  297. @cancel="item.showPickerService = false; $forceUpdate()" />
  298. </van-popup>
  299. <!-- <van-field readonly clickable class="form_input" :value="item.workingTime" name="workingTime" label="工作时长" placeholder="请输入工作时长(单位:小时)"
  300. :rules="[{ required: true, message: '请输入工作时长(单位:小时)' }]" @touchstart.native.stop="showNumberKey = true"/>
  301. <van-number-keyboard v-model="item.workingTime" :show="showNumberKey" close-button-text="完成" extra-key="." :maxlength="4" @blur="showNumberKey = false" /> -->
  302. <!-- 常规选择时间的方式 -->
  303. <!-- 全天上下午模式 -->
  304. <div v-if="reportTimeType.multiWorktime == 0">
  305. <van-field v-if="reportTimeType.type < 2" readonly clickable :disabled="!item.canEdit"
  306. :value="reportTimeType.type == 0 ? item.label : (parseFloat(item.workingTime).toFixed(1) + 'h')"
  307. label="工作时长" placeholder="请选择工作时长(小时)" @click="clickTimePicker(index, item)"
  308. :rules="[{ required: true, message: '请选择工作时长' }]" />
  309. <van-popup v-model="showPickerTime" position="bottom">
  310. <van-picker show-toolbar :columns="timeType" value-key="label" @confirm="choseTimePick"
  311. @cancel="showPickerTime = false" />
  312. </van-popup>
  313. <!-- 选择数字时间长度模式 -->
  314. <van-popup v-model="showPickerHours" position="bottom">
  315. <van-picker show-toolbar :columns="timeRange" :default-index="15" @confirm="choseTimePick"
  316. @cancel="showPickerHours = false" />
  317. </van-popup>
  318. <!-- 时间段选择模式 -->
  319. <van-field readonly v-if="reportTimeType.type == 2" clickable name="datetimePicker"
  320. :value="item.startTime" label="开始时间" placeholder="点击选择时间"
  321. @click="item.canEdit ? showStartTime = true : '', dailyIndex = index" :disabled="!item.canEdit"
  322. :rules="[{ required: true, message: '请选择开始时间' }]" />
  323. <van-popup v-model="showStartTime" position="bottom">
  324. <van-datetime-picker v-model="startTime" type="time" @confirm="confirmTime(item, 0);"
  325. @cancel="showStartTime = false" :min-hour="0" :max-hour="23" />
  326. <!-- :filter="filter" 原本这个属性在里面 -->
  327. </van-popup>
  328. <van-field v-if="reportTimeType.type == 2" readonly clickable name="datetimePicker"
  329. :value="item.endTime" label="结束时间" placeholder="点击选择时间"
  330. @click="item.canEdit ? showEndTime = true : '', dailyIndex = index" :disabled="!item.canEdit"
  331. :rules="[{ required: true, message: '请选择结束时间' }]" />
  332. <van-popup v-model="showEndTime" position="bottom">
  333. <van-datetime-picker v-model="endTime" type="time" :min-hour="0" :max-hour="23"
  334. @confirm="confirmTime(item, 1)" @cancel="showEndTime = false" />
  335. <!-- :filter="filter" 原本这个属性在里面 -->
  336. </van-popup>
  337. <van-cell v-if="reportTimeType.type == 3">
  338. <template>
  339. <div>
  340. <span>用时占比</span>
  341. <van-slider :disabled="!item.canEdit" :min="0" :step="5"
  342. style="width:120px;display:inline-block;margin-left:50px;" v-model="item.progress"
  343. :value="100"
  344. @change="item.workingTime = (reportTimeType.allday * item.progress / 100).toFixed(1), setTotalReportHours()">
  345. <template #button>
  346. <div class="custom-button">{{ item.progress }}%</div>
  347. </template>
  348. </van-slider>
  349. <span style="margin-left:10px;float:right;">{{ item.workingTime }}小时</span>
  350. </div>
  351. </template>
  352. </van-cell>
  353. <van-field class="form_input" :disabled="!item.canEdit" v-model="item.content" name="content"
  354. type="textarea" :label="user.companyId == 781 ? '具体内容与结果' : '工作事项'" placeholder="请输入"
  355. :rules="user.timeType.workContentState == 1 ? [{ required: true, message: '请填写工作事项' }] : null"
  356. rows="3" autosize />
  357. </div>
  358. <!-- 多个时间和工作事项的选择方式 -->
  359. <div v-if="reportTimeType.multiWorktime == 1">
  360. <div v-for="(timeItem, tindex) in item.worktimeList" :key="tindex"
  361. style="position:relative;border:#ccc 0.5px solid;margin:7px;">
  362. <van-tag v-if="tindex > 0 && item.canEdit"
  363. style="position:absolute; right:-7px;top:-7px;z-index:10;"
  364. @click="removeTimeItem(item, tindex)">X</van-tag>
  365. <!-- 时间段选择模式 -->
  366. <van-field readonly v-if="reportTimeType.type == 2" :clickable="item.canEdit"
  367. name="datetimePicker" :value="timeItem.startTime" label="开始时间" placeholder="点击选择时间"
  368. :rules="[{ required: true, message: '必填项' }]"
  369. @click="item.canEdit ? showStartDialog(timeItem) : ''" />
  370. <van-field v-if="reportTimeType.type == 2" readonly :clickable="canEdit" name="datetimePicker"
  371. :value="timeItem.endTime" label="结束时间" placeholder="点击选择时间"
  372. :rules="[{ required: true, message: '必填项' }]"
  373. @click="item.canEdit ? showEndDialog(timeItem) : ''" />
  374. <van-field v-if="multiOptionData.length>0" readonly :clickable="canEdit" name="multiTimePicker"
  375. :value="timeItem.detail" label="细项" placeholder="点击选择"
  376. :rules="[{ required: true, message: '必填项' }]"
  377. @click="item.canEdit ? showChooseDetail(timeItem) : ''" />
  378. <!-- 工作细项, 美莱德 -->
  379. <van-popup v-model="showMultiOpPicker" position="bottom">
  380. <van-picker show-toolbar :columns="multiOptionData" :default-index="1" @confirm="choseMultiOptionPick"
  381. @cancel="showMultiOpPicker = false" />
  382. </van-popup>
  383. <van-field class="form_input" :disabled="!item.canEdit"
  384. style="color:#333;-webkit-text-fill-color:#646566;" v-model="timeItem.content"
  385. name="content" type="textarea" label="工作事项" placeholder="请输入工作事项"
  386. :rules="user.timeType.workContentState == 1 ? [{ required: true, message: '请填写工作事项' }] : null"
  387. rows="1" autosize />
  388. </div>
  389. <!--时间选择器 , 做统一处理,不能放到循环里,不然会有多个公用showStartTime,最后一个会现在最上层UI,导致BUG -->
  390. <van-popup v-model="showWorkStartTime" position="bottom">
  391. <van-datetime-picker v-model="startTime" type="time" @confirm="confirmWorkTime(0);"
  392. @cancel="showWorkStartTime = false" :min-hour="0" :max-hour="23" />
  393. <!-- :filter="filter" 原本这个属性在里面 -->
  394. </van-popup>
  395. <van-popup v-model="showWorkEndTime" position="bottom">
  396. <van-datetime-picker v-model="endTime" type="time" :min-hour="0" :max-hour="23"
  397. @confirm="confirmWorkTime(1)" @cancel="showWorkEndTime = false" />
  398. <!-- :filter="filter" 原本这个属性在里面 -->
  399. </van-popup>
  400. </div>
  401. <div style="width:100%;" v-if="item.canEdit && reportTimeType.multiWorktime == 1">
  402. <van-tag style="text-align:center;padding:5px;margin-left:15px;border: 1px solid #20a0ff;"
  403. :disabled="!item.canEdit" @click="addNewWorktime(index, item)" icon="plus" color="#ffffff"><span
  404. style="color:#999;text-align:center;padding: 0 5px;"> 添加工时 </span></van-tag>
  405. </div>
  406. <div class="overtime"
  407. v-if="((user.timeType.fillOvertime || (isWeekend && user.timeType.lockWorktime != 1)) || (isCorpWX && canEdit))">
  408. <div class="overTimeClas"
  409. v-if="user.timeType.fillOvertime || (isWeekend && user.timeType.lockWorktime != 1)">
  410. <van-checkbox :disabled="!item.canEdit" v-model="item.isOvertime"
  411. style="width: 4.3rem;">含加班</van-checkbox>
  412. <van-field v-model="item.overtimeHours" type="number"
  413. :disabled="!item.canEdit || item.isOvertime == null || item.isOvertime == 0 || !item.isOvertime"
  414. placeholder="请输入加班时长" style="width: 5.2rem" @input="$forceUpdate()"></van-field>
  415. <span :class="item.canEdit ? 'overListTime' : 'overListTime hoveOver'">小时</span>
  416. </div>
  417. <van-tag style="position:absolute;right:10px;" v-if="user.companyId != 4281 && isCorpWX && item.canEdit" type="primary"
  418. size="large" @click="takePhoto(index)">拍照上传</van-tag>
  419. <!-- <van-tag style="position:absolute;right:10px;" type="primary" size="large" @click="takePhoto(index)">拍照上传</van-tag> -->
  420. <!-- <van-tag style="position:absolute;right:10px;" type="primary" size="large" @click="takePhoto(index)">拍照上传</van-tag> -->
  421. </div>
  422. <div style="padding:5px;text-align:center;" v-if="!isIOSystem">
  423. <span v-for="(p, index) in item.pics" :key="p" style="margin-right:15px;">
  424. <div class="imgList">
  425. <van-icon v-if="item.canEdit && user.companyId == 7" size="20" name="clear"
  426. @click="deleteImg(item, index)" class="imgList_i" />
  427. <img :src="p" style="width:100px; height:100px;" @click="showLargeImg(item.pics, index)" />
  428. </div>
  429. </span>
  430. </div>
  431. <div style="padding:5px;text-align:center;" v-if="isIOSystem">
  432. <span v-for="(p, index) in item.iospics" :key="p" style="margin-right:15px;">
  433. <div class="imgList">
  434. <van-icon v-if="item.canEdit && user.companyId == 7" size="20" name="clear"
  435. @click="deleteImg(item, index)" class="imgList_i" />
  436. <img :src="p" style="width:100px; height:100px;"
  437. @click="showLargeImg(item.iospics, index)" />
  438. </div>
  439. </span>
  440. </div>
  441. <van-popup v-model="imgShow" position="bottom" closeable>
  442. <van-swipe class="my-swipe" indicator-color="white">
  443. <van-swipe-item v-for="(picItem, index) in tmpPics" :key="index">
  444. <img :src="picItem" style="width:100%;" />
  445. </van-swipe-item>
  446. </van-swipe>
  447. </van-popup>
  448. </van-cell-group>
  449. </div>
  450. <div style="text-align:center;" v-if="canEdit">
  451. <van-tag size="large"
  452. style="text-align:center;margin:10px;padding:12px;margin-bottom:120px;border: 1px solid #20a0ff;"
  453. @click="addNewPro" icon="plus" color="#ffffff"><span
  454. style="color:#999;text-align:center;padding: 0 50px;"> + 新增{{ user.companyId == 781 ? '任务' : '项目' }}
  455. </span></van-tag>
  456. <!-- <van-button id="btn-start-recording" @click="startRecording">录音</van-button>
  457. <van-button id="btn-stop-recording" @click="stopRecording">停止</van-button>
  458. <van-button id="btn-play-recording" @click="getRecording">获取文件</van-button> -->
  459. </div>
  460. <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
  461. <div style="padding-bottom:10px;" v-if="!substitute">
  462. <van-button v-if="canEdit" square block type="info" @click="isDraft = 0; submitReport()"
  463. native-type="submit" style="width: 50%;float:left;">
  464. <div v-if="flgLg">提交</div>
  465. <van-loading type="spinner" v-if="!flgLg" />
  466. </van-button>
  467. <van-button v-if="canEdit" square block type="default" @click="isDraft = 1; submitReport()"
  468. native-type="submit" style="width:50%;float:left;">
  469. <div v-if="flgLg">暂存</div>
  470. <van-loading type="spinner" v-if="!flgLg" />
  471. </van-button>
  472. </div>
  473. <div style="padding-bottom:10px;" v-if="substitute">
  474. <van-button v-if="canEdit" square block type="info" @click="isDraft = 0; submitReport()"
  475. native-type="submit">
  476. <div v-if="flgLg">提交</div>
  477. <van-loading type="spinner" v-if="!flgLg" />
  478. </van-button>
  479. </div>
  480. <van-button v-if="canDeleteReport" square block type="default" @click="deleteReport" native-type="button"
  481. style=""> 删除 </van-button>
  482. <van-button v-if="canCancelInDialog" block type="default" @click="cancel"> 撤回 </van-button>
  483. <!-- <div v-if="canEdit&&form.domains.length>0 && form.domains[0].id != null"
  484. style="display:block;padding-top:30px;font-size:15px;color:#666;margin:0 auto;text-align:center;padding-bottom:10px;background:#ffffff;"
  485. @click="deleteReport"> 删除 </div> -->
  486. <!-- <van-button v-if="canEdit" square block type="default" @click="deleteReport" native-type="button"
  487. style="margin-top:10px;"> 删除 </van-button> -->
  488. </div>
  489. </van-form>
  490. <div class="form_tip" v-if="!canEdit && !canCancel"> 已审核无法修改 </div>
  491. <!-- 选择项目弹窗 -->
  492. <van-popup v-model="showPickerUserddp" position="bottom" style="height: 84%">
  493. <div class="popupDiv">
  494. <!-- <van-search v-model="userName" placeholder="请输入项目名称/编号" @clear="sea()" @blur="sea()" @search="sea()" @input="sea()"/> -->
  495. <div class="popupSearch">
  496. <van-search v-model="userName" shape="round" background="#F4F4F4" placeholder="请输入项目名称/编号"
  497. @clear="sea()" @blur="sea()" @search="sea()" @input="sea()" />
  498. </div>
  499. <div class="popupCon">
  500. <!-- <div class="ryuan" style="color: rgb(185 185 185);">近期选择项目</div>
  501. <div v-for="(item, index) in integrationProjectList" :key="index" class="ryuan" @click="fZr(item, index)">
  502. <p>{{item.projectName}}</p>
  503. <p style="margin-top: 5px;color: #9697B2;">{{item.projectCode}}</p>
  504. </div>
  505. <div class="ryuan" style="color: rgb(185 185 185);">全部项目</div>
  506. <div v-for="(item, index) in projectss" :key="item.id" class="ryuan" @click="fZr(item, index)">
  507. <p>{{item.projectName}}</p>
  508. <p style="margin-top: 5px;color: #9697B2;">{{item.projectCode}}</p>
  509. </div> -->
  510. <div class="popupTitle">近期选择项目</div>
  511. <div v-for="(item, index) in integrationProjectList" :key="index" class="popupItem paddingDiv"
  512. @click="fZr(item, index)">
  513. <div class="popupItemOne" v-if="item.projectName">{{ item.projectName }}</div>
  514. <p class="popupItemTwo" v-if="item.projectCode">{{ item.projectCode }}</p>
  515. </div>
  516. <div class="popupTitle marginTop">全部项目</div>
  517. <div v-for="(item, index) in projectss" :key="item.id" class="popupItem paddingDiv"
  518. @click="fZr(item, index)">
  519. <div class="popupItemOne" v-if="item.projectName">{{ item.projectName }}</div>
  520. <p class="popupItemTwo" v-if="item.projectCode">{{ item.projectCode }}</p>
  521. </div>
  522. <!-- <div class="popupTitle paddingDiv">全部项目</div> -->
  523. </div>
  524. </div>
  525. </van-popup>
  526. <van-popup v-model="showSelectDeptPopup" position="bottom" style="height: 84%">
  527. <div class="popupDiv">
  528. <div class="popupCon">
  529. <div v-for="(item, index) in userReportDeptList" :key="item.value" class="popupItem paddingDiv"
  530. @click="selectedDeptId(item, index)">
  531. <p class="popupItemOne">
  532. <TranslationOpenDataText type='departmentName' :openid='item.departmentName'></TranslationOpenDataText>
  533. </p>
  534. </div>
  535. </div>
  536. </div>
  537. </van-popup>
  538. </div>
  539. </template>
  540. <script>
  541. import timetoolVue from '../timetool/timetool.vue';
  542. // Vue.prototype.$wx = wx
  543. // import { Recorder } from '../../assets/record/recorder'
  544. // var recorder = null
  545. export default {
  546. data() {
  547. return {
  548. roleList: [{ value: 1, label: 'CRC&LM' }, { value: 2, label: 'PM' }],
  549. jobResponseList: [],
  550. yuzhongCompId: 3385,
  551. dailyIndex: 0,
  552. integrationProjectList: [],
  553. cardRefLoading: false,
  554. today: '',
  555. hasWrittenReport: false,
  556. showPickerStage: false,
  557. showPickerTaskGroup: false,
  558. showPickerSubProject: false,
  559. showPickerCostId: false,
  560. isDraft: 0,
  561. showWorkStartTime: false,
  562. showWorkEndTime: false,
  563. curWorktime: null,
  564. isIOSystem: false,
  565. imgShow: false,
  566. isCorpWX: false,
  567. isWX: false,
  568. showPickerTask: false,
  569. canCancel: false,
  570. canDeleteReport: false,
  571. canCancelInDialog: false,
  572. canEdit: false,
  573. showEndTime: false,
  574. showStartTime: false,
  575. startTime: '09:00',
  576. endTime: '18:00',
  577. nowTime: new Date(),
  578. showPickerHours: false,
  579. timeRange: [],
  580. selectTime: null,
  581. reportTimeType: {},
  582. user: JSON.parse(localStorage.userInfo),
  583. minDate: new Date(2010, 0, 1),
  584. maxDate: new Date(),
  585. currentDate: new Date(),
  586. showPickerTime: false,
  587. showPicker: false,
  588. showPickerProject: false,
  589. showPickDegree: false,
  590. clickIndex: 0,
  591. clickTimeIndex: 0,
  592. showNumberKey: false,
  593. canClick: 2,
  594. timeType: [],
  595. form: {
  596. createDate: this.format(new Date(new Date()), "yyyy-MM-dd"),
  597. domains: [{
  598. id: null,
  599. projectId: "",
  600. projectName: "",
  601. workingTime: "",
  602. content: "",
  603. state: 2,
  604. multiWorktime: 0,
  605. worktimeList: {},
  606. degreeId: ''
  607. // pics:["https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",
  608. // "https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",
  609. // "https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",]
  610. }],
  611. },
  612. rules: {
  613. createDate: [{ required: true, message: '请选择填报日期' }],
  614. },
  615. project: [],
  616. report: {},
  617. showMultiOpPicker: false,
  618. loading: false,
  619. finished: false,
  620. // isOvertime: false
  621. tmpPics: [],
  622. dateAr: [],
  623. showPickerUserddp: false, // 选择项目弹窗
  624. projectss: [],
  625. proads: [],
  626. userName: '',
  627. flgLg: true,
  628. reportBasecostList: [],
  629. isWeekend: false,
  630. multiOptionData:[],
  631. auditorShow: false,
  632. auditor: {
  633. index: 0,
  634. auditorIndex: 'auditorFirst',
  635. searchText: '',
  636. item: {},
  637. list: [],
  638. searchList: []
  639. },
  640. // vacationTime: {},
  641. totalReportHours: 0,
  642. // leftDataList:[],
  643. // rightDataList:[],
  644. substitute: false, // 是否为代填日报
  645. fillingAgent: {
  646. name: '',
  647. id: ''
  648. }, // 代填人员信息
  649. userReportDeptList: [], // 可选部门
  650. showSelectDeptPopup: false
  651. };
  652. },
  653. created() {
  654. },
  655. watch: {},
  656. computed: {
  657. // totalReportHours(){
  658. // let domains = this.form.domains
  659. // let hours = 0
  660. // for(let i in domains){
  661. // if(domains[i].projectId){
  662. // // hours += parseFloat(domains[i].workingTime)
  663. // if(this.reportTimeType.multiWorktime == 1){
  664. // for(let m in domains[i].worktimeList){
  665. // if(domains[i].worktimeList[m].startTime && domains[i].worktimeList[m].endTime){
  666. // hours += this.getHour(domains[i].worktimeList[m].startTime, domains[i].worktimeList[m].endTime)
  667. // }
  668. // }
  669. // }else{
  670. // if(this.user.timeType.type == 2){
  671. // if(domains[i].startTime && domains[i].endTime){
  672. // let selectionTime = this.getHour(domains[i].startTime, domains[i].endTime)
  673. // let subtractedData = 0
  674. // let arr = JSON.parse(JSON.stringify(this.vacationTime))
  675. // arr.unshift({s: domains[i].startTime, e: domains[i].endTime})
  676. // for(var j in arr) {
  677. // subtractedData += +this.timeOverlap(j, arr)
  678. // }
  679. // console.log(selectionTime, subtractedData)
  680. // hours += +selectionTime - +subtractedData
  681. // console.log(hours)
  682. // }
  683. // } else {
  684. // hours += domains[i].workingTime ? parseFloat(domains[i].workingTime) : 0
  685. // }
  686. // }
  687. // }
  688. // }
  689. // return hours.toFixed(2)
  690. // },
  691. },
  692. methods: {
  693. //选中角色
  694. choseRole(value, index) {
  695. if (value) {
  696. this.form.domains[this.clickIndex].extraField1 = value.value;
  697. this.form.domains[this.clickIndex].extraField1Name = value.label;
  698. }
  699. this.form.domains[this.clickIndex].showPickerRole = false;
  700. this.updateResponse(this.form.domains[this.clickIndex]);
  701. this.$forceUpdate();
  702. },
  703. choseWorkContent(value, index) {
  704. if (value) {
  705. this.form.domains[this.clickIndex].extraField3 = value.id;
  706. this.form.domains[this.clickIndex].extraField3Name = value.workContext;
  707. }
  708. this.form.domains[this.clickIndex].showPickerWorkContent = false;
  709. this.$forceUpdate();
  710. },
  711. onResponseChosen(value, index) {
  712. if (value) {
  713. this.form.domains[this.clickIndex].extraField2 = value.id;
  714. this.form.domains[this.clickIndex].extraField2Name = value.jobRespon;
  715. this.form.domains[this.clickIndex].extraField3 = null;
  716. this.form.domains[this.clickIndex].extraField3Name = null;
  717. }
  718. this.form.domains[this.clickIndex].showPickerRespon = false;
  719. this.updateJobContent(this.form.domains[this.clickIndex]);
  720. },
  721. clickPickWorkContent(i, item) {
  722. if (!item.canEdit) return;
  723. this.clickIndex = i;
  724. item.showPickerWorkContent = true;
  725. this.$forceUpdate();
  726. },
  727. clickPickRespon(i, item) {
  728. if (!item.canEdit) return;
  729. this.clickIndex = i;
  730. item.showPickerRespon = true;
  731. this.$forceUpdate();
  732. },
  733. //更新工作内容列表
  734. updateJobContent(domainItem) {
  735. var that = this;
  736. this.$axios.post('/project/getFunWorkContextList', { id: domainItem.extraField2 })
  737. .then(res => {
  738. if (res.code == 'ok') {
  739. that.$set(domainItem, 'extraField3', null);
  740. that.$set(domainItem, 'workContentList', res.data);
  741. }
  742. }).catch(err => { })
  743. },
  744. updateResponse(domainItem) {
  745. console.log(111);
  746. var that = this;
  747. var selectPid = domainItem.projectId;
  748. domainItem.extraField2 = null;
  749. domainItem.extraField3 = null;
  750. domainItem.extraField2Name = null;
  751. domainItem.extraField3Name = null;
  752. if (selectPid && domainItem.extraField1) {
  753. //是否非项目
  754. var isPublic = this.projectss.filter(p => p.id == selectPid)[0].isPublic;
  755. console.log('==========', 'isPublic==' + isPublic);
  756. var filteredRespList = this.jobResponseList.filter(j => j.timeType == (isPublic ? '非项目工时' : '项目工时') && j.role == (this.roleList.filter(r => r.value == domainItem.extraField1)[0].label));
  757. domainItem.filteredRespList = filteredRespList;
  758. }
  759. },
  760. getJobResponList() {
  761. this.$axios.post('/project/getFunctionalDivisionList', {})
  762. .then(res => {
  763. if (res.code == 'ok') {
  764. this.jobResponseList = res.data;
  765. }
  766. }).catch(err => { })
  767. },
  768. getRecentlyProject(userId) {
  769. this.$axios.post('/project/nearProject', {userId: userId})
  770. .then(res => {
  771. if (res.code == 'ok') {
  772. this.integrationProjectList = res.data;
  773. //去掉全部项目中没有的
  774. this.setTimeout(() => {
  775. this.integrationProjectList = this.integrationProjectList.filter(near => this.getProjectAuditorList.find(pItem => pItem.id == near.id) != null);
  776. }, 1000);
  777. }
  778. }).catch(err => { this.$toast.clear(); this.cardRefLoading = false; })
  779. },
  780. // 判断两个时间段是否重叠
  781. timeOverlap(idx, dateAr) {
  782. let zhi = 0
  783. for (let k in dateAr) {
  784. if (idx !== k) {
  785. if (((dateAr[k].s <= dateAr[idx].s && dateAr[k].e >= dateAr[idx].s) || (dateAr[k].s <= dateAr[idx].s && dateAr[k].e <= dateAr[idx].e))) {
  786. // 选择的时间包含设置的休息时间段 (选择的开始时间和结束时间大于设置的休息时间段)
  787. if (dateAr[idx].s > dateAr[k].s && dateAr[idx].e < dateAr[k].e) {
  788. // zhi += 2
  789. zhi += +this.getHour(dateAr[idx].s, dateAr[idx].e)
  790. }
  791. // 选择的时间包含在设置的休息时间 (选择的开始时间和结束时间都处于在设置的休息时间段内)
  792. if (dateAr[idx].s > dateAr[k].s && dateAr[idx].e > dateAr[k].e) {
  793. zhi += +this.getHour(dateAr[idx].s, dateAr[k].e)
  794. } else if (dateAr[idx].s < dateAr[k].s && dateAr[idx].e > dateAr[k].e) {
  795. zhi += +this.getHour(dateAr[k].e, dateAr[idx].s)
  796. } else {
  797. // 选择的结束时间处于设置的休息时间段内 (选择的结束时间处于的休息时间段)
  798. if (dateAr[k].e < dateAr[idx].e && dateAr[k].e > dateAr[idx].s) {
  799. zhi += +this.getHour(dateAr[k].e, dateAr[idx].e)
  800. }
  801. // 选择的开始时间处于设置的休息时间段内 (选择的开始时间处于的休息时间段)
  802. if (dateAr[idx].s > dateAr[k].s && dateAr[idx].s < dateAr[k].e) {
  803. zhi += +this.getHour(dateAr[k].e, dateAr[idx].s)
  804. }
  805. }
  806. }
  807. }
  808. }
  809. return zhi
  810. },
  811. getHour(s1, s2) {
  812. var reDate = /\d{4}-\d{1,2}-\d{1,2} /;
  813. s1 = new Date((reDate.test(s1) ? s1 : '2018-1-1 ' + s1).replace(/-/g, '/'));
  814. s2 = new Date((reDate.test(s2) ? s2 : '2018-1-1 ' + s2).replace(/-/g, '/'));
  815. var ms = s2.getTime() - s1.getTime();
  816. if (ms < 0) return 0;
  817. let ma = ms / 1000 / 60 / 60
  818. return ma; //小时
  819. },
  820. cardtimeRefresh(workdate) { // 考勤记录刷新
  821. if (!workdate) return;
  822. this.cardRefLoading = true;
  823. this.$axios.post('/user-corpwx-time/getPunchRecordBySelf', {
  824. date: workdate
  825. })
  826. .then(res => {
  827. if (res.code == 'ok') {
  828. this.cardRefLoading = false;
  829. this.report.time = res.data.time;
  830. } else {
  831. this.cardRefLoading = false;
  832. this.$toast.fail('获取失败:' + res.msg);
  833. }
  834. }).catch(err => { this.$toast.clear(); this.cardRefLoading = false; })
  835. },
  836. auditorClick(domainIndex, auditorIndex) {
  837. if (this.canEdit) {
  838. this.auditor.index = domainIndex
  839. this.auditor.auditorIndex = auditorIndex
  840. this.auditor.searchList.forEach(u => {
  841. if (this.form.domains[domainIndex][auditorIndex] && u.id == this.form.domains[domainIndex][auditorIndex].id) {
  842. this.auditor.item = u
  843. }
  844. })
  845. this.auditorShow = true
  846. }
  847. },
  848. onSearch(val) {
  849. console.log(val);
  850. this.auditor.searchList = [];
  851. this.auditor.list.forEach(u => {
  852. if (u.name.startsWith(val)) {
  853. this.auditor.searchList.push(u);
  854. }
  855. })
  856. },
  857. searchAuditor() {
  858. if(!this.substitute) {
  859. this.form.domains[this.auditor.index][this.auditor.auditorIndex] = this.auditor.item
  860. }
  861. this.auditorShow = false
  862. if(this.substitute) {
  863. const { id, name } = this.auditor.item
  864. this.fillingAgent = { id, name }
  865. this.getProject(this.fillingAgent.id);
  866. this.getTargetUserCardTime();
  867. }
  868. },
  869. getAllUsersList() {
  870. this.$axios.post('/user/getSimpleActiveUserList', {})
  871. .then(res => {
  872. if (res.code == 'ok') {
  873. this.auditor.list = res.data
  874. this.auditor.searchList = res.data
  875. } else {
  876. this.$toast.fail('获取失败:' + res.msg);
  877. }
  878. }).catch(err => { this.$toast.clear(); })
  879. },
  880. requiredRule(val) {
  881. console.log('requiredRule', val);
  882. return false
  883. },
  884. // 获取预算来源
  885. getReportBasecostList() {
  886. this.$axios.post('/project-basecost-setting/getReportBasecostList', {
  887. companyId: this.user.companyId
  888. }).then(res => {
  889. if (res.code == 'ok') {
  890. this.reportBasecostList = res.data
  891. } else {
  892. this.$toast.fail('获取失败:' + res.msg);
  893. }
  894. }).catch(err => { this.$toast.clear(); })
  895. },
  896. //获取项目审核人
  897. getProjectAuditorList(domainItem) {
  898. this.$axios.post("/project-auditor/getList", { projectId: domainItem.projectId })
  899. .then(res => {
  900. if (res.code == "ok") {
  901. domainItem.auditUserList = res.data;
  902. if (res.data.length == 1) {
  903. domainItem.projectAuditorId = domainItem.auditUserList[0].auditorId;
  904. domainItem.projectAuditorName = domainItem.auditUserList[0].auditorName;
  905. }
  906. this.$forceUpdate();
  907. } else {
  908. this.$toast.fail('获取失败:' + res.msg);
  909. }
  910. }).catch(err => { this.$toast.clear(); });
  911. },
  912. updateTxt() {
  913. this.$forceUpdate();
  914. },
  915. // 获取项目
  916. getProject(userId) {
  917. this.$axios.post("/project/getProjectList", { forReport: 1, userId: userId})
  918. .then(res => {
  919. if (res.code == "ok") {
  920. for (var i in res.data) {
  921. if (res.data[i].projectCode == 'null' || res.data[i].projectCode == null) {
  922. res.data[i].projectCode = ' '
  923. }
  924. }
  925. this.projectss = res.data;
  926. this.project = res.data;
  927. this.projectss = this.projectss.filter(p => p.status == 1 || p.status == 4);
  928. this.proads = res.data
  929. this.getRecentlyProject(userId)
  930. } else {
  931. this.$toast.fail('获取失败:' + res.msg);
  932. }
  933. }).catch(err => { this.$toast.clear(); });
  934. },
  935. sea() {
  936. // console.log(this.userName.length)
  937. if (this.userName.length > 0) {
  938. // let text = this.userName
  939. // let reg = new RegExp(text)
  940. // let data = this.proads.filter(item => reg.test(item.projectName)) //返回
  941. // let datas = this.proads.filter(item => reg.test(item.projectCode))
  942. // let dataTree = data.concat(datas)
  943. // let arrList = Array.from(new Set(dataTree))
  944. // this.projectss = arrList
  945. // console.log(this.userName.toUpperCase())
  946. let data = this.proads.filter(item => { return item.projectName.indexOf(this.userName.toUpperCase()) != '-1' });
  947. let dataList = this.proads.filter(item => { return item.projectCode.indexOf(this.userName.toUpperCase()) != '-1' });
  948. let dataTree = data.concat(dataList)
  949. let arrList = Array.from(new Set(dataTree))
  950. this.projectss = arrList
  951. } else {
  952. // console.log(456)
  953. this.projectss = this.proads
  954. }
  955. },
  956. selectDegreeId(domain, index, domainItem, list) {
  957. this.$axios.post("/report/defaultDegree", {
  958. projectId: domain.id
  959. })
  960. .then(res => {
  961. if (res.code == "ok") {
  962. var arr = domainItem.wuduList
  963. for (var i in arr) {
  964. if (arr[i].id == res.data.id) {
  965. domainItem.weiduName = arr[i].name
  966. domainItem.degreeId = res.data.id
  967. }
  968. }
  969. this.$forceUpdate();
  970. } else {
  971. this.$toast.fail('获取失败:' + res.msg);
  972. }
  973. }).catch(err => { this.$toast.clear(); });
  974. },
  975. fZr(item, index) {
  976. var domainItem = this.form.domains[this.clickIndex];
  977. domainItem.projectId = item.id;
  978. domainItem.projectName = item.projectName;
  979. //清空子项目
  980. domainItem.subProjectId = null;
  981. domainItem.subProjectName = null;
  982. //清空任务
  983. domainItem.taskId = null;
  984. domainItem.taskName = null;
  985. //清空分组和阶段
  986. domainItem.stage = null;
  987. domainItem.groupId = null;
  988. domainItem.weiduName = null;
  989. this.showPickerUserddp = false;
  990. //获取子项目
  991. if (this.user.timeType.mainProjectState != 1) {
  992. this.getSubprojectList(this.form.domains[this.clickIndex]);
  993. }
  994. //加载项目相关的工程进度
  995. if (this.user.company.packageEngineering == 1) {
  996. this.getProjectProfessions(this.form.domains[this.clickIndex], index);
  997. }
  998. //获取任务分组
  999. this.getTaskGroups(this.form.domains[this.clickIndex], this.clickIndex);
  1000. // 获取1相关维度
  1001. this.getTaskList(domainItem)
  1002. this.dimension(domainItem.projectId)
  1003. //获取相关日报提交选择人
  1004. domainItem.projectAuditorId = null;
  1005. domainItem.projectAuditorName = null;
  1006. domainItem.auditUserList = null;
  1007. //获取项目审核人
  1008. // console.log(domainItem.projectId,this.project);
  1009. var curProject = this.project.filter(p => p.id == domainItem.projectId)[0];
  1010. if (curProject && (this.user.timeType.reportAuditType == 0 || this.user.timeType.reportAuditType == 4)) {
  1011. this.getProjectAuditorList(domainItem, index);
  1012. }
  1013. console.log(item, '数据')
  1014. if (this.user.timeType.customDegreeActive == 1 && item) {
  1015. var that = this
  1016. setTimeout(() => {
  1017. that.selectDegreeId(item, index, that.form.domains[that.clickIndex])
  1018. }, 500)
  1019. }
  1020. //加载昱众的工作职责
  1021. if (this.user.companyId == this.yuzhongCompId) {
  1022. this.updateResponse(domainItem);
  1023. }
  1024. },
  1025. //获取项目下的任务分组
  1026. getTaskGroups(domainItem, index) {
  1027. domainItem.groupId = null;
  1028. domainItem.groupName = null;
  1029. this.$axios.post("/task-group/listMyJoinGroup", { projectId: domainItem.projectId })
  1030. .then(res => {
  1031. if (res.code == "ok") {
  1032. domainItem.taskGroups = res.data;
  1033. }
  1034. this.$forceUpdate();
  1035. }).catch(err => { this.$toast.clear(); });
  1036. },
  1037. getSubprojectList(domainItem) {
  1038. domainItem.subProjectList = [];
  1039. this.$axios.post("/sub-project/list", { projectId: domainItem.projectId,isReport:true })
  1040. .then(res => {
  1041. if (res.code == "ok") {
  1042. domainItem.subProjectList = res.data;
  1043. }
  1044. this.$forceUpdate();
  1045. }).catch(err => { this.$toast.clear(); });
  1046. },
  1047. showChooseDetail(timeItem) {
  1048. this.curWorktime = timeItem;
  1049. this.showMultiOpPicker=true;
  1050. },
  1051. choseMultiOptionPick(value) {
  1052. this.curWorktime.detail = value;
  1053. this.showMultiOpPicker = false;
  1054. },
  1055. showEndDialog(timeItem) {
  1056. this.curWorktime = timeItem;
  1057. this.showWorkEndTime = true;
  1058. },
  1059. showStartDialog(timeItem) {
  1060. this.curWorktime = timeItem;
  1061. this.showWorkStartTime = true;
  1062. },
  1063. removeTimeItem(item, index) {
  1064. item.worktimeList.splice(index, 1);
  1065. },
  1066. isIOS() {
  1067. var u = navigator.userAgent;
  1068. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  1069. return isiOS;
  1070. },
  1071. showLargeImg(item, index) {
  1072. this.imgShow = true;
  1073. this.tmpPics = item;
  1074. },
  1075. //拍照上传
  1076. takePhoto(index) {
  1077. var that = this;
  1078. wx.chooseImage({
  1079. count: 9, // 默认9
  1080. sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  1081. sourceType: that.user.timeType.choseFromAlbum == 1 ? ['camera', 'album'] : ['camera'], // 可以指定来源是相册还是相机,默认二者都有
  1082. defaultCameraMode: "batch", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
  1083. isSaveToAlbum: 0, //整型值,0表示拍照时不保存到系统相册,1表示自动保存,默认值是1
  1084. success: function (res) {
  1085. var localIds = res.localIds; // 返回选定照片的本地ID列表,
  1086. // andriod中localId可以作为img标签的src属性显示图片;
  1087. // iOS应当使用 getLocalImgData 获取图片base64数据,从而用于img标签的显示(在img标签内使用 wx.chooseImage 的 localid 显示可能会不成功)
  1088. if (that.form.domains[index].pics == null) {
  1089. that.form.domains[index].pics = [];
  1090. that.form.domains[index].iospics = [];
  1091. }
  1092. if (that.isIOSystem) {
  1093. for (var i = 0; i < localIds.length; i++) {
  1094. wx.getLocalImgData({
  1095. localId: localIds[i], // 图片的localID
  1096. success: function (res) {
  1097. var localData = res.localData; // localData是图片的base64数据,可以用img标签显示
  1098. that.form.domains[index].iospics.push(localData);
  1099. that.$forceUpdate();
  1100. }
  1101. });
  1102. }
  1103. if (that.user.companyId == 7) {
  1104. that.form.domains[index].pics = that.form.domains[index].pics.concat(localIds);
  1105. } else {
  1106. that.form.domains[index].pics = localIds;
  1107. }
  1108. } else {
  1109. if (that.user.companyId == 7) {
  1110. that.form.domains[index].pics = that.form.domains[index].pics.concat(localIds);
  1111. } else {
  1112. that.form.domains[index].pics = localIds;
  1113. }
  1114. that.$forceUpdate();
  1115. }
  1116. // var serverIdList = [];
  1117. if (that.form.domains[index].serverPics == null) {
  1118. that.form.domains[index].serverPics = [];
  1119. }
  1120. //立即就上传到企业微信服务器
  1121. for (var i = 0; i < localIds.length; i++) {
  1122. wx.uploadImage({
  1123. localId: localIds[i], // 需要上传的图片的本地ID,由chooseImage接口获得
  1124. isShowProgressTips: 1, // 默认为1,显示进度提示
  1125. success: function (res) {
  1126. var serverId = res.serverId; // 返回图片的服务器端ID
  1127. // serverIdList.push(serverId);
  1128. that.form.domains[index].serverPics.push(serverId);
  1129. }
  1130. });
  1131. }
  1132. }
  1133. });
  1134. },
  1135. copyProject(index) {
  1136. var leftProgress = 10;
  1137. if (this.reportTimeType.type == 3) {
  1138. //计算已经待分配工时比例
  1139. let array = this.form.domains;
  1140. let totalProgress = 0;
  1141. for (var i = 0; i < array.length; i++) {
  1142. totalProgress += array[i].progress;
  1143. }
  1144. if (totalProgress < 100) {
  1145. leftProgress = 100 - totalProgress;
  1146. }
  1147. }
  1148. var newIndex = index + 1;
  1149. var pName = "";
  1150. if (this.form.domains[index].projectId != '') {
  1151. pName = this.project.filter(p => p.id == this.form.domains[index].projectId)[0].projectName;
  1152. }
  1153. var itemDomain = {
  1154. id: null,
  1155. projectId: this.form.domains[index].projectId,
  1156. projectName: pName,
  1157. workingTime: this.reportTimeType.type == 3 ? (leftProgress * this.reportTimeType.allday / 100).toFixed(1) : "",
  1158. progress: leftProgress,
  1159. content: "",
  1160. state: 2,
  1161. isOvertime: false,
  1162. };
  1163. this.form.domains.splice(newIndex, 0, itemDomain);
  1164. },
  1165. //删除日报
  1166. deleteReport() {
  1167. this.$dialog.confirm({
  1168. title: '删除日报',
  1169. message: '确定要删除当天日报吗?'
  1170. }).then(() => {
  1171. const toast = this.$toast.loading({
  1172. forbidClick: true,
  1173. duration: 0
  1174. });
  1175. this.$axios.post("/report/delete", { userId: this.user.id, date: this.form.createDate })
  1176. .then(res => {
  1177. if (res.code == "ok") {
  1178. this.$toast.clear();
  1179. this.$toast.success('删除成功');
  1180. window.location.reload();
  1181. } else {
  1182. this.$toast.clear();
  1183. this.$toast.fail('删除失败');
  1184. }
  1185. }).catch(err => { this.$toast.clear(); });
  1186. }).catch(() => { });
  1187. },
  1188. changeAllTime() {
  1189. //总时长发生改变,自动按比例计算
  1190. this.form.domains.forEach(d => {
  1191. d.workingTime = (d.progress * this.reportTimeType.allday / 100).toFixed(1);
  1192. });
  1193. },
  1194. cancel() {
  1195. this.$dialog.confirm({
  1196. title: '撤回日报',
  1197. message: '确定要撤回当天日报吗?'
  1198. }).then(() => {
  1199. const toast = this.$toast.loading({
  1200. forbidClick: true,
  1201. duration: 0
  1202. });
  1203. var ids = '';
  1204. var data = this.form.domains;
  1205. data.forEach(element => {
  1206. if (element.id != null && element.id != '') {
  1207. if (element.id) {
  1208. ids += (element.id + ',');
  1209. }
  1210. }
  1211. });
  1212. this.$axios.post("/report/cancel", { userId: this.user.id, reportIds: ids })
  1213. .then(res => {
  1214. if (res.code == "ok") {
  1215. this.$toast.clear();
  1216. this.$toast.success('撤销成功');
  1217. this.getReport();
  1218. } else {
  1219. this.$toast.clear();
  1220. this.$toast.fail('获取失败');
  1221. }
  1222. }).catch(err => { this.$toast.clear(); });
  1223. }).catch(() => { });
  1224. },
  1225. confirmWorkTime(field) {
  1226. if (field == 0) {
  1227. this.curWorktime.startTime = this.startTime;
  1228. this.showWorkStartTime = false;
  1229. } else {
  1230. this.curWorktime.endTime = this.endTime;
  1231. this.showWorkEndTime = false;
  1232. }
  1233. this.setTotalReportHours()
  1234. },
  1235. confirmTime(item, field, index) {
  1236. if (field == 0) {
  1237. console.log(this.dailyIndex)
  1238. // item.startTime = this.startTime;
  1239. this.form.domains[this.dailyIndex].startTime = this.startTime;
  1240. this.showStartTime = false;
  1241. } else {
  1242. this.form.domains[this.dailyIndex].endTime = this.endTime;
  1243. // item.endTime = this.endTime;
  1244. this.showEndTime = false;
  1245. }
  1246. console.log(this.form.domains)
  1247. this.setTotalReportHours()
  1248. },
  1249. setTotalReportHours() {
  1250. let domains = this.form.domains
  1251. let hours = 0
  1252. let arrNum = [] // 用于时间段计算加班时间
  1253. let timeArr = []
  1254. for (let i in domains) {
  1255. if (this.reportTimeType.multiWorktime == 1) {
  1256. for (let m in domains[i].worktimeList) {
  1257. if (domains[i].worktimeList[m].startTime && domains[i].worktimeList[m].endTime) {
  1258. // hours += this.getHour(domains[i].worktimeList[m].startTime, domains[i].worktimeList[m].endTime)
  1259. timeArr.push({ startTime: domains[i].worktimeList[m].startTime, endTime: domains[i].worktimeList[m].endTime })
  1260. }
  1261. }
  1262. } else {
  1263. if (this.user.timeType.type == 2) {
  1264. if (domains[i].startTime && domains[i].endTime) {
  1265. // let selectionTime = this.getHour(domains[i].startTime, domains[i].endTime)
  1266. // let subtractedData = 0
  1267. // let arr = JSON.parse(JSON.stringify(this.vacationTime))
  1268. // arr.unshift({s: domains[i].startTime, e: domains[i].endTime})
  1269. // for(var j in arr) {
  1270. // subtractedData += +this.timeOverlap(j, arr)
  1271. // }
  1272. // console.log(selectionTime, subtractedData)
  1273. // hours += +selectionTime - +subtractedData
  1274. // console.log(hours)
  1275. // arrNum.push(+selectionTime - +subtractedData)
  1276. timeArr.push({ startTime: domains[i].startTime, endTime: domains[i].endTime })
  1277. }
  1278. } else {
  1279. hours += domains[i].workingTime ? parseFloat(domains[i].workingTime) : 0
  1280. }
  1281. }
  1282. }
  1283. // this.totalReportHours = hours.toFixed(2)
  1284. console.log('timeArr', timeArr)
  1285. if (this.reportTimeType.multiWorktime == 1 || this.user.timeType.type == 2) {
  1286. const { timeCanOverlap } = this.reportTimeType // timeCanOverlap 为零时校验不允许重叠
  1287. if(timeCanOverlap == 0) {
  1288. this.getTimeHours(timeArr)
  1289. } else {
  1290. const newTimeArr = this.mergeTimeIntervals(timeArr)
  1291. this.getTimeHours(newTimeArr)
  1292. }
  1293. } else {
  1294. this.totalReportHours = hours.toFixed(2)
  1295. }
  1296. },
  1297. // 处理重叠时间段
  1298. mergeTimeIntervals(timeIntervals) {
  1299. // 按照开始时间排序
  1300. timeIntervals.sort((a, b) => a.startTime.localeCompare(b.startTime));
  1301. const mergedIntervals = [];
  1302. for (const interval of timeIntervals) {
  1303. if (
  1304. mergedIntervals.length === 0 ||
  1305. interval.startTime > mergedIntervals[mergedIntervals.length - 1].endTime
  1306. ) {
  1307. // 当前时间段与存储数组中的时间段没有重叠,直接加入存储数组
  1308. mergedIntervals.push(interval);
  1309. } else if (interval.endTime > mergedIntervals[mergedIntervals.length - 1].endTime) {
  1310. // 当前时间段与存储数组中的时间段有重叠,但是未完全包含,需要合并时间段
  1311. mergedIntervals[mergedIntervals.length - 1].endTime = interval.endTime;
  1312. }
  1313. }
  1314. return mergedIntervals;
  1315. },
  1316. getTimeHours(arr) {
  1317. this.$axios.post("/report/getHoursByTimeRange", { timeJsonStr: JSON.stringify(arr) })
  1318. .then(res => {
  1319. if (res.code == "ok") {
  1320. this.totalReportHours = res.data
  1321. } else {
  1322. this.$toast.clear();
  1323. this.$toast.fail(res.msg);
  1324. }
  1325. }).catch(err => { this.$toast.clear(); });
  1326. },
  1327. filter(type, options) {
  1328. if (type === 'minute') {
  1329. return options.filter(option => option % 30 === 0);
  1330. }
  1331. return options;
  1332. },
  1333. choseTimePick(value, index) {
  1334. if (!value) {
  1335. return
  1336. }
  1337. //选中时间
  1338. if (this.reportTimeType.type == 0) {
  1339. this.form.domains[this.clickTimeIndex].timeType = value.value;
  1340. this.form.domains[this.clickTimeIndex].workingTime = value.hours;
  1341. this.form.domains[this.clickTimeIndex].label = value.label;
  1342. this.showPickerTime = false;
  1343. } else if (this.reportTimeType.type == 1) {
  1344. // console.log('this.reportTimeType.type=='+value,this.form.domains);
  1345. this.form.domains[this.clickTimeIndex].workingTime = value;
  1346. this.form.domains[this.clickTimeIndex].label = value.toFixed(1) + '小时';
  1347. this.showPickerHours = false;
  1348. let allhour = 0
  1349. for (let i in this.form.domains) {
  1350. if (this.isWeekend) {
  1351. this.form.domains[i].isOvertime = true
  1352. this.form.domains[i].overtimeHours = this.form.domains[i].workingTime
  1353. } else {
  1354. this.form.domains[i].isOvertime = false
  1355. delete this.form.domains[i].overtimeHours
  1356. }
  1357. allhour += this.form.domains[i].workingTime * 1
  1358. }
  1359. if (allhour > this.user.timeType.allday && !this.isWeekend) {
  1360. this.form.domains[this.clickTimeIndex].isOvertime = true
  1361. this.form.domains[this.clickTimeIndex].overtimeHours = allhour - this.user.timeType.allday
  1362. }
  1363. }
  1364. this.setTotalReportHours()
  1365. },
  1366. clickTimePicker(i, item) {
  1367. if (!item.canEdit) {
  1368. return;
  1369. }
  1370. this.clickTimeIndex = i;
  1371. if (this.reportTimeType.type == 0) {
  1372. this.showPickerTime = true;
  1373. } else if (this.reportTimeType.type == 1) {
  1374. this.showPickerHours = true;
  1375. }
  1376. },
  1377. getTargetUserCardTime() {
  1378. if (this.user.timeType.showCorpwxCardtime && this.form.createDate && this.fillingAgent.name) {
  1379. //获取代填人的考勤
  1380. var that = this;
  1381. this.$axios.post('/user-corpwx-time/getUserCardTime', {userId: this.fillingAgent.id, date: this.form.createDate})
  1382. .then(res => {
  1383. if (res.code == "ok") {
  1384. // that.report.time = res.data;
  1385. this.$set(that.report, 'time', res.data);
  1386. } else {
  1387. this.$toast.clear();
  1388. this.$toast.fail(res.msg);
  1389. }
  1390. }).catch(err => { this.$toast.clear(); });
  1391. }
  1392. },
  1393. getMultiOptionData() {
  1394. this.$axios.post('/company-dict/getAll', { companyId: this.user.companyId,code: 'multiOption' })
  1395. .then(res => {
  1396. if (res.code == "ok") {
  1397. var list = res.data;
  1398. this.multiOptionData = [];
  1399. for (var i in list) {
  1400. this.multiOptionData.push(list[i].value);
  1401. }
  1402. }
  1403. }).catch(err => { this.$toast.clear(); });
  1404. },
  1405. getTimeType() {
  1406. this.$axios.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId })
  1407. .then(res => {
  1408. if (res.code == "ok") {
  1409. var t = res.data;
  1410. this.reportTimeType = t;
  1411. //转化时间格式
  1412. if (t.allday != null) {
  1413. this.timeType.push({ value: 0, label: '全天 - ' + t.allday + '小时', hours: t.allday });
  1414. }
  1415. if (t.am != null) {
  1416. this.timeType.push({ value: 1, label: '上午 - ' + t.am + '小时', hours: t.am });
  1417. }
  1418. if (t.pm != null) {
  1419. this.timeType.push({ value: 2, label: '下午 - ' + t.pm + '小时', hours: t.pm });
  1420. }
  1421. let arr = []
  1422. for (var i in res.data.excludeTimeList) {
  1423. let obj = {
  1424. s: res.data.excludeTimeList[i].startTime,
  1425. e: res.data.excludeTimeList[i].endTime,
  1426. }
  1427. arr.push(obj)
  1428. }
  1429. this.vacationTime = arr
  1430. } else {
  1431. this.$toast.clear();
  1432. this.$toast.fail(res.msg);
  1433. }
  1434. }).catch(err => { this.$toast.clear(); });
  1435. },
  1436. // 返回
  1437. back() {
  1438. history.back();
  1439. },
  1440. // 时间转换
  1441. format(date, pattern) {
  1442. pattern = pattern || "yyyy-MM-dd";
  1443. var _this = this;
  1444. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  1445. switch ($0.charAt(0)) {
  1446. case 'y': return _this.padding(date.getFullYear(), $0.length);
  1447. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  1448. case 'd': return _this.padding(date.getDate(), $0.length);
  1449. case 'w': return date.getDay() + 1;
  1450. case 'h': return _this.padding(date.getHours(), $0.length);
  1451. case 'm': return _this.padding(date.getMinutes(), $0.length);
  1452. case 's': return _this.padding(date.getSeconds(), $0.length);
  1453. }
  1454. });
  1455. },
  1456. padding(s, len) {
  1457. var len = len - (s + '').length;
  1458. for (var i = 0; i < len; i++) { s = '0' + s; }
  1459. return s;
  1460. },
  1461. getAIReport(createDate) {
  1462. const toast = this.$toast.loading({
  1463. forbidClick: true,
  1464. duration: 0
  1465. });
  1466. this.$axios.post('/report/getAIReport', {})
  1467. .then(res => {
  1468. if (res.code == "ok") {
  1469. var quanbu = 0
  1470. this.jsDay = 1
  1471. var zhi = ''
  1472. var slp = res.data
  1473. for(var i in slp) {
  1474. var sp = +slp[i].workingTime + 0
  1475. zhi = this.jsDay * sp
  1476. quanbu = +quanbu + zhi
  1477. }
  1478. this.jsTime = quanbu
  1479. var aiReportData = res.data;
  1480. this.canCancelInDialog = false
  1481. if(aiReportData.length != 0) {
  1482. var arr = [];
  1483. var list = aiReportData;
  1484. for(var i in list) {
  1485. var subProjectName = null;
  1486. if (list[i].subProjectId) {
  1487. subProjectName = list[i].subProjectList.filter(s => s.id == list[i].subProjectId)[0].name;
  1488. }
  1489. var projectName = list[i].projectName;
  1490. arr.push({
  1491. projectId: list[i].projectId,
  1492. projectName: projectName,
  1493. workingTime: String(list[i].workingTime),
  1494. content: list[i].content,
  1495. state: list[i].state,
  1496. timeType: list[i].timeType,
  1497. // label: timeType[list[i].timeType].label,
  1498. startTime: list[i].startTime,
  1499. endTime: list[i].endTime,
  1500. isOvertime: 0,
  1501. progress: list[i].progress,
  1502. taskList: list[i].taskList,
  1503. taskId: list[i].taskId ? list[i].taskId : null,
  1504. taskName: list[i].taskName,
  1505. professionProgress: list[i].professionProgressList,
  1506. pics: null,
  1507. multiWorktime: list[i].multiWorktime,
  1508. worktimeList: list[i].worktimeList,
  1509. wuduList: list[i].degreeList,
  1510. degreeId: list[i].degreeId==-1?null:list[i].degreeId,
  1511. subProjectId: list[i].subProjectId,
  1512. subProjectName: subProjectName,
  1513. subProjectList: list[i].subProjectList,
  1514. groupId: list[i].groupId == 0 ? null : list[i].groupId,
  1515. groupName: list[i].groupName,
  1516. taskGroups: list[i].taskGroups,
  1517. stages: list[i].stages,
  1518. stage: list[i].stage == '-' ? null : list[i].stage,
  1519. customData: list[i].customData,
  1520. projectAuditorId: list[i].projectAuditorId,
  1521. projectAuditorName: list[i].projectAuditorName,
  1522. auditUserList: list[i].auditUserList,
  1523. overtimeHours: list[i].overtimeHours,
  1524. customText: list[i].customText,
  1525. basecostId: list[i].basecostId,
  1526. //basecostName: basecostName,
  1527. canEdit: true,
  1528. auditorFirst: list[i].auditorFirst ? list[i].auditorFirst : { name: '', id: '' },
  1529. auditorSec: list[i].auditorSec ? list[i].auditorSec : { name: '', id: '' },
  1530. auditorThird: list[i].auditorThird ? list[i].auditorThird : { name: '', id: '' },
  1531. ccUserid: list[i].ccUserid ? list[i].ccUserid : { name: '', id: '' },
  1532. extraField1: list[i].extraField1,
  1533. extraField1Name: list[i].extraField1Name,
  1534. extraField2: list[i].extraField2,
  1535. extraField2Name: list[i].extraField2Name,
  1536. extraField3: list[i].extraField3,
  1537. extraField3Name: list[i].extraField3Name,
  1538. workContentList: list[i].workContentList,
  1539. sapServiceId: list[i].sapServiceId,
  1540. sapServiceName: list[i].sapServiceName,
  1541. serviceList: list[i].serviceList,
  1542. userReportDeptName: list[i].userReportDeptName,
  1543. reportTargetDeptId: list[i].deptId
  1544. })
  1545. }
  1546. this.form.domains = arr;
  1547. } else {
  1548. }
  1549. this.canEdit = true;
  1550. this.originCanEdit = true;
  1551. this.seleChn()
  1552. } else {
  1553. this.$message({
  1554. message: res.msg,
  1555. type: "error"
  1556. });
  1557. }
  1558. }).catch(err => { this.$toast.clear(); });
  1559. },
  1560. // 获取日报
  1561. getReport() {
  1562. this.isWeekend = false
  1563. let weekday = new Date(this.form.createDate).getDay()
  1564. if (this.user.companyId == 817) {
  1565. if (weekday == 0) {
  1566. this.isWeekend = true
  1567. }
  1568. } else {
  1569. if (weekday == 0 || weekday == 6) {
  1570. this.isWeekend = true
  1571. }
  1572. }
  1573. const toast = this.$toast.loading({
  1574. forbidClick: true,
  1575. duration: 0
  1576. });
  1577. this.$axios.post("/report/getReport", { date: this.form.createDate })
  1578. .then(res => {
  1579. if (res.code == "ok") {
  1580. this.$toast.clear();
  1581. this.report = res.data;
  1582. var t = res.data.timeType;
  1583. var timeType = [];
  1584. //转化时间格式
  1585. if (t.allday != null) {
  1586. timeType.push({ value: 0, label: '全天 - ' + t.allday + '小时', hours: t.allday });
  1587. }
  1588. if (t.am != null) {
  1589. timeType.push({ value: 1, label: '上午 - ' + t.am + '小时', hours: t.am });
  1590. }
  1591. if (t.pm != null) {
  1592. timeType.push({ value: 2, label: '下午 - ' + t.pm + '小时', hours: t.pm });
  1593. }
  1594. var list = res.data.report;
  1595. this.canCancelInDialog = false
  1596. this.hasWrittenReport = list.length != 0;
  1597. if (list.length != 0 && !this.substitute) {
  1598. this.canEdit = false;
  1599. this.canCancel = false;
  1600. this.canDeleteReport = true
  1601. let array = [];
  1602. for (var i in list) {
  1603. var projectName = list[i].projectName;
  1604. var flg = (list[i].isOvertime == 1);
  1605. for (var j in this.project) {
  1606. if (this.project[j].id == list[i].projectId) {
  1607. projectName = this.project[j].projectName;
  1608. }
  1609. }
  1610. console.log(projectName);
  1611. let tname = '';
  1612. if (list[i].taskId != null && list[i].taskList.length > 0) {
  1613. let filterList = list[i].taskList.filter(t => t.taskId == list[i].taskId);
  1614. if (filterList.length > 0) {
  1615. tname = filterList[0].taskName;
  1616. }
  1617. }
  1618. let mmm = !t.customDegreeMultiple ? list[i].degreeId : (list[i].multiDegrIdList || [])
  1619. let sss = list[i].degreeList || []
  1620. let radioPickDegree = ''
  1621. let wuduName = ''
  1622. if(!t.customDegreeMultiple) {
  1623. for (var s in sss) {
  1624. if (sss[s].id == mmm) {
  1625. wuduName = sss[s].name
  1626. }
  1627. }
  1628. radioPickDegree = sss.filter(s => s.id == mmm)[0]
  1629. } else {
  1630. let arr = sss.filter(s => mmm.includes(s.id)).map(s => s.name);
  1631. radioPickDegree = sss.filter(s => mmm.includes(s.id))
  1632. wuduName = arr.join(',')
  1633. }
  1634. let serverPicArray = [];
  1635. // console.log('picArray=='+list[i].picStr);
  1636. if (list[i].picStr != null && list[i].picStr != '@') {
  1637. serverPicArray = JSON.parse(list[i].picStr.replace(/@/g, ","));
  1638. }
  1639. var subProjectName = null;
  1640. if (list[i].subProjectId) {
  1641. subProjectName = list[i].subProjectList.filter(s => s.id == list[i].subProjectId)[0].name;
  1642. }
  1643. let basecostName = ''
  1644. if (res.data.timeBasecostList && res.data.timeBasecostList.length > 0) {
  1645. for (let m in res.data.timeBasecostList) {
  1646. if (res.data.timeBasecostList[m].id == list[i].basecostId) {
  1647. basecostName = res.data.timeBasecostList[m].name
  1648. }
  1649. }
  1650. }
  1651. var targetP = this.project.filter(p => p.id == list[i].projectId);
  1652. var filteredRespList = [];
  1653. if (targetP.length > 0 && list[i].extraField1) {
  1654. list[i].extraField1Name = this.roleList.find(r => r.value == list[i].extraField1).label;
  1655. var isPublic = targetP[0].isPublic;
  1656. filteredRespList = this.jobResponseList.filter(j => j.timeType == (isPublic ? '非项目工时' : '项目工时') && j.role == this.roleList.filter(r => r.value == list[i].extraField1)[0].label);
  1657. if (list[i].extraField2) {
  1658. list[i].extraField2Name = filteredRespList.find(f => f.id == list[i].extraField2).jobRespon;
  1659. }
  1660. if (list[i].extraField3) {
  1661. list[i].extraField3Name = list[i].workContentList.find(w => w.id == list[i].extraField3).workContext;
  1662. }
  1663. }
  1664. let copyData = {
  1665. id: list[i].id,
  1666. projectId: list[i].projectId,
  1667. projectName: projectName,
  1668. workingTime: String(list[i].workingTime),
  1669. content: list[i].content,
  1670. state: list[i].state,
  1671. timeType: list[i].timeType,
  1672. label: timeType[list[i].timeType].label,
  1673. startTime: list[i].startTime,
  1674. endTime: list[i].endTime,
  1675. isOvertime: flg,
  1676. progress: list[i].progress,
  1677. taskList: list[i].taskList,
  1678. taskId: list[i].taskId ? list[i].taskId : null,
  1679. taskName: tname,
  1680. professionProgress: list[i].professionProgressList,
  1681. pics: list[i].pics,
  1682. iospics: list[i].pics,
  1683. serverPics: serverPicArray,
  1684. multiWorktime: t.multiWorktime,
  1685. worktimeList: list[i].worktimeList,
  1686. wuduList: list[i].degreeList,
  1687. weiduName: wuduName,
  1688. degreeId: !t.customDegreeMultiple ? list[i].degreeId : list[i].multiDegrIdList,
  1689. radioPickDegree: radioPickDegree,
  1690. subProjectId: list[i].subProjectId,
  1691. subProjectName: subProjectName,
  1692. subProjectList: list[i].subProjectList,
  1693. groupId: list[i].groupId == 0 ? null : list[i].groupId,
  1694. groupName: list[i].groupName,
  1695. taskGroups: list[i].taskGroups,
  1696. stages: list[i].stages,
  1697. stage: list[i].stage == '-' ? null : list[i].stage,
  1698. customData: list[i].customData,
  1699. auditUserList: list[i].auditUserList,
  1700. overtimeHours: list[i].overtimeHours,
  1701. customText: list[i].customText,
  1702. basecostId: list[i].basecostId,
  1703. basecostName: basecostName,
  1704. canEdit: list[i].state >= 2 ? true : false,
  1705. auditorFirst: list[i].auditorFirst ? list[i].auditorFirst : { name: '', id: '' },
  1706. auditorSec: list[i].auditorSec ? list[i].auditorSec : { name: '', id: '' },
  1707. auditorThird: list[i].auditorThird ? list[i].auditorThird : { name: '', id: '' },
  1708. ccUserid: list[i].ccUserid ? list[i].ccUserid : { name: '', id: '' },
  1709. extraField1: list[i].extraField1,
  1710. extraField1Name: list[i].extraField1Name,
  1711. extraField2: list[i].extraField2,
  1712. extraField2Name: list[i].extraField2Name,
  1713. extraField3: list[i].extraField3,
  1714. extraField3Name: list[i].extraField3Name,
  1715. workContentList: list[i].workContentList,
  1716. filteredRespList: filteredRespList,
  1717. sapServiceId: list[i].sapServiceId,
  1718. sapServiceName: list[i].sapServiceName,
  1719. serviceList: list[i].serviceList,
  1720. userReportDeptName: list[i].userReportDeptName,
  1721. reportTargetDeptId: list[i].deptId
  1722. }
  1723. if (this.user.timeType.reportAuditType != 1 && this.user.timeType.reportAuditType != 2 && this.user.timeType.reportAuditType != 9) {
  1724. //分组负责人审核的情况下,前端不需要显示,无需设置
  1725. copyData.projectAuditorId = list[i].projectAuditorId;
  1726. copyData.projectAuditorName = list[i].projectAuditorName;
  1727. }
  1728. console.log(copyData);
  1729. array.push(copyData);
  1730. if (list[i].state >= 2) {
  1731. this.canEdit = true;
  1732. } else {
  1733. this.canDeleteReport = false
  1734. }
  1735. if (list[i].state == 0) {
  1736. this.canCancel = true;
  1737. this.canCancelInDialog = true
  1738. }
  1739. }
  1740. this.form.domains = array;
  1741. // console.log('执行One')
  1742. this.setTotalReportHours()
  1743. } else {
  1744. // console.log('执行TWO')
  1745. this.totalReportHours = 0
  1746. this.canCancel = false;
  1747. this.canEdit = true;
  1748. var shuzhi = this.user.timeType.allday + ''
  1749. //没有填报的可以点击提交
  1750. this.form.domains = [{
  1751. id: null,
  1752. projectId: "",
  1753. projectName: "",
  1754. // workingTime: t.type==3?(t.allday).toFixed(1):"8.0",
  1755. workingTime: t.type == 3 ? (t.allday).toFixed(1) : shuzhi.indexOf('.') == '-1' ? shuzhi + '.0' : shuzhi,
  1756. content: "",
  1757. state: 2,
  1758. progress: 100,
  1759. isOvertime: false,
  1760. professionProgress: [],
  1761. multiWorktime: t.multiWorktime,
  1762. worktimeList: [{}],
  1763. canEdit: true,
  1764. auditorFirst: { name: '', id: '' },
  1765. auditorSec: { name: '', id: '' },
  1766. auditorThird: { name: '', id: '' },
  1767. ccUserid: { name: '', id: '' }
  1768. }]
  1769. if (this.isWeekend && this.user.timeType.lockWorktime != 1) {
  1770. this.$set(this.form.domains[0], 'isOvertime', true)
  1771. if (t.type != 2 && t.type != 0) {
  1772. this.$set(this.form.domains[0], 'overtimeHours', t.allday.toFixed(0))
  1773. }
  1774. }
  1775. if (this.report.timeBasecostList.length != 0 && this.user.company.packageProject == 1) {
  1776. this.form.domains[0].basecostId = this.report.timeBasecostList[0].id;
  1777. this.form.domains[0].basecostName = this.report.timeBasecostList[0].name;
  1778. }
  1779. this.canEdit = true;
  1780. this.setTotalReportHours()
  1781. }
  1782. } else {
  1783. this.$toast.clear();
  1784. this.$toast.fail('获取失败:' + res.msg);
  1785. }
  1786. if (localStorage.getItem("formVal")) {
  1787. // console.log('触发了')
  1788. var obj = localStorage.getItem("formVal")
  1789. this.form = JSON.parse(obj)
  1790. localStorage.removeItem('formVal')
  1791. }
  1792. }).catch(err => { this.$toast.clear(); });
  1793. },
  1794. initFormData() {
  1795. this.totalReportHours = 0
  1796. this.canCancel = false;
  1797. this.canEdit = true;
  1798. var shuzhi = this.user.timeType.allday + '';
  1799. var t = this.user.timeType;
  1800. //没有填报的可以点击提交
  1801. this.form.domains = [{
  1802. id: null,
  1803. projectId: "",
  1804. projectName: "",
  1805. // workingTime: t.type==3?(t.allday).toFixed(1):"8.0",
  1806. workingTime: t.type == 3 ? (t.allday).toFixed(1) : shuzhi.indexOf('.') == '-1' ? shuzhi + '.0' : shuzhi,
  1807. content: "",
  1808. state: 2,
  1809. progress: 100,
  1810. isOvertime: false,
  1811. professionProgress: [],
  1812. multiWorktime: t.multiWorktime,
  1813. worktimeList: [{}],
  1814. canEdit: true,
  1815. auditorFirst: { name: '', id: '' },
  1816. auditorSec: { name: '', id: '' },
  1817. auditorThird: { name: '', id: '' },
  1818. ccUserid: { name: '', id: '' }
  1819. }]
  1820. if (this.isWeekend && this.user.timeType.lockWorktime != 1) {
  1821. this.$set(this.form.domains[0], 'isOvertime', true)
  1822. if (t.type != 2 && t.type != 0) {
  1823. this.$set(this.form.domains[0], 'overtimeHours', t.allday.toFixed(0))
  1824. }
  1825. }
  1826. this.canEdit = true;
  1827. this.setTotalReportHours()
  1828. },
  1829. // 改变时间
  1830. changeTime(time) {
  1831. this.form.createDate = this.format(new Date(time), "yyyy-MM-dd");
  1832. this.currentDate = time;
  1833. this.showPicker = false;
  1834. if (this.substitute) {
  1835. this.getTargetUserCardTime();
  1836. } else {
  1837. this.getReport();
  1838. }
  1839. },
  1840. //点击选择审核人
  1841. clickPickAuditor(i, item) {
  1842. if (!item.canEdit) return;
  1843. if (item.auditUserList.length <= 1) return;
  1844. this.clickIndex = i;
  1845. item.showPickerAuditor = true;
  1846. this.$forceUpdate();
  1847. },
  1848. choseAuditor(value, index) {
  1849. if (value) {
  1850. this.form.domains[this.clickIndex].projectAuditorId = value.auditorId;
  1851. this.form.domains[this.clickIndex].projectAuditorName = value.auditorName;
  1852. }
  1853. this.form.domains[this.clickIndex].showPickerAuditor = false;
  1854. this.$forceUpdate();
  1855. },
  1856. //点击选择角色
  1857. clickPickProjectRole(i, item) {
  1858. if (!item.canEdit) return;
  1859. this.clickIndex = i;
  1860. item.showPickerRole = true;
  1861. this.$forceUpdate();
  1862. },
  1863. //点击选择子项目
  1864. clickPickSubProject(i, item) {
  1865. if (!item.canEdit) return;
  1866. this.clickIndex = i;
  1867. item.showPickerSubProject = true;
  1868. this.$forceUpdate();
  1869. },
  1870. clickPickCostId(i, item) {
  1871. if (!item.canEdit) return;
  1872. this.clickIndex = i;
  1873. item.showPickerCostId = true;
  1874. this.$forceUpdate();
  1875. },
  1876. clickPickTaskGroup(i, item) {
  1877. if (!item.canEdit) return;
  1878. this.clickIndex = i;
  1879. item.showPickerTaskGroup = true;
  1880. this.$forceUpdate();
  1881. },
  1882. clickPickStage(i, item) {
  1883. if (!item.canEdit) return;
  1884. this.clickIndex = i;
  1885. item.showPickerStage = true;
  1886. this.$forceUpdate();
  1887. },
  1888. selectDeptPopup(i, item) {
  1889. this.clickIndex = i;
  1890. this.showSelectDeptPopup = true;
  1891. this.$forceUpdate();
  1892. },
  1893. selectedDeptId(item) {
  1894. const { label, value } = item
  1895. this.form.domains[this.clickIndex].userReportDeptName = label
  1896. this.form.domains[this.clickIndex].reportTargetDeptId = value
  1897. this.showSelectDeptPopup = false;
  1898. this.$forceUpdate();
  1899. },
  1900. // 选择项目
  1901. clickPicker(i, item) {
  1902. if (!item.canEdit) return;
  1903. this.clickIndex = i
  1904. this.showPickerUserddp = true
  1905. },
  1906. clickPickers(i, item) {
  1907. // console.log('wudulist',item.wuduList);
  1908. if (!item.canEdit) return;
  1909. this.clickIndex = i;
  1910. // item.showPickDegree = true;
  1911. this.$set(item, 'showPickDegree', true)
  1912. // var proId = this.form.domains[this.clickIndex].projectId
  1913. // this.dimension(proId)
  1914. },
  1915. //选择服务
  1916. clickPickerService(i, item) {
  1917. if (!item.canEdit) return;
  1918. // console.log(i);
  1919. this.clickIndex = i;
  1920. // var proId = this.form.domains[this.clickIndex].projectId
  1921. // this.getTaskList(proId)
  1922. // console.log(this.form.domains[this.clickIndex].taskList);
  1923. this.$toast.clear();
  1924. if (!this.form.domains[this.clickIndex].serviceList || this.form.domains[this.clickIndex].serviceList.length == 0) {
  1925. this.$toast.fail('当前任务暂无服务');
  1926. } else {
  1927. this.form.domains[this.clickIndex].showPickerService = true;
  1928. this.$forceUpdate();
  1929. }
  1930. },
  1931. choseService(value, index) {
  1932. if (value) {
  1933. this.form.domains[this.clickIndex].sapServiceId = value.id;
  1934. this.form.domains[this.clickIndex].sapServiceName = value.serviceName;
  1935. }
  1936. this.form.domains[this.clickIndex].showPickerService = false;
  1937. this.$forceUpdate();
  1938. },
  1939. //选择任务
  1940. clickPickerTask(i, item) {
  1941. if (!item.canEdit) return;
  1942. this.clickIndex = i;
  1943. this.$toast.clear();
  1944. if (!this.form.domains[this.clickIndex].taskList || this.form.domains[this.clickIndex].taskList.length == 0) {
  1945. this.$toast.fail('当前项目暂无可选的任务/里程碑');
  1946. } else {
  1947. this.form.domains[this.clickIndex].showPickerTask = true;
  1948. this.$forceUpdate();
  1949. }
  1950. },
  1951. choseTask(value, index) {
  1952. if (value) {
  1953. this.form.domains[this.clickIndex].taskId = value.taskId;
  1954. this.form.domains[this.clickIndex].taskName = value.taskName;
  1955. }
  1956. this.form.domains[this.clickIndex].showPickerTask = false;
  1957. this.$forceUpdate();
  1958. if (this.user.companyId == 3092) {
  1959. //依斯贝,加载服务
  1960. this.$axios.post("/task/getMyTaskService", { taskId: value.taskId })
  1961. .then(res => {
  1962. if (res.code == "ok") {
  1963. this.$set(this.form.domains[this.clickIndex], 'sapServiceId', null);
  1964. this.$set(this.form.domains[this.clickIndex], 'sapServiceName', null);
  1965. this.$set(this.form.domains[this.clickIndex], 'serviceList', res.data);
  1966. this.$forceUpdate();
  1967. } else {
  1968. this.$toast.fail('获取失败:' + res.msg);
  1969. }
  1970. }).catch(err => { this.$toast.clear(); });
  1971. }
  1972. },
  1973. choseProjects(value, index) {
  1974. const { timeType } = this.user
  1975. console.log(value, timeType)
  1976. if (value) {
  1977. if(!timeType.customDegreeMultiple) { // 单选
  1978. this.form.domains[this.clickIndex].weiduName = value.name;
  1979. this.form.domains[this.clickIndex].degreeId = value.id;
  1980. }
  1981. if(timeType.customDegreeMultiple) { // 多选
  1982. this.form.domains[this.clickIndex].weiduName = value.map(item => item.name).join(',');
  1983. this.form.domains[this.clickIndex].degreeId = value.map(item => item.id).join(',');
  1984. }
  1985. this.$forceUpdate();
  1986. }
  1987. this.form.domains[this.clickIndex].showPickDegree = false;
  1988. },
  1989. choseSubProject(value, index) {
  1990. if (value) {
  1991. this.form.domains[this.clickIndex].subProjectId = value.id;
  1992. this.form.domains[this.clickIndex].subProjectName = value.name;
  1993. }
  1994. this.form.domains[this.clickIndex].showPickerSubProject = false;
  1995. this.$forceUpdate();
  1996. },
  1997. choseTaskGroup(value, index) {
  1998. if (!value) {
  1999. return
  2000. }
  2001. this.form.domains[this.clickIndex].groupId = value.id;
  2002. this.form.domains[this.clickIndex].groupName = value.name;
  2003. this.form.domains[this.clickIndex].showPickerTaskGroup = false;
  2004. var domainItem = this.form.domains[this.clickIndex];
  2005. this.getGroupStages(this.form.domains[this.clickIndex], index);
  2006. //检查当前的项目是否需要获取分组的负责人
  2007. var curProject = this.project.filter(p => p.id == this.form.domains[this.clickIndex].projectId)[0];
  2008. if (curProject && (this.user.timeType.reportAuditType == 1 || this.user.timeType.reportAuditType == 2)) {
  2009. this.$axios.post("/task-group/getGroupIncharger", { groupId: domainItem.groupId })
  2010. .then(res => {
  2011. if (res.code == "ok") {
  2012. domainItem.auditUserList = res.data;
  2013. if (res.data.length == 1) {
  2014. domainItem.projectAuditorId = domainItem.auditUserList[0].auditorId;
  2015. domainItem.projectAuditorName = domainItem.auditUserList[0].auditorName;
  2016. }
  2017. this.$forceUpdate();
  2018. } else {
  2019. this.$toast.fail('获取失败:' + res.msg);
  2020. }
  2021. }).catch(err => { this.$toast.clear(); });
  2022. }
  2023. },
  2024. choseStage(value, index) {
  2025. if (value) {
  2026. this.form.domains[this.clickIndex].stage = value.stagesName;
  2027. }
  2028. this.form.domains[this.clickIndex].showPickerStage = false;
  2029. this.getTaskList(this.form.domains[this.clickIndex]);
  2030. this.$forceUpdate();
  2031. },
  2032. choseCostId(value, index) {
  2033. if (value) {
  2034. this.form.domains[this.clickIndex].basecostId = value.id;
  2035. this.form.domains[this.clickIndex].basecostName = value.name;
  2036. }
  2037. this.form.domains[this.clickIndex].showPickerCostId = false;
  2038. this.$forceUpdate();
  2039. },
  2040. getGroupStages(domain, index) {
  2041. this.$axios.post("/stages/getProjectStagesByGroup", { groupId: domain.groupId })
  2042. .then(res => {
  2043. if (res.code == "ok") {
  2044. domain.stage = '';
  2045. domain.stages = res.data;
  2046. this.getTaskList(domain);
  2047. this.$forceUpdate();
  2048. } else {
  2049. this.$toast.fail('获取失败');
  2050. }
  2051. }).catch(err => { this.$toast.clear(); });
  2052. },
  2053. getProjectProfessions(domain, index) {
  2054. // console.log(domain, '数据')
  2055. this.$axios.post("/project-profession/getMyProfession", { projectId: domain.projectId })
  2056. .then(res => {
  2057. if (res.code == "ok") {
  2058. this.form.domains[this.clickIndex].professionProgress = res.data;
  2059. // console.log(this.form.domains)
  2060. this.$forceUpdate();
  2061. } else {
  2062. this.$toast.fail('获取失败');
  2063. }
  2064. }).catch(err => { this.$toast.clear(); });
  2065. },
  2066. // 获取维度
  2067. dimension(projectId) {
  2068. this.$axios.post("/project/getDegreeList", { projectId: projectId })
  2069. .then(res => {
  2070. if (res.code == "ok") {
  2071. this.form.domains[this.clickIndex].wuduList = res.data;
  2072. this.$forceUpdate();
  2073. } else {
  2074. this.$toast.fail('获取失败');
  2075. }
  2076. }).catch(err => { this.$toast.clear(); });
  2077. },
  2078. getTaskList(domainItem) {
  2079. //如果是专业版,需要列出任务列表
  2080. if (this.user.company.packageProject == 1) {
  2081. //清空选中的任务
  2082. this.$set(domainItem, 'taskId', null);
  2083. this.$set(domainItem, 'taskName', null);
  2084. this.$set(domainItem, 'sapServiceId', null);
  2085. this.$set(domainItem, 'sapServiceName', null);
  2086. this.$set(domainItem, 'serviceList', null);
  2087. var param = { projectId: domainItem.projectId }
  2088. if (domainItem.groupId) {
  2089. param.groupId = domainItem.groupId;
  2090. }
  2091. if (domainItem.stage) {
  2092. param.stage = domainItem.stage;
  2093. }
  2094. this.$axios.post("/task/getRecentTask", param)
  2095. .then(res => {
  2096. if (res.code == "ok") {
  2097. this.form.domains[this.clickIndex].allTaskList = res.data;
  2098. this.form.domains[this.clickIndex].taskList = res.data;
  2099. this.form = this.form;
  2100. } else {
  2101. this.$toast.fail('获取失败');
  2102. }
  2103. }).catch(err => { this.$toast.clear(); });
  2104. }
  2105. },
  2106. //添加工时
  2107. addNewWorktime(index, item) {
  2108. item.worktimeList.push({});
  2109. },
  2110. // 添加项目
  2111. addNewPro() {
  2112. var leftProgress = 10;
  2113. if (this.reportTimeType.type == 3) {
  2114. //计算已经待分配工时比例
  2115. let array = this.form.domains;
  2116. let totalProgress = 0;
  2117. for (var i = 0; i < array.length; i++) {
  2118. totalProgress += array[i].progress;
  2119. }
  2120. if (totalProgress < 100) {
  2121. leftProgress = 100 - totalProgress;
  2122. }
  2123. }
  2124. let item = {
  2125. id: null,
  2126. projectId: "",
  2127. projectName: "",
  2128. workingTime: this.reportTimeType.type == 3 ? (leftProgress * this.reportTimeType.allday / 100).toFixed(1) : "4.0",
  2129. progress: leftProgress,
  2130. content: "",
  2131. state: 2,
  2132. isOvertime: false,
  2133. multiWorktime: this.reportTimeType.multiWorktime,
  2134. worktimeList: [{}],
  2135. degreeId: null,
  2136. canEdit: true
  2137. }
  2138. if (this.isWeekend && this.user.timeType.lockWorktime != 1) {
  2139. this.$set(item, 'isOvertime', true)
  2140. if (this.reportTimeType.type == 3) {
  2141. this.$set(item, 'overtimeHours', (leftProgress * this.reportTimeType.allday / 100).toFixed(1))
  2142. } else {
  2143. this.$set(item, 'overtimeHours', 4)
  2144. }
  2145. }
  2146. if (this.report.timeBasecostList.length != 0 && this.user.company.packageProject == 1) {
  2147. this.$set(item, 'basecostId', this.report.timeBasecostList[0].id)
  2148. this.$set(item, 'basecostName', this.report.timeBasecostList[0].name)
  2149. }
  2150. this.form.domains.push(item)
  2151. //重新计算总时长
  2152. this.setTotalReportHours();
  2153. this.canEdit = true
  2154. this.$forceUpdate()
  2155. },
  2156. // 移除项目
  2157. delPro(i) {
  2158. this.$dialog.confirm({
  2159. title: '',
  2160. message: '是否移除当前项目'
  2161. }).then(() => {
  2162. this.form.domains.splice(i, 1);
  2163. //重新计算总时长
  2164. this.setTotalReportHours();
  2165. }).catch(() => {
  2166. });
  2167. },
  2168. // 判断时间段
  2169. fns() {
  2170. for (let k in this.dateAr) {
  2171. if (!this.judege(k)) {
  2172. return false
  2173. }
  2174. }
  2175. return true
  2176. },
  2177. judege(idx) {
  2178. for (let k in this.dateAr) {
  2179. if (idx !== k) {
  2180. if (this.dateAr[k].s <= this.dateAr[idx].s && this.dateAr[k].e > this.dateAr[idx].s) {
  2181. return false
  2182. }
  2183. if (this.dateAr[k].s < this.dateAr[idx].e && this.dateAr[k].e >= this.dateAr[idx].e) {
  2184. return false
  2185. }
  2186. }
  2187. }
  2188. return true
  2189. },
  2190. // 提交日报
  2191. submitReport() {
  2192. this.$refs.loginForm.validate().then(
  2193. () => {
  2194. // 验证通过
  2195. if (this.isDraft == 1) {
  2196. //暂存操作
  2197. this.submitReportSon()
  2198. } else {
  2199. if (this.user.companyId == 5978) {
  2200. //调接口,先检查工时是否存在异常
  2201. var totalTime = 0;
  2202. for (var t=0;t<this.form.domains.length; t++) {
  2203. totalTime += parseFloat(this.form.domains[t].workingTime);
  2204. }
  2205. var array = [];
  2206. var workData = {date: this.form.createDate, workingTime: totalTime};
  2207. array.push(workData)
  2208. this.flgLg = false
  2209. var passUserId = this.user.id;
  2210. this.$axios.post("/report/checkBeiSengCardTime", { userId:passUserId, dateWorkingTime:JSON.stringify(array)})
  2211. .then(res => {
  2212. this.flgLg = true
  2213. if (res.code == "ok") {
  2214. this.submitReportSon()
  2215. } else {
  2216. this.$dialog.confirm({
  2217. title: '提示',
  2218. message: res.msg + ',是否忽略并提交?'
  2219. }).then(() => {
  2220. this.submitReportSon()
  2221. }).catch(() => { })
  2222. }
  2223. }).catch(err => { this.$toast.clear(); });
  2224. } else if (this.user.companyId == 469) {
  2225. //校验填报的与考勤时长
  2226. if (this.totalReportHours > this.report.time.workHours) {
  2227. this.$toast('填报工时不得超过考勤时长')
  2228. } else if (this.totalReportHours < this.report.time.workHours) {
  2229. this.$dialog.confirm({
  2230. title: '提示',
  2231. message: '还剩余'+(this.report.time.workHours-this.totalReportHours).toFixed(1)+'h考勤时长尚未分配,是否确定提交'
  2232. }).then(() => {
  2233. this.submitReportSon()
  2234. }).catch(() => { })
  2235. } else {
  2236. this.submitReportSon()
  2237. }
  2238. } else {
  2239. //提交时,做工时时长不足的提醒
  2240. if (this.totalReportHours < this.user.timeType.allday) {
  2241. this.$dialog.confirm({
  2242. title: '提示',
  2243. message: '当日工时不足' + this.user.timeType.allday.toFixed(1) + '小时,是否确定提交?'
  2244. }).then(() => {
  2245. this.submitReportSon()
  2246. }).catch(() => { })
  2247. } else {
  2248. this.submitReportSon()
  2249. }
  2250. }
  2251. }
  2252. }).catch((err) => {
  2253. console.log('验证失败', err);
  2254. return
  2255. })
  2256. },
  2257. submitReportSon() {
  2258. this.dateAr = []
  2259. let alp = []
  2260. if (this.user.timeType.multiWorktime == 1) {
  2261. for (var p in this.form.domains) {
  2262. var slll = this.form.domains[p]
  2263. for (var o in slll.worktimeList) {
  2264. if (slll.worktimeList[o].startTime || slll.worktimeList[o].endTime) {
  2265. let objs = {}
  2266. objs.s = slll.worktimeList[o].startTime
  2267. objs.e = slll.worktimeList[o].endTime
  2268. alp.push(objs)
  2269. }
  2270. }
  2271. }
  2272. } else {
  2273. for (let i in this.form.domains) {
  2274. let objs = {}
  2275. objs.s = this.form.domains[i].startTime
  2276. objs.e = this.form.domains[i].endTime
  2277. alp.push(objs)
  2278. }
  2279. }
  2280. this.dateAr = alp
  2281. const { timeCanOverlap } = this.reportTimeType // timeCanOverlap 为零时校验不允许重叠
  2282. if (this.dateAr.length > 0 && timeCanOverlap == 0) {
  2283. let trus = this.fns()
  2284. if (!trus) {
  2285. this.$toast('填写的时间段重叠')
  2286. return
  2287. }
  2288. }
  2289. //检查子项目
  2290. if (this.user.timeType.subProMustFill == 1) {
  2291. for (var p in this.form.domains) {
  2292. var oneProItem = this.form.domains[p]
  2293. if (oneProItem.subProjectList.length > 0 && !oneProItem.subProjectId) {
  2294. //没有选择子项目
  2295. this.$toast('子项目必填,请检查')
  2296. return
  2297. }
  2298. }
  2299. }
  2300. //昱众需要检查新增的角色,工作职责,工作内容是否填写
  2301. if (this.user.companyId == this.yuzhongCompId) {
  2302. for (var p in this.form.domains) {
  2303. var oneProItem = this.form.domains[p]
  2304. if (!oneProItem.extraField1) {
  2305. this.$toast('角色必填,请检查')
  2306. return
  2307. }
  2308. if (!oneProItem.extraField2) {
  2309. this.$toast('工作职责必填,请检查')
  2310. return
  2311. }
  2312. if (!oneProItem.extraField3) {
  2313. this.$toast('工作内容必填,请检查')
  2314. return
  2315. }
  2316. }
  2317. }
  2318. // return
  2319. const toast = this.$toast.loading({
  2320. forbidClick: true,
  2321. duration: 0
  2322. });
  2323. // let formData = new FormData();
  2324. let formData = new URLSearchParams()
  2325. formData.append("draft", this.isDraft);
  2326. if (this.reportTimeType.type == 0) {
  2327. var alldayNum = 0;
  2328. var amNum = 0;
  2329. var pmNum = 0;
  2330. for (var i in this.form.domains) {
  2331. if (this.form.domains[i].timeType == 0) {
  2332. alldayNum++;
  2333. } else if (this.form.domains[i].timeType == 1) {
  2334. amNum++;
  2335. } else if (this.form.domains[i].timeType == 2) {
  2336. pmNum++;
  2337. }
  2338. }
  2339. if (alldayNum > 1) {
  2340. this.$toast.fail("工作时间-全天,只能选择一次");
  2341. return;
  2342. }
  2343. if (amNum > 1) {
  2344. this.$toast.fail("工作时间-上午,只能选择一次");
  2345. return;
  2346. }
  2347. if (pmNum > 1) {
  2348. this.$toast.fail("工作时间-下午,只能选择一次");
  2349. return;
  2350. }
  2351. if (alldayNum == 1 && (amNum > 0 || pmNum > 0)) {
  2352. this.$toast.fail("工作时间-全天,不能和上下午同时存在");
  2353. return;
  2354. }
  2355. } else if (this.reportTimeType.type == 3) {
  2356. //总百分比不能超过100%
  2357. let total = 0;
  2358. this.form.domains.forEach(w => { total += w.progress });
  2359. if (total > 100) {
  2360. this.$toast.fail("用时比例之和不能超过100%");
  2361. return;
  2362. } else if (total < 100) {
  2363. this.$toast.fail("工时尚未完全分配,无法提交");
  2364. return;
  2365. }
  2366. }
  2367. //非代填情况下要校验考勤
  2368. if (!this.substitute && this.user.timeType.notAllowedNoAttendance == 1 && this.isDraft == 0) {
  2369. if (this.report.time) {
  2370. if (this.report.time.workHours == 0) {
  2371. this.$toast.fail('无考勤记录不可填报')
  2372. return
  2373. }
  2374. } else {
  2375. this.$toast.fail('无考勤记录不可填报')
  2376. return
  2377. }
  2378. }
  2379. //针对凡己,不校验考勤时长
  2380. if (!this.substitute && this.user.companyId != 3918 && this.user.companyId != 5978 && this.user.companyId != 4281 && this.reportTimeType.type == 1 && this.report.time) {
  2381. var totalTime = 0;
  2382. for (var t = 0; t < this.form.domains.length; t++) {
  2383. totalTime += parseFloat(this.form.domains[t].workingTime);
  2384. }
  2385. if (this.report.time.workHours && totalTime > parseFloat(this.report.time.workHours)) {
  2386. this.$toast.fail("填报工时之和" + (totalTime) + "h不能超过考勤总工时(" + this.report.time.workHours.toFixed(1) + "h)");
  2387. return;
  2388. }
  2389. }
  2390. //填字段
  2391. for (var i in this.form.domains) {
  2392. // 检查任务/里程碑是否为必填
  2393. let taskRequired = this.user.timeType.taskRequired
  2394. if(taskRequired == 1) {
  2395. if(!this.form.domains[i].taskId) {
  2396. this.$toast.fail(`【${this.form.domains[i].projectName}】请选择 任务/里程碑`);
  2397. return
  2398. }
  2399. }
  2400. if (this.user.timeType.reportAuditType == 3) {
  2401. let audItem = {}
  2402. let auditRule = ''
  2403. if (this.form.domains[i].id) {
  2404. audItem.reportId = this.form.domains[i].id
  2405. }
  2406. if (this.user.timeType.auditLevel > 0) {
  2407. if (!this.form.domains[i].auditorFirst.id) { auditRule += '第一、' }
  2408. audItem.auditorFirst = this.form.domains[i].auditorFirst.id
  2409. }
  2410. if (this.user.timeType.auditLevel > 1) {
  2411. // if(!this.form.domains[i].auditorSec.id){ auditRule += '第二、' }
  2412. audItem.auditorSec = this.form.domains[i].auditorSec.id
  2413. }
  2414. if (this.user.timeType.auditLevel > 2) {
  2415. // if(!this.form.domains[i].auditorThird.id){ auditRule += '第三、' }
  2416. audItem.auditorThird = this.form.domains[i].auditorThird.id
  2417. }
  2418. if (this.form.domains[i].ccUserid.id) {
  2419. audItem.ccUserid = this.form.domains[i].ccUserid.id
  2420. }
  2421. if (auditRule) {
  2422. auditRule = auditRule.substring(0, auditRule.length - 1)
  2423. this.$toast.fail('请指定' + auditRule + '审核人')
  2424. return
  2425. }
  2426. formData.append("auditorSettingArray", JSON.stringify(audItem).replace(/,/g, "@"));
  2427. }
  2428. if (this.user.timeType.customDegreeActive == 1) {
  2429. let customDegreeMultiple = this.user.timeType.customDegreeMultiple
  2430. if (this.form.domains[i].degreeId) {
  2431. if(!customDegreeMultiple) { // 单选
  2432. formData.append("degreeId", this.form.domains[i].degreeId);
  2433. } else {
  2434. let newDegreeId = this.form.domains[i].degreeId.split(',')
  2435. formData.append("multiDegrId", JSON.stringify(newDegreeId).replace(/,/g, '@'))
  2436. }
  2437. } else {
  2438. if (this.user.timeType.customDegreeStatus && !this.form.domains[i].degreeId) {
  2439. this.$toast.fail('请选择' + this.user.timeType.customDegreeName)
  2440. return
  2441. } else {
  2442. if (!customDegreeMultiple) {
  2443. formData.append("degreeId", -1);
  2444. } else {
  2445. formData.append("multiDegrId", '[]');
  2446. }
  2447. }
  2448. }
  2449. } else {
  2450. formData.append("degreeId", -1);
  2451. }
  2452. if (this.form.domains[i].customData) {
  2453. formData.append("customData", this.form.domains[i].customData);
  2454. } else {
  2455. formData.append("customData", "0");
  2456. }
  2457. if (this.form.domains[i].customText) {
  2458. formData.append("customText", this.form.domains[i].customText);
  2459. } else {
  2460. formData.append("customText", "-");
  2461. }
  2462. if (this.form.domains[i].id) {
  2463. formData.append("id", this.form.domains[i].id);
  2464. } else {
  2465. formData.append("id", -1);
  2466. }
  2467. formData.append("projectId", parseFloat(this.form.domains[i].projectId));
  2468. if (this.form.domains[i].subProjectId) {
  2469. formData.append("subProjectId", this.form.domains[i].subProjectId);
  2470. } else {
  2471. formData.append("subProjectId", 0);
  2472. }
  2473. if (this.form.domains[i].groupId) {
  2474. formData.append("groupId", this.form.domains[i].groupId);
  2475. } else {
  2476. formData.append("groupId", 0);
  2477. }
  2478. if (this.form.domains[i].stage) {
  2479. formData.append("stage", this.form.domains[i].stage);
  2480. } else {
  2481. formData.append("stage", '-');
  2482. }
  2483. formData.append("reportTimeType", this.reportTimeType.type);
  2484. formData.append("multiWorktime", this.reportTimeType.multiWorktime);
  2485. if (this.reportTimeType.type == 0) {
  2486. formData.append("timeType", this.form.domains[i].timeType);
  2487. formData.append("workingTime", parseFloat(this.form.domains[i].workingTime));
  2488. } else if (this.reportTimeType.type == 1) {
  2489. formData.append("workingTime", parseFloat(this.form.domains[i].workingTime));
  2490. } else if (this.reportTimeType.type == 2) {
  2491. formData.append("startTime", this.form.domains[i].startTime);
  2492. formData.append("endTime", this.form.domains[i].endTime);
  2493. } else if (this.reportTimeType.type == 3) {
  2494. formData.append("progress", this.form.domains[i].progress);
  2495. formData.append("workingTime", this.form.domains[i].workingTime);
  2496. }
  2497. if (this.form.domains[i].taskId) {
  2498. formData.append("taskId", this.form.domains[i].taskId);
  2499. } else {
  2500. formData.append("taskId", 0);
  2501. }
  2502. if (this.form.domains[i].taskFinish == true) {
  2503. formData.append("taskFinish", 1);
  2504. } else {
  2505. formData.append("taskFinish", 0);
  2506. }
  2507. // formData.append("createDate", this.form.createDate);
  2508. if(this.substitute) {
  2509. formData.append("createDate", `${this.form.createDate}@${this.form.createDate}`);
  2510. formData.append("targetUids", this.fillingAgent.id || '');
  2511. } else {
  2512. formData.append("createDate", this.form.createDate);
  2513. }
  2514. formData.append("isOvertime", this.form.domains[i].isOvertime && this.user.timeType.fillOvertime ? 1 : 0);
  2515. if (this.form.domains[i].overtimeHours && this.form.domains[i].isOvertime == 1 && this.user.timeType.fillOvertime) {
  2516. formData.append("overtimeHours", this.form.domains[i].overtimeHours);
  2517. } else {
  2518. formData.append("overtimeHours", 0);
  2519. }
  2520. if (this.form.domains[i].basecostId) {
  2521. formData.append("basecostId", this.form.domains[i].basecostId);
  2522. }
  2523. //项目专业进度
  2524. if (this.form.domains[i].professionProgress) {
  2525. let m = JSON.stringify(this.form.domains[i].professionProgress);
  2526. m = m.replace(/,/g, "@");//replaceAll(',','@');企业微信不兼容replaceAll
  2527. formData.append("professionProgress", m);
  2528. } else {
  2529. formData.append("professionProgress", "[]");
  2530. }
  2531. //图片的处理,serverPic是当前所有的照片
  2532. if (this.form.domains[i].serverPics) {
  2533. let m = JSON.stringify(this.form.domains[i].serverPics);
  2534. m = m.replace(/,/g, "@");//replaceAll(',','@');企业微信不兼容replaceAll
  2535. formData.append("pics", m);
  2536. } else {
  2537. formData.append("pics", "@");
  2538. }
  2539. //处理多个时间事项
  2540. if (this.reportTimeType.multiWorktime == 1) {
  2541. //检查时间是否有重叠
  2542. var workList = this.form.domains[i].worktimeList;
  2543. for (var j = 0; j < workList.length; j++) {
  2544. var curItem = workList[j];
  2545. if (curItem.startTime == null || curItem.endTime == null) {
  2546. this.$toast.fail("请设置工作时间");
  2547. return;
  2548. }
  2549. //检查开始时间是否大于结束时间
  2550. if (curItem.startTime >= curItem.endTime) {
  2551. this.$toast.fail("时间段" + curItem.startTime + '-' + curItem.endTime + "有误:" +
  2552. "结束时间必须大于开始时间");
  2553. return;
  2554. }
  2555. //时间段不可重叠
  2556. if (this.reportTimeType.timeCanOverlap == 0) {
  2557. for (var p = j + 1; p < workList.length; p++) {
  2558. var jItem = workList[p];
  2559. if ((jItem.startTime >= curItem.startTime && jItem.startTime < curItem.endTime)
  2560. || (jItem.endTime > curItem.startTime && jItem.endTime <= curItem.endTime)) {
  2561. this.$toast.fail("时间段" + curItem.startTime + '-' + curItem.endTime + "与" +
  2562. jItem.startTime + '-' + jItem.endTime + "存在重叠,请修改。");
  2563. return;
  2564. }
  2565. }
  2566. }
  2567. }
  2568. let m = JSON.stringify(this.form.domains[i].worktimeList);
  2569. m = m.replace(/,/g, "@");//replaceAll(',','@');企业微信不兼容replaceAll
  2570. formData.append("content", m);
  2571. } else {
  2572. if (this.form.domains[i].content) {
  2573. formData.append("content", this.form.domains[i].content);
  2574. } else {
  2575. formData.append("content", '-');
  2576. }
  2577. }
  2578. //审核人
  2579. if (this.form.domains[i].projectAuditorId) {
  2580. formData.append("projectAuditorId", this.form.domains[i].projectAuditorId);
  2581. } else {
  2582. if (this.user.timeType.reportAuditType == 0) {
  2583. this.$toast.fail("请指定[" + this.form.domains[i].projectName + ']项目的审核人');
  2584. return;
  2585. } else if (this.user.timeType.reportAuditType == 1 || this.user.timeType.reportAuditType == 2 || this.user.timeType.reportAuditType == 9) {
  2586. if (this.form.domains[i].taskGroups.length == 0) {
  2587. this.$toast.fail("您在[" + this.form.domains[i].projectName + "]项目上尚无参与的任务分组");
  2588. return;
  2589. } else if (!this.form.domains[i].groupId) {
  2590. this.$toast.fail("请选择[" + this.form.domains[i].projectName + "]项目的任务分组");
  2591. return;
  2592. }
  2593. }
  2594. }
  2595. if (this.user.companyId == this.yuzhongCompId) {
  2596. formData.append('extraField1', this.form.domains[i].extraField1);
  2597. formData.append('extraField2', this.form.domains[i].extraField2);
  2598. formData.append('extraField3', this.form.domains[i].extraField3);
  2599. }
  2600. if (this.user.companyId == 3092) {
  2601. formData.append('sapServiceId', this.form.domains[i].sapServiceId);
  2602. }
  2603. if(this.user.timeType.taskGroupRequired == 1 && !this.form.domains[i].groupId) {
  2604. this.$toast.fail("请选择[" + this.form.domains[i].projectName + "]项目的任务分组");
  2605. return;
  2606. }
  2607. if(this.user.timeType.userWithMultiDept == 1 && this.userReportDeptList.length > 0) {
  2608. if(this.form.domains[i].reportTargetDeptId) {
  2609. formData.append('reportTargetDeptId', this.form.domains[i].reportTargetDeptId || -1);
  2610. } else {
  2611. this.$toast.fail("请选择[" + this.form.domains[i].projectName + "]填报部门");
  2612. return;
  2613. }
  2614. }
  2615. }
  2616. if (!this.flgLg) {
  2617. return
  2618. }
  2619. this.flgLg = false
  2620. this.$axios.post("/report/editReport", formData)
  2621. .then(res => {
  2622. this.flgLg = true
  2623. if (res.code == "ok") {
  2624. this.$toast.clear();
  2625. if (res.msg != null) {
  2626. this.$dialog.alert({
  2627. message: res.msg,
  2628. }).then(() => {
  2629. // on close
  2630. this.$router.push("/index");
  2631. });
  2632. } else {
  2633. this.$toast.success(this.isDraft == 0 ? '提交成功' : '暂存成功');
  2634. setTimeout(() => {
  2635. this.$router.push("/index");
  2636. }, 500);
  2637. }
  2638. } else {
  2639. this.$toast.clear();
  2640. this.$toast.fail((this.isDraft == 0 ? '提交失败' : '暂存失败') + ':' + res.msg);
  2641. }
  2642. }).catch(err => { this.$toast.clear(); this.flgLg = true });
  2643. },
  2644. //初始化参数
  2645. initWxConfig() {
  2646. var curUrl = location.href.split("#")[0];
  2647. this.$axios.post("/wxcorp/getCorpWXConfig", { url: curUrl, token: this.user.id })
  2648. .then(res => {
  2649. if (res.code == "ok") {
  2650. var data = res.data;
  2651. wx.config({
  2652. beta: true,
  2653. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  2654. appId: data.appid, // 必填,公众号的唯一标识
  2655. timestamp: data.timestamp, // 必填,生成签名的时间戳
  2656. nonceStr: data.noncestr, // 必填,生成签名的随机串
  2657. signature: data.sign, // 必填,签名,见附录1
  2658. jsApiList: [
  2659. 'chooseImage',
  2660. 'previewImage',
  2661. 'uploadImage',
  2662. 'downloadImage',
  2663. 'previewFile',
  2664. 'getLocation',
  2665. ]
  2666. });
  2667. var that = this;
  2668. wx.ready(function () {
  2669. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  2670. // if (that.user.companyId == 7) {
  2671. // that.$toast('wx init success==7 ');
  2672. // that.getLocation();
  2673. // }
  2674. });
  2675. } else {
  2676. this.$toast.fail('获取失败');
  2677. }
  2678. }).catch(err => { this.$toast.fail('发生异常' + err); console.log(err) });
  2679. },
  2680. deleteImg(item, index) {
  2681. //删除添加的图片
  2682. if (this.isIOSystem) {
  2683. item.iospics.splice(index, 1);
  2684. item.iospics = item.iospics;
  2685. }
  2686. item.pics.splice(index, 1);
  2687. item.pics = item.pics;
  2688. //传递到后台的数据也要做同步删除
  2689. item.serverPics.splice(index, 1);
  2690. this.$forceUpdate();
  2691. },
  2692. //企业微信获取定位
  2693. getLocation() {
  2694. wx.getLocation({
  2695. type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  2696. success: function (res) {
  2697. var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
  2698. var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
  2699. alert(JSON.stringify(res));
  2700. }
  2701. });
  2702. },
  2703. // 获取可选部门
  2704. getReportDeptList() {
  2705. this.$axios.post("/user/getUserInfo", {userId: this.user.id})
  2706. .then(res => {
  2707. if(res.code == "ok") {
  2708. let lists = res.data.userReportDeptList || []
  2709. const optimizedList = lists.map(item => ({
  2710. ...item,
  2711. label: item.departmentName,
  2712. value: item.departmentId,
  2713. }));
  2714. this.userReportDeptList = optimizedList
  2715. console.log(this.userReportDeptList, '<==== 返回的数据')
  2716. } else {
  2717. this.$toast.fail('获取失败:'+res.msg);
  2718. }
  2719. }).catch(err=> {this.$toast.clear();});
  2720. }
  2721. },
  2722. mounted() {
  2723. const { substitute } = this.$route.query;
  2724. if (substitute) {
  2725. this.substitute = true;
  2726. }
  2727. this.today = this.format(new Date(), 'yyyy-MM-dd')
  2728. this.timeRange = []
  2729. let i = 0.0;
  2730. while(true) {
  2731. if (i < 48) {
  2732. //校验上下限
  2733. if (i >= this.user.timeType.minReportTime && i <= this.user.timeType.maxReportTime) {
  2734. this.timeRange.push(i);
  2735. }
  2736. i += 0.5;
  2737. } else {
  2738. break;
  2739. }
  2740. }
  2741. // console.log('user',this.user)
  2742. var ua = navigator.userAgent.toLowerCase();
  2743. this.isIOSystem = this.isIOS();
  2744. if (ua.indexOf("wxwork") > 0) {
  2745. this.isCorpWX = true;
  2746. } else if (ua.indexOf("micromessenger") > 0) {
  2747. this.isWX = true;
  2748. }
  2749. this.getProject() //获取项目
  2750. this.getReportBasecostList()
  2751. //获取传递过来的日期
  2752. var passDate = this.$route.query.date;
  2753. if (passDate != null) {
  2754. this.form.createDate = this.$route.query.date;
  2755. }
  2756. if (this.substitute) {
  2757. //代填日报
  2758. this.initFormData();
  2759. } else {
  2760. //个人自己填报
  2761. this.getReport();
  2762. }
  2763. this.getAllUsersList()
  2764. this.getTimeType();
  2765. this.getMultiOptionData();
  2766. //初始化微信js-sdk参数
  2767. if (this.isCorpWX) {
  2768. this.initWxConfig();
  2769. }
  2770. if (this.user.timeType.lockWorktime) {
  2771. this.timeRange = this.timeRange.filter(item => { return item <= this.user.timeType.allday })
  2772. }
  2773. if (this.user.companyId == this.yuzhongCompId) {
  2774. this.getJobResponList();
  2775. }
  2776. if(this.user.timeType.userWithMultiDept) {
  2777. this.getReportDeptList()
  2778. }
  2779. },
  2780. beforeDestroy() {
  2781. localStorage.removeItem('formVal')
  2782. }
  2783. };
  2784. </script>
  2785. <style lang="less" scope>
  2786. .groupingSelection {
  2787. height: 100%;
  2788. overflow-y: auto;
  2789. padding: 10px 0;
  2790. .groupingSelectionItem {
  2791. padding: 15px 15px;
  2792. border-bottom: 1px solid #c2c2c2;
  2793. }
  2794. }
  2795. .chooseSomeone {
  2796. height: 80vh;
  2797. display: flex;
  2798. flex-direction: column;
  2799. .chooseSomeoneFlex1 {
  2800. flex: 1;
  2801. overflow: auto;
  2802. }
  2803. .chooseSomeoneBtn {
  2804. width:100%;
  2805. }
  2806. }
  2807. .my-swipe .van-swipe-item {
  2808. color: #fff;
  2809. font-size: 20px;
  2810. line-height: 150px;
  2811. text-align: center;
  2812. background-color: #39a9ed;
  2813. }
  2814. .van-field__control:disabled {
  2815. -webkit-text-fill-color: #646566;
  2816. }
  2817. .login_form {
  2818. margin-top: 46px;
  2819. position: relative;
  2820. }
  2821. .attendanceRecord {
  2822. // position: absolute;
  2823. // top: 0.26667rem;
  2824. // right: 0.42667rem;
  2825. color: #969799;
  2826. text-align: center;
  2827. font-size: 0.35rem;
  2828. line-height: 0.64rem;
  2829. }
  2830. .form_domains {
  2831. position: relative;
  2832. .form_copy {
  2833. position: absolute;
  2834. right: 85px;
  2835. top: 10px;
  2836. }
  2837. .form_addNew {
  2838. text-align: center;
  2839. margin: 10px;
  2840. }
  2841. .form_del {
  2842. position: absolute;
  2843. right: 10px;
  2844. top: 10px;
  2845. }
  2846. // .form_del {
  2847. // color: #ff0000;
  2848. // font-size: 22px;
  2849. // position: absolute;
  2850. // right: 15px;
  2851. // top: 10px;
  2852. // }
  2853. }
  2854. .form_tip {
  2855. text-align: center;
  2856. margin-top: 20px;
  2857. color: #afafaf;
  2858. font-size: 14px;
  2859. }
  2860. .card__footer {
  2861. padding-top: 10px;
  2862. }
  2863. .card__tags {
  2864. .van-tag {
  2865. margin-right: 5px;
  2866. }
  2867. }
  2868. .overTimeClas {
  2869. display: flex;
  2870. width: 7.4rem;
  2871. // justify-content: space-between;
  2872. align-items: center;
  2873. }
  2874. </style>
  2875. <style lang="less">
  2876. .van-nav-bar .van-icon,
  2877. .van-nav-bar__text {
  2878. color: #20a0ff;
  2879. }
  2880. .overtime {
  2881. height: 50px;
  2882. box-sizing: border-box;
  2883. padding-left: 10px;
  2884. display: flex;
  2885. align-items: center;
  2886. }
  2887. .custom-button {
  2888. width: 40px;
  2889. color: #fff;
  2890. font-size: 10px;
  2891. line-height: 16px;
  2892. text-align: center;
  2893. background-color: #1989fa;
  2894. border-radius: 100px;
  2895. }
  2896. .imgList {
  2897. position: relative;
  2898. width: 100px;
  2899. height: 100px;
  2900. display: inline-block;
  2901. }
  2902. .imgList_i {
  2903. position: absolute;
  2904. top: -8px;
  2905. right: -6px;
  2906. z-index: 999;
  2907. }
  2908. .ryuan {
  2909. padding: 0.3rem 0.53333rem;
  2910. // line-height: 40px;
  2911. // height: 40px;
  2912. overflow: auto;
  2913. color: #333;
  2914. border-bottom: 2px solid #f6f6f6;
  2915. width: 100%;
  2916. overflow: hidden;
  2917. text-overflow: ellipsis;
  2918. white-space: nowrap;
  2919. }
  2920. .overListTime {
  2921. margin-left: 5px;
  2922. display: inline-block;
  2923. width: 2rem;
  2924. color: #646566;
  2925. }
  2926. .hoveOver {
  2927. color: #C8C9CC;
  2928. }
  2929. .van-checkbox__label {
  2930. color: #646566 !important;
  2931. }
  2932. .van-checkbox__label--disabled {
  2933. color: #c8c9cc !important;
  2934. }
  2935. </style>