index.vue 151 KB

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