weekEdit.vue 156 KB

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