index.vue 106 KB

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