index.vue 141 KB

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