weekEdit.vue 119 KB

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