weekEdit.vue 158 KB

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