weekEdit.vue 105 KB

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