weekEdit.vue 108 KB

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