weekEdit.vue 151 KB

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