index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <!-- <el-scrollbar max-height="80vh">
  6. <el-aside width="280px">
  7. <div class="JKWTree-tree">
  8. <h3>计件员工加班费核查</h3>
  9. <el-tree
  10. :data="treeData"
  11. :props="defaultProps"
  12. highlight-current="true"
  13. @node-click="handleNodeClick"
  14. />
  15. </div>
  16. </el-aside>
  17. </el-scrollbar> -->
  18. <layout-sider
  19. :resize-directions="['right']"
  20. :width="180"
  21. style="margin-right: 10px;"
  22. >
  23. <div
  24. class="JKWTree-tree"
  25. style="height: 70vh;"
  26. >
  27. <h3>计件员工加班费核查</h3>
  28. <el-tree
  29. :data="treeData"
  30. highlight-current
  31. @node-click="handleNodeClick"
  32. />
  33. </div>
  34. </layout-sider>
  35. <el-container>
  36. <el-main>
  37. <div class="gva-table-box">
  38. <div class="gva-btn-list">
  39. <el-row :span="6">
  40. <el-input
  41. v-model="searchInfo"
  42. placeholder="输入员工编号或姓名"
  43. @keyup.enter="onSearch()"
  44. />
  45. </el-row>
  46. <!-- 按钮区域 -->
  47. <el-button
  48. type="primary"
  49. :icon="Search"
  50. @click="onSearch"
  51. class="bt"
  52. >搜索
  53. </el-button>
  54. <el-button
  55. type="primary"
  56. @click="onAttendance"
  57. class="bt"
  58. >考勤建立
  59. </el-button>
  60. <!-- <el-button
  61. type="primary"
  62. :icon="Refresh"
  63. >重置
  64. </el-button> -->
  65. <div style="margin-left: auto;">
  66. <el-button
  67. type="primary"
  68. :icon="Download"
  69. @click="exportExcel"
  70. class="bt"
  71. >导出到Excel(汇总)
  72. </el-button>
  73. <el-button
  74. type="primary"
  75. :icon="Download"
  76. @click="exportExcel2"
  77. class="bt"
  78. >导出到Excel(明细)
  79. </el-button>
  80. </div>
  81. </div>
  82. <!-- 上半数据展示 -->
  83. <el-table
  84. ref="tab1"
  85. style="width: 100%;height:30vh;"
  86. tooltip-effect="dark"
  87. :data="tableData1"
  88. row-key="ID"
  89. highlight-current-row
  90. border
  91. :row-style="{ height: '20px' }"
  92. :cell-style="{ padding: '0px' }"
  93. :header-row-style="{ height: '20px' }"
  94. :header-cell-style="{ padding: '0px' }"
  95. @cell-dblclick="handleDblclick1"
  96. @row-click="clickybupdate"
  97. @selection-change="handleSelectionChange"
  98. >
  99. <el-table-column
  100. type="selection"
  101. width="40"
  102. />
  103. <!-- 使用 v-for 循环渲染每一列 -->
  104. <el-table-column
  105. v-for="column in tableCols1"
  106. :key="column.prop"
  107. :prop="column.prop"
  108. :label="column.label"
  109. :width="column.width"
  110. show-overflow-tooltip="true"
  111. sortable
  112. />
  113. </el-table>
  114. <br>
  115. <el-table
  116. ref="tab2"
  117. style="width: 100%;height: 40vh;"
  118. tooltip-effect="dark"
  119. :data="tableData2"
  120. row-key="ID"
  121. highlight-current-row
  122. border
  123. :row-style="{ height: '20px' }"
  124. :cell-style="{ padding: '0px' }"
  125. :header-row-style="{ height: '20px' }"
  126. :header-cell-style="{ padding: '0px' }"
  127. @selection-change="handleSelectionChange"
  128. >
  129. <el-table-column
  130. type="selection"
  131. width="40"
  132. />
  133. <!-- 使用 v-for 循环渲染每一列 -->
  134. <el-table-column
  135. v-for="column in tableCols2"
  136. :key="column.prop"
  137. :prop="column.prop"
  138. :label="column.label"
  139. :width="column.width"
  140. :fixed="column.fixed"
  141. show-overflow-tooltip="true"
  142. sortable
  143. />
  144. </el-table>
  145. </div>
  146. </el-main>
  147. </el-container>
  148. </el-container>
  149. </div>
  150. <el-dialog v-model="AttendanceVisible" title="考勤建立" destroy-on-close width="800px" >
  151. <el-row :gutter="24">
  152. <el-col :span="7">
  153. <el-form-item label="年月份" prop="id" style="margin-top=0px; margin-bottom: 1px;">
  154. <el-input v-model="Attendancevalue['month']" style="margin-top=0px; margin-bottom: 1px;" id="年月份" @keydown="handleKeyDown($event, '法定天数', 'C类', '法定天数')" placeholder="" />
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="7" style="margin-top=0px; margin-bottom: 1px;">
  158. <el-form-item label="法定天数" prop="id" style="margin-top=0px; margin-bottom: 1px;">
  159. <el-input v-model="Attendancevalue['day']" style="margin-top=0px; margin-bottom: 1px;" @blur="getdays()" id="法定天数" @keydown="handleKeyDown($event, '法定天数', '年月份', 'A类')" placeholder="" />
  160. </el-form-item>
  161. </el-col>
  162. </el-row>
  163. <el-row :gutter="24">
  164. <el-col :span="7" style="margin-top=0px; margin-bottom: 1px;">
  165. <el-form-item label="A类(双休版)" prop="id" style="margin-top=0px; margin-bottom: 1px;">
  166. <el-input v-model="Attendancevalue['typeA']" id="A类" @keydown="handleKeyDown($event, 'A类', '法定天数', 'B类')" style="margin-top=0px; margin-bottom: 1px;" placeholder="" />
  167. </el-form-item>
  168. </el-col>
  169. </el-row>
  170. <el-row :gutter="24">
  171. <el-col :span="7" style="margin-top=0px; margin-bottom: 1px;">
  172. <el-form-item label="B类(7.5小时班)" prop="id" style="margin-top=0px; margin-bottom: 1px;">
  173. <el-input v-model="Attendancevalue['typeB']" id="B类" @keydown="handleKeyDown($event, 'B类', 'A类', 'C类')" style="margin-top=0px; margin-bottom: 1px;" placeholder="" />
  174. </el-form-item>
  175. </el-col>
  176. </el-row>
  177. <el-row :gutter="24">
  178. <el-col :span="7" style="margin-top=0px; margin-bottom: 1px;">
  179. <el-form-item label="C类(11小时班)" prop="id" style="margin-top=0px; margin-bottom: 1px;">
  180. <el-input v-model="Attendancevalue['typeC']" id="C类" @keydown="handleKeyDown($event, 'C类', 'B类', '年月份')" style="margin-top=0px; margin-bottom: 1px;" placeholder="" />
  181. </el-form-item>
  182. </el-col>
  183. </el-row>
  184. <template #footer>
  185. <div class="dialog-footer">
  186. <el-button @click="closeAttendanceDialog">取 消</el-button>
  187. <el-button type="primary" @click="AttendanceDialog">确 定</el-button>
  188. </div>
  189. </template>
  190. </el-dialog>
  191. </template>
  192. <script>
  193. export default {
  194. data() {
  195. return {
  196. dialogFormVisible: false,
  197. formDataTest: {
  198. imageUrl: '' // 添加一个字段来保存上传的图片路径
  199. },
  200. rule: {} // 初始化rule对象
  201. };
  202. },
  203. methods: {
  204. handleKeyDown(event, currentId, prevId, nextId) {
  205. const currentElement = document.getElementById(currentId);
  206. const isEmpty = currentElement.value === '';
  207. const atStart = currentElement.selectionStart === 0;
  208. const atEnd = currentElement.selectionStart === currentElement.value.length;
  209. switch (event.keyCode) {
  210. case 13: // Enter
  211. case 40: // 向下箭头
  212. if (nextId) {
  213. document.getElementById(nextId).focus();
  214. }
  215. break;
  216. case 38: // 向上箭头
  217. if (prevId) {
  218. document.getElementById(prevId).focus();
  219. }
  220. break;
  221. case 8: // 删除键
  222. if (prevId && (isEmpty || atStart)) {
  223. document.getElementById(prevId).focus();
  224. }
  225. break;
  226. case 37: // 向左箭头
  227. if (prevId && atStart) {
  228. document.getElementById(prevId).focus();
  229. }
  230. break;
  231. case 39: // 向右箭头
  232. if (nextId && atEnd) {
  233. document.getElementById(nextId).focus();
  234. }
  235. break;
  236. default:
  237. break;
  238. }
  239. },
  240. closeDialog() {
  241. // 关闭对话框的逻辑
  242. this.dialogFormVisible = false;
  243. },
  244. enterDialog() {
  245. // 确定按钮的逻辑
  246. // 在这里可以执行提交表单的逻辑
  247. },
  248. handleFileUpload(event) {
  249. // 处理文件上传逻辑
  250. const file = event.target.files[0];
  251. console.log(file)
  252. // 模拟上传并保存文件路径
  253. // 在实际应用中,您需要将文件上传到服务器并保存路径
  254. this.formDataTest.imageUrl = URL.createObjectURL(file);
  255. // 手动触发Vue的更新
  256. this.$forceUpdate();
  257. }
  258. }
  259. };
  260. </script>
  261. <script setup>
  262. // 全量引入格式化工具 请按需保留
  263. import { Download, Refresh, Search } from '@element-plus/icons-vue'
  264. import { reactive, ref } from 'vue'
  265. import { getDownData, getSide, getUpData } from '@/api/mes_api_gty/overTimePayVerification'
  266. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  267. import { useUserStore } from '@/pinia/modules/user'
  268. import {clockUpdate} from '@/api/yunyin/yunying'
  269. import {ElMessage} from "element-plus";
  270. import * as XLSX from "xlsx";
  271. const userStore = useUserStore()
  272. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  273. defineOptions({
  274. name: '06PackingDocuments',
  275. })
  276. const Attendancevalue = ref({})
  277. // 侧边栏数据请求
  278. const treeData = reactive([])
  279. const getSideData = async() => {
  280. try {
  281. const res = await getSide()
  282. if (res.code === 0) {
  283. treeData.splice(0, treeData.length, ...res.data)
  284. }
  285. } catch (e) {
  286. console.log(e)
  287. }
  288. }
  289. getSideData()
  290. // =========== 表格控制部分 ===========
  291. const tableCols1 = [
  292. { label: '员工编号', prop: 'bh', width: '105' },
  293. { label: '员工姓名', prop: '员工姓名', width: '105' },
  294. { label: '工资表类别', prop: '工资表类别', width: '120' },
  295. { label: '聘用日期', prop: '聘用日期', width: '105' },
  296. { label: '法定天数', prop: '法定天数', width: '105' },
  297. { label: '当月定额', prop: '当月定额', width: '105' },
  298. { label: '月度合计产量', prop: '月度合计产量', width: '135' },
  299. { label: '个人计件工资', prop: '个人计件工资', width: '135' },
  300. { label: '个人加班工资', prop: '个人加班工资', width: '135' },
  301. { label: '月计时时数', prop: '月计时时数', width: '120' },
  302. { label: '计时补差', prop: '计时补差', width: '120' },
  303. ]
  304. const tableCols2 = [
  305. { label: '日期', prop: 'sczl_rq', width: '105', fixed: true },
  306. { label: '工单编号', prop: 'sczl_gdbh', width: '105', fixed: true },
  307. { label: '成品名称', prop: 'Gd_cpmc', width: '150' },
  308. { label: '印件及工序', prop: 'sczl_type', width: '150' },
  309. { label: '车头产量', prop: '班组车头产量', width: '105' },
  310. { label: '机台编号', prop: 'sczl_jtbh', width: '105' },
  311. { label: '产量系数', prop: '产量系数', width: '105' },
  312. { label: '计件产量', prop: '计件产量', width: '105' },
  313. { label: '补产产量', prop: '补产产量', width: '105' },
  314. { label: '核算产量', prop: '核算产量', width: '105' },
  315. { label: '日定额', prop: '日定额', width: '91' },
  316. { label: '达标定额', prop: '达标定额', width: '105' },
  317. { label: '千件工价', prop: '千件工价', width: '105' },
  318. { label: '补产标准', prop: '补产标准', width: '105' },
  319. { label: '个人计件工资', prop: '个人计件工资', width: '135' },
  320. { label: '个人加班工资', prop: '个人加班工资', width: '135' },
  321. { label: '个人比例', prop: '个人比例', width: '105' },
  322. { label: '装版工时', prop: '装版工时', width: '105' },
  323. { label: '保养工时', prop: '保养工时', width: '105' },
  324. { label: '打样工时', prop: '打样工时', width: '105' },
  325. { label: '分摊计时', prop: '分摊计时', width: '105' },
  326. { label: '计时补差', prop: '计时补差', width: '105' },
  327. ]
  328. const tableData1 = reactive([])
  329. const tableData2 = reactive([])
  330. let originData = []
  331. const searchInfo = ref('')
  332. const params = {
  333. date: '',
  334. department: '',
  335. code: '',
  336. }
  337. const handleNodeClick = async(node, check) => {
  338. if (!node.children) {
  339. const val = {
  340. date: node.gdbh,
  341. department: node.label.slice(0, node.label.indexOf('(')),
  342. }
  343. params.date = val.date
  344. params.department = val.department
  345. const res = await getUpData(val)
  346. if (res.code === 0) {
  347. const data = res.data
  348. let totalPersonalPieceWage = 0
  349. let totalOvertimeWage = 0
  350. data.forEach(employee => {
  351. const personalPieceWage = parseFloat(employee['个人计件工资']) || 0
  352. const overtimeWage = parseFloat(employee['个人加班工资']) || 0
  353. totalPersonalPieceWage += personalPieceWage
  354. totalOvertimeWage += overtimeWage
  355. })
  356. data.push({
  357. '员工姓名': '合计',
  358. '个人计件工资': totalPersonalPieceWage.toFixed(2),
  359. '个人加班工资': totalOvertimeWage.toFixed(2),
  360. })
  361. tableData1.splice(0, tableData1.length, ...data)
  362. originData = [...tableData1]
  363. }
  364. }
  365. }
  366. const handleDblclick1 = async(row) => {
  367. // params.code = row.bh
  368. // const { date, code } = params
  369. // const res = await getDownData({ date, code })
  370. // if (res.code === 0) {
  371. // const data = res.data
  372. // let totalPersonalPieceWage = 0
  373. // let totalOvertimeWage = 0
  374. // data.forEach(employee => {
  375. // const personalPieceWage = parseFloat(employee['个人计件工资']) || 0
  376. // const overtimeWage = parseFloat(employee['个人加班工资']) || 0
  377. // totalPersonalPieceWage += personalPieceWage
  378. // totalOvertimeWage += overtimeWage
  379. // })
  380. // data.push({
  381. // 'Gd_cpmc': '合计',
  382. // '个人计件工资': totalPersonalPieceWage.toFixed(2),
  383. // '个人加班工资': totalOvertimeWage.toFixed(2),
  384. // })
  385. // tableData2.splice(0, tableData2.length, ...data)
  386. // }
  387. }
  388. const clickybupdate = async(row) => {
  389. if(row.bh == undefined) return
  390. params.code = row.bh
  391. const { date, code } = params
  392. const res = await getDownData({ date, code })
  393. if (res.code === 0) {
  394. const data = res.data
  395. let totalPersonalPieceWage = 0
  396. let totalOvertimeWage = 0
  397. data.forEach(employee => {
  398. const personalPieceWage = parseFloat(employee['个人计件工资']) || 0
  399. const overtimeWage = parseFloat(employee['个人加班工资']) || 0
  400. totalPersonalPieceWage += personalPieceWage
  401. totalOvertimeWage += overtimeWage
  402. })
  403. data.push({
  404. 'Gd_cpmc': '合计',
  405. '个人计件工资': totalPersonalPieceWage.toFixed(2),
  406. '个人加班工资': totalOvertimeWage.toFixed(2),
  407. })
  408. tableData2.splice(0, tableData2.length, ...data)
  409. }
  410. }
  411. // 搜索
  412. const onSearch = () => {
  413. if (searchInfo.value === '') {
  414. tableData1.splice(0, tableData1.length, ...originData)
  415. return
  416. }
  417. const val = originData.filter(item => {
  418. const bh = item.bh
  419. const name = item.员工姓名
  420. return (bh?.match(searchInfo.value) || name?.match(searchInfo.value))
  421. })
  422. tableData1.splice(0, tableData1.length, ...val)
  423. }
  424. // 导出excel
  425. function exportExcel() {
  426. if(tableData1.length<1){
  427. ElMessage({
  428. type: 'error',
  429. message: '请确认上方表格内是否存在内容'
  430. })
  431. }else{
  432. exportExcelFile(tableData1,tableCols1)
  433. }
  434. }
  435. function exportExcel2() {
  436. if(tableData2.length<1){
  437. ElMessage({
  438. type: 'error',
  439. message: '请确认上方表格内是否存在内容'
  440. })
  441. }else{
  442. exportExcelFile(tableData2,tableCols2)
  443. }
  444. }
  445. const exportExcelFile = (tableData, tableCols) => {
  446. const data = tableData.map(row => {
  447. const rowData = {};
  448. tableCols.forEach(column => {
  449. rowData[column.label] = row[column.prop];
  450. });
  451. return rowData;
  452. });
  453. const worksheet = XLSX.utils.json_to_sheet(data);
  454. const workbook = XLSX.utils.book_new();
  455. XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
  456. XLSX.writeFile(workbook, 'exported_table.xlsx');
  457. };
  458. //点击【考勤建立】按钮
  459. const AttendanceVisible=ref(false)
  460. const onAttendance = () => {
  461. Attendancevalue.value['day']=22
  462. const currentDate = new Date();
  463. // 获取当前年份和月份
  464. const year = currentDate.getFullYear();
  465. const month = currentDate.getMonth() + 1;
  466. // 如果月份小于 10,补零
  467. const formattedMonth = month < 10 ? '0' + month : month;
  468. console.log(year)
  469. console.log(month)
  470. Attendancevalue.value['month']=year.toString() + formattedMonth.toString();
  471. Attendancevalue.value['day']=22
  472. AttendanceVisible.value=true
  473. };
  474. //获取小时数
  475. const getdays = () => {
  476. console.log(Attendancevalue.value['day'])
  477. if(Attendancevalue.value['day']!=''){
  478. Attendancevalue.value['typeA']=Attendancevalue.value['day']*7.5
  479. Attendancevalue.value['typeB']=Attendancevalue.value['day']*8
  480. Attendancevalue.value['typeC']=Attendancevalue.value['day']*8
  481. }else{
  482. ElMessage({
  483. type: 'error',
  484. message: '请输入法定天数'
  485. })
  486. }
  487. }
  488. //考勤建立弹窗确定
  489. const AttendanceDialog = async () => {
  490. _clockUpdate()
  491. }
  492. const closeAttendanceDialog = async () => {
  493. AttendanceVisible.value=false
  494. }
  495. //设置法定天数
  496. const _clockUpdate = async ()=>{
  497. const formattedData = {
  498. month:Attendancevalue.value['month'],
  499. number:Attendancevalue.value['day'],
  500. typeA:Attendancevalue.value['typeA'],
  501. typeB:Attendancevalue.value['typeB'],
  502. typeC:Attendancevalue.value['typeC'],
  503. sys_id:sys_id
  504. };
  505. console.log(formattedData)
  506. const response = await clockUpdate(formattedData);
  507. if (response.code === 0) {
  508. ElMessage({
  509. type: 'success',
  510. message: '成功'
  511. })
  512. AttendanceVisible.value=false
  513. }else{
  514. ElMessage({
  515. type: 'error',
  516. message: '失败'
  517. })
  518. }
  519. }
  520. </script>
  521. <style scoped>
  522. .JKWTree-container {
  523. display: flex;
  524. }
  525. .JKWTree-tree {
  526. width: 300px;
  527. background-color: #fff;
  528. padding: 10px;
  529. margin-right: 20px;
  530. }
  531. .JKWTree-tree h3 {
  532. font-size: 15px;
  533. font-weight: 700;
  534. margin: 10px 0;
  535. }
  536. .JKWTree-content {
  537. flex: 1;
  538. }
  539. /* 选中某行时的背景色 */
  540. :deep(.el-table__body tr.current-row) > td {
  541. background: #ff80ff !important;
  542. }
  543. :deep(.el-table td .cell) {
  544. line-height: 30px !important;
  545. }
  546. .bt {
  547. margin-left: 2px !important;
  548. padding: 3px !important;
  549. font-size: 12px;
  550. }
  551. </style>