weekEdit-01.vue 109 KB

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