related.vue 33 KB

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