applyAgainHoliday.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :close-on-press-escape="false"
  5. :title="dialogTitle"
  6. :visible.sync="dialogVisible"
  7. top="50px"
  8. width="85%"
  9. >
  10. <div class="tabsdom">
  11. <el-tabs v-model="activeName" @tab-click="handleClick">
  12. <el-tab-pane label="请假申请" name="first">
  13. <el-card shadow="always" style="padding: 20px 10px 10px 20px">
  14. <div v-for="(item,index) in hoildaylist" style="margin:10px 0px">
  15. <el-row v-if="item.offWorkType==1" :gutter="10" class="holidayRow">
  16. <el-col :span="2" class="col-txt">
  17. <div style="width: 100%">
  18. &nbsp;
  19. <span v-if="index==0">请假类型 </span>
  20. </div>
  21. </el-col>
  22. <el-col :span="5">
  23. <el-select
  24. v-model="item.offWorkType"
  25. filterable
  26. placeholder="请假类型"
  27. @change="getHolidayType($event,index,item)"
  28. >
  29. <el-option
  30. v-for="itam in ProjectData"
  31. :key="itam.name"
  32. :disabled="!itam.disabled"
  33. :label="itam.name"
  34. :value="itam.type"
  35. />
  36. </el-select>
  37. </el-col>
  38. <el-col :span="4">
  39. <el-date-picker
  40. v-model="item.startDate"
  41. placeholder="选择日期"
  42. style="width: 100%!important;"
  43. type="date"
  44. value-format="yyyy-MM-dd"
  45. width="100%"
  46. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  47. />
  48. </el-col>
  49. <el-col :span="2">
  50. <el-select
  51. v-model="item.startIsAllday"
  52. filterable
  53. placeholder=""
  54. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  55. >
  56. <el-option label="上午" value="上午" />
  57. <el-option label="下午" value="下午" />
  58. </el-select>
  59. </el-col>
  60. <el-col :span="1">
  61. <div style="height: 1px;background: #606266;width:100%;margin-top:40%" />
  62. </el-col>
  63. <el-col :span="4">
  64. <el-date-picker
  65. v-model="item.endDate"
  66. :readonly="!item.startDate||item.startDate.length==0?true:false"
  67. placeholder="选择日期"
  68. style="width:100%"
  69. type="date"
  70. value-format="yyyy-MM-dd"
  71. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  72. />
  73. </el-col>
  74. <el-col :span="2">
  75. <el-select
  76. v-model="item.endIsAllday"
  77. filterable
  78. placeholder=""
  79. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  80. >
  81. <el-option label="上午" value="上午" />
  82. <el-option label="下午" value="下午" />
  83. </el-select>
  84. </el-col>
  85. <el-col :span="2" class="col-txt" style="text-align: center">
  86. 共{{
  87. !item.days ? 0 : item.days
  88. }}天
  89. </el-col>
  90. <el-col :span="1" class="col-txt" style="text-align: center">
  91. &nbsp;
  92. <el-button
  93. v-if="index!=0"
  94. circle
  95. icon="el-icon-minus"
  96. @click="spliceListRow(index)"
  97. />
  98. </el-col>
  99. <el-col :span="1" class="col-txt" style="text-align: center">
  100. <el-button
  101. circle
  102. icon="el-icon-plus"
  103. type="primary"
  104. @click="addListRow()"
  105. />
  106. </el-col>
  107. </el-row>
  108. <el-row v-if="item.offWorkType==3||item.offWorkType==2" :gutter="10" class="holidayRow">
  109. <el-col :span="2" class="col-txt">
  110. <div style="width: 100%">
  111. <span v-if="index==0">请假类型 </span>&nbsp;
  112. </div>
  113. </el-col>
  114. <el-col :span="5" class="col-input">
  115. <el-select
  116. v-model="item.offWorkType"
  117. filterable
  118. placeholder="请假类型"
  119. style="width: 100%"
  120. @change="getHolidayType($event,index,item)"
  121. >
  122. <el-option
  123. v-for="itam in ProjectData"
  124. :key="itam.name"
  125. :label="itam.name"
  126. :value="itam.type"
  127. />
  128. </el-select>
  129. </el-col>
  130. <el-col :span="6">
  131. <el-date-picker
  132. v-model="item.dayMerange"
  133. class="pdr10px mgb10px"
  134. placeholder="选择日期"
  135. type="date"
  136. value-format="yyyy-MM-dd"
  137. />
  138. </el-col>
  139. <el-col :span="7">
  140. <div style="display: flex;align-items: center">
  141. <el-time-picker
  142. v-model="item.startTime"
  143. :disabled="!item.dayMerange"
  144. value-format="HH:mm"
  145. format="HH:mm"
  146. placeholder="开始时间"
  147. @change="getStartTime(item.startTime,item.startTime,item.dayMerange,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  148. />
  149. <div class="zhi">至</div>
  150. <el-time-picker
  151. v-model="item.endTime"
  152. :disabled="!(item.dayMerange&&item.startTime)"
  153. format="HH:mm"
  154. value-format="HH:mm"
  155. placeholder="结束时间"
  156. @change="getEndTime(item.startTime,item.endTime,item.dayMerange,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  157. />
  158. </div>
  159. </el-col>
  160. <el-col :span="2" class="col-txt" style="text-align: center">
  161. <!-- {{ JSON.stringify(item) }}-->
  162. 共{{ !item.hour ? 0 : item.hour.toFixed(2) }}小时
  163. </el-col>
  164. <el-col :span="1" class="col-txt" style="text-align: center">
  165. &nbsp;
  166. <el-button
  167. v-if="index!=0"
  168. circle
  169. icon="el-icon-minus"
  170. @click="spliceListRow(index)"
  171. />
  172. </el-col>
  173. <el-col :span="1" class="col-txt" style="text-align: center">
  174. <el-button
  175. circle
  176. icon="el-icon-plus"
  177. type="primary"
  178. @click="addListRow()"
  179. />
  180. </el-col>
  181. </el-row>
  182. <el-row
  183. v-if="item.offWorkType!=1&& item.offWorkType!=3&&item.offWorkType!=2"
  184. :gutter="10"
  185. class="holidayRow"
  186. >
  187. <el-col :span="2" class="col-txt">
  188. <div style="width: 100%">
  189. &nbsp;
  190. <span v-if="index==0">请假类型 </span>
  191. </div>
  192. </el-col>
  193. <el-col :span="5">
  194. <el-select
  195. v-model="item.offWorkType"
  196. filterable
  197. placeholder="请假类型"
  198. @change="getHolidayType($event,index,item)"
  199. >
  200. <el-option
  201. v-for="itam in ProjectData"
  202. :key="itam.name"
  203. :disabled="!itam.disabled"
  204. :label="itam.name"
  205. :value="itam.type"
  206. />
  207. </el-select>
  208. </el-col>
  209. <el-col :span="4">
  210. <el-date-picker
  211. v-model="item.startDate"
  212. placeholder="选择日期"
  213. style="width: 100%!important;"
  214. type="date"
  215. value-format="yyyy-MM-dd"
  216. width="100%"
  217. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  218. />
  219. </el-col>
  220. <el-col :span="2">
  221. <el-select
  222. v-model="item.startIsAllday"
  223. filterable
  224. placeholder=""
  225. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  226. >
  227. <el-option label="上午" value="上午" />
  228. <el-option label="下午" value="下午" />
  229. </el-select>
  230. </el-col>
  231. <el-col :span="1">
  232. <div style="height: 1px;background: #606266;width:100%;margin-top:40%" />
  233. </el-col>
  234. <el-col :span="4">
  235. <el-date-picker
  236. v-model="item.endDate"
  237. :readonly="!item.startDate||item.startDate.length==0?true:false"
  238. placeholder="选择日期"
  239. style="width:100%"
  240. type="date"
  241. value-format="yyyy-MM-dd"
  242. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  243. />
  244. </el-col>
  245. <el-col :span="2">
  246. <el-select
  247. v-model="item.endIsAllday"
  248. filterable
  249. placeholder=""
  250. @change="countDays(item.startDate,item.endDate,item.startIsAllday,item.endIsAllday,index,item.offWorkType)"
  251. >
  252. <el-option label="上午" value="上午" />
  253. <el-option label="下午" value="下午" />
  254. </el-select>
  255. </el-col>
  256. <el-col :span="2" class="col-txt" style="text-align: center">
  257. 共{{
  258. !item.days ? 0 : item.days
  259. }}天
  260. </el-col>
  261. <el-col :span="1" class="col-txt" style="text-align: center">
  262. &nbsp;
  263. <el-button
  264. v-if="index!=0"
  265. circle
  266. icon="el-icon-minus"
  267. @click="spliceListRow(index)"
  268. />
  269. </el-col>
  270. <el-col :span="1" class="col-txt" style="text-align: center">
  271. <el-button
  272. circle
  273. icon="el-icon-plus"
  274. type="primary"
  275. @click="addListRow()"
  276. />
  277. </el-col>
  278. </el-row>
  279. </div>
  280. <div class="totalApplyTime">{{ totalApplyTime }}</div>
  281. <el-row>
  282. <el-col :span="2" class="col-txt"><span>请假事由</span></el-col>
  283. <el-col :span="22">
  284. <el-input v-model="form.applyReasons" style="min-height:50px;margin-bottom: 25px" type="textarea" />
  285. </el-col>
  286. </el-row>
  287. <el-row>
  288. <el-col :span="2" class="col-txt">附件</el-col>
  289. <el-col :span="22">
  290. <el-upload
  291. :action="$constant.BASE_URI+'/FileController/upload'"
  292. :file-list="form.fileUrlList"
  293. :http-request="uploadFile"
  294. class="upload-demo"
  295. multiple
  296. >
  297. <el-button size="small" type="primary">点击上传</el-button>
  298. <div slot="file" slot-scope="{file}">
  299. <a :href="file.url">{{ file.name }}</a>
  300. <span class="el-upload-list__item-actions">
  301. <i class="el-icon-delete" @click="handlePictureRemove(file,form.fileUrlList)" />
  302. </span>
  303. </div>
  304. </el-upload>
  305. </el-col>
  306. </el-row>
  307. <el-row style="margin-top: 25px">
  308. <el-col :span="2" class="col-txt">抄送</el-col>
  309. <el-col :span="22">
  310. <user-select
  311. ref="userSelect"
  312. :default-select="selectList"
  313. :multiple="true"
  314. width="700"
  315. @selectValue="parentMethod"
  316. />
  317. </el-col>
  318. </el-row>
  319. </el-card>
  320. </el-tab-pane>
  321. <el-tab-pane label="流程图 " name="second">
  322. <holidayCanvas ref="holidayCanvas" />
  323. </el-tab-pane>
  324. </el-tabs>
  325. </div>
  326. <div slot="footer">
  327. <el-button @click="dialogVisible = false">取 消</el-button>
  328. <el-button :loading="loading" type="primary" @click="confirmSubmit()">确 定</el-button>
  329. </div>
  330. </el-dialog>
  331. </template>
  332. <script>
  333. import userSelect from '@/views/components/UserSelect.vue'
  334. import { upload } from '@/static/utils/channel'
  335. import Base from '@/views/base/base'
  336. import BaseData from '@/views/base/baseData'
  337. import holidayCanvas from '@/views/workflow/components/myProcess/holidayCanvas.vue'
  338. export default {
  339. name: 'ApplyPay',
  340. components: {
  341. userSelect, holidayCanvas
  342. },
  343. mixins: [Base, BaseData],
  344. data() {
  345. return {
  346. row: {},
  347. freezeHolidayTime: 0,
  348. freezeExchangeTime: 0,
  349. restHolidayDate: '',
  350. confirmForm: {
  351. confirmContent: ''
  352. },
  353. dc_key: ['ORDER_STATUS', 'PAY_TYPE', 'BUDGET_FY', 'COMMON_PHRASES'],
  354. dc_data: {},
  355. tableData: [],
  356. loading: false,
  357. totalApplyTime: '共计请假0天,0.00小时',
  358. dialogVisible: false,
  359. hoildaylist: [
  360. { offWorkType: 2, hour: 0, days: 0 }
  361. ],
  362. fileError: false,
  363. fileList: [],
  364. selectList: [],
  365. form: {
  366. fileUrlList: []
  367. },
  368. daysNum: 0,
  369. holidayDays: {},
  370. options: [
  371. { value: '陈鹏铭', label: '陈鹏铭' },
  372. { value: '宣胜伟', label: '宣胜伟' },
  373. { value: '张洮', label: '张洮' },
  374. { value: '潘毅', label: '潘毅' },
  375. { value: '崔伟', label: '崔伟' }
  376. ],
  377. value1: [],
  378. ProjectData: [
  379. { name: '年假(剩余x天)', type: 'year' },
  380. { name: '调休(x小时)', type: 'affair' },
  381. { name: '病假', type: 'illness' }
  382. ],
  383. dialogTitle: '请假申请',
  384. activeName: 'first'
  385. }
  386. },
  387. watch: {
  388. 'hoildaylist': {
  389. deep: true,
  390. handler(newValue, oldValue) {
  391. let day = 0
  392. let hour = 0
  393. for (let i = 0; i < this.hoildaylist.length; i++) {
  394. if (this.hoildaylist[i].hour === 0 || this.hoildaylist[i].hour) {
  395. hour = (hour + Number(this.hoildaylist[i].hour))
  396. }
  397. if (this.hoildaylist[i].days === 0 || this.hoildaylist[i].days) {
  398. day = (day + Number(this.hoildaylist[i].days))
  399. }
  400. }
  401. this.holidayDate = day
  402. this.holidayTime = Number(hour).toFixed(2)
  403. this.changeCotalApplyTime(`共计请假${day}天,${hour.toFixed(2)}小时`)
  404. }
  405. }
  406. },
  407. mounted() {
  408. const _this = this
  409. _this.initDict(this.dc_key).then((res) => {
  410. _this.initProject({ /* signstatus: '2,3'*/ })
  411. })
  412. },
  413. methods: {
  414. getStartTime(startTime, endTime, dayMerange, startIsAllday, endIsAllday, index, type) {
  415. console.log(startTime)
  416. if (this.hoildaylist[index].endTime) delete this.hoildaylist[index].endTime
  417. this.hoildaylist[index].hour = 0
  418. this.hoildaylist[index].endDate = ''
  419. if (startTime && dayMerange && (index == 0 || index) && (type == 0 || type)) {
  420. this.hoildaylist[index].startDate = dayMerange + ' ' + startTime + ':00'
  421. }
  422. this.$forceUpdate()
  423. },
  424. getEndTime(startTime, endTime, dayMerange, startIsAllday, endIsAllday, index, type) {
  425. if (endTime && dayMerange && (index == 0 || index) && (type == 0 || type)) {
  426. this.hoildaylist[index].endDate = dayMerange + ' ' + endTime + ':00'
  427. }
  428. if (startTime && endTime && dayMerange && (index == 0 || index) && (type == 0 || type)) {
  429. this.countDays(dayMerange + ' ' + startTime, dayMerange + ' ' + endTime, startIsAllday, endIsAllday, index, type)
  430. }
  431. },
  432. handleClick(tab, event) {
  433. this.canVasStatus = false
  434. if (this.activeName == 'second') {
  435. this.canVasStatus = true
  436. this.$nextTick(() => {
  437. this.$refs.holidayCanvas.createNodeCanvas(this.row)
  438. })
  439. }
  440. },
  441. getTimeMerange(timeMerange, dayMerange, startIsAllday, endIsAllday, index, type) {
  442. this.hoildaylist[index].startDate = dayMerange + ' ' + timeMerange[0] + ':00'
  443. this.hoildaylist[index].endDate = dayMerange + ' ' + timeMerange[1] + ':00'
  444. this.countDays(dayMerange + ' ' + timeMerange[0], dayMerange + ' ' + timeMerange[1], startIsAllday, endIsAllday, index, type)
  445. },
  446. countDays(startDate, endDate, startIsAllday, endIsAllday, index, type) {
  447. // 如果是年假
  448. if (type == 1) {
  449. if (startDate && endDate && startIsAllday && endIsAllday) {
  450. // 判断是不是都已经选择完成
  451. const endDateParams = new Date(endDate).getTime() // 计算一下开始时间
  452. const startDateParams = new Date(startDate).getTime() // 计算一下结束时间
  453. let days = (endDateParams - startDateParams) / (1000 * 60 * 60 * 24) // 开始和结束时间相减 单位:毫秒
  454. if (
  455. startDateParams == endIsAllday ||
  456. (startIsAllday == '上午' && endIsAllday == '上午') ||
  457. (startIsAllday == '下午' && endIsAllday == '下午')
  458. ) {
  459. // 如果选择的情况是 开始:上午 ,结束:上午 或者 开始:下午 ,结束:下午。则都加0.5天
  460. days = days + 0.5
  461. } else if (
  462. startIsAllday == '上午' &&
  463. endIsAllday == '下午'
  464. ) {
  465. // 如果选择情况是 开始:上午 结束:下午 ,则加一天,其他情况不加减
  466. days = days + 1
  467. }
  468. this.hoildaylist[index].days = days
  469. let daysNum = 0
  470. const i = this.ProjectData.findIndex((e) => e.type == type)
  471. for (let j = 0; j < this.hoildaylist.length; j++) {
  472. if (this.hoildaylist[j].offWorkType == 1) {
  473. daysNum = daysNum + this.hoildaylist[j].days
  474. }
  475. }
  476. this.ProjectData[i] = {
  477. name: `年假(剩余${this.holidayDays.restHolidayTime - daysNum}天,已冻结${this.freezeHolidayTime + daysNum}天)(截止${this.restHolidayDate})`,
  478. type: 1,
  479. disabled: (this.holidayDays.restHolidayTime - daysNum) <= 0
  480. }
  481. }
  482. } else if (type == 3) {
  483. // 如果是调休
  484. if (startDate && endDate) {
  485. const endDateParams = new Date(endDate).getTime()
  486. const startDateParams = new Date(startDate).getTime()
  487. let hour = endDateParams - startDateParams
  488. hour = hour / (1000 * 60 * 60)
  489. this.$nextTick(() => {
  490. this.hoildaylist[index].hour = hour
  491. const i = this.ProjectData.findIndex((e) => e.type == type)
  492. const timeNum = this.ProjectData[i].timeNum - hour
  493. let yearsTime = 0
  494. for (let j = 0; j < this.hoildaylist.length; j++) {
  495. if (this.hoildaylist[j].offWorkType == 3) {
  496. yearsTime = yearsTime + this.hoildaylist[j].hour
  497. }
  498. }
  499. this.ProjectData[i] = {
  500. name: `调休(剩余${this.holidayDays.restExchangeTime - yearsTime}小时,已冻结${this.freezeExchangeTime + yearsTime}小时)`,
  501. type: 3,
  502. disabled: this.holidayDays.restExchangeTime - yearsTime <= 0
  503. }
  504. })
  505. }
  506. } else if (type == 2) {
  507. // 如果是事假
  508. if (startDate && endDate) {
  509. this.$nextTick(() => {
  510. const endDateParams = new Date(endDate).getTime()
  511. const startDateParams = new Date(startDate).getTime()
  512. let hour = endDateParams - startDateParams
  513. hour = hour / (1000 * 60 * 60)
  514. this.hoildaylist[index].hour = hour.toFixed(2)
  515. })
  516. }
  517. } else if (type == 4 || type == 5 || type == 6 || type == 7 || type == 8) {
  518. if (startDate && endDate && startIsAllday && endIsAllday) {
  519. // 判断是不是都已经选择完成
  520. const endDateParams = new Date(endDate).getTime() // 计算一下开始时间
  521. const startDateParams = new Date(startDate).getTime() // 计算一下结束时间
  522. let days = (endDateParams - startDateParams) / (1000 * 60 * 60 * 24) // 开始和结束时间相减 单位:毫秒
  523. if (
  524. startDateParams == endIsAllday ||
  525. (startIsAllday == '上午' && endIsAllday == '上午') ||
  526. (startIsAllday == '下午' && endIsAllday == '下午')
  527. ) {
  528. // 如果选择的情况是 开始:上午 ,结束:上午 或者 开始:下午 ,结束:下午。则都加0.5天
  529. days = days + 0.5
  530. } else if (
  531. startIsAllday == '上午' &&
  532. endIsAllday == '下午'
  533. ) {
  534. // 如果选择情况是 开始:上午 结束:下午 ,则加一天,其他情况不加减
  535. days = days + 1
  536. }
  537. this.hoildaylist[index].days = days
  538. }
  539. }
  540. },
  541. getHolidayType($event, i, item) {
  542. delete this.hoildaylist[i].startDate
  543. delete this.hoildaylist[i].endDate
  544. this.hoildaylist[i].hour = 0
  545. this.hoildaylist[i].days = 0
  546. },
  547. selectCommonPhrases(e) {
  548. if (!this.confirmForm.confirmContent) this.confirmForm.confirmContent = ''
  549. this.confirmForm.confirmContent += e
  550. },
  551. changeCotalApplyTime(e) {
  552. this.totalApplyTime = e
  553. },
  554. uploadFile(param) {
  555. upload(param, true).then((res) => {
  556. this.form.fileUrlList.push(res)
  557. console.log(res)
  558. })
  559. },
  560. spliceListRow(index) {
  561. this.hoildaylist.splice(index, 1)
  562. let daysNum = 0
  563. for (let j = 0; j < this.hoildaylist.length; j++) {
  564. if (this.hoildaylist[j].offWorkType == 1) {
  565. daysNum = daysNum + this.hoildaylist[j].days
  566. }
  567. }
  568. this.ProjectData[0] = {
  569. name: `年假(剩余${this.holidayDays.restHolidayTime - daysNum}天,已冻结${daysNum}天)`,
  570. type: 1,
  571. disabled: this.holidayDays.restHolidayTime - daysNum <= 0
  572. }
  573. let yearsTime = 0
  574. for (let j = 0; j < this.hoildaylist.length; j++) {
  575. if (this.hoildaylist[j].offWorkType == 2) {
  576. yearsTime += this.hoildaylist[j].hour
  577. }
  578. }
  579. this.ProjectData[1] = {
  580. name: `调休(剩余${this.holidayDays.restExchangeTime - yearsTime}小时,已冻结${yearsTime}小时)`,
  581. type: 3,
  582. disabled: this.holidayDays.restExchangeTime - yearsTime <= 0
  583. }
  584. },
  585. parentMethod(val) {
  586. if (val.length > 0) {
  587. this.form.ccList = val.join(',')
  588. }
  589. },
  590. async confirmSubmit() {
  591. let yearsTime = 0
  592. let daysNum = 0
  593. for (let j = 0; j < this.hoildaylist.length; j++) {
  594. if (this.hoildaylist[j].offWorkType == 3) {
  595. yearsTime += this.hoildaylist[j].hour
  596. }
  597. if (this.hoildaylist[j].offWorkType == 1) {
  598. daysNum = daysNum + this.hoildaylist[j].days
  599. }
  600. }
  601. if ((this.holidayDays.restHolidayTime - daysNum) < 0) {
  602. this.$message.error('年假选择时间超时')
  603. return
  604. }
  605. if (this.holidayDays.restExchangeTime - yearsTime < 0) {
  606. this.$message.error('调休假选择时间超时')
  607. return
  608. }
  609. if (!this.form.applyReasons || this.form.applyReasons.length == 0) {
  610. this.$message.error('请填写请假事由')
  611. return
  612. }
  613. const applyOffWorkTimeString = this.hoildaylist.map((e) => {
  614. return {
  615. offWorkType: e.offWorkType,
  616. timeUnit: e.offWorkType == 3 || e.offWorkType == 2 ? '小时' : '天',
  617. useTime: e.offWorkType == 3 || e.offWorkType == 2 ? e.hour : e.days,
  618. startDay: e.startDate,
  619. endDay: e.endDate,
  620. endTime: e.offWorkType == 3 || e.offWorkType == 2 ? null : e.startIsAllday,
  621. startTime: e.offWorkType == 3 || e.offWorkType == 2 ? null : e.endIsAllday
  622. }
  623. })
  624. let fileDataIds = ''
  625. if (this.form.fileUrlList && this.form.fileUrlList.length > 0) {
  626. fileDataIds = this.form.fileUrlList.map((e) => {
  627. if (e && e.data) {
  628. return e.data
  629. }
  630. }).toString()
  631. }
  632. const confirmForm = {
  633. ccList: this.form.ccList,
  634. applyReasons: this.form.applyReasons,
  635. applyOffWorkTimeString: JSON.stringify(applyOffWorkTimeString),
  636. fileDataIds: fileDataIds,
  637. flowMainId: this.form.flowMainId
  638. }
  639. this.loading = true
  640. const { data } = await this.baseRequest1('ApplyOffWorkController', 'addApplyOffWorkAgain', { ...confirmForm })
  641. this.loading = false
  642. if (data.code == 200) {
  643. this.$message.success('流程已重新发起')
  644. this.hoildaylist = []
  645. this.selectList = []
  646. this.form = {
  647. fileUrlList: []
  648. }
  649. this.hoildaylist = [
  650. { offWorkType: 2, hour: 0, days: 0 }
  651. ]
  652. this.dialogVisible = false
  653. this.$emit('getData')
  654. }
  655. this.dialogVisibl = false
  656. },
  657. baseRequest1(prefix, opUrl, postData) {
  658. return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
  659. },
  660. async setVisible(status, row) {
  661. this.activeName = 'first'
  662. const { data: holidayDays } = await this.baseRequest1('ApplyOffWorkController', 'getHolidayManagementByApplyUserId', { userId: row.applyUser })
  663. const { data: holidayInfo } = await this.baseRequest1('ApplyOffWorkController', 'getHolidayByApplyUserId', { userId: row.applyUser })
  664. this.holidayDays = holidayDays
  665. this.freezeHolidayTime = holidayDays.freezeHolidayTime
  666. this.freezeExchangeTime = holidayDays.freezeExchangeTime
  667. this.restHolidayDate = this.$common.transDate(holidayInfo.restHolidayDate)
  668. this.ProjectData = [
  669. {
  670. name: `年假(剩余${holidayDays.restHolidayTime}天,已冻结${holidayDays.freezeHolidayTime}天)(截止${this.restHolidayDate})`,
  671. type: 1,
  672. disabled: holidayDays.restHolidayTime <= 0
  673. },
  674. {
  675. name: `调休(剩余${holidayDays.restExchangeTime}小时,已冻结${holidayDays.freezeExchangeTime}小时)`,
  676. type: 3,
  677. disabled: holidayDays.restExchangeTime <= 0
  678. },
  679. {
  680. name: `事假`,
  681. type: 2
  682. },
  683. {
  684. name: `病假`,
  685. type: 4
  686. },
  687. {
  688. name: `婚假`,
  689. type: 5
  690. },
  691. {
  692. name: `产假`,
  693. type: 6
  694. },
  695. {
  696. name: `陪产假`,
  697. type: 7
  698. },
  699. {
  700. name: `丧假`,
  701. type: 8
  702. }
  703. ]
  704. const { data } = await this.baseRequest1('ApplyOffWorkController', 'getInfoByFlowMainId', { flowMainId: row.id })
  705. this.form.flowMainId = data.flowMainId
  706. const { data: flowHistroy } = await this.baseRequest1('FlowMainController', 'getFlowHistroyByFlowMainId', { flowMainId: row.id })
  707. this.form = data
  708. this.tableData = flowHistroy
  709. this.hoildaylist = data.applyOffWorkTimeList.map((e) => {
  710. return {
  711. offWorkType: Number(e.offWorkType),
  712. endDate: this.$common.transTime(e.endDay),
  713. startDate: this.$common.transTime(e.startDay),
  714. days: Number(e.offWorkType) != 2 && Number(e.offWorkType) != 3 ? e.useTime : 0,
  715. hour: Number(e.offWorkType) == 2 || Number(e.offWorkType) == 3 ? e.useTime : 0,
  716. startIsAllday: e.startTime,
  717. dayMerange: Number(e.offWorkType) == 2 || Number(e.offWorkType) == 3 ? this.$common.transDate(e.startDay) : null,
  718. timeMerange: Number(e.offWorkType) == 2 || Number(e.offWorkType) == 3 ? [this.$common.transhh(e.startDay), this.$common.transhh(e.endDay)] : null,
  719. endIsAllday: e.endTime,
  720. startTime: this.$common.transhh(e.startDay),
  721. endTime: this.$common.transhh(e.endDay)
  722. }
  723. })
  724. //
  725. // let daysNum = 0
  726. // for (let j = 0; j < this.hoildaylist.length; j++) {
  727. // if (this.hoildaylist[j].offWorkType == 1) {
  728. // daysNum = daysNum + this.hoildaylist[j].days
  729. // }
  730. // }
  731. // this.ProjectData[0] = {
  732. // name: `年假(剩余${this.holidayDays.restHolidayTime - daysNum}天,已冻结${daysNum}天)`,
  733. // type: 1
  734. // }
  735. // let yearsTime = 0
  736. // for (let j = 0; j < this.hoildaylist.length; j++) {
  737. // if (this.hoildaylist[j].offWorkType == 2) {
  738. // yearsTime += this.hoildaylist[j].hour
  739. // }
  740. // }
  741. // this.ProjectData[1] = {
  742. // name: `调休${this.holidayDays.restExchangeTime - yearsTime}小时,已冻结${yearsTime}小时)`,
  743. // type: 3
  744. // }
  745. // this.totalApplyTime = `共计请假${daysNum}天,${yearsTime.toFixed(2)}小时`
  746. const selectList = data.flowMainCcList.map((e) => {
  747. return e.ccUser
  748. })
  749. this.selectList = selectList
  750. if (data.fileDataIds) {
  751. const { data: fileTaoTaoList } = await this.baseRequest1('FileZtController', 'findFileInfoByIds/' + data.fileDataIds, '')
  752. console.log(fileTaoTaoList.data)
  753. this.form.fileUrlList = fileTaoTaoList.data.map((e) => {
  754. return {
  755. url: this.$constant.BASE_URI + '/FileController/download/' + e.id,
  756. name: e.fileName,
  757. data: e.id,
  758. uid: new Date().getTime()
  759. }
  760. })
  761. console.log(this.form.fileUrlList)
  762. } else {
  763. this.form.fileUrlList = []
  764. }
  765. this.dialogVisible = status
  766. this.row = row
  767. },
  768. addListRow() {
  769. const _this = this
  770. _this.hoildaylist.push({ offWorkType: 2, hour: 0, days: 0 })
  771. }
  772. }
  773. }
  774. </script>
  775. <style lang="scss">
  776. .ml5 {
  777. margin-left: 5px;
  778. }
  779. .tabsdom {
  780. .el-tabs__header {
  781. text-align: center !important;
  782. width: 139px !important;
  783. text-align: center !important;
  784. display: block !important;
  785. margin: auto !important;
  786. margin-bottom: 15px !important;
  787. }
  788. .el-tabs__nav-wrap::after {
  789. display: none;
  790. }
  791. .el-upload {
  792. width: 100%;
  793. }
  794. }
  795. </style>