related.vue 32 KB

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