weekEdit.vue 121 KB

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