index.vue 135 KB

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