index.vue 79 KB

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