index.vue 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834
  1. <template>
  2. <div>
  3. <van-nav-bar title="填写日报" left-text="返回" @click-left="back" fixed left-arrow/>
  4. <van-form class="login_form">
  5. <div>
  6. <van-field readonly clickable name="datetimePicker" :value="form.createDate" label="时间选择" placeholder="点击选择时间"
  7. @click="showPicker = true" :rules="rules.createDate" />
  8. <div v-if="report.time" class="attendanceRecord">
  9. <i class="iconfont firerock-icondakajilu" style="font-size:0.35rem;margin-right:0.12rem"></i>
  10. <span v-if="user.timeType.syncDingding==1&&!report.time">暂无考勤记录</span>
  11. <span v-else>{{report.time.startTime}}-{{report.time.endTime}}, {{report.time.workHours}}小时</span>
  12. </div>
  13. </div>
  14. <van-popup v-model="showPicker" position="bottom">
  15. <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate" @confirm="changeTime" @cancel="showPicker = false"/>
  16. </van-popup>
  17. <van-cell title="总时长(h)" v-if="reportTimeType.type == 3">
  18. <template>
  19. <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" />
  20. </template>
  21. </van-cell>
  22. <!-- <van-cell title="待分配时长" :value="report.time + 'h'" size="large"></van-cell> -->
  23. <div class="form_domains" v-for="(item,index) in form.domains" :key="item.id">
  24. <div style="float:right;margin-top:10px;margin-right:10px;">
  25. <!-- <van-tag v-if="canEdit&&item.projectName.length>0" color="#fff"
  26. @click="copyProject(index)" style="border: 1px solid #20a0ff;padding:5px;"
  27. icon="plus" type="default" ><span style="color:#666;padding: 0 5px;">复制项目</span></van-tag> -->
  28. <van-tag v-if="index>0&&item.canEdit" color="#fff"
  29. @click="delPro(index)" style="border: 1px solid #ff0000;padding:5px;margin-left:10px;"
  30. icon="plus" type="default" ><span style="color:#666;padding: 0 5px;">删除</span></van-tag>
  31. </div>
  32. <!-- <van-icon v-if="index>0&&canEdit" class="form_del" name="delete" @click="delPro(index)" /> -->
  33. <van-cell-group :title="(user.companyId==781?'任务':'项目') + (index+1)">
  34. <!-- <div>请选择投入项目</div> -->
  35. <van-field readonly name="projectId" clickable :value="item.projectName" :label="user.companyId==781?'工作任务':'投入项目'" :placeholder="user.companyId==781?'请选择工作任务':'请选择项目'" @click="clickPicker(index, item)"
  36. :rules="[{ required: true, message: user.companyId==781?'请选择任务':'请选择项目' }]" />
  37. <van-field readonly name="subProjectId" v-if="item.subProjectList != null && item.subProjectList.length > 0 && user.timeType.mainProjectState != 1" clickable
  38. :value="item.subProjectName" label="子项目" placeholder="请选择子项目"
  39. @click="clickPickSubProject(index, item)" />
  40. <van-popup v-model="item.showPickerSubProject" position="bottom">
  41. <van-picker show-toolbar :columns="item.subProjectList" value-key="name" @confirm="choseSubProject"
  42. @cancel="item.showPickerSubProject = false;$forceUpdate();" />
  43. </van-popup>
  44. <!--任务分组 -->
  45. <van-field readonly name="groupId" v-if="user.timeType.reportAuditType >= 1 || (user.company.packageProject==1&&item.taskGroups != null && item.taskGroups.length > 0)" clickable
  46. :value="item.groupName" label="任务分组" placeholder="请选择任务分组"
  47. @click="clickPickTaskGroup(index, item)" />
  48. <van-popup v-model="item.showPickerTaskGroup" position="bottom">
  49. <van-picker show-toolbar :columns="item.taskGroups" value-key="name" @confirm="choseTaskGroup"
  50. @cancel="item.showPickerTaskGroup = false;$forceUpdate();" />
  51. </van-popup>
  52. <!--任务阶段 -->
  53. <van-field readonly name="stage" v-if="user.company.packageProject==1&&item.stages != null && item.stages.length > 0" clickable
  54. :value="item.stage" label="投入阶段" placeholder="请选择投入阶段"
  55. @click="clickPickStage(index, item)" />
  56. <van-popup v-model="item.showPickerStage" position="bottom">
  57. <van-picker show-toolbar :columns="item.stages" value-key="stagesName" @confirm="choseStage"
  58. @cancel="item.showPickerStage = false;$forceUpdate();" />
  59. </van-popup>
  60. <!-- 预算来源 -->
  61. <van-field readonly name="basecostId" v-if="user.company.packageProject==1&&reportBasecostList &&reportBasecostList.length>0"
  62. :value="item.basecostName" label="预算来源" placeholder="请选择预算来源"
  63. @click="clickPickCostId(index, item)" />
  64. <van-popup v-model="item.showPickerCostId" position="bottom">
  65. <van-picker show-toolbar :columns="reportBasecostList" value-key="name" @confirm="choseCostId"
  66. @cancel="item.showPickerCostId = false;$forceUpdate();" />
  67. </van-popup>
  68. <!-- 审核人 -->
  69. <van-field readonly name="projectAuditorId" v-if="item.auditUserList != null && item.auditUserList.length > 0" clickable
  70. :value="item.projectAuditorName" :label="user.companyId==781?'审核人':'项目审核人'" placeholder="请选择审核人"
  71. @click="clickPickAuditor(index, item)" />
  72. <van-popup v-model="item.showPickerAuditor" position="bottom">
  73. <van-picker show-toolbar :columns="item.auditUserList" value-key="auditorName" @confirm="choseAuditor"
  74. @cancel="item.showPickerAuditor = false;$forceUpdate();" />
  75. </van-popup>
  76. <!-- 相关维度 -->
  77. <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)"/>
  78. <van-popup v-model="item.showPickDegree" position="bottom">
  79. <van-picker show-toolbar :columns="item.wuduList" value-key="name" @confirm="choseProjects" @cancel="item.showPickDegree = false;$forceUpdate()" />
  80. </van-popup>
  81. <!-- 自定义数值 -->
  82. <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>
  83. <!-- 自定义文本 -->
  84. <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>
  85. <van-cell title="专业进度" v-if="user.company.packageEngineering == 1">
  86. </van-cell>
  87. <van-field :disabled="!item.canEdit"
  88. type="number" :name="'progress_'+pItem.professionId" input-align="right"
  89. v-for="pItem in item.professionProgress" :key="pItem.professionId"
  90. :label="'-- '+pItem.professionName"
  91. >
  92. <template slot="input">
  93. <van-stepper v-model="pItem.progress" integer min="0" max="100" />%
  94. </template>
  95. </van-field>
  96. <van-field v-if="user.company.packageProject == 1" readonly name="taskId" :value="item.taskName" label="关联任务" placeholder="请选择关联任务" @click="clickPickerTask(index,item)"
  97. ></van-field>
  98. <van-field name="taskFinish" label="是否已完成" v-if="item.taskId != null">
  99. <template #input>
  100. <van-checkbox :disabled="!item.canEdit" v-model="item.taskFinish" shape="square">已完成</van-checkbox>
  101. </template>
  102. </van-field>
  103. <van-popup v-model="item.showPickerTask" position="bottom">
  104. <van-picker show-toolbar :columns="item.taskList" value-key="taskName" @confirm="choseTask" @cancel="item.showPickerTask = false;$forceUpdate()" />
  105. </van-popup>
  106. <!-- <van-field readonly clickable class="form_input" :value="item.workingTime" name="workingTime" label="工作时长" placeholder="请输入工作时长(单位:小时)"
  107. :rules="[{ required: true, message: '请输入工作时长(单位:小时)' }]" @touchstart.native.stop="showNumberKey = true"/>
  108. <van-number-keyboard v-model="item.workingTime" :show="showNumberKey" close-button-text="完成" extra-key="." :maxlength="4" @blur="showNumberKey = false" /> -->
  109. <!-- 常规选择时间的方式 -->
  110. <!-- 全天上下午模式 -->
  111. <div v-if="reportTimeType.multiWorktime==0">
  112. <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)"
  113. :rules="[{ required: true, message: '请选择工作时长' }]"/>
  114. <van-popup v-model="showPickerTime" position="bottom">
  115. <van-picker show-toolbar :columns="timeType" value-key="label" @confirm="choseTimePick" @cancel="showPickerTime = false" />
  116. </van-popup>
  117. <!-- 选择数字时间长度模式 -->
  118. <van-popup v-model="showPickerHours" position="bottom">
  119. <van-picker show-toolbar :columns="timeRange"
  120. :default-index="15"
  121. @confirm="choseTimePick" @cancel="showPickerHours = false" />
  122. </van-popup>
  123. <!-- 时间段选择模式 -->
  124. <van-field readonly v-if="reportTimeType.type == 2" clickable name="datetimePicker" :value="item.startTime" label="开始时间" placeholder="点击选择时间"
  125. @click="item.canEdit?showStartTime = true:''" :disabled="!item.canEdit"
  126. :rules="[{ required: true, message: '请选择开始时间' }]"
  127. />
  128. <van-popup v-model="showStartTime" position="bottom">
  129. <van-datetime-picker
  130. v-model="startTime"
  131. type="time"
  132. @confirm="confirmTime(item,0);"
  133. @cancel="showStartTime = false"
  134. :min-hour="0"
  135. :max-hour="23"
  136. />
  137. <!-- :filter="filter" 原本这个属性在里面 -->
  138. </van-popup>
  139. <van-field v-if="reportTimeType.type == 2" readonly clickable name="datetimePicker" :value="item.endTime" label="结束时间" placeholder="点击选择时间"
  140. @click="item.canEdit?showEndTime = true:''" :disabled="!item.canEdit"
  141. :rules="[{ required: true, message: '请选择结束时间' }]" />
  142. <van-popup v-model="showEndTime" position="bottom" >
  143. <van-datetime-picker
  144. v-model="endTime"
  145. type="time"
  146. :min-hour="0"
  147. :max-hour="23"
  148. @confirm="confirmTime(item,1)"
  149. @cancel="showEndTime = false"
  150. />
  151. <!-- :filter="filter" 原本这个属性在里面 -->
  152. </van-popup>
  153. <van-cell v-if="reportTimeType.type == 3" >
  154. <template >
  155. <div>
  156. <span>用时占比</span>
  157. <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)" >
  158. <template #button>
  159. <div class="custom-button">{{ item.progress }}%</div>
  160. </template>
  161. </van-slider>
  162. <span style="margin-left:10px;float:right;">{{item.workingTime}}小时</span>
  163. </div>
  164. </template>
  165. </van-cell>
  166. <van-field class="form_input" :disabled="!item.canEdit"
  167. v-model="item.content" name="content" type="textarea" :label="user.companyId==781?'具体内容与结果':'工作事项'" placeholder="请输入" :rules="user.timeType.workContentState == 1 ? [{ required: true, message: '请填写工作事项' }] : null"
  168. rows="3" autosize />
  169. </div>
  170. <!-- 多个时间和工作事项的选择方式 -->
  171. <div v-if="reportTimeType.multiWorktime==1">
  172. <div v-for="(timeItem, tindex) in item.worktimeList" :key="tindex" style="position:relative;border:#ccc 0.5px solid;margin:7px;">
  173. <van-tag v-if="tindex>0 && item.canEdit" style="position:absolute; right:-7px;top:-7px;z-index:10;"
  174. @click="removeTimeItem(item,tindex)">X</van-tag>
  175. <!-- 时间段选择模式 -->
  176. <van-field readonly v-if="reportTimeType.type == 2" :clickable="item.canEdit" name="datetimePicker"
  177. :value="timeItem.startTime" label="开始时间" placeholder="点击选择时间"
  178. :rules="[{ required: true, message: '必填项' }]"
  179. @click="item.canEdit?showStartDialog(timeItem):''" />
  180. <van-field v-if="reportTimeType.type == 2" readonly :clickable="canEdit" name="datetimePicker"
  181. :value="timeItem.endTime" label="结束时间" placeholder="点击选择时间"
  182. :rules="[{ required: true, message: '必填项' }]"
  183. @click="item.canEdit?showEndDialog(timeItem):''" />
  184. <van-field class="form_input" :disabled="!item.canEdit" style="color:#333;-webkit-text-fill-color:#646566;"
  185. v-model="timeItem.content" name="content" type="textarea" label="工作事项" placeholder="请输入工作事项"
  186. :rules="user.timeType.workContentState == 1 ? [{ required: true, message: '请填写工作事项' }] : null"
  187. rows="1" autosize />
  188. </div>
  189. <!--时间选择器 , 做统一处理,不能放到循环里,不然会有多个公用showStartTime,最后一个会现在最上层UI,导致BUG -->
  190. <van-popup v-model="showWorkStartTime" position="bottom">
  191. <van-datetime-picker
  192. v-model="startTime"
  193. type="time"
  194. @confirm="confirmWorkTime(0);"
  195. @cancel="showWorkStartTime = false"
  196. :min-hour="0"
  197. :max-hour="23"
  198. />
  199. <!-- :filter="filter" 原本这个属性在里面 -->
  200. </van-popup>
  201. <van-popup v-model="showWorkEndTime" position="bottom" >
  202. <van-datetime-picker
  203. v-model="endTime"
  204. type="time"
  205. :min-hour="0"
  206. :max-hour="23"
  207. @confirm="confirmWorkTime(1)"
  208. @cancel="showWorkEndTime = false"
  209. />
  210. <!-- :filter="filter" 原本这个属性在里面 -->
  211. </van-popup>
  212. </div>
  213. <div style="width:100%;" v-if="item.canEdit&&reportTimeType.multiWorktime==1">
  214. <van-tag style="text-align:center;padding:5px;margin-left:15px;border: 1px solid #20a0ff;"
  215. :disabled="!item.canEdit" @click="addNewWorktime(index, item)"
  216. icon="plus" color="#ffffff" ><span style="color:#999;text-align:center;padding: 0 5px;"> 添加工时 </span></van-tag>
  217. </div>
  218. <div class="overtime" v-if="((user.timeType.fillOvertime || isWeekend) || (isCorpWX&&canEdit))">
  219. <div class="overTimeClas" v-if="user.timeType.fillOvertime || isWeekend">
  220. <van-checkbox :disabled="!item.canEdit" v-model="item.isOvertime" style="width: 4.3rem;">含加班</van-checkbox>
  221. <van-field v-model="item.overtimeHours" type="number" :disabled="!item.canEdit || item.isOvertime==null||item.isOvertime==0 || !item.isOvertime"
  222. placeholder="请输入加班时长" style="width: 5rem"></van-field>
  223. <span :class="item.canEdit ? 'overListTime' : 'overListTime hoveOver'">小时</span>
  224. </div>
  225. <van-tag style="position:absolute;right:10px;" v-if="isCorpWX&&item.canEdit" type="primary" size="large" @click="takePhoto(index)">拍照上传</van-tag>
  226. <!-- <van-tag style="position:absolute;right:10px;" type="primary" size="large" @click="takePhoto(index)">拍照上传</van-tag> -->
  227. <!-- <van-tag style="position:absolute;right:10px;" type="primary" size="large" @click="takePhoto(index)">拍照上传</van-tag> -->
  228. </div>
  229. <div style="padding:5px;text-align:center;" v-if="!isIOSystem">
  230. <span v-for="(p, index) in item.pics" :key="p" style="margin-right:15px;">
  231. <div class="imgList">
  232. <van-icon v-if="item.canEdit && user.companyId==7" size="20" name="clear" @click="deleteImg(item, index)" class="imgList_i"/>
  233. <img :src="p" style="width:100px; height:100px;" @click="showLargeImg(item.pics, index)"/>
  234. </div>
  235. </span>
  236. </div>
  237. <div style="padding:5px;text-align:center;" v-if="isIOSystem">
  238. <span v-for="(p, index) in item.iospics" :key="p" style="margin-right:15px;">
  239. <div class="imgList">
  240. <van-icon v-if="item.canEdit && user.companyId==7" size="20" name="clear" @click="deleteImg(item, index)" class="imgList_i"/>
  241. <img :src="p" style="width:100px; height:100px;" @click="showLargeImg(item.iospics, index)"/>
  242. </div>
  243. </span>
  244. </div>
  245. <van-popup v-model="imgShow" position="bottom" closeable >
  246. <van-swipe class="my-swipe" indicator-color="white">
  247. <van-swipe-item v-for="(picItem, index) in tmpPics" :key="index">
  248. <img :src="picItem" style="width:100%;" />
  249. </van-swipe-item>
  250. </van-swipe>
  251. </van-popup>
  252. </van-cell-group>
  253. </div>
  254. <div style="text-align:center;" >
  255. <van-tag size="large" style="text-align:center;margin:10px;padding:12px;margin-bottom:120px;border: 1px solid #20a0ff;"
  256. @click="addNewPro"
  257. icon="plus" color="#ffffff" ><span style="color:#999;text-align:center;padding: 0 50px;"> + 新增{{user.companyId==781?'任务':'项目'}} </span></van-tag>
  258. </div>
  259. <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
  260. <div style="padding-bottom:10px;">
  261. <van-button v-if="canEdit" square block type="info" @click="isDraft=0;submitReport()" native-type="submit" style="width:50%;float:left;">
  262. <div v-if="flgLg">提交</div>
  263. <van-loading type="spinner" v-if="!flgLg" />
  264. </van-button>
  265. <van-button v-if="canEdit" square block type="default" @click="isDraft=1;submitReport()" native-type="submit" style="width:50%;float:left;">
  266. <div v-if="flgLg">暂存</div>
  267. <van-loading type="spinner" v-if="!flgLg" />
  268. </van-button>
  269. </div>
  270. <van-button v-if="canDeleteReport"
  271. square block type="default" @click="deleteReport" native-type="button"
  272. style=""> 删除 </van-button>
  273. <van-button v-if="canCancelInDialog" block type="default" @click="cancel"> 撤销 </van-button>
  274. <!-- <div v-if="canEdit&&form.domains.length>0 && form.domains[0].id != null"
  275. style="display:block;padding-top:30px;font-size:15px;color:#666;margin:0 auto;text-align:center;padding-bottom:10px;background:#ffffff;"
  276. @click="deleteReport"> 删除 </div> -->
  277. <!-- <van-button v-if="canEdit" square block type="default" @click="deleteReport" native-type="button"
  278. style="margin-top:10px;"> 删除 </van-button> -->
  279. </div>
  280. </van-form>
  281. <div class="form_tip" v-if="!canEdit && !canCancel"> 已审核无法修改 </div>
  282. <!-- 选择项目弹窗 -->
  283. <van-popup v-model="showPickerUserddp" position="bottom" style="height: 80%">
  284. <!-- <van-search v-model="userName" placeholder="输入项目名称搜索" @clear="sea()" @blur="sea()" @search="sea()"></van-search> -->
  285. <van-search v-model="userName" placeholder="请输入项目名称/编号" @clear="sea()" @blur="sea()" @search="sea()" @input="sea()"/>
  286. <div style="minHeight:300px;">
  287. <div v-for="(item, index) in projectss" :key="item.id" class="ryuan" @click="fZr(item, index)">
  288. <p>{{item.projectName}}</p>
  289. <p style="margin-top: 5px;color: #9697B2;">{{item.projectCode}}</p>
  290. </div>
  291. </div>
  292. </van-popup>
  293. </div>
  294. </template>
  295. <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  296. <script>
  297. import wx from 'weixin-js-sdk'
  298. // Vue.prototype.$wx = wx
  299. export default {
  300. data() {
  301. return {
  302. showPickerStage: false,
  303. showPickerTaskGroup: false,
  304. showPickerSubProject: false,
  305. showPickerCostId: false,
  306. isDraft:0,
  307. showWorkStartTime:false,
  308. showWorkEndTime:false,
  309. curWorktime:null,
  310. isIOSystem:false,
  311. imgShow: false,
  312. isCorpWX:false,
  313. isWX: false,
  314. showPickerTask:false,
  315. canCancel:false,
  316. canDeleteReport: false,
  317. canCancelInDialog: false,
  318. canEdit:false,
  319. showEndTime: false,
  320. showStartTime: false,
  321. startTime:'09:00',
  322. endTime: '18:00',
  323. nowTime:new Date(),
  324. showPickerHours: false,
  325. 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],
  326. selectTime:null,
  327. reportTimeType:{},
  328. user: JSON.parse(localStorage.userInfo),
  329. minDate: new Date(2010, 0, 1),
  330. maxDate: new Date(),
  331. currentDate: new Date(),
  332. showPickerTime: false,
  333. showPicker: false,
  334. showPickerProject: false,
  335. showPickDegree: false,
  336. clickIndex: 0,
  337. clickTimeIndex: 0,
  338. showNumberKey: false,
  339. canClick: 2,
  340. timeType:[],
  341. form: {
  342. createDate: this.format(new Date(new Date()),"yyyy-MM-dd"),
  343. domains: [{
  344. id: null,
  345. projectId: "",
  346. projectName: "",
  347. workingTime: "",
  348. content: "",
  349. state: 2,
  350. multiWorktime:0,
  351. worktimeList:{},
  352. degreeId: ''
  353. // pics:["https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",
  354. // "https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",
  355. // "https://worktime.ttkuaiban.com/upload/bc4df504fa724e6cab69872e2c1cfb35.png",]
  356. }],
  357. },
  358. rules: {
  359. createDate: [{ required: true, message: '请选择填报日期' }],
  360. },
  361. project: [],
  362. report: "",
  363. loading: false,
  364. finished: false,
  365. // isOvertime: false
  366. tmpPics:[],
  367. dateAr: [],
  368. showPickerUserddp: false, // 选择项目弹窗
  369. projectss: [],
  370. proads: [],
  371. userName: '',
  372. flgLg: true,
  373. reportBasecostList: [],
  374. isWeekend: false
  375. };
  376. },
  377. created() {
  378. },
  379. methods: {
  380. // 获取预算来源
  381. getReportBasecostList(){
  382. this.$axios.post('/project-basecost-setting/getReportBasecostList',{
  383. companyId: this.user.companyId
  384. }).then(res => {
  385. if(res.code == 'ok'){
  386. this.reportBasecostList = res.data
  387. }else{
  388. this.$toast.fail('获取失败:'+res.msg);
  389. }
  390. }).catch(err => {this.$toast.clear();})
  391. },
  392. //获取项目审核人
  393. getProjectAuditorList(domainItem) {
  394. this.$axios.post("/project-auditor/getList", {projectId: domainItem.projectId})
  395. .then(res => {
  396. if(res.code == "ok") {
  397. domainItem.auditUserList = res.data;
  398. if (res.data.length==1) {
  399. domainItem.projectAuditorId = domainItem.auditUserList[0].auditorId;
  400. domainItem.projectAuditorName = domainItem.auditUserList[0].auditorName;
  401. }
  402. this.$forceUpdate();
  403. } else {
  404. this.$toast.fail('获取失败:'+res.msg);
  405. }
  406. }).catch(err=> {this.$toast.clear();});
  407. },
  408. updateTxt() {
  409. this.$forceUpdate();
  410. },
  411. // 获取项目
  412. getPeoject() {
  413. this.$axios.post("/project/getProjectList", {forReport: 1})
  414. .then(res => {
  415. if(res.code == "ok") {
  416. for(var i in res.data) {
  417. if(res.data[i].projectCode == 'null' || res.data[i].projectCode == null) {
  418. res.data[i].projectCode = ' '
  419. }
  420. }
  421. this.projectss = res.data;
  422. this.project = res.data;
  423. this.projectss = this.projectss.filter(p=>p.status == 1 || p.status == 4);
  424. this.proads = res.data
  425. } else {
  426. this.$toast.fail('获取失败:'+res.msg);
  427. }
  428. }).catch(err=> {this.$toast.clear();});
  429. },
  430. sea() {
  431. // console.log(this.userName.length)
  432. if(this.userName.length > 0) {
  433. // let text = this.userName
  434. // let reg = new RegExp(text)
  435. // let data = this.proads.filter(item => reg.test(item.projectName)) //返回
  436. // let datas = this.proads.filter(item => reg.test(item.projectCode))
  437. // let dataTree = data.concat(datas)
  438. // let arrList = Array.from(new Set(dataTree))
  439. // this.projectss = arrList
  440. // console.log(this.userName.toUpperCase())
  441. let data = this.proads.filter(item => {return item.projectName.indexOf(this.userName.toUpperCase()) != '-1'});
  442. let dataList = this.proads.filter(item => {return item.projectCode.indexOf(this.userName.toUpperCase()) != '-1'});
  443. let dataTree = data.concat(dataList)
  444. let arrList = Array.from(new Set(dataTree))
  445. this.projectss = arrList
  446. } else {
  447. // console.log(456)
  448. this.projectss = this.proads
  449. }
  450. },
  451. fZr(item,index) {
  452. var domainItem = this.form.domains[this.clickIndex];
  453. domainItem.projectId = item.id;
  454. domainItem.projectName = item.projectName;
  455. //清空子项目
  456. domainItem.subProjectId = null;
  457. domainItem.subProjectName = null;
  458. //清空任务
  459. domainItem.taskId = null;
  460. domainItem.taskName = null;
  461. //清空分组和阶段
  462. domainItem.stage = null;
  463. domainItem.groupId = null;
  464. domainItem.weiduName = null;
  465. this.showPickerUserddp = false;
  466. //获取子项目
  467. if(this.user.timeType.mainProjectState != 1){
  468. this.getSubprojectList(this.form.domains[this.clickIndex]);
  469. }
  470. //加载项目相关的工程进度
  471. if (this.user.company.packageEngineering == 1){
  472. this.getProjectProfessions(this.form.domains[this.clickIndex],index);
  473. }
  474. //获取任务分组
  475. this.getTaskGroups(this.form.domains[this.clickIndex], this.clickIndex);
  476. // 获取1相关维度
  477. this.getTaskList(domainItem.projectId)
  478. this.dimension(domainItem.projectId)
  479. //获取相关日报提交选择人
  480. domainItem.projectAuditorId = null;
  481. domainItem.projectAuditorName = null;
  482. domainItem.auditUserList = null;
  483. //获取项目审核人
  484. // console.log(domainItem.projectId,this.project);
  485. var curProject = this.project.filter(p=>p.id == domainItem.projectId)[0];
  486. if (curProject && this.user.timeType.reportAuditType == 0) {
  487. this.getProjectAuditorList(domainItem, index);
  488. }
  489. },
  490. //获取项目下的任务分组
  491. getTaskGroups(domainItem, index) {
  492. domainItem.groupId=null;
  493. domainItem.groupName=null;
  494. this.$axios.post("/task-group/listMyJoinGroup", {projectId: domainItem.projectId})
  495. .then(res => {
  496. if(res.code == "ok") {
  497. domainItem.taskGroups = res.data;
  498. }
  499. this.$forceUpdate();
  500. }).catch(err=> {this.$toast.clear();});
  501. },
  502. getSubprojectList(domainItem) {
  503. domainItem.subProjectList = [];
  504. this.$axios.post("/sub-project/list", {projectId: domainItem.projectId})
  505. .then(res => {
  506. if(res.code == "ok") {
  507. domainItem.subProjectList = res.data;
  508. }
  509. this.$forceUpdate();
  510. }).catch(err=> {this.$toast.clear();});
  511. },
  512. showEndDialog(timeItem) {
  513. this.curWorktime = timeItem;
  514. this.showWorkEndTime = true;
  515. },
  516. showStartDialog(timeItem) {
  517. this.curWorktime = timeItem;
  518. this.showWorkStartTime = true;
  519. },
  520. removeTimeItem(item, index) {
  521. item.worktimeList.splice(index, 1);
  522. },
  523. isIOS(){
  524. var u = navigator.userAgent;
  525. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  526. return isiOS;
  527. },
  528. showLargeImg(item, index) {
  529. this.imgShow = true;
  530. this.tmpPics = item;
  531. },
  532. //拍照上传
  533. takePhoto(index) {
  534. var that = this;
  535. wx.chooseImage({
  536. count: 9, // 默认9
  537. sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  538. sourceType: that.user.timeType.choseFromAlbum == 1 ? ['camera','album'] : ['camera'], // 可以指定来源是相册还是相机,默认二者都有
  539. defaultCameraMode: "batch", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
  540. isSaveToAlbum: 0, //整型值,0表示拍照时不保存到系统相册,1表示自动保存,默认值是1
  541. success: function (res) {
  542. var localIds = res.localIds; // 返回选定照片的本地ID列表,
  543. // andriod中localId可以作为img标签的src属性显示图片;
  544. // iOS应当使用 getLocalImgData 获取图片base64数据,从而用于img标签的显示(在img标签内使用 wx.chooseImage 的 localid 显示可能会不成功)
  545. if (that.form.domains[index].pics == null) {
  546. that.form.domains[index].pics = [];
  547. that.form.domains[index].iospics = [];
  548. }
  549. if (that.isIOSystem) {
  550. for (var i=0;i<localIds.length; i++) {
  551. wx.getLocalImgData({
  552. localId: localIds[i], // 图片的localID
  553. success: function (res) {
  554. var localData = res.localData; // localData是图片的base64数据,可以用img标签显示
  555. that.form.domains[index].iospics.push(localData);
  556. that.$forceUpdate();
  557. }
  558. });
  559. }
  560. if (that.user.companyId == 7) {
  561. that.form.domains[index].pics = that.form.domains[index].pics.concat(localIds);
  562. } else {
  563. that.form.domains[index].pics = localIds;
  564. }
  565. } else {
  566. if (that.user.companyId == 7) {
  567. that.form.domains[index].pics = that.form.domains[index].pics.concat(localIds);
  568. } else {
  569. that.form.domains[index].pics = localIds;
  570. }
  571. that.$forceUpdate();
  572. }
  573. // var serverIdList = [];
  574. if (that.form.domains[index].serverPics == null) {
  575. that.form.domains[index].serverPics = [];
  576. }
  577. //立即就上传到企业微信服务器
  578. for (var i=0;i<localIds.length; i++) {
  579. wx.uploadImage({
  580. localId: localIds[i], // 需要上传的图片的本地ID,由chooseImage接口获得
  581. isShowProgressTips: 1, // 默认为1,显示进度提示
  582. success: function (res) {
  583. var serverId = res.serverId; // 返回图片的服务器端ID
  584. // serverIdList.push(serverId);
  585. that.form.domains[index].serverPics.push(serverId);
  586. }
  587. });
  588. }
  589. }
  590. });
  591. },
  592. copyProject(index) {
  593. var leftProgress = 10;
  594. if (this.reportTimeType.type == 3) {
  595. //计算已经待分配工时比例
  596. let array = this.form.domains;
  597. let totalProgress = 0;
  598. for (var i=0;i<array.length; i++) {
  599. totalProgress += array[i].progress;
  600. }
  601. if (totalProgress < 100) {
  602. leftProgress = 100 - totalProgress;
  603. }
  604. }
  605. var newIndex = index+1;
  606. var pName = "";
  607. if (this.form.domains[index].projectId != '') {
  608. pName = this.project.filter(p=>p.id == this.form.domains[index].projectId)[0].projectName;
  609. }
  610. var itemDomain = {
  611. id: null,
  612. projectId: this.form.domains[index].projectId,
  613. projectName: pName,
  614. workingTime: this.reportTimeType.type==3?(leftProgress*this.reportTimeType.allday/100).toFixed(1):"",
  615. progress:leftProgress,
  616. content: "",
  617. state: 2,
  618. isOvertime:false,
  619. };
  620. this.form.domains.splice(newIndex, 0,itemDomain);
  621. },
  622. //删除日报
  623. deleteReport() {
  624. this.$dialog.confirm({
  625. title: '删除日报',
  626. message: '确定要删除当天日报吗?'
  627. }).then(() => {
  628. const toast = this.$toast.loading({
  629. forbidClick: true,
  630. duration: 0
  631. });
  632. this.$axios.post("/report/delete", {userId: this.user.id, date:this.form.createDate})
  633. .then(res => {
  634. if(res.code == "ok") {
  635. this.$toast.clear();
  636. this.$toast.success('删除成功');
  637. window.location.reload();
  638. } else {
  639. this.$toast.clear();
  640. this.$toast.fail('删除失败');
  641. }
  642. }).catch(err=> {this.$toast.clear();});
  643. }).catch(() => {});
  644. },
  645. changeAllTime() {
  646. //总时长发生改变,自动按比例计算
  647. this.form.domains.forEach(d=>{
  648. d.workingTime = (d.progress*this.reportTimeType.allday/100).toFixed(1);
  649. });
  650. },
  651. cancel() {
  652. const toast = this.$toast.loading({
  653. forbidClick: true,
  654. duration: 0
  655. });
  656. var ids = '';
  657. var data = this.form.domains;
  658. data.forEach(element => {
  659. if (element.id != null && element.id != '') {
  660. if(element.id){
  661. ids +=(element.id+',');
  662. }
  663. }
  664. });
  665. this.$axios.post("/report/cancel", {userId: this.user.id, reportIds:ids})
  666. .then(res => {
  667. if(res.code == "ok") {
  668. this.$toast.clear();
  669. this.$toast.success('撤销成功');
  670. this.getReport();
  671. } else {
  672. this.$toast.clear();
  673. this.$toast.fail('获取失败');
  674. }
  675. }).catch(err=> {this.$toast.clear();});
  676. },
  677. confirmWorkTime(field) {
  678. if (field == 0) {
  679. this.curWorktime.startTime = this.startTime;
  680. this.showWorkStartTime = false;
  681. } else {
  682. this.curWorktime.endTime = this.endTime;
  683. this.showWorkEndTime = false;
  684. }
  685. },
  686. confirmTime(item, field) {
  687. if (field == 0) {
  688. item.startTime = this.startTime;
  689. this.showStartTime = false;
  690. } else {
  691. item.endTime = this.endTime;
  692. this.showEndTime = false;
  693. }
  694. },
  695. filter(type, options) {
  696. if (type === 'minute') {
  697. return options.filter(option => option % 30 === 0);
  698. }
  699. return options;
  700. },
  701. choseTimePick(value, index) {
  702. //选中时间
  703. if (this.reportTimeType.type == 0) {
  704. this.form.domains[this.clickTimeIndex].timeType = value.value;
  705. this.form.domains[this.clickTimeIndex].workingTime = value.hours;
  706. this.form.domains[this.clickTimeIndex].label = value.label;
  707. this.showPickerTime = false;
  708. } else if (this.reportTimeType.type == 1) {
  709. // console.log('this.reportTimeType.type=='+value,this.form.domains);
  710. this.form.domains[this.clickTimeIndex].workingTime = value;
  711. this.form.domains[this.clickTimeIndex].label = value.toFixed(1)+'小时';
  712. this.showPickerHours = false;
  713. let allhour = 0
  714. for(let i in this.form.domains){
  715. if(this.isWeekend){
  716. this.form.domains[i].isOvertime = true
  717. this.form.domains[i].overtimeHours = this.form.domains[i].workingTime
  718. }else{
  719. this.form.domains[i].isOvertime = false
  720. delete this.form.domains[i].overtimeHours
  721. }
  722. allhour += this.form.domains[i].workingTime*1
  723. }
  724. if(allhour > this.user.timeType.allday && !this.isWeekend){
  725. this.form.domains[this.clickTimeIndex].isOvertime = true
  726. this.form.domains[this.clickTimeIndex].overtimeHours = allhour - this.user.timeType.allday
  727. }
  728. }
  729. },
  730. clickTimePicker(i,item) {
  731. if (!item.canEdit) {
  732. return;
  733. }
  734. this.clickTimeIndex = i;
  735. if (this.reportTimeType.type == 0) {
  736. this.showPickerTime = true;
  737. } else if (this.reportTimeType.type == 1) {
  738. this.showPickerHours = true;
  739. }
  740. },
  741. getTimeType() {
  742. this.$axios.post('/time-type/getCompanyTimeSetting', { companyId: this.user.companyId})
  743. .then(res => {
  744. if(res.code == "ok") {
  745. var t = res.data;
  746. this.reportTimeType = t;
  747. //转化时间格式
  748. if (t.allday != null) {
  749. this.timeType.push({value:0, label:'全天 - '+t.allday+'小时', hours:t.allday});
  750. }
  751. if (t.am != null) {
  752. this.timeType.push({value:1, label:'上午 - '+t.am+'小时', hours: t.am});
  753. }
  754. if (t.pm != null) {
  755. this.timeType.push({value:2, label:'下午 - '+t.pm+'小时', hours: t.pm});
  756. }
  757. } else {
  758. this.$toast.clear();
  759. this.$toast.fail(res.msg);
  760. }
  761. }).catch(err=> {this.$toast.clear();});
  762. },
  763. // 返回
  764. back() {
  765. history.back();
  766. },
  767. // 时间转换
  768. format(date, pattern) {
  769. pattern = pattern || "yyyy-MM-dd";
  770. var _this = this;
  771. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  772. switch ($0.charAt(0)) {
  773. case 'y': return _this.padding(date.getFullYear(), $0.length);
  774. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  775. case 'd': return _this.padding(date.getDate(), $0.length);
  776. case 'w': return date.getDay() + 1;
  777. case 'h': return _this.padding(date.getHours(), $0.length);
  778. case 'm': return _this.padding(date.getMinutes(), $0.length);
  779. case 's': return _this.padding(date.getSeconds(), $0.length);
  780. }
  781. });
  782. },
  783. padding(s, len) {
  784. var len = len - (s + '').length;
  785. for (var i = 0; i < len; i++) { s = '0' + s; }
  786. return s;
  787. },
  788. // 获取项目
  789. getProject() {
  790. const toast = this.$toast.loading({
  791. forbidClick: true,
  792. duration: 0
  793. });
  794. this.$axios.post("/project/getProjectList", {})
  795. .then(res => {
  796. if(res.code == "ok") {
  797. this.$toast.clear();
  798. // if (this.project.length > 0) {
  799. // console.log('this.project[0].id=='+this.project[0].id);
  800. // this.getTaskList(this.project[0].id);
  801. // }
  802. } else {
  803. this.$toast.clear();
  804. this.$toast.fail('获取失败:'+res.msg);
  805. }
  806. }).catch(err=> {this.$toast.clear();});
  807. },
  808. // 获取日报
  809. getReport() {
  810. this.isWeekend = false
  811. let weekday = new Date(this.form.createDate).getDay()
  812. if(this.user.companyId == 817){
  813. if(weekday == 0){
  814. this.isWeekend = true
  815. }
  816. }else{
  817. if(weekday == 0 || weekday == 6){
  818. this.isWeekend = true
  819. }
  820. }
  821. const toast = this.$toast.loading({
  822. forbidClick: true,
  823. duration: 0
  824. });
  825. this.$axios.post("/report/getReport", {date: this.form.createDate})
  826. .then(res => {
  827. if(res.code == "ok") {
  828. this.$toast.clear();
  829. this.report = res.data;
  830. var t = res.data.timeType;
  831. var timeType=[];
  832. //转化时间格式
  833. if (t.allday != null) {
  834. timeType.push({value:0, label:'全天 - '+t.allday+'小时', hours:t.allday});
  835. }
  836. if (t.am != null) {
  837. timeType.push({value:1, label:'上午 - '+t.am+'小时', hours: t.am});
  838. }
  839. if (t.pm != null) {
  840. timeType.push({value:2, label:'下午 - '+t.pm+'小时', hours: t.pm});
  841. }
  842. var list = res.data.report;
  843. this.canCancelInDialog = false
  844. if(list.length != 0) {
  845. this.canEdit = false;
  846. this.canCancel = false;
  847. this.canDeleteReport = true
  848. let array = [];
  849. for(var i in list) {
  850. var projectName = "";
  851. var flg = (list[i].isOvertime == 1);
  852. for(var j in this.project) {
  853. if(this.project[j].id == list[i].projectId) {
  854. projectName = this.project[j].projectName;
  855. }
  856. }
  857. let tname = '';
  858. if (list[i].taskId != null && list[i].taskList.length > 0) {
  859. let filterList = list[i].taskList.filter(t=>t.taskId == list[i].taskId);
  860. if (filterList.length > 0) {
  861. tname = filterList[0].taskName;
  862. }
  863. }
  864. let mmm = list[i].degreeId
  865. let sss = list[i].degreeList
  866. let wuduName = ''
  867. for (var s in sss) {
  868. if(sss[s].id == mmm) {
  869. wuduName = sss[s].name
  870. }
  871. }
  872. let serverPicArray = [];
  873. // console.log('picArray=='+list[i].picStr);
  874. if (list[i].picStr != null && list[i].picStr != '@') {
  875. serverPicArray = JSON.parse(list[i].picStr.replace(/@/g,","));
  876. }
  877. var subProjectName = null;
  878. if (list[i].subProjectId) {
  879. subProjectName = list[i].subProjectList.filter(s=>s.id==list[i].subProjectId)[0].name;
  880. }
  881. array.push({
  882. id: list[i].id,
  883. projectId: list[i].projectId,
  884. projectName: projectName,
  885. workingTime: String(list[i].workingTime),
  886. content: list[i].content,
  887. state: list[i].state,
  888. timeType: list[i].timeType,
  889. label: timeType[list[i].timeType].label,
  890. startTime: list[i].startTime,
  891. endTime: list[i].endTime,
  892. isOvertime: flg,
  893. progress: list[i].progress,
  894. taskList: list[i].taskList,
  895. taskId: list[i].taskId,
  896. taskName:tname,
  897. professionProgress:list[i].professionProgressList,
  898. pics: list[i].pics,
  899. iospics:list[i].pics,
  900. serverPics:serverPicArray,
  901. multiWorktime:t.multiWorktime,
  902. worktimeList:list[i].worktimeList,
  903. wuduList: list[i].degreeList,
  904. weiduName: wuduName,
  905. degreeId: list[i].degreeId,
  906. subProjectId: list[i].subProjectId,
  907. subProjectName: subProjectName,
  908. subProjectList: list[i].subProjectList,
  909. groupId: list[i].groupId == 0?null:list[i].groupId,
  910. groupName: list[i].groupName,
  911. taskGroups:list[i].taskGroups,
  912. stages:list[i].stages,
  913. stage:list[i].stage == '-'?null:list[i].stage,
  914. customData: list[i].customData,
  915. projectAuditorId: list[i].projectAuditorId,
  916. projectAuditorName: list[i].projectAuditorName,
  917. auditUserList: list[i].auditUserList,
  918. overtimeHours: list[i].overtimeHours,
  919. customText: list[i].customText,
  920. canEdit: list[i].state >= 2 ? true : false
  921. })
  922. if (list[i].state >= 2) {
  923. this.canEdit = true;
  924. } else {
  925. this.canDeleteReport = false
  926. }
  927. if (list[i].state == 0) {
  928. this.canCancel = true;
  929. this.canCancelInDialog = true
  930. }
  931. }
  932. this.form.domains = array;
  933. } else {
  934. this.canCancel = false;
  935. this.canEdit = true;
  936. var shuzhi = this.user.timeType.allday + ''
  937. //没有填报的可以点击提交
  938. this.form.domains = [{
  939. id: null,
  940. projectId: "",
  941. projectName: "",
  942. // workingTime: t.type==3?(t.allday).toFixed(1):"8.0",
  943. workingTime: t.type==3?(t.allday).toFixed(1):shuzhi.indexOf('.') == '-1' ? shuzhi + '.0' : shuzhi,
  944. content: "",
  945. state: 2,
  946. progress:100,
  947. isOvertime:false,
  948. professionProgress:[],
  949. multiWorktime:t.multiWorktime,
  950. worktimeList:[{}],
  951. canEdit: true
  952. }]
  953. if(this.isWeekend){
  954. this.$set(this.form.domains[0],'isOvertime',true)
  955. if(t.type != 2 && t.type != 0){
  956. this.$set(this.form.domains[0],'overtimeHours',t.allday.toFixed(0))
  957. }
  958. }
  959. if(this.report.timeBasecostList.length != 0 && this.user.company.packageProject == 1){
  960. this.form.domains[0].basecostId = this.report.timeBasecostList[0].id;
  961. this.form.domains[0].basecostName = this.report.timeBasecostList[0].name;
  962. }
  963. this.canEdit = true;
  964. }
  965. } else {
  966. this.$toast.clear();
  967. this.$toast.fail('获取失败:'+res.msg);
  968. }
  969. if(localStorage.getItem("formVal")) {
  970. // console.log('触发了')
  971. var obj = localStorage.getItem("formVal")
  972. this.form = JSON.parse(obj)
  973. localStorage.removeItem('formVal')
  974. }
  975. }).catch(err=> {this.$toast.clear();});
  976. },
  977. // 改变时间
  978. changeTime(time) {
  979. this.form.createDate = this.format(new Date(time),"yyyy-MM-dd");
  980. this.currentDate = time;
  981. this.showPicker = false;
  982. this.getReport();
  983. },
  984. //点击选择审核人
  985. clickPickAuditor(i, item) {
  986. if (!item.canEdit) return;
  987. if (item.auditUserList.length<=1) return;
  988. this.clickIndex = i;
  989. item.showPickerAuditor = true;
  990. this.$forceUpdate();
  991. },
  992. choseAuditor(value, index) {
  993. this.form.domains[this.clickIndex].projectAuditorId = value.auditorId;
  994. this.form.domains[this.clickIndex].projectAuditorName = value.auditorName;
  995. this.form.domains[this.clickIndex].showPickerAuditor = false;
  996. this.$forceUpdate();
  997. },
  998. //点击选择子项目
  999. clickPickSubProject(i, item) {
  1000. if (!item.canEdit) return;
  1001. this.clickIndex = i;
  1002. item.showPickerSubProject = true;
  1003. this.$forceUpdate();
  1004. },
  1005. clickPickCostId(i, item) {
  1006. if (!item.canEdit) return;
  1007. this.clickIndex = i;
  1008. item.showPickerCostId = true;
  1009. this.$forceUpdate();
  1010. },
  1011. clickPickTaskGroup(i, item) {
  1012. if (!item.canEdit) return;
  1013. this.clickIndex = i;
  1014. item.showPickerTaskGroup = true;
  1015. this.$forceUpdate();
  1016. },
  1017. clickPickStage(i, item) {
  1018. if (!item.canEdit) return;
  1019. this.clickIndex = i;
  1020. item.showPickerStage = true;
  1021. this.$forceUpdate();
  1022. },
  1023. // 选择项目
  1024. clickPicker(i, item) {
  1025. if (!item.canEdit) return;
  1026. // this.clickIndex = i;
  1027. // this.showPickerProject = true;
  1028. // console.log(i, item, this.form)
  1029. this.clickIndex = i
  1030. this.showPickerUserddp = true
  1031. // console.log(item);
  1032. // this.dimension()
  1033. // this.$router.push({
  1034. // path: '/search',
  1035. // query: {
  1036. // // from: JSON.stringify(this.form)
  1037. // from: this.form,
  1038. // idx: i
  1039. // }
  1040. // });
  1041. },
  1042. clickPickers(i,item) {
  1043. // console.log('wudulist',item.wuduList);
  1044. if (!item.canEdit) return;
  1045. this.clickIndex = i;
  1046. // item.showPickDegree = true;
  1047. this.$set(item,'showPickDegree',true)
  1048. // var proId = this.form.domains[this.clickIndex].projectId
  1049. // this.dimension(proId)
  1050. },
  1051. //选择任务
  1052. clickPickerTask(i,item) {
  1053. if (!item.canEdit) return;
  1054. // console.log(i);
  1055. this.clickIndex = i;
  1056. // var proId = this.form.domains[this.clickIndex].projectId
  1057. // this.getTaskList(proId)
  1058. this.form.domains[this.clickIndex].showPickerTask = true;
  1059. this.$forceUpdate();
  1060. },
  1061. choseTask(value, index) {
  1062. this.form.domains[this.clickIndex].taskId = value.taskId;
  1063. this.form.domains[this.clickIndex].taskName = value.taskName;
  1064. this.form.domains[this.clickIndex].showPickerTask = false;
  1065. this.$forceUpdate();
  1066. },
  1067. choseProjects(value, index) {
  1068. // console.log(value)
  1069. if(value){
  1070. this.form.domains[this.clickIndex].weiduName = value.name;
  1071. this.form.domains[this.clickIndex].degreeId = value.id;
  1072. this.$forceUpdate();}
  1073. this.form.domains[this.clickIndex].showPickDegree = false;
  1074. },
  1075. choseSubProject(value, index) {
  1076. this.form.domains[this.clickIndex].subProjectId = value.id;
  1077. this.form.domains[this.clickIndex].subProjectName = value.name;
  1078. this.form.domains[this.clickIndex].showPickerSubProject = false;
  1079. this.$forceUpdate();
  1080. },
  1081. choseTaskGroup(value, index) {
  1082. this.form.domains[this.clickIndex].groupId = value.id;
  1083. this.form.domains[this.clickIndex].groupName = value.name;
  1084. this.form.domains[this.clickIndex].showPickerTaskGroup = false;
  1085. var domainItem = this.form.domains[this.clickIndex];
  1086. this.getGroupStages(this.form.domains[this.clickIndex], index);
  1087. //检查当前的项目是否需要获取分组的负责人
  1088. var curProject = this.project.filter(p=>p.id == this.form.domains[this.clickIndex].projectId)[0];
  1089. if (curProject && this.user.timeType.reportAuditType >= 1) {
  1090. this.$axios.post("/task-group/getGroupIncharger", {groupId: domainItem.groupId})
  1091. .then(res => {
  1092. if(res.code == "ok") {
  1093. domainItem.auditUserList = res.data;
  1094. if (res.data.length==1) {
  1095. domainItem.projectAuditorId = domainItem.auditUserList[0].auditorId;
  1096. domainItem.projectAuditorName = domainItem.auditUserList[0].auditorName;
  1097. }
  1098. this.$forceUpdate();
  1099. } else {
  1100. this.$toast.fail('获取失败:'+res.msg);
  1101. }
  1102. }).catch(err=> {this.$toast.clear();});
  1103. }
  1104. },
  1105. choseStage(value, index) {
  1106. this.form.domains[this.clickIndex].stage = value.stagesName;
  1107. this.form.domains[this.clickIndex].showPickerStage = false;
  1108. this.$forceUpdate();
  1109. },
  1110. choseCostId(value,index){
  1111. this.form.domains[this.clickIndex].basecostId = value.id;
  1112. this.form.domains[this.clickIndex].basecostName = value.name;
  1113. this.form.domains[this.clickIndex].showPickerCostId = false;
  1114. this.$forceUpdate();
  1115. },
  1116. getGroupStages(domain, index) {
  1117. this.$axios.post("/stages/getProjectStagesByGroup", {groupId: domain.groupId})
  1118. .then(res => {
  1119. if(res.code == "ok") {
  1120. domain.stage = '';
  1121. domain.stages = res.data;
  1122. this.$forceUpdate();
  1123. } else {
  1124. this.$toast.fail('获取失败');
  1125. }
  1126. }).catch(err=> {this.$toast.clear();});
  1127. },
  1128. getProjectProfessions(domain, index) {
  1129. // console.log(domain, '数据')
  1130. this.$axios.post("/project-profession/getMyProfession", {projectId: domain.projectId})
  1131. .then(res => {
  1132. if(res.code == "ok") {
  1133. this.form.domains[this.clickIndex].professionProgress = res.data;
  1134. // console.log(this.form.domains)
  1135. this.$forceUpdate();
  1136. } else {
  1137. this.$toast.fail('获取失败');
  1138. }
  1139. }).catch(err=> {this.$toast.clear();});
  1140. },
  1141. // 获取维度
  1142. dimension(projectId) {
  1143. this.$axios.post("/project/getDegreeList", {projectId: projectId})
  1144. .then(res => {
  1145. if(res.code == "ok") {
  1146. this.form.domains[this.clickIndex].wuduList = res.data;
  1147. this.$forceUpdate();
  1148. } else {
  1149. this.$toast.fail('获取失败');
  1150. }
  1151. }).catch(err=> {this.$toast.clear();});
  1152. },
  1153. getTaskList(projectId) {
  1154. //如果是专业版,需要列出任务列表
  1155. if (this.user.company.packageProject == 1) {
  1156. this.$axios.post("/task/getRecentTask", {projectId: projectId})
  1157. .then(res => {
  1158. if(res.code == "ok") {
  1159. this.form.domains[this.clickIndex].taskList = res.data;
  1160. this.form = this.form;
  1161. // this.$forceUpdate();
  1162. } else {
  1163. this.$toast.fail('获取失败');
  1164. }
  1165. }).catch(err=> {this.$toast.clear();});
  1166. }
  1167. },
  1168. //添加工时
  1169. addNewWorktime(index, item) {
  1170. item.worktimeList.push({});
  1171. },
  1172. // 添加项目
  1173. addNewPro() {
  1174. var leftProgress = 10;
  1175. if (this.reportTimeType.type == 3) {
  1176. //计算已经待分配工时比例
  1177. let array = this.form.domains;
  1178. let totalProgress = 0;
  1179. for (var i=0;i<array.length; i++) {
  1180. totalProgress += array[i].progress;
  1181. }
  1182. if (totalProgress < 100) {
  1183. leftProgress = 100 - totalProgress;
  1184. }
  1185. }
  1186. let item = {
  1187. id: null,
  1188. projectId: "",
  1189. projectName: "",
  1190. workingTime: this.reportTimeType.type==3?(leftProgress*this.reportTimeType.allday/100).toFixed(1):"4.0",
  1191. progress:leftProgress,
  1192. content: "",
  1193. state: 2,
  1194. isOvertime:false,
  1195. multiWorktime: this.reportTimeType.multiWorktime,
  1196. worktimeList:[{}],
  1197. degreeId: null,
  1198. canEdit: true
  1199. }
  1200. if(this.isWeekend){
  1201. this.$set(item,'isOvertime',true)
  1202. if(this.reportTimeType.type == 3){
  1203. this.$set(item,'overtimeHours',(leftProgress*this.reportTimeType.allday/100).toFixed(1))
  1204. }else{
  1205. this.$set(item,'overtimeHours',4)
  1206. }
  1207. }
  1208. if(this.report.timeBasecostList.length != 0 && this.user.company.packageProject==1){
  1209. this.$set(item,'basecostId',this.report.timeBasecostList[0].id)
  1210. this.$set(item,'basecostName',this.report.timeBasecostList[0].name)
  1211. }
  1212. this.form.domains.push(item)
  1213. this.canEdit = true
  1214. this.$forceUpdate()
  1215. },
  1216. // 移除项目
  1217. delPro(i) {
  1218. this.$dialog.confirm({
  1219. title: '',
  1220. message: '是否移除当前项目'
  1221. }).then(() => {
  1222. this.form.domains.splice(i,1);
  1223. }).catch(() => {
  1224. });
  1225. },
  1226. // 判断时间段
  1227. fns() {
  1228. for (let k in this.dateAr) {
  1229. if (!this.judege(k)) {
  1230. return false
  1231. }
  1232. }
  1233. return true
  1234. },
  1235. judege(idx){
  1236. for (let k in this.dateAr) {
  1237. if (idx !== k) {
  1238. if (this.dateAr[k].s <= this.dateAr[idx].s && this.dateAr[k].e > this.dateAr[idx].s) {
  1239. return false
  1240. }
  1241. if (this.dateAr[k].s < this.dateAr[idx].e && this.dateAr[k].e >= this.dateAr[idx].e) {
  1242. return false
  1243. }
  1244. }
  1245. }
  1246. return true
  1247. },
  1248. // 提交日报
  1249. submitReport() {
  1250. this.dateAr = []
  1251. let alp = []
  1252. if(this.user.timeType.multiWorktime == 1) {
  1253. for(var p in this.form.domains) {
  1254. var slll = this.form.domains[p]
  1255. for(var o in slll.worktimeList) {
  1256. if(slll.worktimeList[o].startTime || slll.worktimeList[o].endTime) {
  1257. let objs = {}
  1258. objs.s = slll.worktimeList[o].startTime
  1259. objs.e = slll.worktimeList[o].endTime
  1260. alp.push(objs)
  1261. }
  1262. }
  1263. }
  1264. }else{
  1265. for(let i in this.form.domains){
  1266. let objs = {}
  1267. objs.s = this.form.domains[i].startTime
  1268. objs.e = this.form.domains[i].endTime
  1269. alp.push(objs)
  1270. }
  1271. }
  1272. this.dateAr = alp
  1273. if(this.dateAr.length > 0) {
  1274. let trus = this.fns()
  1275. if(!trus) {
  1276. this.$toast('填写的时间段重叠')
  1277. return
  1278. }
  1279. }
  1280. // return
  1281. const toast = this.$toast.loading({
  1282. forbidClick: true,
  1283. duration: 0
  1284. });
  1285. // let formData = new FormData();
  1286. let formData = new URLSearchParams()
  1287. formData.append("draft", this.isDraft);
  1288. if (this.reportTimeType.type == 0) {
  1289. var alldayNum = 0;
  1290. var amNum = 0;
  1291. var pmNum = 0;
  1292. for(var i in this.form.domains) {
  1293. if (this.form.domains[i].timeType == 0) {
  1294. alldayNum ++;
  1295. } else if (this.form.domains[i].timeType == 1) {
  1296. amNum++;
  1297. } else if (this.form.domains[i].timeType == 2) {
  1298. pmNum++;
  1299. }
  1300. }
  1301. if (alldayNum > 1) {
  1302. this.$toast.fail("工作时间-全天,只能选择一次");
  1303. return;
  1304. }
  1305. if (amNum > 1) {
  1306. this.$toast.fail("工作时间-上午,只能选择一次");
  1307. return;
  1308. }
  1309. if (pmNum > 1) {
  1310. this.$toast.fail("工作时间-下午,只能选择一次");
  1311. return;
  1312. }
  1313. if (alldayNum == 1 && (amNum > 0 || pmNum > 0)) {
  1314. this.$toast.fail("工作时间-全天,不能和上下午同时存在");
  1315. return;
  1316. }
  1317. } else if (this.reportTimeType.type == 3) {
  1318. //总百分比不能超过100%
  1319. let total = 0;
  1320. this.form.domains.forEach(w=>{total += w.progress});
  1321. if (total > 100) {
  1322. this.$toast.fail("用时比例之和不能超过100%");
  1323. return;
  1324. } else if (total < 100) {
  1325. this.$toast.fail("工时尚未完全分配,无法提交");
  1326. return;
  1327. }
  1328. }
  1329. if (this.reportTimeType.type == 1 && this.report.time) {
  1330. var totalTime = 0;
  1331. for (var t=0;t<this.form.domains.length; t++) {
  1332. totalTime += parseFloat(this.form.domains[t].workingTime);
  1333. }
  1334. if (this.report.time.workHours && totalTime > parseFloat(this.report.time.workHours)) {
  1335. this.$toast.fail("填报工时之和"+(totalTime)+"h不能超过考勤总工时("+this.report.time.workHours.toFixed(1)+"h)");
  1336. return;
  1337. }
  1338. }
  1339. //填字段
  1340. for(var i in this.form.domains) {
  1341. if (this.user.timeType.customDegreeActive == 1) {
  1342. if(this.form.domains[i].degreeId) {
  1343. formData.append("degreeId", this.form.domains[i].degreeId);
  1344. } else {
  1345. if(this.user.timeType.customDegreeStatus && this.form.domains[i].wuduList.length){
  1346. this.$toast.fail('请选择' + this.user.timeType.customDegreeName)
  1347. return
  1348. }else{
  1349. formData.append("degreeId", -1);
  1350. }
  1351. }
  1352. } else {
  1353. formData.append("degreeId", -1);
  1354. }
  1355. if(this.form.domains[i].customData) {
  1356. formData.append("customData", this.form.domains[i].customData);
  1357. } else {
  1358. formData.append("customData", "0");
  1359. }
  1360. if(this.form.domains[i].customText) {
  1361. formData.append("customText", this.form.domains[i].customText);
  1362. } else {
  1363. formData.append("customText", "-");
  1364. }
  1365. if (this.form.domains[i].id) {
  1366. formData.append("id", this.form.domains[i].id);
  1367. } else {
  1368. formData.append("id", -1);
  1369. }
  1370. formData.append("projectId", parseFloat(this.form.domains[i].projectId));
  1371. if (this.form.domains[i].subProjectId) {
  1372. formData.append("subProjectId", this.form.domains[i].subProjectId);
  1373. } else {
  1374. formData.append("subProjectId", 0);
  1375. }
  1376. if (this.form.domains[i].groupId) {
  1377. formData.append("groupId", this.form.domains[i].groupId);
  1378. } else {
  1379. formData.append("groupId", 0);
  1380. }
  1381. if (this.form.domains[i].stage) {
  1382. formData.append("stage", this.form.domains[i].stage);
  1383. } else {
  1384. formData.append("stage", '-');
  1385. }
  1386. formData.append("reportTimeType", this.reportTimeType.type);
  1387. formData.append("multiWorktime", this.reportTimeType.multiWorktime);
  1388. if (this.reportTimeType.type == 0) {
  1389. formData.append("timeType", this.form.domains[i].timeType);
  1390. formData.append("workingTime", parseFloat(this.form.domains[i].workingTime));
  1391. } else if (this.reportTimeType.type == 1) {
  1392. formData.append("workingTime", parseFloat(this.form.domains[i].workingTime));
  1393. } else if (this.reportTimeType.type == 2) {
  1394. formData.append("startTime", this.form.domains[i].startTime);
  1395. formData.append("endTime",this.form.domains[i].endTime);
  1396. } else if (this.reportTimeType.type == 3) {
  1397. formData.append("progress", this.form.domains[i].progress);
  1398. formData.append("workingTime",this.form.domains[i].workingTime);
  1399. }
  1400. if (this.form.domains[i].taskId) {
  1401. formData.append("taskId", this.form.domains[i].taskId);
  1402. } else {
  1403. formData.append("taskId", 0);
  1404. }
  1405. if (this.form.domains[i].taskFinish == true) {
  1406. formData.append("taskFinish", 1);
  1407. } else {
  1408. formData.append("taskFinish", 0);
  1409. }
  1410. formData.append("createDate", this.form.createDate);
  1411. formData.append("isOvertime", this.form.domains[i].isOvertime?1:0);
  1412. if (this.form.domains[i].overtimeHours && this.form.domains[i].isOvertime == 1) {
  1413. formData.append("overtimeHours", this.form.domains[i].overtimeHours);
  1414. } else {
  1415. formData.append("overtimeHours", 0);
  1416. }
  1417. if(this.form.domains[i].basecostId){
  1418. formData.append("basecostId", this.form.domains[i].basecostId);
  1419. }
  1420. //项目专业进度
  1421. if (this.form.domains[i].professionProgress) {
  1422. let m = JSON.stringify(this.form.domains[i].professionProgress);
  1423. m = m.replace(/,/g,"@");//replaceAll(',','@');企业微信不兼容replaceAll
  1424. formData.append("professionProgress", m);
  1425. } else {
  1426. formData.append("professionProgress", "[]");
  1427. }
  1428. //图片的处理,serverPic是当前所有的照片
  1429. if (this.form.domains[i].serverPics) {
  1430. let m = JSON.stringify(this.form.domains[i].serverPics);
  1431. m = m.replace(/,/g,"@");//replaceAll(',','@');企业微信不兼容replaceAll
  1432. formData.append("pics", m);
  1433. } else {
  1434. formData.append("pics", "@");
  1435. }
  1436. //处理多个时间事项
  1437. if (this.reportTimeType.multiWorktime == 1) {
  1438. //检查时间是否有重叠
  1439. var workList = this.form.domains[i].worktimeList;
  1440. for (var j=0;j<workList.length; j++) {
  1441. var curItem = workList[j];
  1442. if (curItem.startTime == null || curItem.endTime == null) {
  1443. this.$toast.fail("请设置工作时间");
  1444. return;
  1445. }
  1446. //检查开始时间是否大于结束时间
  1447. if (curItem.startTime >= curItem.endTime) {
  1448. this.$toast.fail("时间段"+curItem.startTime+'-'+curItem.endTime+"有误:"+
  1449. "结束时间必须大于开始时间");
  1450. return;
  1451. }
  1452. for (var p = j+1;p<workList.length; p++) {
  1453. var jItem = workList[p];
  1454. if ((jItem.startTime>=curItem.startTime&&jItem.startTime < curItem.endTime)
  1455. || (jItem.endTime>curItem.startTime&&jItem.endTime <= curItem.endTime)) {
  1456. this.$toast.fail("时间段"+curItem.startTime+'-'+curItem.endTime+"与"+
  1457. jItem.startTime+'-'+jItem.endTime+ "存在重叠,请修改。");
  1458. return;
  1459. }
  1460. }
  1461. }
  1462. let m = JSON.stringify(this.form.domains[i].worktimeList);
  1463. m = m.replace(/,/g,"@");//replaceAll(',','@');企业微信不兼容replaceAll
  1464. formData.append("content", m);
  1465. } else {
  1466. if (this.form.domains[i].content) {
  1467. formData.append("content", this.form.domains[i].content);
  1468. } else {
  1469. formData.append("content", '-');
  1470. }
  1471. }
  1472. //审核人
  1473. if (this.form.domains[i].projectAuditorId) {
  1474. formData.append("projectAuditorId", this.form.domains[i].projectAuditorId);
  1475. } else {
  1476. if (this.user.timeType.reportAuditType == 0) {
  1477. this.$toast.fail("请指定["+this.form.domains[i].projectName+']项目的审核人');
  1478. } else {
  1479. if (this.form.domains[i].taskGroups.length == 0) {
  1480. this.$toast.fail("您在["+this.form.domains[i].projectName+"]项目上尚无参与的任务分组");
  1481. } else if (!this.form.domains[i].groupId) {
  1482. this.$toast.fail("请选择["+this.form.domains[i].projectName+"]项目的任务分组");
  1483. } else {
  1484. this.$toast.fail("请先设置["+this.form.domains[i].projectName+']-['+this.form.domains[i].groupName+']的分组负责人');
  1485. }
  1486. }
  1487. return;
  1488. }
  1489. }
  1490. if(!this.flgLg) {
  1491. return
  1492. }
  1493. this.flgLg = false
  1494. this.$axios.post("/report/editReport", formData)
  1495. .then(res => {
  1496. this.flgLg = true
  1497. if(res.code == "ok") {
  1498. this.$toast.clear();
  1499. this.$toast.success(this.isDraft==0?'提交成功':'暂存成功');
  1500. this.$router.push("/index");
  1501. } else {
  1502. this.$toast.clear();
  1503. this.$toast.fail((this.isDraft==0?'提交失败':'暂存失败')+':'+res.msg);
  1504. }
  1505. }).catch(err=> {this.$toast.clear(); this.flgLg = true});
  1506. },
  1507. //初始化参数
  1508. initWxConfig() {
  1509. var curUrl=location.href.split("#")[0];
  1510. this.$axios.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id})
  1511. .then(res => {
  1512. if(res.code == "ok") {
  1513. var data=res.data;
  1514. wx.config({
  1515. beta: true,
  1516. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  1517. appId: data.appid, // 必填,公众号的唯一标识
  1518. timestamp: data.timestamp, // 必填,生成签名的时间戳
  1519. nonceStr: data.noncestr, // 必填,生成签名的随机串
  1520. signature: data.sign, // 必填,签名,见附录1
  1521. jsApiList: [
  1522. 'chooseImage',
  1523. 'previewImage',
  1524. 'uploadImage',
  1525. 'downloadImage',
  1526. 'previewFile',
  1527. 'getLocation',
  1528. ]
  1529. });
  1530. var that = this;
  1531. wx.ready(function(){
  1532. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  1533. // if (that.user.companyId == 7) {
  1534. // that.$toast('wx init success==7 ');
  1535. // that.getLocation();
  1536. // }
  1537. });
  1538. } else {
  1539. this.$toast.fail('获取失败');
  1540. }
  1541. }).catch(err=> {this.$toast.fail('发生异常'+err);console.log(err)});
  1542. },
  1543. deleteImg(item, index) {
  1544. //删除添加的图片
  1545. if (this.isIOSystem) {
  1546. item.iospics.splice(index,1);
  1547. item.iospics = item.iospics;
  1548. }
  1549. item.pics.splice(index,1);
  1550. item.pics = item.pics;
  1551. //传递到后台的数据也要做同步删除
  1552. item.serverPics.splice(index,1);
  1553. this.$forceUpdate();
  1554. },
  1555. //企业微信获取定位
  1556. getLocation() {
  1557. wx.getLocation({
  1558. type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  1559. success: function (res) {
  1560. var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
  1561. var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
  1562. alert(JSON.stringify(res));
  1563. }
  1564. });
  1565. }
  1566. },
  1567. mounted() {
  1568. // console.log('user',this.user)
  1569. var ua = navigator.userAgent.toLowerCase();
  1570. this.isIOSystem = this.isIOS();
  1571. if (ua.indexOf("wxwork") > 0) {
  1572. this.isCorpWX = true;
  1573. } else if (ua.indexOf("micromessenger") > 0) {
  1574. this.isWX = true;
  1575. }
  1576. this.getPeoject() // 获取项目
  1577. // console.log('mounted');
  1578. this.getReportBasecostList()
  1579. //获取传递过来的日期
  1580. var passDate = this.$route.query.date;
  1581. if (passDate != null) {
  1582. this.form.createDate = this.$route.query.date;
  1583. }
  1584. // this.getProject();
  1585. this.getReport();
  1586. this.getTimeType();
  1587. //初始化微信js-sdk参数
  1588. if (this.isCorpWX) {
  1589. this.initWxConfig();
  1590. }
  1591. if(this.user.timeType.lockWorktime){
  1592. this.timeRange = this.timeRange.filter(item => {return item <= this.user.timeType.allday})
  1593. }
  1594. // if(localStorage.getItem("formVal")) {
  1595. // var obj = localStorage.getItem("formVal")
  1596. // this.form = JSON.parse(obj)
  1597. // localStorage.removeItem('formVal')
  1598. // }
  1599. },
  1600. beforeDestroy() {
  1601. localStorage.removeItem('formVal')
  1602. }
  1603. };
  1604. </script>
  1605. <style lang="less" scope>
  1606. .my-swipe .van-swipe-item {
  1607. color: #fff;
  1608. font-size: 20px;
  1609. line-height: 150px;
  1610. text-align: center;
  1611. background-color: #39a9ed;
  1612. }
  1613. .van-field__control:disabled {
  1614. -webkit-text-fill-color:#646566;
  1615. }
  1616. .login_form {
  1617. margin-top: 46px;
  1618. position: relative;
  1619. }
  1620. .attendanceRecord{
  1621. position: absolute;
  1622. top: 0.26667rem;
  1623. right: 0.42667rem;
  1624. color: #969799;
  1625. font-size: 0.35rem;
  1626. line-height: 0.64rem;
  1627. }
  1628. .form_domains {
  1629. position: relative;
  1630. .form_copy {
  1631. position: absolute;
  1632. right: 85px;
  1633. top: 10px;
  1634. }
  1635. .form_addNew {
  1636. text-align: center;
  1637. margin:10px;
  1638. }
  1639. .form_del {
  1640. position: absolute;
  1641. right: 10px;
  1642. top: 10px;
  1643. }
  1644. // .form_del {
  1645. // color: #ff0000;
  1646. // font-size: 22px;
  1647. // position: absolute;
  1648. // right: 15px;
  1649. // top: 10px;
  1650. // }
  1651. }
  1652. .form_tip {
  1653. text-align: center;
  1654. margin-top: 20px;
  1655. color: #afafaf;
  1656. font-size: 14px;
  1657. }
  1658. .card__footer {
  1659. padding-top: 10px;
  1660. }
  1661. .card__tags {
  1662. .van-tag {
  1663. margin-right: 5px;
  1664. }
  1665. }
  1666. .overTimeClas{
  1667. display: flex;
  1668. width: 7.4rem;
  1669. // justify-content: space-between;
  1670. align-items: center;
  1671. }
  1672. </style>
  1673. <style lang="less">
  1674. .van-nav-bar .van-icon , .van-nav-bar__text {
  1675. color: #20a0ff;
  1676. }
  1677. .overtime {
  1678. height: 50px;
  1679. box-sizing: border-box;
  1680. padding-left: 10px;
  1681. display: flex;
  1682. align-items: center;
  1683. }
  1684. .custom-button {
  1685. width: 40px;
  1686. color: #fff;
  1687. font-size: 10px;
  1688. line-height: 16px;
  1689. text-align: center;
  1690. background-color: #1989fa;
  1691. border-radius: 100px;
  1692. }
  1693. .imgList {
  1694. position: relative;
  1695. width: 100px;
  1696. height: 100px;
  1697. display: inline-block;
  1698. }
  1699. .imgList_i {
  1700. position: absolute;
  1701. top: -8px;
  1702. right: -6px;
  1703. z-index: 999;
  1704. }
  1705. .ryuan {
  1706. padding: 0.3rem 0.53333rem;
  1707. // line-height: 40px;
  1708. // height: 40px;
  1709. color: #333;
  1710. border-bottom: 2px solid #f6f6f6;
  1711. width: 100%;
  1712. overflow: hidden;
  1713. text-overflow:ellipsis;
  1714. white-space: nowrap;
  1715. }
  1716. .overListTime {
  1717. margin-left:5px;
  1718. display: inline-block;
  1719. width: 2rem;
  1720. color: #646566;
  1721. }
  1722. .hoveOver {
  1723. color: #C8C9CC;
  1724. }
  1725. .van-checkbox__label {
  1726. color: #646566 !important;
  1727. }
  1728. .van-checkbox__label--disabled {
  1729. color: #c8c9cc !important;
  1730. }
  1731. </style>