weekEdit.vue 135 KB

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