index.vue 93 KB

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