index.vue 75 KB

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