weekEdit.vue 105 KB

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