weekEdit.vue 101 KB

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