index.vue 91 KB

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