weekEdit.vue 123 KB

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