index.vue 119 KB

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