weekEdit.vue 108 KB

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