index.vue 102 KB

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