related.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  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. if(!res.data.length){
  528. return
  529. }
  530. relevancyselectData.value = res.data
  531. formData.value.日期 = res.data[0].日期.replace(/\./g, "-")
  532. formData.value.关联人员工号 = res.data[0].关联人员工号
  533. formData.value.关联人员姓名 = res.data[0].关联人员姓名
  534. formData.value.日关联人数 = res.data[0].日关联人数
  535. formData.value.日关联系数 = res.data[0].日关联系数
  536. dialogFormVisible.value = true
  537. }
  538. }
  539. //员工编号回车事件
  540. const getygsubmit = (event) => {
  541. GetYg()
  542. }
  543. //获取员工信息
  544. const GetYg = async () => {
  545. const response = await getYg({sczl_bh:formData.value.关联人员工号});
  546. console.log(response)
  547. if (response.code === 0) {
  548. console.log(response.data.ygxm)
  549. formData.value.关联人员姓名=response.data.ygxm
  550. }
  551. }
  552. function onflushed() {
  553. Setting(formData.value.日期,formData.value.关联人员工号)
  554. }
  555. const relevancySelection=ref([])
  556. //列表勾选
  557. const relevancySelectionChange = (val) => {
  558. relevancySelection.value = val.map(item => {
  559. return {
  560. UniqID: item.UniqID,
  561. };
  562. });
  563. console.log(relevancySelection.value)
  564. }
  565. const copyselectData=ref([])
  566. // 组员复制
  567. const oncopy = () => {
  568. formData.value.old_time = '';
  569. formData.value.new_time = '';
  570. copyselectData.value = [];
  571. copySelection.value = [];
  572. copyshow.value=true
  573. }
  574. //时间回车/失去焦点事件
  575. const getcopylist = (event, inputName) => {
  576. if(formData.value.old_time){
  577. copyLst({date:formData.value.old_time}).then(response=>{
  578. if (response.code === 0) {
  579. copyselectData.value=response.data
  580. }
  581. })
  582. }
  583. }
  584. const copySelection=ref([])
  585. //列表勾选
  586. const copySelectionChange = (val) => {
  587. copySelection.value = val.map(item => {
  588. return {
  589. old_time:formData.value.old_time,
  590. new_time:formData.value.new_time,
  591. 关联员工: item.员工编号
  592. };
  593. });
  594. }
  595. const oncopyup = () => {
  596. if(!formData.value.old_time){
  597. ElMessage({
  598. type: 'error',
  599. message: '请填写日期'
  600. })
  601. return
  602. }
  603. if(!formData.value.new_time){
  604. ElMessage({
  605. type: 'error',
  606. message: '请填写目标日期'
  607. })
  608. return
  609. }
  610. if(copySelection.value.length==0){
  611. ElMessage({
  612. type: 'error',
  613. message: '请勾选复制人员'
  614. })
  615. return
  616. }
  617. copySelection.value.forEach(subArr => {
  618. subArr.old_time = formData.value.old_time;
  619. subArr.new_time = formData.value.new_time;
  620. });
  621. copy(copySelection.value).then(response=>{
  622. if (response.code === 0) {
  623. ElMessage({
  624. type: 'success',
  625. message: '复制成功'
  626. })
  627. copyshow.value=false
  628. }
  629. })
  630. }
  631. // 更新关联系数
  632. const uprelevancy = () => {
  633. ElMessageBox.confirm('确定要执行此操作吗?', '提示', {
  634. confirmButtonText: '确定',
  635. cancelButtonText: '取消',
  636. type: 'warning'
  637. }).then(() => {
  638. UpdateNum()
  639. })
  640. }
  641. //更新关联系数
  642. const UpdateNum = async () => {
  643. const response = await updateNum({date:formData.value.日期,code:formData.value.关联人员工号,num:formData.value.日关联系数});
  644. if (response.code === 0) {
  645. ElMessage({
  646. type: 'success',
  647. message: '更新成功'
  648. })
  649. tableData[rowIndex.value].关联系数=formData.value.日关联系数
  650. }
  651. }
  652. // 批量删除
  653. const batchdel = () => {
  654. ElMessageBox.confirm('确定要删除吗?', '提示', {
  655. confirmButtonText: '确定',
  656. cancelButtonText: '取消',
  657. type: 'warning'
  658. }).then(() => {
  659. BatchDel()
  660. })
  661. }
  662. //删除提交
  663. const BatchDel = async () => {
  664. const response = await batchDel(relevancySelection.value);
  665. if (response.code === 0) {
  666. ElMessage({
  667. type: 'success',
  668. message: '删除成功'
  669. })
  670. Setting(formData.value.日期,formData.value.关联人员工号)
  671. }
  672. }
  673. //关联表格双击事件
  674. const relevancySelectClick = (row, column, event) => {
  675. console.log(row.日期)
  676. console.log(row.班组员工编号)
  677. WeightDetail(row.日期,row.班组员工编号)
  678. }
  679. //获取关联员工信息
  680. const WeightDetail = async (date,code) => {
  681. const response = await weightDetail({date:date,code:code.split("(")[0]});
  682. console.log(response.data[0].员工编号)
  683. if (response.code === 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. formData.value.入职日期=response.data[0].入职日期
  689. formData.value.关联权重=response.data[0].关联权重
  690. console.log(formData)
  691. positioningVisibleshow.value=true
  692. }
  693. }
  694. // 批量添加
  695. const batchadd = () => {
  696. BatchAddLst()
  697. }
  698. const batchaddselectData=ref([])
  699. //批量附加组员列表
  700. const BatchAddLst = async () => {
  701. const response = await batchAddLst({date:formData.value.日期});
  702. if (response.code === 0) {
  703. batchaddselectData.value=response.data
  704. formData.value.定位 = ''
  705. batchaddshow.value=true
  706. }
  707. }
  708. // 批量附加组员搜索
  709. const oninvestigate = () => {
  710. batchAddSearch({date:formData.value.日期,search:formData.value.定位}).then(response=>{
  711. if (response.code === 0) {
  712. batchaddselectData.value=response.data
  713. }
  714. })
  715. }
  716. const batchaddSelection=ref([])
  717. //列表勾选
  718. const batchaddSelectionChange = (val) => {
  719. batchaddSelection.value = val.map(item => {
  720. return {
  721. date: formData.value.日期,
  722. 关联员工: formData.value.关联人员工号,
  723. 被关联员工: item.bh,
  724. 关联系数: formData.value.日关联系数,
  725. };
  726. });
  727. console.log(batchaddSelection.value)
  728. }
  729. //提交
  730. const batchup = () => {
  731. BatchAdd()
  732. }
  733. //提交数组
  734. const BatchAdd= async () => {
  735. const response = await batchAdd(batchaddSelection.value);
  736. if (response.code === 0) {
  737. Setting(formData.value.日期,formData.value.关联人员工号)
  738. batchaddshow.value=false
  739. }
  740. }
  741. // 搜索
  742. const onSearch = () => {
  743. console.log(params.date)
  744. console.log(searchInfo.value)
  745. console.log(params.sys_id)
  746. if(params.date && searchInfo.value && params.sys_id){
  747. Relatedsearch()
  748. }
  749. }
  750. //定位
  751. const fillTableData = (data) => {
  752. tableData.splice(0, tableData.length, ...data);
  753. };
  754. const Relatedsearch = async () => {
  755. const response = await relatedsearch({
  756. date: params.date,
  757. search: searchInfo.value,
  758. department: params.sys_id
  759. });
  760. if (response.code === 0) {
  761. const filledData = response.data.map((item) => {
  762. return item;
  763. });
  764. // Update table data using await to ensure data is updated before proceeding
  765. await fillTableData(filledData);
  766. }
  767. };
  768. // ============== 表格控制部分结束 ===============
  769. // 获取需要的字典 可能为空 按需保留
  770. const setOptions = async () => {
  771. }
  772. // 获取需要的字典 可能为空 按需保留
  773. setOptions()
  774. // 多选数据
  775. const multipleSelection = ref([])
  776. let code=ref()
  777. let time=ref()
  778. // 多选
  779. const handleSelectionChange = (val,row) => {
  780. if(val.length>0){
  781. multipleSelection.value = val
  782. const lenth=val.length
  783. code=val[lenth-1].员工编号
  784. time=val[lenth-1].日期
  785. formData.value.员工编号=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. val.splice(0, val.length); // 清空 val 数组
  791. }
  792. }
  793. // 批量删除控制标记
  794. const deleteVisible = ref(false)
  795. // 多选删除
  796. const onDelete = async () => {
  797. const ids = []
  798. if (multipleSelection.value.length === 0) {
  799. ElMessage({
  800. type: 'warning',
  801. message: '请选择要删除的数据'
  802. })
  803. return
  804. }
  805. multipleSelection.value &&
  806. multipleSelection.value.map(item => {
  807. ids.push(item.ID)
  808. })
  809. const res = await deleteCompanyByIds({ ids })
  810. if (res.code === 0) {
  811. ElMessage({
  812. type: 'success',
  813. message: '删除成功'
  814. })
  815. if (tableData.value.length === ids.length && page.value > 1) {
  816. page.value--
  817. }
  818. deleteVisible.value = false
  819. getTableData()
  820. }
  821. }
  822. // 行为控制标记(弹窗内部需要增还是改)
  823. const type = ref('')
  824. // 更新行
  825. const updateCompanyFunc = async (row) => {
  826. const res = await findCompany({ ID: row.ID })
  827. type.value = 'update'
  828. if (res.code === 0) {
  829. formData.value = res.data.recompany
  830. dialogFormVisible.value = true
  831. }
  832. }
  833. // 弹窗控制标记
  834. const dialogFormVisible = ref(false)
  835. const positioningVisibleshow = ref(false)
  836. const weightDetailVisible = ref(false)
  837. const batchaddshow = ref(false)
  838. const copyshow = ref(false)
  839. // 打开弹窗
  840. const openDialog = () => {
  841. type.value = 'create'
  842. dialogFormVisible.value = true
  843. }
  844. // 关闭弹窗
  845. const closeDialog = () => {
  846. dialogFormVisible.value = false
  847. formData.value = {
  848. address: '',
  849. image: '',
  850. name: '',
  851. }
  852. }
  853. // 弹窗确定
  854. const enterDialog = async () => {
  855. elFormRef.value?.validate(async (valid) => {
  856. if (!valid) return
  857. let res
  858. switch (type.value) {
  859. case 'create':
  860. res = await createCompany(formData.value)
  861. break
  862. case 'update':
  863. res = await updateCompany(formData.value)
  864. break
  865. default:
  866. res = await createCompany(formData.value)
  867. break
  868. }
  869. if (res.code === 0) {
  870. ElMessage({
  871. type: 'success',
  872. message: '创建/更改成功'
  873. })
  874. closeDialog()
  875. getTableData()
  876. }
  877. })
  878. }
  879. // 单击表格操作
  880. const rowIndex=ref()
  881. function ontable(row) {
  882. console.log(row)
  883. code.value=row.员工编号
  884. time.value=row.日期
  885. rowIndex.value = tableData.indexOf(row);
  886. RelatedAllList(time.value.replace(".","").substr(0,6),code.value)
  887. }
  888. let temporary = {
  889. 员工编号: '',
  890. 员工姓名: '',
  891. 日期: '',
  892. 关联系数: '',
  893. 关联人数: ''
  894. };
  895. //获取下列表
  896. const RelatedAllList = async (date,bh) => {
  897. const response = await relatedAllList({date:date,code:bh});
  898. if(response.code==0){
  899. console.log(response)
  900. tableData2.splice(0, tableData2.length, ...response.data);
  901. }
  902. }
  903. // 双击表格操作
  904. function doubleClick(row, column, event) {
  905. // console.log(row, column, event);
  906. // // updateCompanyFunc(row);
  907. // type.value = 'update';
  908. // dialogFormVisible.value = true
  909. Setting(time.value,code.value)
  910. }
  911. // 导出excel
  912. function exportExcel() {
  913. if(tableData.length<1){
  914. ElMessage({
  915. type: 'error',
  916. message: '请确认上方表格内是否存在内容'
  917. })
  918. }else{
  919. exportExcelFile(tableData,tableCols1)
  920. }
  921. }
  922. function exportExcel2() {
  923. if(tableData2.length<1){
  924. ElMessage({
  925. type: 'error',
  926. message: '请确认下方表格内是否存在内容'
  927. })
  928. }else{
  929. exportExcelFile(tableData2,tableCols2)
  930. }
  931. }
  932. const exportExcelFile = (tableData, tableCols) => {
  933. const data = tableData.map(row => {
  934. const rowData = {};
  935. tableCols.forEach(column => {
  936. rowData[column.label] = row[column.prop];
  937. });
  938. return rowData;
  939. });
  940. const worksheet = XLSX.utils.json_to_sheet(data);
  941. const workbook = XLSX.utils.book_new();
  942. XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
  943. XLSX.writeFile(workbook, 'exported_table.xlsx');
  944. };
  945. // 生命周期钩子
  946. onMounted(async () => {
  947. });
  948. </script>
  949. <style>
  950. .JKWTree-container {
  951. display: flex;
  952. }
  953. .JKWTree-tree {
  954. width: 300px;
  955. background-color: #fff;
  956. padding: 10px;
  957. margin-right: 20px;
  958. }
  959. .JKWTree-tree h3 {
  960. font-size: 15px;
  961. font-weight: 700;
  962. margin: 10px 0;
  963. }
  964. .JKWTree-content {
  965. flex: 1;
  966. }
  967. /* 选中某行时的背景色*/
  968. .el-table__body tr.current-row>td {
  969. background: #ff80ff !important;
  970. /* 背景颜色 */
  971. }
  972. </style>
  973. <style scoped>
  974. :deep(.el-table td .cell) {
  975. line-height: 20px !important;
  976. }
  977. :deep(.el-tabs__header){
  978. margin-bottom: 0;
  979. }
  980. .search{
  981. margin-left: 0px !important;
  982. margin-right: 10px !important;
  983. }
  984. .bt{
  985. margin-left: 2px !important;
  986. padding: 3px !important;
  987. font-size: 12px;
  988. }
  989. .el-tabs__header{
  990. margin: 0px !important;
  991. }
  992. .gva-table-box{
  993. padding: 0px !important;
  994. }
  995. .mab{
  996. margin-bottom: 5px;
  997. }
  998. </style>