index.vue 91 KB

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