weekEdit-02.vue 128 KB

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