applyAgainHoliday.vue 25 KB

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