weekEdit.vue 156 KB

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