weekEdit.vue 104 KB

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