weekEdit.vue 125 KB

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