index.vue 122 KB

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