edit.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :close-on-press-escape="false"
  5. :visible.sync="dialogVisible"
  6. title="修改当日考勤"
  7. >
  8. <el-form ref="elForm" :model="formData" label-width="150px" size="medium">
  9. <el-form-item label="违规类别" prop="field101">
  10. <el-checkbox-group v-model="formData.weiGuiType" size="medium">
  11. <el-checkbox
  12. v-for="(item, index) in field101Options"
  13. :key="index"
  14. :label="item.value"
  15. >
  16. {{ item.label }}
  17. </el-checkbox>
  18. </el-checkbox-group>
  19. </el-form-item>
  20. <el-row>
  21. <el-form-item label="违规时长说明" prop="field103">
  22. <el-input v-model="formData.weiguiRemarke" :autosize="{minRows: 4, maxRows: 4}"
  23. :style="{width: '100%'}"
  24. placeholder="请输入违规时长说明" type="textarea"
  25. ></el-input>
  26. </el-form-item>
  27. </el-row>
  28. <el-form-item label="出勤类别" prop="happen_type1">
  29. <el-checkbox-group v-model="formData.chuqingType" size="medium">
  30. <el-checkbox
  31. v-for="(item, index) in field104Options"
  32. :key="index"
  33. :label="item.value"
  34. >
  35. {{ item.label }}
  36. </el-checkbox>
  37. </el-checkbox-group>
  38. </el-form-item>
  39. <el-form-item label="出勤时长说明" prop="field105">
  40. <el-input v-model="formData.chuqingRemarke" :autosize="{minRows: 4, maxRows: 4}"
  41. :style="{width: '100%'}"
  42. placeholder="请输入出勤时长说明" type="textarea"
  43. ></el-input>
  44. </el-form-item>
  45. </el-form>
  46. <el-row :gutter="15">
  47. <el-col :col="24">
  48. <el-table :data="holiadyData" style="width: 100%" border>
  49. <el-table-column
  50. prop="happenTypeString"
  51. label="类型"
  52. width="100"
  53. >
  54. </el-table-column>
  55. <el-table-column
  56. prop="name"
  57. label="时间范围"
  58. >
  59. <template slot-scope="scope">
  60. {{ $common.transTime(scope.row.doStartTime) }}至{{ $common.transTime(scope.row.doEndTime) }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="name"
  65. label="操作时间"
  66. >
  67. <template slot-scope="scope">
  68. {{ $common.transTime(scope.row.createdAt) }}
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </el-col>
  73. </el-row>
  74. <div slot="footer">
  75. <el-button @click="dialogVisible=false">取消</el-button>
  76. <el-button type="primary" :loading="buttonStatus" :disabled="buttonStatus" @click="handelConfirm">确定
  77. </el-button>
  78. </div>
  79. </el-dialog>
  80. </template>
  81. <script>
  82. const formData = {
  83. weiGuiType: [],
  84. chuqingType: []
  85. }
  86. export default {
  87. inheritAttrs: false,
  88. components: {},
  89. props: [],
  90. data() {
  91. return {
  92. buttonStatus: false,
  93. holiadyData: [],
  94. logUserId: null,
  95. formData: { ...formData },
  96. dialogVisible: false,
  97. field101Options: [
  98. {
  99. label: '迟到',
  100. value: 10
  101. },
  102. {
  103. label: '早退',
  104. value: 11
  105. },
  106. {
  107. label: '旷工',
  108. value: 12
  109. }
  110. ],
  111. field104Options: [
  112. {
  113. label: '外出',
  114. value: 13
  115. },
  116. {
  117. label: '居家',
  118. value: 14
  119. },
  120. {
  121. label: '出差(离开本市)',
  122. value: 15
  123. }
  124. ]
  125. }
  126. },
  127. computed: {},
  128. watch: {},
  129. created() {
  130. },
  131. mounted() {
  132. },
  133. methods: {
  134. setVisible(val, logUserId, row) {
  135. try {
  136. this.buttonStatus = false
  137. this.formData = { ...formData }
  138. this.dialogVisible = true
  139. this.formData.year_month = val.year_month
  140. this.logUserId = logUserId
  141. this.holiadyData = val.workAttendanceLogList
  142. if (val.workAttendanceLogList) {
  143. let workAttendanceLogList = val.workAttendanceLogList
  144. // console.log(workAttendanceLogList.length)
  145. let weiguiId = null // : workAttendanceLogList[0].id ? workAttendanceLogList[0].id : null,
  146. let chuqingId = null // : workAttendanceLogList[1].id ? workAttendanceLogList[1].id : null,
  147. let weiGuiType = [] // : workAttendanceLogList[0].happenType ? workAttendanceLogList[0].happenType : null,
  148. let chuqingType = [] // : workAttendanceLogList[1].happenType ? workAttendanceLogList[1].happenType : null,
  149. let weiguiRemarke = null // : workAttendanceLogList[0].remark ? workAttendanceLogList[0].remark : null,
  150. let chuqingRemarke = null // : workAttendanceLogList[1].remark ? workAttendanceLogList[1].remark : null,
  151. for (let i = 0; i < workAttendanceLogList.length; i++) {
  152. let workAttendanceLog = workAttendanceLogList[i]
  153. console.log(workAttendanceLog.happenType)
  154. let happenType = workAttendanceLogList[i].happenType
  155. if (happenType == 11 || happenType == 10 || happenType == 12) {
  156. weiGuiType.push(workAttendanceLogList[i].happenType)
  157. weiguiRemarke = workAttendanceLogList[i].remark
  158. } else if (happenType == 13 || happenType == 14 || happenType == 15) {
  159. chuqingType.push(workAttendanceLogList[i].happenType)
  160. chuqingRemarke = workAttendanceLogList[i].remark
  161. }
  162. for (let j = 0; j < this.field101Options.length; j++) {
  163. let oneInfo = this.field101Options[j]
  164. if (oneInfo.value == workAttendanceLog.happenType) {
  165. weiguiId = workAttendanceLogList[i].id
  166. }
  167. }
  168. for (let j = 0; j < this.field104Options.length; j++) {
  169. let twoInfo = this.field104Options[j]
  170. if (twoInfo.value == workAttendanceLog.happenType) {
  171. chuqingId = workAttendanceLogList[i].id
  172. }
  173. }
  174. }
  175. console.log('chuqingTypechuqingTypechuqingType', chuqingType)
  176. console.log('weiGuiTypeweiGuiTypeweiGuiType', weiGuiType)
  177. this.formData = {
  178. year_month: val.year_month,
  179. weiguiId: weiguiId,
  180. chuqingId: chuqingId,
  181. weiGuiType: weiGuiType,
  182. chuqingType: chuqingType,
  183. weiguiRemarke: weiguiRemarke,
  184. chuqingRemarke: chuqingRemarke
  185. // weiguiId: workAttendanceLogList[0].id ? workAttendanceLogList[0].id : null,
  186. // chuqingId: workAttendanceLogList[1].id ? workAttendanceLogList[1].id : null,
  187. // weiGuiType: workAttendanceLogList[0].happenType ? workAttendanceLogList[0].happenType : null,
  188. // chuqingType: workAttendanceLogList[1].happenType ? workAttendanceLogList[1].happenType : null,
  189. // weiguiRemarke: workAttendanceLogList[0].remark ? workAttendanceLogList[0].remark : null,
  190. // chuqingRemarke: workAttendanceLogList[1].remark ? workAttendanceLogList[1].remark : null,
  191. }
  192. console.log(this.formData)
  193. }
  194. this.$forceUpdate()
  195. } catch (e) {
  196. console.log(e)
  197. }
  198. },
  199. baseRequest(opUrl, postData) {
  200. return this.$channel.globleRequest('WorkAttendanceLogController', opUrl, postData, 'project')
  201. },
  202. async handelConfirm() {
  203. try {
  204. let array = []
  205. for (let i = 0; i < this.formData.chuqingType.length; i++) {
  206. if (this.formData.chuqingType) {
  207. array.push({
  208. doDay: this.formData.year_month + ' 00:00:00',
  209. happenType: this.formData.chuqingType[i],
  210. remark: this.formData.chuqingRemarke,
  211. id: !this.formData.chuqingId ? null : this.formData.chuqingId,
  212. userId: this.logUserId
  213. })
  214. }
  215. }
  216. for (let i = 0; i < this.formData.weiGuiType.length; i++) {
  217. if (this.formData.weiGuiType) {
  218. array.push({
  219. doDay: this.formData.year_month + ' 00:00:00',
  220. happenType: this.formData.weiGuiType[i],
  221. remark: this.formData.chuqingRemarke,
  222. id: !this.formData.weiguiId ? null : this.formData.weiguiId,
  223. userId: this.logUserId
  224. })
  225. }
  226. }
  227. let obj = {
  228. userId: this.logUserId,
  229. doDay: this.formData.year_month + ' 00:00:00',
  230. records: JSON.stringify(array)
  231. }
  232. this.buttonStatus = true
  233. let { data } = await this.baseRequest('addOrEditList', obj)
  234. this.buttonStatus = false
  235. if (data.code == 200) {
  236. this.$message.success('操作成功')
  237. this.dialogVisible = false
  238. this.$emit('getData')
  239. }
  240. } catch (e) {
  241. console.log(e)
  242. }
  243. }
  244. }
  245. }
  246. </script>
  247. <style>
  248. </style>