related.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <div>
  3. <!-- 左侧树形结构 -->
  4. <el-container>
  5. <!-- <el-aside width="250px">
  6. <div class="JKWTree-tree">
  7. <h3>关联工资核算</h3>
  8. <el-tree :data="treeData" :props="defaultProps" highlight-current="true"
  9. @node-click="handleNodeClick"></el-tree>
  10. </div>
  11. </el-aside> -->
  12. <layout-sider
  13. :resize-directions="['right']"
  14. :width="220"
  15. style="margin-right: 10px;"
  16. >
  17. <div
  18. class="JKWTree-tree"
  19. style="height: 70vh;"
  20. >
  21. <h3>关联工资核算</h3>
  22. <el-tree
  23. :data="treeData"
  24. highlight-current
  25. @node-click="handleNodeClick"
  26. />
  27. </div>
  28. </layout-sider>
  29. <el-container>
  30. <el-main>
  31. <!-- 按钮区域 -->
  32. <div class="gva-table-box">
  33. <div class="gva-btn-list">
  34. <el-row :span="6">
  35. <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" />
  36. </el-row>
  37. <el-button type="primary" :icon="Search" @click="onSearch">搜索</el-button>
  38. <el-button type="primary" @click="onrelevancy">关联工资设置</el-button>
  39. <el-button type="primary" :icon="Search" @click="onposition">定位</el-button>
  40. <el-button type="primary" :icon="Search">查改</el-button>
  41. <div style="margin-left: auto;">
  42. <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
  43. </div>
  44. </div>
  45. <!-- 数据展示 -->
  46. <el-table ref="multipleTable" style="width: 100%;height: 40vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
  47. highlight-current-row="true" border @selection-change="handleSelectionChange" :show-overflow-tooltip="true"
  48. :row-style="{ height: '20px' }"
  49. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  50. :header-cell-style="{ padding: '0px' }" @row-click="ontable" @row-dblclick="doubleClick">
  51. <!-- <el-table-column type="selection" width="55" /> -->
  52. <el-table-column align="left" sortable label="员工编号" prop="员工编号" width="120"/>
  53. <el-table-column align="left" sortable label="员工姓名" prop="员工姓名" width="120"/>
  54. <el-table-column align="left" sortable label="职称职务" prop="职称职务" width="160"/>
  55. <el-table-column align="left" sortable label="所在部门" prop="所在部门" width="160"/>
  56. <el-table-column align="left" sortable label="日期" prop="日期" width="160"/>
  57. <el-table-column align="left" sortable label="关联系数" prop="关联系数" width="120"/>
  58. <el-table-column align="left" sortable label="关联人数" prop="关联人数" width="120"/>
  59. <el-table-column align="left" sortable label="关联计件工资" prop="个人计件工资" width="120"/>
  60. <el-table-column align="left" sortable label="关联加班工资" prop="个人加班工资" width="160"/>
  61. <el-table-column align="left" sortable label="关联额定补差" prop="计时" width="160"/>
  62. <el-table-column align="left" sortable label="关联计时工资" prop="计时工资" width="160"/>
  63. <el-table-column align="left" sortable label="关联工资合计" prop="日工资合计" width="120"/>
  64. </el-table>
  65. <!-- 分页 -->
  66. <!-- <div class="gva-pagination">
  67. <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
  68. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  69. @size-change="handleSizeChange" />
  70. </div> -->
  71. </div>
  72. <div class="gva-table-box">
  73. <!-- 数据展示 -->
  74. <el-table ref="multipleTable" style="width: 100%" height="300px" tooltip-effect="dark" :data="tableData2" row-key="ID"
  75. highlight-current-row="true" border @selection-change="handleSelectionChange" :show-overflow-tooltip="true" @row-dblclick="doubleClick">
  76. <el-table-column type="selection" width="55" />
  77. <el-table-column align="left" sortable label="日期" prop="日期" width="120"/>
  78. <el-table-column align="left" sortable label="员工编号" prop="员工编号" width="120"/>
  79. <el-table-column align="left" sortable label="员工姓名" prop="员工姓名" width="120"/>
  80. <el-table-column align="left" sortable label="职称职务" prop="职称职务" width="120"/>
  81. <el-table-column align="left" sortable label="所在部门" prop="所在部门" width="160"/>
  82. <el-table-column align="left" sortable label="被关联员工" prop="被关联员工" width="160"/>
  83. <el-table-column align="left" sortable label="被关联姓名" prop="被关联姓名" width="120"/>
  84. <el-table-column align="left" sortable label="权重" prop="权重" width="120"/>
  85. <el-table-column align="left" sortable label="计件工资" prop="个人计件工资" width="120"/>
  86. <el-table-column align="left" sortable label="加班工资" prop="个人加班工资" width="120"/>
  87. <el-table-column align="left" sortable label="定额补差" prop="定额补差" width="120"/>
  88. <el-table-column align="left" sortable label="计时工资" prop="计时工资" width="160"/>
  89. </el-table>
  90. <!-- 分页 -->
  91. <!-- <div class="gva-pagination">
  92. <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
  93. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  94. @size-change="handleSizeChange" />
  95. </div> -->
  96. </div>
  97. <!-- 弹出框 -->
  98. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '添加' : '修改'"
  99. destroy-on-close width="1200px" style="height: 700px;" >
  100. <!-- <el-scrollbar height="500px"> -->
  101. <el-form :model="formData" label-position="left" ref="elFormRef" :rules="rule">
  102. <el-row :gutter="20">
  103. <el-col :span="6">
  104. <el-form-item label="关联人员工号" prop="name">
  105. <el-row :gutter="20">
  106. <el-col :span="12">
  107. <el-input v-model="formData.关联人员工号" @keyup.enter.native="getygsubmit" :clearable="true" placeholder="ZT01733" />
  108. </el-col>
  109. <el-col :span="12">
  110. <el-input v-model="formData.关联人员姓名" :clearable="true" placeholder="ZT01733" />
  111. </el-col>
  112. </el-row>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="6">
  116. <el-form-item label="日期" prop="name">
  117. <el-row :gutter="3">
  118. <el-col :span="10">
  119. <el-input v-model="formData.日期" :clearable="true" placeholder="ZT01733" />
  120. </el-col>
  121. </el-row>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="4">
  125. <el-form-item label="关联系数" prop="name">
  126. <el-row :gutter="3">
  127. <el-col :span="12">
  128. <el-input v-model="formData.日关联系数" :clearable="true" placeholder="ZT01733" />
  129. </el-col>
  130. </el-row>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="3">
  134. <el-col :span="3">
  135. <el-button type="primary" @click="onflushed">刷新</el-button>
  136. </el-col>
  137. </el-col>
  138. <el-col :span="4">
  139. <el-form-item label="关联人数" prop="name">
  140. <el-row :gutter="20">
  141. <el-col :span="12">
  142. <el-input v-model="formData.日关联人数" :clearable="true" placeholder="ZT01733" />
  143. </el-col>
  144. </el-row>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. </el-form>
  149. <el-table
  150. tooltip-effect="dark"
  151. :data="relevancyselectData"
  152. row-key="ID"
  153. highlight-current-row="true"
  154. border
  155. style="width:100%"
  156. height="400px"
  157. @row-dblclick="relevancySelectClick"
  158. :selectable="row => rowSelectable(row)"
  159. @selection-change="relevancySelectionChange"
  160. >
  161. <el-table-column type="selection" width="55" align="center" label=""></el-table-column>
  162. <el-table-column
  163. prop="日期"
  164. label="日期"
  165. width="150"
  166. />
  167. <el-table-column
  168. prop="班组员工编号"
  169. label="班组员工编号"
  170. width="400"
  171. />
  172. <el-table-column
  173. prop="组员权重"
  174. label="组员权重"
  175. width="150"
  176. />
  177. <el-table-column
  178. prop="计件工资基数"
  179. label="计件工资基数"
  180. width="400"
  181. />
  182. <el-table-column
  183. prop="加班工资基数"
  184. label="加班工资基数"
  185. width="150"
  186. />
  187. <el-table-column
  188. prop="UniqID"
  189. label="UniqID"
  190. width="150"
  191. />
  192. </el-table>
  193. <!-- </el-scrollbar> -->
  194. <template #footer>
  195. <div class="dialog-footer">
  196. <el-button @click="batchadd">批量附加组员</el-button>
  197. <el-button @click="batchdel">批量删除组员</el-button>
  198. <el-button @click="uprelevancy">更新关联系数</el-button>
  199. <el-button @click="oncopy">组员复制</el-button>
  200. <el-button @click="closeDialog">取 消</el-button>
  201. <el-button type="primary" @click="enterDialog">确 定</el-button>
  202. </div>
  203. </template>
  204. </el-dialog>
  205. <el-dialog v-model="positioningVisibleshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
  206. <el-row :gutter="20">
  207. <el-col :span="6">
  208. <el-form-item label="员工编号" prop="name">
  209. <el-row :gutter="20">
  210. <el-col :span="12">
  211. <el-input v-model="formData.员工编号" :clearable="true" placeholder="ZT01733" />
  212. </el-col>
  213. </el-row>
  214. </el-form-item>
  215. </el-col>
  216. <el-col :span="6">
  217. <el-form-item label="姓名" prop="name">
  218. <el-row :gutter="20">
  219. <el-col :span="12">
  220. <el-input v-model="formData.姓名" :clearable="true" placeholder="ZT01733" />
  221. </el-col>
  222. </el-row>
  223. </el-form-item>
  224. </el-col>
  225. </el-row>
  226. <el-row :gutter="20">
  227. <el-col :span="6">
  228. <el-form-item label="部门名称" prop="name">
  229. <el-row :gutter="20">
  230. <el-col :span="12">
  231. <el-input v-model="formData.部门名称" :clearable="true" placeholder="ZT01733" />
  232. </el-col>
  233. </el-row>
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="6">
  237. <el-form-item label="职务" prop="name">
  238. <el-row :gutter="20">
  239. <el-col :span="12">
  240. <el-input v-model="formData.职务" :clearable="true" placeholder="ZT01733" />
  241. </el-col>
  242. </el-row>
  243. </el-form-item>
  244. </el-col>
  245. </el-row>
  246. <el-row :gutter="20">
  247. <el-col :span="6">
  248. <el-form-item label="入职日期" prop="name">
  249. <el-row :gutter="20">
  250. <el-col :span="12">
  251. <el-input v-model="formData.入职日期" :clearable="true" placeholder="ZT01733" />
  252. </el-col>
  253. </el-row>
  254. </el-form-item>
  255. </el-col>
  256. </el-row>
  257. <el-row :gutter="20">
  258. <el-col :span="6">
  259. <el-form-item label="关联权重" prop="name">
  260. <el-row :gutter="20">
  261. <el-col :span="12">
  262. <el-input v-model="formData.关联权重" :clearable="true" placeholder="ZT01733" />
  263. </el-col>
  264. </el-row>
  265. </el-form-item>
  266. </el-col>
  267. </el-row>
  268. </el-dialog>
  269. <el-dialog v-model="batchaddshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
  270. <el-col :span="12">
  271. <el-form-item label="定位" prop="name">
  272. <el-row :gutter="3">
  273. <el-col :span="12">
  274. <el-input v-model="formData.定位" :clearable="true" placeholder="ZT01733" />
  275. </el-col>
  276. <el-col :span="3">
  277. <el-button type="primary" @click="oninvestigate">查找</el-button>
  278. </el-col>
  279. </el-row>
  280. </el-form-item>
  281. </el-col>
  282. <el-table
  283. tooltip-effect="dark"
  284. :data="batchaddselectData"
  285. row-key="ID"
  286. highlight-current-row="true"
  287. border
  288. style="width:100%"
  289. height="400px"
  290. @row-dblclick="batchaddSelectClick"
  291. :selectable="row => rowSelectable(row)"
  292. @selection-change="batchaddSelectionChange"
  293. >
  294. <el-table-column type="selection" width="55" align="center" label=""></el-table-column>
  295. <el-table-column
  296. prop="日期"
  297. label="日期"
  298. width="150"
  299. />
  300. <el-table-column
  301. prop="所在部门"
  302. label="所在部门"
  303. width="400"
  304. />
  305. <el-table-column
  306. prop="职称职务"
  307. label="职称职务"
  308. width="150"
  309. />
  310. <el-table-column
  311. prop="班组员工编号"
  312. label="班组员工编号"
  313. width="400"
  314. />
  315. <el-table-column
  316. prop="班组"
  317. label="班组"
  318. width="150"
  319. />
  320. <el-table-column
  321. prop="计件工资基数"
  322. label="计件工资基数"
  323. width="150"
  324. />
  325. <el-table-column
  326. prop="加班工资基数"
  327. label="加班工资基数"
  328. width="150"
  329. />
  330. <el-table-column
  331. prop="UniqID"
  332. label="UniqID"
  333. width="150"
  334. />
  335. </el-table>
  336. <template #footer>
  337. <div class="dialog-footer">
  338. <el-button @click="batchup">提 交</el-button>
  339. </div>
  340. </template>
  341. </el-dialog>
  342. <el-dialog v-model="copyshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
  343. <el-col :span="10">
  344. <el-form-item label="日期" prop="name">
  345. <el-row :gutter="3">
  346. <el-col :span="10">
  347. <el-input v-model="formData.old_time" @keyup.enter.native="getcopylist" :clearable="true" placeholder="ZT01733" />
  348. </el-col>
  349. <el-col :span="13">
  350. <el-form-item label="复制成" prop="name">
  351. <el-row :gutter="3">
  352. <el-col :span="20">
  353. <el-input v-model="formData.new_time" :clearable="true" placeholder="ZT01733" />
  354. </el-col>
  355. <el-col :span="3">
  356. <el-button type="primary" @click="oncopyup">执行</el-button>
  357. </el-col>
  358. </el-row>
  359. </el-form-item>
  360. </el-col>
  361. </el-row>
  362. </el-form-item>
  363. </el-col>
  364. <el-table
  365. tooltip-effect="dark"
  366. :data="copyselectData"
  367. row-key="ID"
  368. highlight-current-row="true"
  369. border
  370. style="width:100%"
  371. height="400px"
  372. @row-dblclick="copySelectClick"
  373. :selectable="row => rowSelectable(row)"
  374. @selection-change="copySelectionChange"
  375. >
  376. <el-table-column type="selection" width="55" align="center" label=""></el-table-column>
  377. <el-table-column
  378. prop="员工编号"
  379. label="员工编号"
  380. width="150"
  381. />
  382. <el-table-column
  383. prop="员工姓名"
  384. label="员工姓名"
  385. width="400"
  386. />
  387. <el-table-column
  388. prop="所在部门"
  389. label="所在部门"
  390. width="150"
  391. />
  392. <el-table-column
  393. prop="职称职务"
  394. label="职称职务"
  395. width="150"
  396. />
  397. <el-table-column
  398. prop="UniqID"
  399. label="UniqID"
  400. width="150"
  401. />
  402. </el-table>
  403. </el-dialog>
  404. </el-main>
  405. </el-container>
  406. </el-container>
  407. </div>
  408. </template>
  409. <script setup>
  410. import {
  411. getList,
  412. getTab,
  413. dailygetTab,
  414. dailygetList,
  415. dailygetAllList,
  416. dailygetDetail,
  417. dailysearch,
  418. relatedTab,
  419. relatedList,
  420. relatedsearch,
  421. relatedAllList,
  422. setting,
  423. getYg,
  424. weightDetail,
  425. updateNum,
  426. batchAddLst,
  427. copyLst,
  428. batchAdd,
  429. batchDel,
  430. copy,
  431. batchAddSearch
  432. } from '@/api/jixiaoguanli/jitairibaobiao'
  433. // 全量引入格式化工具 请按需保留
  434. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  435. import { ElMessage, ElMessageBox } from 'element-plus'
  436. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  437. import { ref, reactive, onMounted, onBeforeMount } from 'vue'
  438. import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'
  439. import { Value } from 'sass'
  440. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  441. defineOptions({
  442. name: '06-packingDocuments'
  443. })
  444. // 侧边栏数据请求
  445. const treeData = reactive([]);
  446. const getTabdata = async () => {
  447. //接口调用函数
  448. const response = await relatedTab();
  449. console.log(response)
  450. const transformedData = response.data.map(item => ({
  451. label: `${item.label}`,
  452. children: item.children.map(sysItem => ({
  453. label: `${sysItem.label}`,
  454. params: {
  455. date: item.label,
  456. sys_id: sysItem.label,
  457. total:'',
  458. },
  459. })),
  460. }));
  461. treeData.splice(0, treeData.length, ...transformedData);
  462. console.log(treeData)
  463. }
  464. getTabdata();
  465. // 自动化生成的字典(可能为空)以及字段
  466. const formData = ref({
  467. 关联人员工号: '',
  468. 关联人员姓名: '',
  469. 日关联系数: '',
  470. 日关联人数: '',
  471. 日期: '',
  472. 员工编号:'',
  473. 姓名:'',
  474. 部门名称:'',
  475. 职务:'',
  476. 入职日期:'',
  477. 关联权重:'',
  478. 定位:'',
  479. old_time:'',
  480. new_time:'',
  481. })
  482. // 验证规则
  483. const rule = reactive({
  484. })
  485. const elFormRef = ref()
  486. const elSearchFormRef = ref()
  487. // =========== 表格控制部分 ===========
  488. const tableData = reactive([])
  489. const tableData2 = reactive([])
  490. const detailData = reactive([])
  491. const total = ref(0)
  492. const page = ref(1)
  493. const limit = ref(10)
  494. const searchInfo = ref('')
  495. const params = {
  496. date: '',
  497. sys_id: '',
  498. page: page.value.toString(),
  499. limit: limit.value.toString(),
  500. }
  501. // 分页设置
  502. const handleSizeChange = (val) => {
  503. limit.value = val;
  504. params.limit = val.toString();
  505. getTableData();
  506. }
  507. // 页面跳转
  508. const handleCurrentChange = (val) => {
  509. page.value = val
  510. params.page = val.toString();
  511. getTableData()
  512. }
  513. // 查询
  514. const getTableData = async () => {
  515. const response = await relatedList({
  516. date: params.date, department: params.sys_id,});
  517. console.log(response)
  518. if (response.code === 0) {
  519. const originalData = response.data;
  520. const summaryData = generateSummaryData(originalData);
  521. // 将合计数据插入到原始数据中
  522. const combinedData = [];
  523. originalData.forEach((item, index) => {
  524. combinedData.push(item);
  525. const nextItem = originalData[index + 1];
  526. if (nextItem && nextItem['员工姓名'] !== item['员工姓名']) {
  527. // 如果下一个员工姓名与当前不同,插入合计数据
  528. const currentSummary = summaryData.shift();
  529. combinedData.push(currentSummary);
  530. console.log(currentSummary)
  531. }
  532. });
  533. console.log(combinedData)
  534. // 更新表格数据
  535. tableData.splice(0, tableData.length, ...combinedData);
  536. }
  537. }
  538. const generateSummaryData = (data) => {
  539. const summaryData = [];
  540. let currentName = null;
  541. let currentSummary = null;
  542. data.forEach((item, index) => {
  543. const name = item['员工姓名'].trim(); // 获取员工姓名并去除空格
  544. const nextItem = data[index + 1];
  545. // 更新合计数据
  546. if (currentName === name) {
  547. currentSummary['日期']++;
  548. currentSummary['计件工资'] += parseFloat(item['计件工资']);
  549. currentSummary['加班工资'] += parseFloat(item['加班工资']);
  550. currentSummary['日工资合计'] += parseFloat(item['日工资合计']);
  551. } else {
  552. // 如果员工姓名发生改变,或者已经到达数据结尾,将上一个员工的合计数据插入到数组中
  553. if (currentSummary) {
  554. currentSummary['员工姓名'] = '合计(' + currentSummary['日期'] + '天)';
  555. currentSummary['计件工资'] = currentSummary['计件工资'].toFixed(2); // 保留两位小数
  556. currentSummary['加班工资'] = currentSummary['加班工资'].toFixed(2);
  557. currentSummary['日工资合计'] = currentSummary['日工资合计'].toFixed(2);
  558. summaryData.push(currentSummary);
  559. }
  560. // 创建新的合计数据
  561. currentSummary = {
  562. '员工姓名': name,
  563. '日期': 1,
  564. '计件工资': parseFloat(item['计件工资']),
  565. '加班工资': parseFloat(item['加班工资']),
  566. '日工资合计': parseFloat(item['日工资合计'])
  567. };
  568. currentName = name;
  569. }
  570. // 如果已经到达数据结尾,将最后一个员工的合计数据插入到数组中
  571. if (!nextItem) {
  572. currentSummary['员工姓名'] = '合计(' + currentSummary['日期'] + '天)';
  573. currentSummary['计件工资'] = currentSummary['计件工资'].toFixed(2); // 保留两位小数
  574. currentSummary['加班工资'] = currentSummary['加班工资'].toFixed(2);
  575. currentSummary['日工资合计'] = currentSummary['日工资合计'].toFixed(2);
  576. summaryData.push(currentSummary);
  577. }
  578. });
  579. return summaryData;
  580. };
  581. let date=ref()
  582. const handleNodeClick = (node, check) => {
  583. //存放当前节点的nodeId
  584. if (node.params) {
  585. params.date = node.params.date;
  586. params.sys_id = node.params.sys_id;
  587. total.value = node.params.total;
  588. date=node.params.date
  589. console.log(date)
  590. getTableData();
  591. }
  592. }
  593. const relevancyselectData=ref([]);
  594. // 关联工资设置
  595. function onrelevancy() {
  596. console.log(formData)
  597. console.log(code)
  598. console.log(time)
  599. Setting(time.value,code.value)
  600. }
  601. //获取关联工资信息
  602. const Setting = async (date,code) => {
  603. const res = await setting({date:date,code:code})
  604. console.log(res)
  605. if (res.code === 0) {
  606. relevancyselectData.value=res.data
  607. formData.value.日期=res.data[0].日期
  608. formData.value.关联人员工号=res.data[0].关联人员工号
  609. formData.value.关联人员姓名=res.data[0].关联人员姓名
  610. formData.value.日关联人数=res.data[0].日关联人数
  611. formData.value.日关联系数=res.data[0].日关联系数
  612. dialogFormVisible.value=true
  613. }
  614. }
  615. //员工编号回车事件
  616. const getygsubmit = (event) => {
  617. GetYg()
  618. }
  619. //获取员工信息
  620. const GetYg = async () => {
  621. const response = await getYg({sczl_bh:formData.value.关联人员工号});
  622. console.log(response)
  623. if (response.code === 0) {
  624. console.log(response.data.ygxm)
  625. formData.value.关联人员姓名=response.data.ygxm
  626. }
  627. }
  628. function onflushed() {
  629. Setting(formData.value.日期,formData.value.关联人员工号)
  630. }
  631. const relevancySelection=ref([])
  632. //列表勾选
  633. const relevancySelectionChange = (val) => {
  634. relevancySelection.value = val.map(item => {
  635. return {
  636. UniqID: item.UniqID,
  637. };
  638. });
  639. console.log(relevancySelection.value)
  640. }
  641. const copyselectData=ref([])
  642. // 组员复制
  643. const oncopy = () => {
  644. copyshow.value=true
  645. }
  646. //时间回车事件
  647. const getcopylist = (event, inputName) => {
  648. CopyLst()
  649. }
  650. //获取复制信息
  651. const CopyLst = async () => {
  652. const response = await copyLst({date:formData.value.old_time});
  653. console.log(response)
  654. if (response.code === 0) {
  655. copyselectData.value=response.data
  656. }
  657. }
  658. const copySelection=ref([])
  659. //列表勾选
  660. const copySelectionChange = (val) => {
  661. copySelection.value = val.map(item => {
  662. return {
  663. old_time:formData.value.old_time,
  664. new_time:formData.value.new_time,
  665. 关联员工: item.员工编号
  666. };
  667. });
  668. console.log(copySelection.value)
  669. }
  670. const oncopyup = () => {
  671. Copy()
  672. }
  673. //提交数组
  674. const Copy= async () => {
  675. const response = await copy(copySelection.value);
  676. console.log(response)
  677. if (response.code === 0) {
  678. copyshow.value=false
  679. // batchaddselectData.value=response.data
  680. // batchaddshow.value=true
  681. }
  682. }
  683. // 更新关联系数
  684. const uprelevancy = () => {
  685. UpdateNum()
  686. }
  687. //更新关联系数
  688. const UpdateNum = async () => {
  689. const response = await updateNum({date:formData.value.日期,code:formData.value.关联人员工号,num:formData.value.日关联系数});
  690. console.log(response)
  691. if (response.code === 0) {
  692. // Setting(formData.value.日期,formData.value.关联人员工号)
  693. tableData[rowIndex.value].关联系数=formData.value.日关联系数
  694. console.log(); // Accessing the value of rowIndex
  695. }
  696. }
  697. // 批量删除
  698. const batchdel = () => {
  699. BatchDel()
  700. }
  701. //删除提交
  702. const BatchDel = async () => {
  703. const response = await batchDel(relevancySelection.value);
  704. console.log(response)
  705. if (response.code === 0) {
  706. Setting(formData.value.日期,formData.value.关联人员工号)
  707. }
  708. }
  709. //关联表格双击事件
  710. const relevancySelectClick = (row, column, event) => {
  711. console.log(row.日期)
  712. console.log(row.班组员工编号)
  713. WeightDetail(row.日期,row.班组员工编号)
  714. }
  715. //获取关联员工信息
  716. const WeightDetail = async (date,code) => {
  717. const response = await weightDetail({date:date,code:code.split("(")[0]});
  718. console.log(response.data[0].员工编号)
  719. if (response.code === 0) {
  720. formData.value.员工编号=response.data[0].员工编号
  721. formData.value.姓名=response.data[0].姓名
  722. formData.value.部门名称=response.data[0].部门名称
  723. formData.value.职务=response.data[0].职务
  724. formData.value.入职日期=response.data[0].入职日期
  725. formData.value.关联权重=response.data[0].关联权重
  726. console.log(formData)
  727. positioningVisibleshow.value=true
  728. }
  729. }
  730. // 批量添加
  731. const batchadd = () => {
  732. BatchAddLst()
  733. }
  734. const batchaddselectData=ref([])
  735. //批量附加组员列表
  736. const BatchAddLst = async () => {
  737. const response = await batchAddLst({date:formData.value.日期,code:formData.value.关联人员工号});
  738. console.log(response)
  739. if (response.code === 0) {
  740. batchaddselectData.value=response.data
  741. batchaddshow.value=true
  742. }
  743. }
  744. // 查找
  745. const oninvestigate = () => {
  746. BatchAddSearch()
  747. }
  748. //查找
  749. const BatchAddSearch= async () => {
  750. const response = await batchAddSearch({date:formData.value.日期,search:formData.value.定位});
  751. console.log(response)
  752. if (response.code === 0) {
  753. batchaddselectData.value=response.data
  754. // batchaddshow.value=true
  755. }
  756. }
  757. const batchaddSelection=ref([])
  758. //列表勾选
  759. const batchaddSelectionChange = (val) => {
  760. batchaddSelection.value = val.map(item => {
  761. return {
  762. UniqID: item.UniqID,
  763. 关联员工: item.班组员工编号.split("(")[0]
  764. };
  765. });
  766. console.log(batchaddSelection.value)
  767. }
  768. //提交
  769. const batchup = () => {
  770. BatchAdd()
  771. }
  772. //提交数组
  773. const BatchAdd= async () => {
  774. const response = await batchAdd(batchaddSelection.value);
  775. console.log(response)
  776. if (response.code === 0) {
  777. Setting(formData.value.日期,formData.value.关联人员工号)
  778. batchaddshow.value=false
  779. // batchaddselectData.value=response.data
  780. // batchaddshow.value=true
  781. }
  782. }
  783. // 搜索
  784. function onSearch() {
  785. console.log(searchInfo.value)
  786. Relatedsearch()
  787. }
  788. //定位
  789. const fillTableData = (data) => {
  790. // Fill the table data
  791. tableData.splice(0, tableData.length, ...data);
  792. };
  793. const Relatedsearch = async () => {
  794. const response = await relatedsearch({
  795. date: params.date,
  796. search: searchInfo.value
  797. });
  798. console.log(response);
  799. if (response.code === 0) {
  800. const filledData = response.data.map((item) => {
  801. // Handle empty values for "个人计件工资" and "个人加班工资"
  802. if (item["个人计件工资"] === "") {
  803. item["个人计件工资"] = "0";
  804. }
  805. if (item["个人加班工资"] === "") {
  806. item["个人加班工资"] = "0";
  807. }
  808. return item;
  809. });
  810. // Update table data using await to ensure data is updated before proceeding
  811. await fillTableData(filledData);
  812. }
  813. };
  814. // ============== 表格控制部分结束 ===============
  815. // 获取需要的字典 可能为空 按需保留
  816. const setOptions = async () => {
  817. }
  818. // 获取需要的字典 可能为空 按需保留
  819. setOptions()
  820. // 多选数据
  821. const multipleSelection = ref([])
  822. let code=ref()
  823. let time=ref()
  824. // 多选
  825. const handleSelectionChange = (val,row) => {
  826. // multipleSelection.value = val
  827. console.log(val)
  828. console.log(row)
  829. if(val.length>0){
  830. multipleSelection.value = val
  831. const lenth=val.length
  832. code=val[lenth-1].员工编号
  833. time=val[lenth-1].日期
  834. formData.value.员工编号=val[lenth-1].员工编号,
  835. formData.value.员工姓名= val[lenth-1].员工姓名,
  836. formData.value.日期=val[lenth-1].日期,
  837. formData.value.关联系数= val[lenth-1].关联系数,
  838. formData.value.关联人数= val[lenth-1].关联人数
  839. val.splice(0, val.length); // 清空 val 数组
  840. console.log(code+time)
  841. }
  842. }
  843. // 批量删除控制标记
  844. const deleteVisible = ref(false)
  845. // 多选删除
  846. const onDelete = async () => {
  847. const ids = []
  848. if (multipleSelection.value.length === 0) {
  849. ElMessage({
  850. type: 'warning',
  851. message: '请选择要删除的数据'
  852. })
  853. return
  854. }
  855. multipleSelection.value &&
  856. multipleSelection.value.map(item => {
  857. ids.push(item.ID)
  858. })
  859. const res = await deleteCompanyByIds({ ids })
  860. if (res.code === 0) {
  861. ElMessage({
  862. type: 'success',
  863. message: '删除成功'
  864. })
  865. if (tableData.value.length === ids.length && page.value > 1) {
  866. page.value--
  867. }
  868. deleteVisible.value = false
  869. getTableData()
  870. }
  871. }
  872. // 行为控制标记(弹窗内部需要增还是改)
  873. const type = ref('')
  874. // 更新行
  875. const updateCompanyFunc = async (row) => {
  876. const res = await findCompany({ ID: row.ID })
  877. type.value = 'update'
  878. if (res.code === 0) {
  879. formData.value = res.data.recompany
  880. dialogFormVisible.value = true
  881. }
  882. }
  883. // 弹窗控制标记
  884. const dialogFormVisible = ref(false)
  885. const positioningVisibleshow = ref(false)
  886. const weightDetailVisible = ref(false)
  887. const batchaddshow = ref(false)
  888. const copyshow = ref(false)
  889. // 打开弹窗
  890. const openDialog = () => {
  891. type.value = 'create'
  892. dialogFormVisible.value = true
  893. }
  894. // 关闭弹窗
  895. const closeDialog = () => {
  896. dialogFormVisible.value = false
  897. formData.value = {
  898. address: '',
  899. image: '',
  900. name: '',
  901. }
  902. }
  903. // 弹窗确定
  904. const enterDialog = async () => {
  905. elFormRef.value?.validate(async (valid) => {
  906. if (!valid) return
  907. let res
  908. switch (type.value) {
  909. case 'create':
  910. res = await createCompany(formData.value)
  911. break
  912. case 'update':
  913. res = await updateCompany(formData.value)
  914. break
  915. default:
  916. res = await createCompany(formData.value)
  917. break
  918. }
  919. if (res.code === 0) {
  920. ElMessage({
  921. type: 'success',
  922. message: '创建/更改成功'
  923. })
  924. closeDialog()
  925. getTableData()
  926. }
  927. })
  928. }
  929. // 单击表格操作
  930. const rowIndex=ref()
  931. function ontable(row, column, event) {
  932. // console.log(params.date)
  933. // let parts = params.date.split('-')
  934. // console.log(row.员工编号)
  935. // RelatedAllList(params.date,row.员工编号)
  936. // console.log(formData);
  937. console.log(row)
  938. code.value=row.员工编号
  939. time.value=row.日期
  940. console.log(code.value+time.value.replace(".","").substr(0,6))
  941. rowIndex.value = tableData.indexOf(row);
  942. console.log('单击的行数:', rowIndex.value);
  943. RelatedAllList(time.value.replace(".","").substr(0,6),code.value)
  944. }
  945. let temporary = {
  946. 员工编号: '',
  947. 员工姓名: '',
  948. 日期: '',
  949. 关联系数: '',
  950. 关联人数: ''
  951. };
  952. //获取下列表
  953. const RelatedAllList = async (date,bh) => {
  954. const response = await relatedAllList({date:date,code:bh});
  955. if(response.code==0){
  956. console.log(response)
  957. tableData2.splice(0, tableData2.length, ...response.data);
  958. }
  959. }
  960. // 双击表格操作
  961. function doubleClick(row, column, event) {
  962. // console.log(row, column, event);
  963. // // updateCompanyFunc(row);
  964. // type.value = 'update';
  965. // dialogFormVisible.value = true
  966. Setting(time.value,code.value)
  967. }
  968. // 导出excel
  969. function exportExcel() {
  970. console.log('导出到excel');
  971. }
  972. // 生命周期钩子
  973. onMounted(async () => {
  974. });
  975. </script>
  976. <style>
  977. .JKWTree-container {
  978. display: flex;
  979. }
  980. .JKWTree-tree {
  981. width: 300px;
  982. background-color: #fff;
  983. padding: 10px;
  984. margin-right: 20px;
  985. }
  986. .JKWTree-tree h3 {
  987. font-size: 15px;
  988. font-weight: 700;
  989. margin: 10px 0;
  990. }
  991. .JKWTree-content {
  992. flex: 1;
  993. }
  994. /* 选中某行时的背景色*/
  995. .el-table__body tr.current-row>td {
  996. background: #ff80ff !important;
  997. /* 背景颜色 */
  998. }
  999. </style>