daily.vue 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-date-picker v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" @change="changeMonthOut" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
  8. </el-form-item>
  9. </el-form>
  10. </el-col> -->
  11. <!--列表-->
  12. <div>
  13. <el-card class="box-card daily" shadow="never">
  14. <div slot="header" class="clearfix" id="clearfix" style="padding-left: 195px;">
  15. <div class="jjk" style="display:inline-block;position:fixed;top:70px;background:#fff;left:250px;">
  16. <el-date-picker size="small" v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" style="width:190px;"
  17. @change="changeMonthOut" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
  18. </div>
  19. <span v-for="(item,index) in allDate" :id="'day'+index" :class="index==choseDay?'chooseDate date_item':'date_item'"
  20. @click="choseDate(index, item)" :key="index" >
  21. <div :style="'display:inline-block;'+(item.state == null?'padding:0px 6px;':'')" >
  22. <div><span>{{item.showDate}}</span>
  23. <span style="font-size:10px;text-align:center;color:#999;">{{item.weekDay}}</span>
  24. </div>
  25. </div>
  26. <i v-if="item.state != null" class="iconfont firerock-icondot" :class="statusStyle[item.state]"></i>
  27. </span>
  28. </div>
  29. <div style="display:flex;">
  30. <div v-if="user.role > 0 || user.manageDeptId != 0" >
  31. <div style="width:190px;">
  32. <el-select v-model="selectState" size="small" @change="stateChange" >
  33. <el-option value="-1" label="全部状态" >全部状态</el-option>
  34. <el-option value="-2" label="未填报">未填报</el-option>
  35. <el-option value="1" label="已通过">已通过</el-option>
  36. <el-option value="0" label="待审核">待审核</el-option>
  37. <el-option value="2" label="不通过">不通过</el-option>
  38. <el-option value="3" label="已撤回">已撤回</el-option>
  39. </el-select></div>
  40. <div>
  41. <el-tree :data="data" @node-click="handleNodeClick" >
  42. <span class="custom-tree-node" slot-scope="{ node, data}">
  43. <span>{{ node.label }}</span>
  44. <span v-if="data.membCount != null && data.isUser == null">({{data.membCount}})</span>
  45. <div style="width:0%;float:right;">
  46. <span v-if="data.isUser == 1 && data.state == null" style="color:red;">
  47. 未填报
  48. </span>
  49. <span v-if="data.isUser == 1 && data.state == 0" style="color:orange;">
  50. 待审核
  51. </span>
  52. <span v-if="data.isUser == 1 && data.state == 1" style="color:green;">
  53. 已通过
  54. </span>
  55. <span v-if="data.isUser == 1 && data.state == 2" style="color:red;">
  56. 未通过
  57. </span>
  58. <span v-if="data.isUser == 1 && data.state == 3" style="color:red;">
  59. 已撤回
  60. </span>
  61. </div>
  62. </span>
  63. </el-tree>
  64. </div>
  65. </div>
  66. <div :style="'height:'+tableHeight+'px;width:0.5px;background:#eee;margin-right:10px;margin-left:10px;'" ></div>
  67. <div class="allDaily" style="float:left;flex-grow:1">
  68. <!--系统管理员和部门负责人 -->
  69. <div class="report_title" v-if="user.role == 1 || user.role == 2 || user.manageDeptId > 0">
  70. <span>工作日报 | {{depData != null ?depData.label:""}}</span>
  71. <span v-if="targetUid == null">
  72. - 已填写
  73. <el-link :underline="false" @click="showMembList(1)"><span style="margin-left:5px;margin-right:5px;color:green;">{{reportList.length}}</span></el-link>人,
  74. 未填写<el-link :underline="false" @click="showMembList(0)"><span style="margin-left:5px;margin-right:5px;color:red;">{{(depData == null?data[0].membCount:(depData.isUser == 1?1:depData.membCount))-reportList.length}}</span></el-link>人
  75. </span>
  76. <span style="float:right;">
  77. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,0)">填写日报</el-link>
  78. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,1)">批量填报</el-link>
  79. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="showExportDialog">导出日报</el-link>
  80. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="batchApprove" >批量审核</el-link>
  81. </span>
  82. </div>
  83. <!--普通员工,含项目经理 -->
  84. <div class="report_title" v-if="(user.role==0||user.role==5) && user.manageDeptId == 0"><span>日报列表</span>
  85. <span style="float:right;" v-if="(user.role==0||user.role==5) && user.manageDeptId == 0">
  86. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,0)">填写日报</el-link>
  87. <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,1)">批量填报</el-link>
  88. <el-link type="primary" v-if="user.leader" style="margin-right:10px;" :underline="false" @click="batchApprove">批量审核</el-link>
  89. </span>
  90. </div>
  91. <div :style="'height:'+(tableHeight-50)+'px;overflow:scroll;padding-top:10px;'">
  92. <div class="one_daily" v-for="(item1,index1) in reportList" :key="index1">
  93. <i class="fa fa-circle"></i>{{item1.name}}
  94. <span style="margin-left:30px;">
  95. <span style="margin-right:20px;">
  96. <!-- <i v-if="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5" style="color:red;margin-right:8px;" class="fa fa-exclamation-triangle"></i> -->
  97. 工作总时长:
  98. <!-- <span :style="parseFloat(item1.reportTime)>parseFloat(item1.calculateTime)+0.5?'color:red':''">{{item1.reportTime}}h</span> -->
  99. <span >{{item1.reportTime}}</span>h
  100. <span v-if="user.role ==4 || user.role ==6"><span style="margin-left:10px;">成本:</span>
  101. <span >{{item1.cost}}</span>元</span>
  102. </span>
  103. </span>
  104. <div class="checkbtn">
  105. <el-button v-if="(user.role == 1 || user.role == 2 || user.id == item1.data[0].inchargerId) && item1.state == 0" type="primary" :loading="logining" size="small" @click="approve(item1.id, item1)">通过</el-button>
  106. <el-button v-if="(user.role == 1 || user.role == 2 || user.id == item1.data[0].inchargerId) && item1.state == 0" type="danger" :loading="logining" size="small" @click="deny(item1.id,0, item1)">驳回</el-button>
  107. <!--自己可以撤回待审核状态的报告 -->
  108. <el-button v-if="(user.id == item1.id) && item1.state == 0" type="normal" :loading="logining" size="small" @click="cancel(item1)">撤回</el-button>
  109. <el-button v-if="(user.role == 1 || user.role == 2 || user.id == item1.data[0].inchargerId) && item1.state == 1" type="normal" :loading="logining" size="small" @click="deny(item1.id,1, item1)">撤销</el-button>
  110. <el-button v-if="item1.state >= 2 && user.id == item1.id" type="primary" size="small" @click="fillInReport(index1,0)">编辑日报</el-button>
  111. </div>
  112. <div class="one_daily_body">
  113. <el-timeline>
  114. <el-timeline-item v-for="(item2,index2) in item1.data" :key="index2">
  115. <el-card shadow="never">
  116. <p>项目:<b>{{item2.project}}</b><span v-if="item2.subProjectName != null"> / {{item2.subProjectName}}</span>
  117. <span style="margin-left:15px;color:#DAA520;" v-if="item2.state == 0">[ 待审核 ]</span>
  118. <span style="margin-left:15px;color:#32CD32;" v-else-if="item2.state == 1">[ 已通过 ]</span>
  119. <span style="margin-left:15px;color:#FF0000;" v-else-if="item2.state == 2">[ 已驳回 ]</span>
  120. <span style="margin-left:15px;color:#FF0000;" v-else-if="item2.state == 3">[ 已撤回 ]</span>
  121. </p>
  122. <p v-if="item2.taskId != null">任务:{{item2.taskName}}
  123. </p>
  124. <p style="display: inline-block;">时长:
  125. <span v-if="item2.reportTimeType == 0" style="margin-right:10px;">{{typeList[item2.timeType]}}</span>
  126. <span v-if="item2.reportTimeType == 2" style="margin-right:10px;">{{item2.startTime+'-'+item2.endTime}}</span>
  127. {{item2.time.toFixed(1)}}h
  128. <el-tag type="danger" size="mini" style="margin-left: 65px" v-if="item2.isOvertime === 1">加班</el-tag>
  129. </p>
  130. <p>事项:<span v-html="item2.content"></span></p>
  131. </el-card>
  132. </el-timeline-item>
  133. </el-timeline>
  134. </div>
  135. </div>
  136. <!-- 简陋的无报告提示 -->
  137. <div v-if="reportList.length==0" style="width:100%;font-size:17px;text-align:center;color:#aaa;">{{curDate}}暂无报告</div>
  138. </div>
  139. </div>
  140. </div>
  141. </el-card>
  142. </div>
  143. <!-- 填写日报的dialog -->
  144. <el-dialog :title="isBatch==0?'填写日报':'批量填报'" :visible.sync="dialogVisible" width="60%" :close-on-click-modal="false">
  145. <el-form ref="workForm" :model="workForm" :rules="workRules" label-width="100px">
  146. <el-form-item label="工作日期" prop="createDate">
  147. <el-date-picker v-model="workForm.createDate" :editable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  148. :style="'width:'+(isBatch==0?'200':'280')+'px;'" :type="isBatch==0?'date':'daterange'"
  149. @change="changeMonth()" :clearable="false" placeholder="选择工作日期" :disabled="isDisable"></el-date-picker>
  150. <span v-if="reportTimeType.type == 3" style="margin-left:30px;">总时长:</span>
  151. <el-input-number :disabled="!canEdit" v-if="reportTimeType.type == 3" style="margin-left:10px;" @change="changeAllTime"
  152. v-model="reportTimeType.allday" :precision="1" :step="0.5" :max="12" :min="0.5"></el-input-number>
  153. <span v-if="reportTimeType.type == 3">小时</span>
  154. </el-form-item>
  155. <div v-for="(domain, index) in workForm.domains" :key="domain.id">
  156. <el-form-item v-if="reportTimeType.type != 3" label="工作时长" :prop="'domains.' + index + '.'+timeFields[reportTimeType.type]"
  157. :rules="{ required: true, message: '请选择工作时长', trigger: 'blur' }">
  158. <el-select v-model="domain.timeType" style="width:200px;"
  159. v-if="reportTimeType.type == 0"
  160. placeholder="请选择工作时长"
  161. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)"
  162. @change="onTimeTypeChange(domain.timeType)">
  163. <el-option
  164. v-for="item in timeType"
  165. :key="item.value"
  166. :label="item.label"
  167. :value="item.value">
  168. </el-option>
  169. </el-select>
  170. <!-- 数字时长选择 -->
  171. <el-select v-model="domain.workingTime" style="width:200px;"
  172. v-if="reportTimeType.type == 1"
  173. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)"
  174. placeholder="请选择工作时长" >
  175. <el-option v-for="item in timeRange" :key="item" :value="item.toFixed(1)">{{item.toFixed(1)}}</el-option>
  176. </el-select>
  177. <span v-if="reportTimeType.type == 1">小时</span>
  178. <span v-if="reportTimeType.type == 2">
  179. <!--时间范围选择 -->
  180. <el-time-picker
  181. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)"
  182. v-model="domain.startTime"
  183. placeholder="起始时间"
  184. style="width:120px;"
  185. format="HH:mm"
  186. value-format="HH:mm"
  187. :picker-options="{
  188. start: '08:00',
  189. end: '23:30'
  190. }">
  191. </el-time-picker> - <el-time-picker
  192. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)"
  193. v-model="domain.endTime"
  194. placeholder="结束时间"
  195. style="width:120px;"
  196. format="HH:mm"
  197. value-format="HH:mm"
  198. :picker-options="{
  199. start: '08:00',
  200. end: '23:30',
  201. minTime: domain.startTime
  202. }">
  203. </el-time-picker>
  204. </span>
  205. <div class="overtime"><el-checkbox :disabled="!canEdit" v-model="domain.isOvertime">加班</el-checkbox></div>
  206. </el-form-item>
  207. <el-form-item label="投入项目" :prop="'domains.' + index + '.projectId'"
  208. :rules="{ required: true, message: '请选择投入项目', trigger: ['change','blur'] }">
  209. <el-select v-model="domain.projectId" placeholder="请选择" style="width:200px;" clearable="true" @change="selectProject(domain, index)"
  210. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)">
  211. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  212. </el-select>
  213. <!--子项目 -->
  214. <el-select v-model="domain.subProjectId" placeholder="请选择" style="width:200px;" clearable="true" v-if="domain.subProjectList != null && domain.subProjectList.length> 0"
  215. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)">
  216. <el-option v-for="item in domain.subProjectList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  217. </el-select>
  218. <el-link v-if="index >= 1" type="primary" :underline="false" @click="delDomain(index)" style="float:right;margin-right:10px;"
  219. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)">
  220. <i class="fa fa-trash" style="color: red;;font-size:18px;"></i>
  221. </el-link>
  222. </el-form-item>
  223. <el-form-item v-if="reportTimeType.type == 3" label="用时占比" :prop="'domains.' + index + '.'+timeFields[reportTimeType.type]"
  224. :rules="{ required: true, message: '请选择工作时长', trigger: 'blur' }">
  225. <div style="width:300px;">
  226. <el-col span="14"><el-slider :disabled="!canEdit" v-model="domain.progress" :min="10" :show-tooltip="false" :step="10" style="width:180px;" @change="domain.workingTime = (reportTimeType.allday*domain.progress/100).toFixed(1)"></el-slider></el-col>
  227. <el-col span="10"><span style="margin-left:10px;float:right;"><span style="margin-right:10px;">{{domain.progress}}%</span>{{domain.workingTime}}小时</span></el-col>
  228. </div>
  229. <div class="overtime"><el-checkbox :disabled="!canEdit" v-model="domain.isOvertime">加班</el-checkbox></div>
  230. </el-form-item>
  231. <!--项目管理专业版模式下,项目下的近期执行的任务 -->
  232. <el-form-item label="相关任务" :prop="'domains.' + index + '.taskId'" v-if="user.company.packageProject==1">
  233. <el-select v-model="domain.taskId" placeholder="请选择" style="width:100%;"
  234. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)">
  235. <el-option v-for="item in domain.taskList" :key="item.taskId" :label="item.taskName" :value="item.taskId"></el-option>
  236. </el-select>
  237. </el-form-item>
  238. <el-form-item label="工作事项" :prop="'domains.' + index + '.content'" >
  239. <el-input v-model="domain.content" type="textarea" :rows="4" placeholder="请填写工作事项" clearable
  240. :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)"></el-input>
  241. </el-form-item>
  242. <el-divider v-if="workForm.domains.length>1" style="margin-bottom:10px;"></el-divider>
  243. </div>
  244. <el-link v-if="showAddMore" :disabled="!canEdit" type="primary" :underline="false" @click="addDomain" style="margin-left:40px">添加更多</el-link>
  245. </el-form>
  246. <span slot="footer" class="dialog-footer">
  247. <el-button @click="deleteReport" v-if="workForm.domains[0].id != null">删除</el-button>
  248. <el-button @click="dialogVisible = false">取消</el-button>
  249. <el-button type="primary" @click="submitDepartment"
  250. :disabled="workForm.domains.length==0?true:(canEdit?false:true)" >提交</el-button>
  251. </span>
  252. </el-dialog>
  253. <!-- 批量日报审核 -->
  254. <el-dialog title="批量日报审核" :visible.sync="approveDialogVisible" width="500px" >
  255. <el-checkbox v-model="isAllSelect" label="全选" style="margin-left:24px;" @change="selectAll" v-if="reportNames.length > 0"></el-checkbox>
  256. <el-tree ref="approveTree" node-key="id" :data="reportNames" show-checkbox="true" @check-change="handleCheckChange" >
  257. </el-tree>
  258. <span slot="footer" class="dialog-footer">
  259. <el-button @click="approveDialogVisible = false">取消</el-button>
  260. <el-button type="primary" @click="submitBatchApprove" :disabled="batchShowData.length == 0">审核通过</el-button>
  261. </span>
  262. </el-dialog>
  263. <!--导出报表条件选择 -->
  264. <el-dialog title="日报导出" v-if="exportDialog" :visible.sync="exportDialog" customClass="customWidth" width="500px">
  265. <el-form ref="form3" :model="exportParam" >
  266. <el-form-item prop="projectId" label="选择项目">
  267. <el-select v-model="exportParam.projectId" placeholder="全部项目" clearable style="width:350px;">
  268. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
  269. </el-select>
  270. </el-form-item>
  271. <el-form-item prop="projectId" label="日期范围">
  272. <el-date-picker
  273. v-model="exportParam.dateRange" :editable="false"
  274. format="yyyy-MM-dd" value-format="yyyy-MM-dd"
  275. :clearable="true"
  276. range-separator="至"
  277. type="daterange"
  278. start-placeholder="开始日期"
  279. end-placeholder="结束日期"
  280. ></el-date-picker>
  281. </el-form-item>
  282. </el-form>
  283. <div slot="footer" class="dialog-footer">
  284. <el-button type="primary" @click="exportReport" style="width:100%;" >导出</el-button>
  285. </div>
  286. </el-dialog>
  287. <!--人员列表 -->
  288. <el-dialog :title="(isFill?'已填':'未填')+'人员列表'" v-if="membListVisible" :visible.sync="membListVisible" width="500px">
  289. <el-table :show-header="false" :data="fillMembList" highlight-current-row :height="400" style="width: 100%;">
  290. <el-table-column type="index" width="60">
  291. <template slot-scope="scope" >
  292. {{scope.$index+1}}
  293. </template>
  294. </el-table-column>
  295. <el-table-column prop="label" label="姓名" ></el-table-column>
  296. <el-table-column prop="deptName" label="部门" >
  297. </el-table-column>
  298. </el-table>
  299. <div slot="footer" class="dialog-footer">
  300. <el-button type="primary" @click="weixinNotify" v-if="!isFill" :disabled="fillMembList == 0">微信催填</el-button>
  301. <el-button type="default" @click="exportMemb" :disabled="fillMembList == 0">导出</el-button>
  302. </div>
  303. </el-dialog>
  304. </section>
  305. </template>
  306. <script>
  307. import util from "../../common/js/util";
  308. export default {
  309. data() {
  310. return {
  311. isFill:false,
  312. unFillList:[],
  313. fillList:[],
  314. fillMembList:[],
  315. membListVisible: false,
  316. isBatch:0,//是否是批量填报
  317. weekDay : ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
  318. statusStyle:["waiting", "filledReportStyle", "RejectStyle", ""],
  319. fillStatusList: [],
  320. exportParam:{projectId: null, dateRange:[]},
  321. exportDialog:false,
  322. timeFields:['timeType', 'workingTime', 'startTime', 'progress'],
  323. subProjectList:[],
  324. canEdit: true,
  325. 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.0,12.5,13.0,13.5,14.0,14.5,15.0],
  326. selectTime:null,
  327. reportTimeType:{},
  328. curDate:'',
  329. isAllSelect: false,
  330. approveDialogVisible:false,
  331. deptId:null,
  332. targetUid: null,
  333. membCount:0,
  334. selectState:"-1",
  335. user: JSON.parse(sessionStorage.getItem("user")),
  336. showAddMore:false,
  337. allDate: [],
  338. typeList:['全天','上午','下午'],
  339. date: sessionStorage.msg?sessionStorage.msg.split('-')[0]+"-"+sessionStorage.msg.split('-')[1]:util.formatDate.format(new Date(new Date()), "yyyy-MM"),
  340. choseDay: 0,
  341. tableHeight: 0,
  342. listLoading: false,
  343. projectList: [], //项目列表
  344. reportList: [], //日报列表
  345. reportNames:[], //批量审批列表
  346. dialogVisible: false, //项目弹窗
  347. report: '',
  348. workForm: {
  349. createDate: sessionStorage.msg?sessionStorage.msg:util.formatDate.format(new Date(new Date()), "yyyy-MM-dd"),
  350. domains: [{
  351. id: null,
  352. projectId: "",
  353. workingTime: "",
  354. timeType:0,
  355. content: "",
  356. state: 2,
  357. }],
  358. },
  359. workRules: {
  360. createDate: [{ required: true, message: "请选择工作日期", trigger: "change" }],
  361. },
  362. logining: false,
  363. isDisable: false,
  364. timeType:[],
  365. //部门人员树状结构
  366. data: [
  367. {
  368. id: -1,
  369. label: '全部人员',
  370. membCount:0
  371. },
  372. {
  373. id: 0,
  374. label: '未分配',
  375. }
  376. ],
  377. allData:{},
  378. batchShowData:{},
  379. option: [],
  380. depData: {
  381. id: -1,
  382. label: '全部人员',
  383. },
  384. defaultProps: {
  385. children: 'children',
  386. label: 'label'
  387. },
  388. isNew: false,
  389. selected: false,
  390. valuet: new Date(),
  391. domObj: null,
  392. };
  393. },
  394. methods: {
  395. //微信通知人员填写
  396. weixinNotify() {
  397. if (this.fillMembList.length == 0) return;
  398. var ids = '';
  399. this.fillMembList.forEach(f=>{
  400. ids += f.id+',';
  401. })
  402. this.http.post('/user/pushFillReport',{
  403. ids: ids, date: this.curDate
  404. },
  405. res => {
  406. if (res.code == "ok") {
  407. this.$message({
  408. message: '已发送成功',
  409. type: "success"
  410. });
  411. }
  412. },
  413. error => {
  414. this.$message({
  415. message: error,
  416. type: "error"
  417. });
  418. }
  419. );
  420. },
  421. //导出人员列表
  422. exportMemb() {
  423. if (this.fillMembList.length == 0) return;
  424. var ids = '';
  425. this.fillMembList.forEach(f=>{
  426. ids += f.id+',';
  427. })
  428. this.http.post('/user/exportMembList',{
  429. ids: ids,isFill: this.isFill, date: this.curDate
  430. },
  431. res => {
  432. if (res.code == "ok") {
  433. var aTag = document.createElement('a');
  434. aTag.download = this.curDate+(this.isFill?"已填":"未填")+"人员列表.xls";
  435. aTag.href = res.data;
  436. aTag.click();
  437. }
  438. },
  439. error => {
  440. this.$message({
  441. message: error,
  442. type: "error"
  443. });
  444. }
  445. );
  446. },
  447. showMembList(fill) {
  448. this.membListVisible = true;
  449. if (fill == 0) {
  450. this.fillMembList = this.unFillList;
  451. this.isFill = false;
  452. } else {
  453. this.fillMembList = this.fillList;
  454. this.isFill = true;
  455. }
  456. },
  457. //获取自己填写的日报状态
  458. getReportFillStatus() {
  459. this.http.post('/report/getReportFillStatus',{
  460. startDate: this.date+"-01", endDate: this.date+"-31", userId: this.user.id
  461. },
  462. res => {
  463. if (res.code == "ok") {
  464. this.fillStatusList = res.data;
  465. this.allDate.forEach(d=>{
  466. var fillInfo = null;
  467. d.state = null;
  468. this.fillStatusList.forEach(s=>{
  469. var d1 = s.createDate.split('-')[2];
  470. var d2 = d.date.split('月')[1].split('日')[0];
  471. if (d1.indexOf('0') == 0) {
  472. d1 = d1.substring(1,d1.length);
  473. }
  474. if (d1 == d2) {
  475. d.state = s.state;
  476. }
  477. })
  478. })
  479. this.$forceUpdate();
  480. }
  481. },
  482. error => {
  483. this.$message({
  484. message: error,
  485. type: "error"
  486. });
  487. }
  488. );
  489. },
  490. scrollFunction () {
  491. this.domObj = document.getElementById('clearfix') // 通过id获取要设置的div
  492. if (this.domObj.attachEvent) { // IE
  493. this.domObj.attachEvent('onmousewheel', this.mouseScroll)
  494. } else if (this.domObj.addEventListener) {
  495. this.domObj.addEventListener('DOMMouseScroll', this.mouseScroll, false)
  496. }
  497. this.domObj.onmousewheel = this.domObj.onmousewheel = this.mouseScroll
  498. },
  499. mouseScroll(event) { // google 浏览器下
  500. let detail = event.wheelDelta || event.detail
  501. let moveForwardStep = -1
  502. let moveBackStep = 1
  503. let step = 0
  504. step = detail > 0 ? moveForwardStep * 100 : moveBackStep * 100
  505. event.preventDefault() // 阻止浏览器默认事件
  506. this.domObj.scrollLeft = this.domObj.scrollLeft + step
  507. },
  508. // //左右滚动
  509. // wheel(e){
  510. // var a = document.getElementById("dateScroll");
  511. // var scroll_width = 80; //滚动一下的距离
  512. // var e = e || window.event, v;
  513. // e.wheelDelta ? v=e.wheelDelta : v=e.detail;
  514. // if(v>3||-v>3) v=-v;
  515. // v>0 ? a.scrollLeft+=scroll_width : a.scrollLeft-=scroll_width;
  516. // e.preventDefault(); //阻止浏览器的默认滚动
  517. // },
  518. showExportDialog() {
  519. this.exportDialog = true;
  520. },
  521. changeAllTime() {
  522. //总时长发生改变,自动按比例计算
  523. this.workForm.domains.forEach(d=>{
  524. d.workingTime = (d.progress*this.reportTimeType.allday/100).toFixed(1);
  525. });
  526. },
  527. // 是否加班的单机事件
  528. check() {
  529. this.selected = !this.selected
  530. this.isNew = this.selected
  531. },
  532. //项目选中了, 加载子项目
  533. selectProject(domain, index) {
  534. this.http.post('/sub-project/list',{
  535. projectId: domain.projectId
  536. },
  537. res => {
  538. if (res.code == "ok") {
  539. this.workForm.domains[index].subProjectList = res.data;
  540. this.$forceUpdate();
  541. }
  542. },
  543. error => {
  544. this.$message({
  545. message: error,
  546. type: "error"
  547. });
  548. }
  549. );
  550. //项目相关的近期任务
  551. if (this.user.company.packageProject == 1) {
  552. this.http.post('/task/getRecentTask',{
  553. projectId: domain.projectId
  554. },
  555. res => {
  556. if (res.code == "ok") {
  557. this.workForm.domains[index].taskList = res.data;
  558. this.$forceUpdate();
  559. }
  560. },
  561. error => {
  562. this.$message({
  563. message: error,
  564. type: "error"
  565. });
  566. }
  567. );
  568. }
  569. },
  570. //删除自己的日报
  571. deleteReport() {
  572. this.$confirm("确定要删除该日报吗?","提示", {
  573. confirmButtonText: "确定",
  574. cancelButtonText: "取消",
  575. type: "warning"
  576. })
  577. .then(() => {
  578. this.listLoading = true;
  579. this.http.post('/report/delete',{
  580. userId: this.user.id,
  581. date: this.workForm.createDate
  582. },
  583. res => {
  584. this.listLoading = false;
  585. if (res.code == "ok") {
  586. this.$message({
  587. message: "删除成功",
  588. type: "success"
  589. });
  590. this.getReportList();
  591. this.getDepartment();
  592. this.dialogVisible = false;
  593. } else {
  594. this.$message({
  595. message: res.msg,
  596. type: "error"
  597. });
  598. }
  599. },
  600. error => {
  601. this.listLoading = false;
  602. this.$message({
  603. message: error,
  604. type: "error"
  605. });
  606. }
  607. );
  608. })
  609. .catch(() => {});
  610. },
  611. //提交批量审核数据
  612. submitBatchApprove() {
  613. var data = this.$refs.approveTree.getCheckedNodes();
  614. var ids = '';
  615. if (data.length == 0) {
  616. this.$message({
  617. message: '请选择要审核的人员',
  618. type: "error"
  619. });
  620. return;
  621. }
  622. for (var i=0;i<data.length; i++) {
  623. ids += data[i].id;
  624. if (i < data.length-1) {
  625. ids += ',';
  626. }
  627. }
  628. let day = (this.choseDay + 1)> 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  629. this.http.post("/report/batchApproveReport", {ids:ids, date:this.date + day},
  630. res => {
  631. if (res.code == "ok") {
  632. this.$message({
  633. message: '审核成功',
  634. type: "success"
  635. });
  636. this.getReportList();
  637. this.getDepartment();
  638. this.approveDialogVisible = false;
  639. } else {
  640. this.$message({
  641. message: res.msg,
  642. type: "error"
  643. });
  644. }
  645. },
  646. error => {
  647. this.$message({
  648. message: error,
  649. type: "error"
  650. });
  651. });
  652. },
  653. selectAll() {
  654. if (this.isAllSelect) {
  655. var keys = [];
  656. this.reportNames.forEach(b=>{
  657. keys.push(b.id);
  658. })
  659. this.$refs.approveTree.setCheckedKeys(keys);
  660. } else {
  661. this.$refs.approveTree.setCheckedKeys([]);
  662. }
  663. },
  664. //批量审核
  665. batchApprove() {
  666. this.approveDialogVisible = true;
  667. this.reportNames = [];
  668. for (var i=0;i<this.reportList.length; i++) {
  669. var report = this.reportList[i];
  670. var hasUnChecked =false;
  671. var id = '';
  672. for (var j=0;j<report.data.length; j++) {
  673. if (report.data[j].state == 0) {
  674. hasUnChecked = true;
  675. id += report.data[j].id+',';
  676. }
  677. }
  678. if (hasUnChecked) {
  679. this.reportNames.push({id:id, label: report.name});
  680. }
  681. }
  682. },
  683. removeEmptyNode(list) {
  684. for (var i=0;i<list.length;i++) {
  685. var cnt = 0;
  686. if (list[i].membCount == 0) {
  687. list.splice(i, 1);
  688. i--;
  689. } else if (list[i].children != null) {
  690. this.removeEmptyNode(list[i].children);
  691. }
  692. }
  693. },
  694. calculateMembCount(list) {
  695. for (var i in list) {
  696. var cnt = 0;
  697. if (list[i].children != null) {
  698. this.calculateMembCount(list[i].children);
  699. for (var m in list[i].children) {
  700. cnt += list[i].children[m].membCount;
  701. }
  702. }
  703. if (list[i].isUser == 1) {
  704. cnt++;
  705. this.membCount++;
  706. }
  707. list[i].membCount = cnt;
  708. }
  709. },
  710. stateChange() {
  711. this.membCount = 0;
  712. if (this.selectState == -1) {
  713. //全部状态
  714. this.data = this.allData;
  715. } else {
  716. //未填报
  717. var newData = JSON.parse(JSON.stringify(this.allData));
  718. this.filterState(this.selectState, newData);
  719. this.data = newData;
  720. }
  721. this.calculateMembCount(this.data);
  722. this.data[0].membCount = this.membCount;//总人数
  723. },
  724. //按状态过滤部门人员
  725. filterState(state, list) {
  726. for (var i =0;i<list.length; i++) {
  727. var obj = list[i];
  728. if (obj.isUser == 1) {
  729. var match = false;
  730. if (state == -2) {
  731. if (obj.state == null) {
  732. match = true;
  733. }
  734. } else {
  735. if (obj.state == state) {
  736. match = true;
  737. }
  738. }
  739. if (!match) {
  740. list.splice(i, 1);
  741. i--;
  742. } else {
  743. }
  744. } else {
  745. if (obj.children != null) {
  746. this.filterState(state, obj.children);
  747. }
  748. }
  749. }
  750. },
  751. // 部门列表点击
  752. handleNodeClick(data) {
  753. this.depData = data;
  754. var list = [];
  755. if (data.id == -1) {
  756. this.deptId = null;
  757. this.targetUid = null;
  758. list = this.data;
  759. } else if (data.isUser == 1) {
  760. this.deptId = null;
  761. this.targetUid = data.id;
  762. } else {
  763. this.deptId = data.id;
  764. this.targetUid = null;
  765. list.push(data);
  766. }
  767. this.getReportList();
  768. if (list.length > 0) {
  769. this.unFillList = this.getUserMembListFromDeptList(list, 0);
  770. this.fillList = this.getUserMembListFromDeptList(list, 1);
  771. }
  772. },
  773. // 获取部门列表
  774. getDepartment() {
  775. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  776. var param = {date:this.date + day};
  777. if (this.user.manageDeptId != 0) {
  778. param.manageDeptId = this.user.manageDeptId;
  779. }
  780. this.http.post("/report/getMembList", param,
  781. res => {
  782. if (res.code == "ok") {
  783. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  784. if (this.user.role > 0) {
  785. list.splice(0,0,{
  786. id: -1,
  787. label: '全部人员',
  788. })
  789. }
  790. this.membCount = 0;
  791. //设置员工到部门下面
  792. this.setUserToDept(list);
  793. this.data = list;
  794. this.allData = list;
  795. this.option = this.changeArr(list1);
  796. list[0].membCount = this.membCount;
  797. if (this.depData.id == -1) {
  798. this.depData.membCount = this.membCount;
  799. this.unFillList = this.getUserMembListFromDeptList(this.data, 0);
  800. this.fillList = this.getUserMembListFromDeptList(this.data, 1);
  801. } else {
  802. if (this.depData.isUser == null) {
  803. var dep = this.findTargetDept(this.data, this.depData.id);
  804. var membDeptList = [];
  805. membDeptList.push(dep);
  806. this.unFillList = this.getUserMembListFromDeptList(membDeptList, 0);
  807. this.fillList = this.getUserMembListFromDeptList(membDeptList, 1);
  808. }
  809. }
  810. if (this.depData.isUser == null) {
  811. if (this.isFill) {
  812. this.fillMembList = this.fillList;
  813. } else {
  814. this.fillMembList = this.unFillList;
  815. }
  816. }
  817. } else {
  818. this.$message({
  819. message: res.msg,
  820. type: "error"
  821. });
  822. }
  823. },
  824. error => {
  825. this.$message({
  826. message: error,
  827. type: "error"
  828. });
  829. });
  830. this.getReportFillStatus();
  831. },
  832. findTargetDept(list, deptId) {
  833. var t = null;
  834. for (var i=0;i<list.length; i++) {
  835. if (list[i].isUser == null && list[i].id == deptId) {
  836. t = list[i];
  837. break;
  838. }
  839. }
  840. if (t == null) {
  841. for (var i=0;i<list.length; i++) {
  842. if (list[i].children != null && list[i].children.length > 0) {
  843. t = this.findTargetDept(list[i].children, deptId);
  844. if (t != null) {
  845. break;
  846. }
  847. }
  848. }
  849. }
  850. return t;
  851. },
  852. getUserMembListFromDeptList(list, isFill) {
  853. var membList = [];
  854. for (var i in list) {
  855. var deptName = list[i].label;
  856. if (list[i].userList != null) {
  857. list[i].userList.forEach(element => {
  858. if (isFill == 0) {
  859. //获取未填的
  860. if (element.state == null) {
  861. var obj = {id: element.id, label:element.name, deptId:element.departmentId, deptName: deptName};
  862. membList.push(obj);
  863. }
  864. } else {
  865. if (element.state != null) {
  866. var obj = {id: element.id, label:element.name, deptId:element.departmentId, deptName: deptName};
  867. membList.push(obj);
  868. }
  869. }
  870. });
  871. }
  872. if (list[i].children != null) {
  873. membList = membList.concat(this.getUserMembListFromDeptList(list[i].children, isFill));
  874. }
  875. }
  876. return membList;
  877. },
  878. setUserToDept(list) {
  879. for (var i in list) {
  880. var cnt = 0;
  881. if (list[i].children != null) {
  882. this.setUserToDept(list[i].children);
  883. for (var m in list[i].children) {
  884. cnt += list[i].children[m].membCount;
  885. }
  886. }
  887. if (list[i].userList != null) {
  888. if (list[i].children == null) {
  889. list[i].children = [];
  890. }
  891. list[i].userList.forEach(element => {
  892. var obj = {id: element.id, label:element.name, state:element.state, parentId:element.departmentId, isUser:1};
  893. list[i].children.push(obj);
  894. this.membCount++;
  895. cnt++;
  896. });
  897. }
  898. list[i].membCount = cnt;
  899. }
  900. },
  901. // 修改数组
  902. changeArr(arr) {
  903. for (var i = 0; i < arr.length; i++) {
  904. if(arr[i].id != -1 && arr[i].id != 0) {
  905. if (arr[i].children != null && arr[i].children.length>0) {
  906. arr[i].children = this.changeArr(arr[i].children);
  907. }
  908. arr[i].id && (arr[i].value = arr[i].id);
  909. delete arr[i].id;
  910. }
  911. }
  912. for(var i in arr) {
  913. if(arr[i].id == -1 || arr[i].id == 0) {
  914. arr.splice(i,1)
  915. }
  916. }
  917. return arr;
  918. },
  919. //时间段范围设置改动,监听
  920. onTimeTypeChange(timeType) {
  921. this.showAddMore = true;
  922. for(var i in this.workForm.domains) {
  923. if (this.workForm.domains[i].timeType == 0) {
  924. this.showAddMore = false;
  925. break;
  926. }
  927. }
  928. if (this.showAddMore) {
  929. //检测数量
  930. if (this.workForm.domains.length == 2) {
  931. this.showAddMore = false;
  932. } else {
  933. this.showAddMore = true;
  934. }
  935. }
  936. },
  937. getTimeType() {
  938. this.http.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId},
  939. res => {
  940. if (res.code == "ok") {
  941. var t = res.data;
  942. this.reportTimeType = t;
  943. if (this.reportTimeType.type > 0) {
  944. this.showAddMore = true;
  945. }
  946. //转化时间格式
  947. if (t.allday != null) {
  948. this.timeType.push({value:0, label:'全天 - '+t.allday+'小时', hours:t.allday});
  949. }
  950. if (t.am != null) {
  951. this.timeType.push({value:1, label:'上午 - '+t.am+'小时', hours: t.am});
  952. }
  953. if (t.pm != null) {
  954. this.timeType.push({value:2, label:'下午 - '+t.pm+'小时', hours: t.pm});
  955. }
  956. } else {
  957. this.$message({
  958. message: res.msg,
  959. type: "error"
  960. });
  961. }
  962. },
  963. error => {
  964. this.listLoading = false;
  965. this.$message({
  966. message: error,
  967. type: "error"
  968. });
  969. });
  970. },
  971. // 改变月份
  972. changeMonthOut() {
  973. this.getAllDate();
  974. this.getReportList();
  975. this.getDepartment();
  976. },
  977. // 选择日期
  978. choseDate(i, item) {
  979. this.choseDay = i;
  980. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  981. sessionStorage.msg = this.date + day,
  982. this.getReportList();
  983. this.getDepartment();
  984. this.curDate = item.date;
  985. },
  986. // 获取日期列表
  987. getAllDate() {
  988. var dayArry = [];
  989. var day = this.getCountDays();
  990. let curMonthDay = null;
  991. for (var k = 1; k <= day; k++) {
  992. var str = new Date(this.date.replace(/-/g, "/")+'/01').getMonth() + 1 + "月" + k+'日';
  993. var showStr = new Date(this.date.replace(/-/g, "/")+'/01').getMonth() + 1+'.'+k;
  994. if ( new Date(this.date.replace(/-/g, "/")+'/01').getFullYear() == new Date(new Date()).getFullYear() &&
  995. new Date(this.date.replace(/-/g, "/")+'/01').getMonth() == new Date(new Date()).getMonth()) {
  996. if(sessionStorage.msg) {
  997. if(parseInt(sessionStorage.msg.split("-")[2]) == k) {
  998. this.choseDay = k - 1;
  999. curMonthDay = str;
  1000. }
  1001. } else {
  1002. if (new Date().getDate() == k) {
  1003. this.choseDay = k - 1;
  1004. }
  1005. }
  1006. } else {
  1007. this.choseDay = 0;
  1008. }
  1009. var curDateStr = (this.date +'-'+ (k<10?('0'+k):k));
  1010. var curDateTime = util.formatDate.parse(curDateStr, 'yyyy-MM-dd');
  1011. dayArry.push({date:str, weekDay:this.weekDay[curDateTime.getDay()], showDate:showStr});
  1012. }
  1013. this.allDate = dayArry;
  1014. //不能超过最大日期
  1015. if (this.choseDay > day-1) {
  1016. this.choseDay = day-1;
  1017. }
  1018. //从消息点击跳转过来的,直接加载指定日期
  1019. if (sessionStorage.from == 1 && sessionStorage.msg) {
  1020. this.curDate = sessionStorage.msg;
  1021. sessionStorage.from = 0;
  1022. } else {
  1023. if (curMonthDay != null) {
  1024. this.curDate = curMonthDay;
  1025. } else {
  1026. var d = new Date(this.date.replace(/-/g, "/")+'/01')
  1027. this.curDate = (d.getMonth()+1)+'月'+d.getDate()+'日';
  1028. }
  1029. }
  1030. this.getReportFillStatus();
  1031. },
  1032. getCountDays() {
  1033. var newstr = this.date.replace(/-/g, "/");
  1034. var curDate = new Date(newstr+'/01');
  1035. var curMonth = curDate.getMonth();
  1036. curDate.setMonth(curMonth + 1);
  1037. curDate.setDate(0);
  1038. return curDate.getDate();
  1039. },
  1040. //获取日报列表
  1041. getReportList() {
  1042. this.listLoading = true;
  1043. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  1044. let param = {date: this.date + day};
  1045. if (this.deptId != null) {
  1046. param.deptId = this.deptId;
  1047. }
  1048. if (this.targetUid != null) {
  1049. param.userId = this.targetUid;
  1050. }
  1051. this.http.post( this.port.report.list, param,
  1052. res => {
  1053. this.listLoading = false;
  1054. if (res.code == "ok") {
  1055. this.reportList = res.data;
  1056. document.querySelector("#day"+this.choseDay).scrollIntoView(true);
  1057. } else {
  1058. this.$message({
  1059. message: res.msg,
  1060. type: "error"
  1061. });
  1062. }
  1063. },
  1064. error => {
  1065. this.listLoading = false;
  1066. this.$message({
  1067. message: error,
  1068. type: "error"
  1069. });
  1070. });
  1071. },
  1072. //导出日报
  1073. exportReport() {
  1074. this.listLoading = true;
  1075. var param = {};
  1076. if (this.exportParam.dateRange != null) {
  1077. param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1]};
  1078. }
  1079. if (this.exportParam.projectId != null) {
  1080. param.projectId = this.exportParam.projectId;
  1081. }
  1082. this.http.post( this.port.report.export, param,
  1083. res => {
  1084. this.listLoading = false;
  1085. if (res.code == "ok") {
  1086. location.href = res.data;
  1087. this.exportDialog = false;
  1088. } else {
  1089. this.$message({
  1090. message: res.msg,
  1091. type: "error"
  1092. });
  1093. }
  1094. },
  1095. error => {
  1096. this.listLoading = false;
  1097. this.$message({
  1098. message: error,
  1099. type: "error"
  1100. });
  1101. });
  1102. },
  1103. //获取项目列表
  1104. getProjectList() {
  1105. this.listLoading = true;
  1106. this.http.post( this.port.project.list, {},
  1107. res => {
  1108. this.listLoading = false;
  1109. if (res.code == "ok") {
  1110. this.projectList = res.data;
  1111. } else {
  1112. this.$message({
  1113. message: res.msg,
  1114. type: "error"
  1115. });
  1116. }
  1117. },
  1118. error => {
  1119. this.listLoading = false;
  1120. this.$message({
  1121. message: error,
  1122. type: "error"
  1123. });
  1124. });
  1125. },
  1126. // 获取个人某天的日报
  1127. getReport() {
  1128. this.http.post( this.port.report.getPort, {
  1129. date: this.workForm.createDate
  1130. },
  1131. res => {
  1132. if (res.code == "ok") {
  1133. var list = res.data;
  1134. this.report = list;
  1135. if(list.report.length != 0) {
  1136. var arr = [];
  1137. this.canEdit = false;
  1138. for(var i in list.report) {
  1139. var flg = null
  1140. list.report[i].isOvertime == 1 ? flg = true : flg = false
  1141. arr.push({
  1142. id: list.report[i].id,
  1143. projectId: list.report[i].projectId,
  1144. workingTime: list.report[i].workingTime,
  1145. content: list.report[i].content,
  1146. state: list.report[i].state,
  1147. timeType: list.report[i].timeType,
  1148. subProjectList: list.report[i].subProjectList,
  1149. taskList: list.report[i].taskList,
  1150. subProjectId: list.report[i].subProjectId,
  1151. taskId: list.report[i].taskId,
  1152. // startTime: `Fri May 16 2021 ${list.report[i].startTime}:12 GMT+0800 (中国标准时间)`,
  1153. startTime: list.report[i].startTime,
  1154. // endTime: `Fri May 16 2021 ${list.report[i].endTime}:12 GMT+0800 (中国标准时间)`,
  1155. endTime: list.report[i].endTime,
  1156. isOvertime: flg,
  1157. progress:list.report[i].progress,
  1158. })
  1159. if (list.report[i].state >= 2) {
  1160. this.canEdit = true;
  1161. }
  1162. }
  1163. this.workForm = {
  1164. createDate: this.workForm.createDate,
  1165. domains: arr,
  1166. }
  1167. } else {
  1168. this.workForm = {
  1169. createDate: this.workForm.createDate,
  1170. domains: [{
  1171. id: null,
  1172. projectId: "",
  1173. workingTime: this.reportTimeType.type==3?(this.reportTimeType.allday).toFixed(1):"",
  1174. content: "",
  1175. progress:100,
  1176. state: 2,
  1177. timeType:0,
  1178. }],
  1179. }
  1180. this.canEdit = true;
  1181. }
  1182. } else {
  1183. this.$message({
  1184. message: res.msg,
  1185. type: "error"
  1186. });
  1187. }
  1188. },
  1189. error => {
  1190. this.$message({
  1191. message: error,
  1192. type: "error"
  1193. });
  1194. });
  1195. },
  1196. // 打开日报填写
  1197. fillInReport(i, isBatch) {
  1198. if(i == -1) {
  1199. this.isDisable = false;
  1200. } else {
  1201. this.isDisable = true;
  1202. }
  1203. let day = (this.choseDay +1)> 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  1204. this.isBatch = isBatch;
  1205. if (this.isBatch == 0) {
  1206. this.workForm.createDate = this.date + day; // 获取个人某天的日报
  1207. this.getReport(i);
  1208. } else {
  1209. this.workForm = {
  1210. createDate: null,//批量填报没有日期
  1211. domains: [{
  1212. id: null,
  1213. projectId: "",
  1214. workingTime: this.reportTimeType.type==3?(this.reportTimeType.allday).toFixed(1):"",
  1215. content: "",
  1216. progress:100,
  1217. state: 2,
  1218. timeType:0,
  1219. }],
  1220. }
  1221. this.canEdit = true;
  1222. }
  1223. this.dialogVisible = true;
  1224. },
  1225. // 添加模块
  1226. addDomain() {
  1227. var leftProgress = 10;
  1228. if (this.reportTimeType.type == 3) {
  1229. //计算已经待分配工时比例
  1230. let array = this.workForm.domains;
  1231. let totalProgress = 0;
  1232. for (var i=0;i<array.length; i++) {
  1233. totalProgress += array[i].progress;
  1234. }
  1235. if (totalProgress < 100) {
  1236. leftProgress = 100 - totalProgress;
  1237. }
  1238. }
  1239. this.workForm.domains.push({
  1240. projectId: "",
  1241. workingTime: this.reportTimeType.type == 3?(leftProgress*this.reportTimeType.allday/100).toFixed(1):"",
  1242. content: "",
  1243. progress:leftProgress,
  1244. state:2,//2-表示待提交
  1245. });
  1246. if (this.reportTimeType.type == 0) {
  1247. //全天上下午模式下,检测时间段数量,达到2个,不能再加了
  1248. var length = this.workForm.domains.length;
  1249. if (length == 2) {
  1250. this.showAddMore = false;
  1251. }
  1252. }
  1253. },
  1254. // 移除模块
  1255. delDomain(i) {
  1256. this.workForm.domains.splice(i,1)
  1257. //检测当前剩下的一个,时间类型是否是全天
  1258. if (this.reportTimeType.type == 0) {
  1259. if (this.workForm.domains[0].timeType == 0) {
  1260. this.showAddMore = false;
  1261. } else {
  1262. this.showAddMore = true;
  1263. }
  1264. }
  1265. },
  1266. // 改变月份
  1267. changeMonth() {
  1268. if (this.isBatch == 0) {
  1269. //只有按天填报才能获取当天的日报
  1270. this.getReport()
  1271. }
  1272. },
  1273. // 保存日报
  1274. submitDepartment() {
  1275. this.$refs.workForm.validate(valid => {
  1276. if (valid) {
  1277. //检查时间,全天和上下午不能同时存在
  1278. if (this.reportTimeType.type == 0) {
  1279. var alldayNum = 0;
  1280. var amNum = 0;
  1281. var pmNum = 0;
  1282. for(var i in this.workForm.domains) {
  1283. if (this.workForm.domains[i].timeType == 0) {
  1284. alldayNum ++;
  1285. } else if (this.workForm.domains[i].timeType == 1) {
  1286. amNum++;
  1287. } else if (this.workForm.domains[i].timeType == 2) {
  1288. pmNum++;
  1289. }
  1290. }
  1291. if (alldayNum > 1) {
  1292. this.$message({
  1293. message: "工作时间-全天,只能选择一次",
  1294. type: "error"
  1295. });
  1296. return;
  1297. }
  1298. if (amNum > 1) {
  1299. this.$message({
  1300. message: "工作时间-上午,只能选择一次",
  1301. type: "error"
  1302. });
  1303. return;
  1304. }
  1305. if (pmNum > 1) {
  1306. this.$message({
  1307. message: "工作时间-下午,只能选择一次",
  1308. type: "error"
  1309. });
  1310. return;
  1311. }
  1312. if (alldayNum == 1 && (amNum > 0 || pmNum > 0)) {
  1313. this.$message({
  1314. message: "工作时间-全天,不能和上下午同时存在",
  1315. type: "error"
  1316. });
  1317. return;
  1318. }
  1319. } else if (this.reportTimeType.type == 3) {
  1320. //总百分比不能超过100%
  1321. let total = 0;
  1322. this.workForm.domains.forEach(w=>{total += w.progress});
  1323. if (total > 100) {
  1324. this.$message({
  1325. message: "用时比例之和不能超过100%",
  1326. type: "error"
  1327. });
  1328. return;
  1329. } else if (total < 100) {
  1330. this.$message({
  1331. message: "工时尚未完全分配,无法提交",
  1332. type: "error"
  1333. });
  1334. return;
  1335. }
  1336. }
  1337. this.listLoading = true;
  1338. let formData = new FormData();
  1339. for(var i in this.workForm.domains) {
  1340. if (this.workForm.domains[i].id != null) {
  1341. formData.append("id", this.workForm.domains[i].id);
  1342. } else {
  1343. formData.append("id", -1);
  1344. }
  1345. formData.append("projectId", this.workForm.domains[i].projectId);
  1346. if (this.workForm.domains[i].subProjectId != null) {
  1347. formData.append("subProjectId", this.workForm.domains[i].subProjectId);
  1348. } else {
  1349. formData.append("subProjectId", 0);
  1350. }
  1351. if (this.workForm.domains[i].taskId != null) {
  1352. formData.append("taskId", this.workForm.domains[i].taskId);
  1353. } else {
  1354. formData.append("taskId", 0);
  1355. }
  1356. formData.append("reportTimeType", this.reportTimeType.type);
  1357. if (this.reportTimeType.type == 0) {
  1358. formData.append("timeType", this.workForm.domains[i].timeType);
  1359. var workingTime = this.timeType.filter(t=>t.value == this.workForm.domains[i].timeType)[0].hours;
  1360. formData.append("workingTime", workingTime);
  1361. } else if (this.reportTimeType.type == 1){
  1362. formData.append("workingTime", this.workForm.domains[i].workingTime);
  1363. } else if (this.reportTimeType.type == 2) {
  1364. formData.append("endTime", this.workForm.domains[i].endTime);
  1365. formData.append("startTime", this.workForm.domains[i].startTime);
  1366. } else if (this.reportTimeType.type == 3) {
  1367. //按比例分配
  1368. formData.append("progress", this.workForm.domains[i].progress);
  1369. formData.append("workingTime", this.workForm.domains[i].workingTime);
  1370. }
  1371. if (this.workForm.domains[i].content == null || this.workForm.domains[i].content == '') {
  1372. formData.append("content", '-');
  1373. } else {
  1374. formData.append("content", this.workForm.domains[i].content);
  1375. }
  1376. if (this.isBatch == 0) {
  1377. formData.append("createDate", this.workForm.createDate);
  1378. } else {
  1379. //批量填报,时间范围
  1380. formData.append("createDate", this.workForm.createDate[0]+'@'+this.workForm.createDate[1]);
  1381. }
  1382. if(this.workForm.domains[i].isOvertime == undefined ) {
  1383. this.workForm.domains[i].isOvertime = '0'
  1384. formData.append("isOvertime", this.workForm.domains[i].isOvertime);
  1385. } else if (this.workForm.domains[i].isOvertime == false){
  1386. this.workForm.domains[i].isOvertime = '0'
  1387. formData.append("isOvertime", this.workForm.domains[i].isOvertime);
  1388. } else {
  1389. this.workForm.domains[i].isOvertime = '1'
  1390. formData.append("isOvertime", this.workForm.domains[i].isOvertime);
  1391. }
  1392. }
  1393. this.http.uploadFile( this.port.report.editPort, formData,
  1394. res => {
  1395. this.listLoading = false;
  1396. if (res.code == "ok") {
  1397. this.$message({
  1398. message: "填报成功",
  1399. type: "success"
  1400. });
  1401. this.dialogVisible = false;
  1402. this.getReportList();
  1403. this.getDepartment();
  1404. } else {
  1405. this.$message({
  1406. message: res.msg,
  1407. type: "error"
  1408. });
  1409. }
  1410. },
  1411. error => {
  1412. this.listLoading = false;
  1413. this.$message({
  1414. message: error,
  1415. type: "error"
  1416. });
  1417. });
  1418. }
  1419. });
  1420. },
  1421. cli() {
  1422. },
  1423. // 跳转
  1424. junpToDeskTop(id) {
  1425. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  1426. this.$router.push("/desktop/" + id + "/" + this.date +day);
  1427. },
  1428. // 通过日报
  1429. approve(id, item) {
  1430. this.logining = true;
  1431. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  1432. var ids = '';
  1433. var data = item.data;
  1434. data.forEach(element => {
  1435. ids +=(element.id+',');
  1436. });
  1437. this.http.post( this.port.report.approve, {id: id , date: this.date +day, reportIds: ids},
  1438. res => {
  1439. this.logining = false;
  1440. if (res.code == "ok") {
  1441. this.$message({
  1442. message: "审核成功",
  1443. type: "success"
  1444. });
  1445. this.getReportList();
  1446. this.getDepartment();
  1447. } else {
  1448. this.$message({
  1449. message: res.msg,
  1450. type: "error"
  1451. });
  1452. }
  1453. },
  1454. error => {
  1455. this.logining = false;
  1456. this.$message({
  1457. message: error,
  1458. type: "error"
  1459. });
  1460. });
  1461. },
  1462. //撤回日报
  1463. cancel(item) {
  1464. this.logining = true;
  1465. var ids = '';
  1466. var data = item.data;
  1467. data.forEach(element => {
  1468. ids +=(element.id+',');
  1469. });
  1470. this.http.post(this.port.report.cancelReport, {userId: this.user.id, reportIds: ids},
  1471. res => {
  1472. this.logining = false;
  1473. if (res.code == "ok") {
  1474. this.$message({
  1475. message:"撤回成功",
  1476. type: "success"
  1477. });
  1478. this.getReportList();
  1479. this.getDepartment();
  1480. } else {
  1481. this.$message({
  1482. message: res.msg,
  1483. type: "error"
  1484. });
  1485. }
  1486. },
  1487. error => {
  1488. this.logining = false;
  1489. this.$message({
  1490. message: error,
  1491. type: "error"
  1492. });
  1493. });
  1494. },
  1495. // 未通过日报
  1496. deny(id,i, item) {
  1497. this.logining = true;
  1498. let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
  1499. var ids = '';
  1500. var data = item.data;
  1501. data.forEach(element => {
  1502. ids +=(element.id+',');
  1503. });
  1504. this.http.post( this.port.report.deny, {id: id , date: this.date +day, reportIds: ids},
  1505. res => {
  1506. this.logining = false;
  1507. if (res.code == "ok") {
  1508. this.$message({
  1509. message: i==0?"驳回成功":"撤销成功",
  1510. type: "success"
  1511. });
  1512. this.getReportList();
  1513. this.getDepartment();
  1514. } else {
  1515. this.$message({
  1516. message: res.msg,
  1517. type: "error"
  1518. });
  1519. }
  1520. },
  1521. error => {
  1522. this.logining = false;
  1523. this.$message({
  1524. message: error,
  1525. type: "error"
  1526. });
  1527. });
  1528. }
  1529. },
  1530. created() {
  1531. let height = window.innerHeight;
  1532. this.tableHeight = height - 178;
  1533. const that = this;
  1534. window.onresize = function temp() {
  1535. that.tableHeight = window.innerHeight - 178;
  1536. };
  1537. },
  1538. mounted() {
  1539. var now = new Date();
  1540. var t = util.formatDate.format(now, 'yyyy-MM-dd');
  1541. var startStr = util.formatDate.format(new Date(), 'yyyy-MM') + "-01";
  1542. this.exportParam.dateRange = [startStr,t];
  1543. this.getAllDate();
  1544. this.getReportList();
  1545. this.getProjectList();
  1546. this.getTimeType();
  1547. this.getDepartment();
  1548. this.scrollFunction()
  1549. }
  1550. };
  1551. </script>
  1552. <style lang="scss" scoped>
  1553. .waiting {
  1554. color:orange;
  1555. }
  1556. .filledReportStyle {
  1557. color:#32CD32;
  1558. }
  1559. .RejectStyle {
  1560. color:red;
  1561. }
  1562. .allDaily {
  1563. width:82%;
  1564. }
  1565. .report_title {
  1566. padding:10px 0;
  1567. color:#666;
  1568. }
  1569. .clearfix {
  1570. overflow-x: auto;
  1571. white-space: nowrap;
  1572. padding: 15px 0;
  1573. // overflow-y: hidden;
  1574. .date_item {
  1575. padding: 0 3px;
  1576. cursor: pointer;
  1577. }
  1578. .chooseDate {
  1579. color: #20a0ff;
  1580. }
  1581. }
  1582. .one_daily {
  1583. i {
  1584. color: #9ed0ff;
  1585. margin-right: 5px;
  1586. }
  1587. .one_daily_body {
  1588. padding: 15px 0px;
  1589. p {
  1590. margin: 0;
  1591. line-height: 30px;
  1592. }
  1593. }
  1594. ul {
  1595. padding: 0;
  1596. }
  1597. }
  1598. .checkbtn {
  1599. float: right;
  1600. margin-top: -10px;
  1601. }
  1602. </style>
  1603. <style lang="scss">
  1604. .daily {
  1605. .el-card__body {
  1606. height: 80%;
  1607. overflow-y: auto;
  1608. }
  1609. .el-card__header {
  1610. padding: 0 20px;
  1611. }
  1612. }
  1613. </style>
  1614. <style scoped>
  1615. /* 项目标签的样式 */
  1616. .el-tag + .el-tag {
  1617. margin-left: 10px;
  1618. }
  1619. .button-new-tag {
  1620. margin-left: 10px;
  1621. height: 32px;
  1622. line-height: 30px;
  1623. padding-top: 0;
  1624. padding-bottom: 0;
  1625. }
  1626. .input-new-tag {
  1627. width: 90px;
  1628. margin-left: 10px;
  1629. vertical-align: bottom;
  1630. }
  1631. </style>
  1632. <style lang="scss" scoped>
  1633. // 加班样式
  1634. .overtime {
  1635. display: inline-block;
  1636. margin-left: 20px;
  1637. input {
  1638. display: inline-block;
  1639. margin-top: 5px;
  1640. }
  1641. }
  1642. .plus {
  1643. display: inline-block;
  1644. }
  1645. // .tages {
  1646. // float: right;
  1647. // }
  1648. .overtime {
  1649. display: inline-block;
  1650. margin-left: 30px;
  1651. }
  1652. </style>