applyAgainAddWork.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :close-on-press-escape="false"
  5. :visible.sync="dialogVisible"
  6. title="加班申请单"
  7. top="50px"
  8. width="75%"
  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: 15px 5px 5px 15px">
  14. <el-row :gutter="15">
  15. <el-form ref="elForm" :model="formData" :rules="rules" label-width="100px">
  16. <el-col :span="24">
  17. <el-form-item label="姓名">
  18. <el-input v-model="userinfo.truename" placeholder="请输入加班申请" readonly>
  19. </el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="12">
  23. <el-form-item label="所在部门">
  24. <el-input v-model="userinfo.deptName" placeholder="请输入所在部门" readonly>
  25. </el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="12">
  29. <el-form-item label="岗位">
  30. <el-input v-model="userinfo.postName" placeholder="请输入岗位" readonly>
  31. </el-input>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="24">
  35. <el-form-item label="关联项目" prop="proId">
  36. <el-select v-model="formData.proId" filterable placeholder="关联项目名称">
  37. <el-option
  38. v-for="item in ProjectData"
  39. :key="item.value"
  40. :label="item.label"
  41. :value="item.value"
  42. >
  43. <span style="float: left">{{ item.label }}</span>
  44. <span style="float: right; color: #8492a6; font-size: 13px">{{
  45. item.custname
  46. }}</span>
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="24">
  52. <el-form-item label="加班事由" prop="applyReasons">
  53. <el-input v-model="formData.applyReasons" :autosize="{minRows: 4, maxRows: 4}"
  54. placeholder="请输入加班事由"
  55. type="textarea"
  56. ></el-input>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="24">
  60. <el-form-item label="加班位置" prop="position">
  61. <el-radio-group v-model="formData.position" size="medium">
  62. <el-radio
  63. v-for="(item, index) in positionOptions"
  64. :key="index" :disabled="item.disabled"
  65. :label="item.value"
  66. >
  67. {{ item.label }}
  68. </el-radio>
  69. </el-radio-group>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="24">
  73. <el-form-item label="加班时间">
  74. <el-row v-for="(item,index) in applyAddWorkTime">
  75. <el-col :span="10">
  76. <el-date-picker
  77. v-model="item.startDay"
  78. class="pdr10px mgb10px"
  79. placeholder="选择日期"
  80. type="date"
  81. value-format="yyyy-MM-dd"
  82. >
  83. </el-date-picker>
  84. </el-col>
  85. <el-col :span="10">
  86. <el-time-picker
  87. v-model="item.timeRange"
  88. :disabled="!item.startDay"
  89. class="el-input pdr10px mgb10px"
  90. clearable
  91. end-placeholder="结束时间" format="HH:mm"
  92. is-range
  93. range-separator="至"
  94. start-placeholder="开始时间"
  95. value-format="HH:mm"
  96. @change="getTimeRange($event,index)"
  97. />
  98. </el-col>
  99. <el-col :span="2">
  100. <div style="text-align: center">小计{{ item.useTime }}(h)</div>
  101. </el-col>
  102. <el-col :span="1" class="col-txt" style="text-align: center">
  103. &nbsp;
  104. <el-button
  105. v-if="index!=0"
  106. circle
  107. icon="el-icon-minus"
  108. @click="spliceListRow(index)"
  109. />
  110. </el-col>
  111. <el-col :span="1" class="col-txt" style="text-align: center">
  112. <el-button
  113. circle
  114. icon="el-icon-plus"
  115. type="primary"
  116. @click="addListRow()"
  117. />
  118. </el-col>
  119. </el-row>
  120. <div class="totalApplyTime">共计加班时长{{ formData.totalAddTime }}(h)</div>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="24">
  124. <el-form-item label="备注">
  125. <el-input
  126. v-model="formData.remark"
  127. :autosize="{minRows: 4, maxRows: 4}"
  128. :style="{width: '100%'}"
  129. placeholder="请输入备注"
  130. type="textarea"
  131. ></el-input>
  132. </el-form-item>
  133. </el-col>
  134. </el-form>
  135. </el-row>
  136. </el-card>
  137. </el-tab-pane>
  138. <el-tab-pane label="流程图 " name="second">
  139. <add-work-canvas ref="addWorkCanvas"/>
  140. </el-tab-pane>
  141. </el-tabs>
  142. </div>
  143. <div slot="footer">
  144. <el-button @click="dialogVisible=false">取消</el-button>
  145. <el-button :loading="loading" type="primary" @click="handelConfirm">确定</el-button>
  146. </div>
  147. </el-dialog>
  148. </template>
  149. <script>
  150. import { upload } from '@/static/utils/channel'
  151. import Base from '@/views/base/base'
  152. import BaseData from '@/views/base/baseData'
  153. import UserSelect from '@/views/components/UserSelect'
  154. const applyAddWorkTime = { useTime: 0 }
  155. export default {
  156. name: 'ApplyPay',
  157. mixins: [Base, BaseData],
  158. components: {
  159. upload, UserSelect
  160. },
  161. data() {
  162. return {
  163. row: {},
  164. loading: false,
  165. dc_key: ['ORDER_STATUS', 'PAY_TYPE', 'BUDGET_FY'],
  166. ProjectData: [],
  167. dialogVisible: false,
  168. applyAddWorkTime: [{ ...applyAddWorkTime }],
  169. formData: {
  170. proId: '',
  171. totalAddTime: 0,
  172. applyReasons: '',
  173. position: '',
  174. applyAddWorkTime: [
  175. {
  176. useTime: 0
  177. }
  178. ]
  179. },
  180. userinfo: {},
  181. activeName: 'first',
  182. rules: {
  183. proId: [{
  184. required: true,
  185. message: '请选择关联项目',
  186. trigger: 'change'
  187. }],
  188. applyReasons: [{
  189. required: true,
  190. message: '请输入加班事由',
  191. trigger: 'change'
  192. }],
  193. position: [{
  194. required: true,
  195. message: '加班位置不能为空',
  196. trigger: 'change'
  197. }]
  198. },
  199. positionOptions: [
  200. {
  201. 'label': '公司',
  202. 'value': 1
  203. },
  204. {
  205. 'label': '客户处',
  206. 'value': 2
  207. }, {
  208. 'label': '居家',
  209. 'value': 3
  210. }]
  211. }
  212. },
  213. computed: {},
  214. watch: {
  215. 'applyAddWorkTime': {
  216. deep: true,
  217. handler(newValue, oldValue) {
  218. let totalAddTime = 0
  219. for (let i = 0; i < this.applyAddWorkTime.length; i++) {
  220. if (this.applyAddWorkTime[i].useTime === 0 || this.applyAddWorkTime[i].useTime) {
  221. totalAddTime = totalAddTime + Number(this.applyAddWorkTime[i].useTime)
  222. }
  223. }
  224. console.log(totalAddTime)
  225. this.changeAddWorkTime(totalAddTime.toFixed(1))
  226. }
  227. }
  228. },
  229. created() {
  230. },
  231. mounted() {
  232. this.initDict(this.dc_key).then((res) => {
  233. })
  234. this.initProject({ /* signstatus: '2,3'*/ })
  235. },
  236. methods: {
  237. handleClick(tab, event) {
  238. this.canVasStatus = false
  239. if (this.activeName == 'second') {
  240. this.canVasStatus = true
  241. this.$nextTick(() => {
  242. this.$refs.addWorkCanvas.createNodeCanvas(this.row)
  243. })
  244. }
  245. },
  246. changeAddWorkTime(totalAddTime) {
  247. this.formData.totalAddTime = totalAddTime
  248. },
  249. getHour(s1, s2) {
  250. var reDate = /\d{4}-\d{1,2}-\d{1,2} /
  251. s1 = new Date((reDate.test(s1) ? s1 : '2018-1-1 ' + s1).replace(/-/g, '/'))
  252. s2 = new Date((reDate.test(s2) ? s2 : '2018-1-1 ' + s2).replace(/-/g, '/'))
  253. var ms = s2.getTime() - s1.getTime()
  254. if (ms < 0) return 0
  255. console.log(ms)
  256. return (ms / 1000 / 60 / 60).toFixed(1) //小时
  257. },
  258. getTimeRange(event, i) {
  259. this.$nextTick(() => {
  260. this.applyAddWorkTime[i].startTime = this.applyAddWorkTime[i].startDay + ' ' + event[0] + ':00'
  261. this.applyAddWorkTime[i].endTime = this.applyAddWorkTime[i].startDay + ' ' + event[1] + ':00'
  262. let timeRang = this.getHour(event[0], event[1])
  263. this.applyAddWorkTime[i].useTime = timeRang
  264. })
  265. },
  266. async getUserInfo() {
  267. let { data: userinfo } = await this.baseRequest1('ApplyAddWorkController', 'getUserInfoByUserId', { userId: '' })
  268. this.userinfo = userinfo
  269. console.log(this.userinfo)
  270. },
  271. baseRequest1(prefix, opUrl, postData) {
  272. return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
  273. },
  274. addListRow() {
  275. this.applyAddWorkTime.push({ ...applyAddWorkTime })
  276. },
  277. spliceListRow(index) {
  278. this.applyAddWorkTime.splice(index, 1)
  279. },
  280. async setVisible(status, row) {
  281. this.row = row
  282. this.activeName = 'first'
  283. this.getUserInfo(row.applyUser)
  284. let { data } = await this.baseRequest1('ApplyAddWorkController', 'getInfoByFlowMainId', { flowMainId: row.id })
  285. this.formData = data
  286. this.formData.flowMainId = data.flowMainId
  287. this.applyAddWorkTime = data.applyAddWorkTimeList.map((e) => {
  288. return {
  289. useTime: e.useTime,
  290. startDay: this.$common.transDate(e.startDay),
  291. timeRange: [this.$common.transMinute(e.startTime), this.$common.transMinute(e.endTime)],
  292. startTime: this.$common.transMinute(e.startTime),
  293. endTime: this.$common.transMinute(e.endTime)
  294. }
  295. })
  296. console.log(this.applyAddWorkTime)
  297. // flowMainPushId
  298. this.dialogVisible = status
  299. },
  300. onOpen() {
  301. },
  302. onClose() {
  303. this.$refs['elForm'].resetFields()
  304. },
  305. close() {
  306. this.$emit('update:visible', false)
  307. },
  308. async handelConfirm() {
  309. this.$refs['elForm'].validate(async valid => {
  310. if (!valid) return
  311. let formData = {
  312. ...this.formData,
  313. applyAddWorkTimeString: JSON.stringify(this.applyAddWorkTime)
  314. }
  315. delete formData.applyAddWorkTime
  316. delete formData.applyAddWorkTimeList
  317. console.error('formDataformDataformDataformDataformData', formData)
  318. this.loading = true
  319. let { data } = await this.baseRequest1('ApplyAddWorkController', 'addApplyAddWorkAgain', { ...formData })
  320. this.loading = false
  321. if (data.code == 200) {
  322. this.$message.success('加班申请发起成功')
  323. this.dialogVisible = false
  324. this.$emit('getData')
  325. }
  326. this.close()
  327. })
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss">
  333. .cclist {
  334. .col-input {
  335. padding: 0;
  336. }
  337. }
  338. .pdr10px {
  339. padding-right: 10px;
  340. }
  341. .mgb10px {
  342. margin-bottom: 10px;
  343. }
  344. .mb25 {
  345. margin-bottom: 25px;
  346. }
  347. .pdtopbottom16 {
  348. padding: 0px 16px;
  349. }
  350. .pdtop16px {
  351. padding-top: 16px;
  352. }
  353. .totalApplyTime {
  354. font-size: 16px;
  355. font-family: 微软雅黑;
  356. font-weight: 400;
  357. color: #1890FF;
  358. text-align: right;
  359. margin: 15px 0 15px 0;
  360. width: 100%;
  361. }
  362. .cost_form {
  363. .col-input {
  364. font-weight: 400;
  365. }
  366. .el-form-item__label .moneydetails {
  367. text-align: right;
  368. font-size: 16px;
  369. font-family: 微软雅黑;
  370. padding-right: 10px;
  371. line-height: 40px;
  372. word-break: keep-all;
  373. white-space: nowrap;
  374. color: #606266;
  375. text-rendering: optimizeLegibility;
  376. font-weight: 400;
  377. }
  378. .moneydetails {
  379. text-align: right;
  380. font-size: 16px;
  381. font-family: 微软雅黑;
  382. padding-right: 10px;
  383. word-break: keep-all;
  384. white-space: nowrap;
  385. color: #606266;
  386. text-rendering: optimizeLegibility;
  387. font-weight: 400;
  388. }
  389. .moneydetails:before {
  390. content: "*";
  391. color: #ff4949;
  392. }
  393. }
  394. .txtc {
  395. text-align: center
  396. }
  397. .ml5 {
  398. margin-left: 5px;
  399. }
  400. .eltype {
  401. margin-bottom: 15px;
  402. }
  403. .tabsdom {
  404. .el-input {
  405. width: 100%;
  406. }
  407. .el-tabs__header {
  408. text-align: center !important;
  409. width: 139px !important;
  410. text-align: center !important;
  411. display: block !important;
  412. margin: auto !important;
  413. margin-bottom: 15px !important;
  414. }
  415. .el-tabs__nav-wrap::after {
  416. display: none;
  417. }
  418. .el-upload {
  419. width: 100%;
  420. }
  421. }
  422. .feeMoneyTotal {
  423. width: 100%;
  424. height: 14px;
  425. font-size: 14px;
  426. font-weight: 400;
  427. color: #1890FF;
  428. margin-top: 31px;
  429. margin-bottom: 13px;
  430. }
  431. </style>