| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 |
- <template>
- <div>
- <!-- 左侧树形结构 -->
- <el-container>
-
- <layout-sider
- :resize-directions="['right']"
- :width="220"
- style="margin-right: 10px;"
- >
- <div class="JKWTree-tree" style="height: 70vh;" >
- <h3>关联工资核算</h3>
- <el-tree :data="treeData"
- highlight-current
- @node-click="handleNodeClick"
- />
- </div>
- </layout-sider>
- <el-container>
- <el-main>
- <!-- 按钮区域 -->
- <div class="gva-table-box">
- <el-form>
- <el-form-item>
- <el-input v-model="searchInfo" placeholder="输入员工编号" style="width: 180px;"/>
- <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
- <el-button type="primary" class="bt" icon="" @click="oncopy">组员复制</el-button>
- <el-button type="primary" class="bt" icon="edit" @click="onrelevancy">关联工资设置</el-button>
- <div style="margin-left: auto;">
- <el-button type="primary" class="bt" icon="download" @click="exportExcel">导出到Excel(汇总)</el-button>
- <el-button type="primary" class="bt" icon="download" @click="exportExcel2">导出到Excel(明细)</el-button>
- </div>
- </el-form-item>
- </el-form>
- <!-- 数据展示 -->
- <el-table ref="multipleTable" style="width: 100%;height: 40vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
- highlight-current-row="true" border
- :row-style="{ height: '0px' }"
- :header-row-style="{ height: '20px' }"
- :header-cell-style="{ padding: '0px' }"
- size="small"
- :show-overflow-tooltip="true" @row-click="ontable"
- @selection-change="handleSelectionChange" @row-dblclick="doubleClick">
- <!-- <el-table-column type="selection" width="55" /> -->
- <el-table-column
- v-for="column in tableCols1"
- :key="column.prop"
- :prop="column.prop"
- :label="column.label"
- :width="column.width"
- show-overflow-tooltip="true"
- sortable
- />
- </el-table>
- <!-- 分页 -->
- <!-- <div class="gva-pagination">
- <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
- :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
- @size-change="handleSizeChange" />
- </div> -->
- </div>
-
-
- <div class="gva-table-box">
- <!-- 数据展示 -->
- <el-table ref="multipleTable" style="width: 100%" height="300px" tooltip-effect="dark" :data="tableData2" row-key="ID"
- highlight-current-row="true" border
- :row-style="{ height: '0px' }"
- :header-row-style="{ height: '20px' }"
- :header-cell-style="{ padding: '0px' }"
- size="small"
- @selection-change="handleSelectionChange"
- :show-overflow-tooltip="true" @row-dblclick="doubleClick">
- <el-table-column type="selection" width="55" />
- <el-table-column
- v-for="column in tableCols2"
- :key="column.prop"
- :prop="column.prop"
- :label="column.label"
- :width="column.width"
- show-overflow-tooltip="true"
- sortable
- />
- </el-table>
- <!-- 分页 -->
- <!-- <div class="gva-pagination">
- <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
- :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
- @size-change="handleSizeChange" />
- </div> -->
- </div>
- <!-- 弹出框 -->
- <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="设置"
- destroy-on-close width="1000px" style="height: 700px;" >
- <!-- <el-scrollbar height="500px"> -->
- <el-form :model="formData" label-position="left" ref="elFormRef" :rules="rule">
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="关联人员工号" prop="name">
- <el-input v-model="formData.关联人员工号" @keyup.enter.native="getygsubmit" :clearable="true" style="width: 110px;" />
- <el-input v-model="formData.关联人员姓名" :readonly=true style="width: 80px; margin-left: 5px;" />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="日期" prop="name">
- <el-input type="date" max="9999-12-31" v-model="formData.日期" :clearable="true" style="width: 80px; "/>
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="关联系数" prop="name">
- <el-input v-model="formData.日关联系数" :clearable="true" style="width: 100px; "/>
- </el-form-item>
- </el-col>
- <el-col :span="3">
- <el-button type="primary" @click="onflushed">刷新</el-button>
- </el-col>
- <el-col :span="4">
- <el-form-item label="关联人数" prop="name">
- <el-input v-model="formData.日关联人数" :readonly=true style="width: 50px; "/>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
-
-
- <el-table tooltip-effect="dark" :data="relevancyselectData" row-key="ID"
- highlight-current-row="true" border
- style="width:100%;" height="500px"
- :row-style="{ height: '0px' }"
- :header-row-style="{ height: '20px' }"
- :header-cell-style="{ padding: '0px' }"
- size="small"
- @row-dblclick="relevancySelectClick"
- :selectable="row => rowSelectable(row)"
- @selection-change="relevancySelectionChange"
- >
- <el-table-column type="selection" width="55" align="center" label=""/>
- <el-table-column prop="日期" label="日期" width="165" />
- <el-table-column prop="班组员工编号" label="班组员工编号" width="250" />
- <el-table-column prop="组员权重" label="组员权重" width="150" />
- <el-table-column prop="计件工资基数" label="计件工资基数" width="170" />
- <el-table-column prop="加班工资基数" label="加班工资基数" width="170" />
- </el-table>
-
- <!-- </el-scrollbar> -->
- <template #header>
- <el-form-item style="margin-bottom: 0px;">
- <el-button type="primary" class="bt" icon="plus" @click="batchadd">批量附加组员</el-button>
- <el-button type="primary" class="bt" icon="delete" @click="batchdel">批量删除组员</el-button>
- <el-button type="primary" class="bt" icon="edit" @click="uprelevancy">更新关联系数</el-button>
- <!-- <el-button type="success" class="bt" style="margin-left: 20px !important;" icon="plus" @click="zyadd">新增</el-button>
- <el-button type="success" class="bt" icon="edit" @click="zyedit">修改</el-button>
- <el-button type="success" class="bt" icon="delete" @click="zydel">删除</el-button> -->
- </el-form-item>
- </template>
- </el-dialog>
- <el-dialog v-model="positioningVisibleshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
-
- <el-row :gutter="20">
-
- <el-col :span="6">
- <el-form-item label="员工编号" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.员工编号" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="姓名" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.姓名" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row :gutter="20">
-
- <el-col :span="6">
- <el-form-item label="部门名称" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.部门名称" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="职务" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.职务" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- </el-row>
-
-
- <el-row :gutter="20">
-
- <el-col :span="6">
- <el-form-item label="入职日期" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.入职日期" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- </el-row>
-
-
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="关联权重" prop="name">
- <el-row :gutter="20">
- <el-col :span="12">
- <el-input v-model="formData.关联权重" :clearable="true" />
- </el-col>
- </el-row>
- </el-form-item>
- </el-col>
- </el-row>
- </el-dialog>
-
-
- <el-dialog v-model="batchaddshow" :before-close="closepositioningVisible" :title="批量附加"
- destroy-on-close width="900px" >
- <el-row :gutter="24">
- <el-col :span="12">
- <el-form-item label="定位" prop="name">
- <el-input v-model="formData.定位" @keyup.enter.native="oninvestigate" :clearable="true" style="width: 200px; margin-right: 5px;" />
- <el-button type="primary" @click="oninvestigate">查找</el-button>
- </el-form-item>
- </el-col>
- </el-row>
- <el-table tooltip-effect="dark" :data="batchaddselectData" row-key="ID"
- highlight-current-row="true" border
- style="width:100%" height="400px"
- @row-dblclick="batchaddSelectClick"
- :selectable="row => rowSelectable(row)"
- @selection-change="batchaddSelectionChange"
- >
- <el-table-column type="selection" width="40" align="center" />
- <el-table-column prop="日期" label="日期" width="100" />
- <el-table-column prop="所在部门" label="所在部门" width="115" />
- <el-table-column prop="班组" label="班组" width="55" />
- <el-table-column prop="职称职务" label="职称职务" width="150" />
- <el-table-column prop="班组员工编号" label="班组员工编号" width="160" />
- <el-table-column prop="个人计件工资" label="计件工资基数" width="120" />
- <el-table-column prop="个人加班工资" label="加班工资基数" width="120" />
- </el-table>
-
- <template #footer>
- <div class="dialog-footer">
- <el-button @click="batchup">提 交</el-button>
- </div>
- </template>
- </el-dialog>
-
-
- <el-dialog v-model="copyshow" :before-close="closepositioningVisible" :title="复制" destroy-on-close>
- <el-row :gutter="24">
- <el-col :span="7">
- <el-form-item label="日期:" prop="name" class="mab">
- <el-input type="date" max="9999-12-31" v-model="formData.old_time" @blur="getcopylist" @keyup.enter.native="getcopylist" :clearable="true" />
- </el-form-item>
- </el-col>
- <el-col :span="7">
- <el-form-item label="复制成:" prop="name" class="mab">
- <el-input type="date" max="9999-12-31" v-model="formData.new_time" :clearable="true" />
- </el-form-item>
- </el-col>
- <el-col :span="3">
- <el-button type="primary" @click="oncopyup">执行</el-button>
- </el-col>
- </el-row>
-
- <el-table tooltip-effect="dark" :data="copyselectData" row-key="ID"
- highlight-current-row="true" border
- style="width:100%" height="400px"
- @row-dblclick="copySelectClick"
- :selectable="row => rowSelectable(row)"
- @selection-change="copySelectionChange"
- >
- <el-table-column type="selection" width="42" align="center"/>
- <el-table-column prop="员工编号" label="员工编号" width="120" />
- <el-table-column prop="员工姓名" label="员工姓名" width="120" />
- <el-table-column prop="所在部门" label="所在部门" width="200" />
- <el-table-column prop="职称职务" label="职称职务" width="200" />
- </el-table>
-
- </el-dialog>
-
- </el-main>
- </el-container>
- </el-container>
- </div>
- </template>
- <script setup>
- import {
- getList,
- getTab,
- dailygetTab,
- dailygetList,
- dailygetAllList,
- dailygetDetail,
- dailysearch,
- relatedTab,
- relatedList,
- relatedsearch,
- relatedAllList,
- setting,
- getYg,
- weightDetail,
- updateNum,
- batchAddLst,
- copyLst,
- batchAdd,
- batchDel,
- copy,
- batchAddSearch
- } from '@/api/jixiaoguanli/jitairibaobiao'
- // 全量引入格式化工具 请按需保留
- import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
- import { ElMessage, ElMessageBox } from 'element-plus'
- import { Search, Refresh, Download } from '@element-plus/icons-vue'
- import { ref, reactive, onMounted, onBeforeMount, nextTick } from 'vue'
- import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'
- import { Value } from 'sass'
- import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
- import * as XLSX from "xlsx";
- import { useUserStore } from '@/pinia/modules/user'
- const userStore = useUserStore()
- const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
- defineOptions({
- name: '06-packingDocuments'
- })
- const tableCols1 = [
- { label: '员工编号', prop: '员工编号', width: '105' },
- { label: '员工姓名', prop: '员工姓名', width: '105' },
- { label: '职称职务', prop: '职称职务', width: '120' },
- { label: '所在部门', prop: '所在部门', width: '105' },
- { label: '日期', prop: '日期', width: '105' },
- { label: '关联系数', prop: '关联系数', width: '105' },
- { label: '关联人数', prop: '关联人数', width: '135' },
- { label: '关联计件工资', prop: '关联计件工资', width: '135' },
- { label: '关联加班工资', prop: '关联加班工资', width: '135' },
- { label: '关联定额补差', prop: '关联定额补差', width: '130' },
- { label: '关联计时工资', prop: '关联计时工资', width: '130' },
- { label: '关联工资合计', prop: '关联工资合计', width: '130' },
- ]
- const tableCols2 = [
- { label: '日期', prop: '日期', width: '105' },
- { label: '员工编号', prop: '员工编号', width: '105' },
- { label: '员工姓名', prop: '员工姓名', width: '150' },
- { label: '所在部门', prop: '所在部门', width: '150' },
- { label: '被关联员工', prop: '被关联员工', width: '125' },
- { label: '被关联姓名', prop: '被关联姓名', width: '125' },
- { label: '权重', prop: '权重', width: '105' },
- { label: '计件工资', prop: '计件工资', width: '105' },
- { label: '加班工资', prop: '加班工资', width: '105' },
- { label: '定额补差', prop: '定额补差', width: '105' },
- { label: '计时工资', prop: '计时工资', width: '105' },
- ]
- // 侧边栏数据请求
- const treeData = reactive([]);
- const getTabdata = async () => {
- //接口调用函数
- const response = await relatedTab();
- const transformedData = response.data.map(item => ({
- label: `${item.label}`,
- children: item.children.map(sysItem => ({
- label: `${sysItem.label}`,
- params: {
- date: item.label,
- sys_id: sysItem.label,
- total:'',
- },
- })),
- }));
- treeData.splice(0, treeData.length, ...transformedData);
- }
-
- getTabdata();
- // 自动化生成的字典(可能为空)以及字段
- const formData = ref({
- 关联人员工号: '',
- 关联人员姓名: '',
- 日关联系数: '',
- 日关联人数: '',
- 日期: '',
- 员工编号:'',
- 姓名:'',
- 部门名称:'',
- 职务:'',
- 入职日期:'',
- 关联权重:'',
- 定位:'',
-
- old_time:'',
- new_time:'',
- })
- // 验证规则
- const rule = reactive({
- })
- const elFormRef = ref()
- const elSearchFormRef = ref()
- // =========== 表格控制部分 ===========
- const tableData = reactive([])
- const tableData2 = reactive([])
- const detailData = reactive([])
- const total = ref(0)
- const page = ref(1)
- const limit = ref(10)
- const searchInfo = ref('')
- const params = {
- date: '',
- sys_id: '',
- page: page.value.toString(),
- limit: limit.value.toString(),
- }
- // 分页设置
- const handleSizeChange = (val) => {
- limit.value = val;
- params.limit = val.toString();
- getTableData();
- }
- // 页面跳转
- const handleCurrentChange = (val) => {
- page.value = val
- params.page = val.toString();
- getTableData()
- }
- // 查询
- const getTableData = async () => {
- const response = await relatedList({
- date: params.date, department: params.sys_id,});
- if (response.code === 0) {
- const originalData = response.data;
- const summaryData = generateSummaryData(originalData);
- // 将合计数据插入到原始数据中
- const combinedData = [];
- originalData.forEach((item, index) => {
- combinedData.push(item);
- const nextItem = originalData[index + 1];
- if (nextItem && nextItem['员工姓名'] !== item['员工姓名']) {
- // 如果下一个员工姓名与当前不同,插入合计数据
- const currentSummary = summaryData.shift();
- combinedData.push(currentSummary);
-
- }
- });
- // 更新表格数据
- tableData.splice(0, tableData.length, ...combinedData);
-
- }
- }
- const generateSummaryData = (data) => {
- const summaryData = [];
- let currentName = null;
- let currentSummary = null;
- data.forEach((item, index) => {
- const name = item['员工姓名'].trim(); // 获取员工姓名并去除空格
- const nextItem = data[index + 1];
- // 更新合计数据
- if (currentName === name) {
- currentSummary['日期']++;
- currentSummary['计件工资'] += parseFloat(item['计件工资']);
- currentSummary['加班工资'] += parseFloat(item['加班工资']);
- currentSummary['日工资合计'] += parseFloat(item['日工资合计']);
- } else {
- // 如果员工姓名发生改变,或者已经到达数据结尾,将上一个员工的合计数据插入到数组中
- if (currentSummary) {
- currentSummary['员工姓名'] = '合计(' + currentSummary['日期'] + '天)';
- currentSummary['计件工资'] = currentSummary['计件工资'].toFixed(2); // 保留两位小数
- currentSummary['加班工资'] = currentSummary['加班工资'].toFixed(2);
- currentSummary['日工资合计'] = currentSummary['日工资合计'].toFixed(2);
- summaryData.push(currentSummary);
- }
- // 创建新的合计数据
- currentSummary = {
- '员工姓名': name,
- '日期': 1,
- '计件工资': parseFloat(item['计件工资']),
- '加班工资': parseFloat(item['加班工资']),
- '日工资合计': parseFloat(item['日工资合计'])
- };
- currentName = name;
- }
- // 如果已经到达数据结尾,将最后一个员工的合计数据插入到数组中
- if (!nextItem) {
- currentSummary['员工姓名'] = '合计(' + currentSummary['日期'] + '天)';
- currentSummary['计件工资'] = currentSummary['计件工资'].toFixed(2); // 保留两位小数
- currentSummary['加班工资'] = currentSummary['加班工资'].toFixed(2);
- currentSummary['日工资合计'] = currentSummary['日工资合计'].toFixed(2);
- summaryData.push(currentSummary);
- }
- });
- return summaryData;
- };
- let date=ref()
- const handleNodeClick = (node, check) => {
- //存放当前节点的nodeId
- if (node.params) {
- params.date = node.params.date;
- params.sys_id = node.params.sys_id;
- total.value = node.params.total;
- date=node.params.date
- relatedList({date: params.date, department: params.sys_id,}).then(response=>{
- if (response.code === 0) {
- const originalData = response.data;
- const summaryData = generateSummaryData(originalData);
- // 将合计数据插入到原始数据中
- const combinedData = [];
- originalData.forEach((item, index) => {
- combinedData.push(item);
- const nextItem = originalData[index + 1];
- if (nextItem && nextItem['员工姓名'] !== item['员工姓名']) {
- // 如果下一个员工姓名与当前不同,插入合计数据
- const currentSummary = summaryData.shift();
- combinedData.push(currentSummary);
-
- }
- });
- // 更新表格数据
- tableData.splice(0, tableData.length, ...combinedData);
- //选中第一条记录
- // ontable(tableData[0])
- }
- })
- }
- }
- const relevancyselectData=ref([]);
- // 关联工资设置
- const onrelevancy = () => {
- if(time.value!=undefined && code.value!=undefined){
- Setting(time.value,code.value)
- }else{
- ElMessage({
- type: 'error',
- message: '请选择树形目录中的节点后,再操作此功能!'
- })
- }
-
- }
- //获取关联工资信息
- const Setting = async (date,code) => {
- const res = await setting({date:date,code:code})
- if (res.code === 0) {
- relevancyselectData.value = res.data
- formData.value.日期 = res.data[0].日期.replace(/\./g, "-")
- formData.value.关联人员工号 = res.data[0].关联人员工号
- formData.value.关联人员姓名 = res.data[0].关联人员姓名
- formData.value.日关联人数 = res.data[0].日关联人数
- formData.value.日关联系数 = res.data[0].日关联系数
- dialogFormVisible.value = true
- }
- }
- //员工编号回车事件
- const getygsubmit = (event) => {
- GetYg()
- }
- //获取员工信息
- const GetYg = async () => {
- const response = await getYg({sczl_bh:formData.value.关联人员工号});
- console.log(response)
- if (response.code === 0) {
- formData.value.关联人员姓名=response.data[0].ygxm
- formData.value.关联人员工号=response.data[0].员工编号
- Setting(formData.value.日期,formData.value.关联人员工号)
- }
- }
- function onflushed() {
- Setting(formData.value.日期,formData.value.关联人员工号)
- }
- const relevancySelection=ref([])
- //列表勾选
- const relevancySelectionChange = (val) => {
- relevancySelection.value = val.map(item => {
- return {
- UniqID: item.UniqID,
- };
- });
- console.log(relevancySelection.value)
- }
- const copyselectData=ref([])
- // 组员复制
- const oncopy = () => {
- formData.value.old_time = '';
- formData.value.new_time = '';
- copyselectData.value = [];
- copySelection.value = [];
- copyshow.value=true
- }
- //时间回车/失去焦点事件
- const getcopylist = (event, inputName) => {
- if(formData.value.old_time){
- copyLst({date:formData.value.old_time}).then(response=>{
- if (response.code === 0) {
- copyselectData.value=response.data
- }
- })
- }
- }
- const copySelection=ref([])
- //列表勾选
- const copySelectionChange = (val) => {
- copySelection.value = val.map(item => {
- return {
- old_time:formData.value.old_time,
- new_time:formData.value.new_time,
- 关联员工: item.员工编号
- };
- });
- }
- const oncopyup = () => {
- if(!formData.value.old_time){
- ElMessage({
- type: 'error',
- message: '请填写日期'
- })
- return
- }
- if(!formData.value.new_time){
- ElMessage({
- type: 'error',
- message: '请填写目标日期'
- })
- return
- }
- if(copySelection.value.length==0){
- ElMessage({
- type: 'error',
- message: '请勾选复制人员'
- })
- return
- }
- copySelection.value.forEach(subArr => {
- subArr.old_time = formData.value.old_time;
- subArr.new_time = formData.value.new_time;
- });
- copy(copySelection.value).then(response=>{
- if (response.code === 0) {
- ElMessage({
- type: 'success',
- message: '复制成功'
- })
- copyshow.value=false
- }
- })
-
- }
- // 更新关联系数
- const uprelevancy = () => {
- ElMessageBox.confirm('确定要执行此操作吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- UpdateNum()
- })
- }
- //更新关联系数
- const UpdateNum = async () => {
- const response = await updateNum({date:formData.value.日期,code:formData.value.关联人员工号,num:formData.value.日关联系数});
- if (response.code === 0) {
- ElMessage({
- type: 'success',
- message: '更新成功'
- })
- tableData[rowIndex.value].关联系数=formData.value.日关联系数
- }
- }
- // 批量删除
- const batchdel = () => {
- ElMessageBox.confirm('确定要删除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- BatchDel()
- })
- }
- //删除提交
- const BatchDel = async () => {
- const response = await batchDel(relevancySelection.value);
- if (response.code === 0) {
- ElMessage({
- type: 'success',
- message: '删除成功'
- })
- Setting(formData.value.日期,formData.value.关联人员工号)
- }
- }
- //关联表格双击事件
- const relevancySelectClick = (row, column, event) => {
- console.log(row.日期)
- console.log(row.班组员工编号)
- WeightDetail(row.日期,row.班组员工编号)
- }
- //获取关联员工信息
- const WeightDetail = async (date,code) => {
- const response = await weightDetail({date:date,code:code.split("(")[0]});
- console.log(response.data[0].员工编号)
- if (response.code === 0) {
- formData.value.员工编号=response.data[0].员工编号
- formData.value.姓名=response.data[0].姓名
- formData.value.部门名称=response.data[0].部门名称
- formData.value.职务=response.data[0].职务
- formData.value.入职日期=response.data[0].入职日期
- formData.value.关联权重=response.data[0].关联权重
- console.log(formData)
- positioningVisibleshow.value=true
- }
- }
- // 批量添加
- const batchadd = () => {
- BatchAddLst()
- }
- const batchaddselectData=ref([])
- //批量附加组员列表
- const BatchAddLst = async () => {
- const response = await batchAddLst({date:formData.value.日期});
- if (response.code === 0) {
- batchaddselectData.value=response.data
- formData.value.定位 = ''
- batchaddshow.value=true
- }
- }
- // 批量附加组员搜索
- const oninvestigate = () => {
- batchAddSearch({date:formData.value.日期,search:formData.value.定位}).then(response=>{
- if (response.code === 0) {
- batchaddselectData.value=response.data
- }
- })
- }
- const batchaddSelection=ref([])
- //列表勾选
- const batchaddSelectionChange = (val) => {
- batchaddSelection.value = val.map(item => {
- return {
- date: formData.value.日期,
- 关联员工: formData.value.关联人员工号,
- 被关联员工: item.bh,
- 关联系数: formData.value.日关联系数,
- };
- });
- console.log(batchaddSelection.value)
- }
- //提交
- const batchup = () => {
-
- BatchAdd()
- }
- //提交数组
- const BatchAdd= async () => {
-
- const batch = batchaddSelection.value.map((item) => {
- return { sys_id: sys_id, ...item};
- });
- const response = await batchAdd(batch);
- if (response.code === 0) {
- Setting(formData.value.日期,formData.value.关联人员工号)
- batchaddshow.value=false
- }
- }
- // 搜索
- const onSearch = () => {
- console.log(params.date)
- console.log(searchInfo.value)
- console.log(params.sys_id)
- if(params.date && searchInfo.value && params.sys_id){
- Relatedsearch()
- }
-
- }
- //定位
- const fillTableData = (data) => {
- tableData.splice(0, tableData.length, ...data);
- };
- const Relatedsearch = async () => {
- const response = await relatedsearch({
- date: params.date,
- search: searchInfo.value,
- department: params.sys_id
- });
- if (response.code === 0) {
- const filledData = response.data.map((item) => {
- return item;
- });
- // Update table data using await to ensure data is updated before proceeding
- await fillTableData(filledData);
- }
- };
- // ============== 表格控制部分结束 ===============
- // 获取需要的字典 可能为空 按需保留
- const setOptions = async () => {
- }
- // 获取需要的字典 可能为空 按需保留
- setOptions()
- // 多选数据
- const multipleSelection = ref([])
- let code=ref()
- let time=ref()
- // 多选
- const handleSelectionChange = (val,row) => {
- if(val.length>0){
- multipleSelection.value = val
- const lenth=val.length
- code=val[lenth-1].员工编号
- time=val[lenth-1].日期
- formData.value.员工编号=val[lenth-1].员工编号,
- formData.value.员工姓名= val[lenth-1].员工姓名,
- formData.value.日期=val[lenth-1].日期,
- formData.value.关联系数= val[lenth-1].关联系数,
- formData.value.关联人数= val[lenth-1].关联人数
- val.splice(0, val.length); // 清空 val 数组
- }
- }
- // 批量删除控制标记
- const deleteVisible = ref(false)
- // 多选删除
- const onDelete = async () => {
- const ids = []
- if (multipleSelection.value.length === 0) {
- ElMessage({
- type: 'warning',
- message: '请选择要删除的数据'
- })
- return
- }
- multipleSelection.value &&
- multipleSelection.value.map(item => {
- ids.push(item.ID)
- })
- const res = await deleteCompanyByIds({ ids })
- if (res.code === 0) {
- ElMessage({
- type: 'success',
- message: '删除成功'
- })
- if (tableData.value.length === ids.length && page.value > 1) {
- page.value--
- }
- deleteVisible.value = false
- getTableData()
- }
- }
- // 行为控制标记(弹窗内部需要增还是改)
- const type = ref('')
- // 更新行
- const updateCompanyFunc = async (row) => {
- const res = await findCompany({ ID: row.ID })
- type.value = 'update'
- if (res.code === 0) {
- formData.value = res.data.recompany
- dialogFormVisible.value = true
- }
- }
- // 弹窗控制标记
- const dialogFormVisible = ref(false)
- const positioningVisibleshow = ref(false)
- const weightDetailVisible = ref(false)
- const batchaddshow = ref(false)
- const copyshow = ref(false)
- // 打开弹窗
- const openDialog = () => {
- type.value = 'create'
- dialogFormVisible.value = true
- }
- // 关闭弹窗
- const closeDialog = () => {
- dialogFormVisible.value = false
- formData.value = {
- address: '',
- image: '',
- name: '',
- }
- }
- // 弹窗确定
- const enterDialog = async () => {
- elFormRef.value?.validate(async (valid) => {
- if (!valid) return
- let res
- switch (type.value) {
- case 'create':
- res = await createCompany(formData.value)
- break
- case 'update':
- res = await updateCompany(formData.value)
- break
- default:
- res = await createCompany(formData.value)
- break
- }
- if (res.code === 0) {
- ElMessage({
- type: 'success',
- message: '创建/更改成功'
- })
- closeDialog()
- getTableData()
- }
- })
- }
- // 单击表格操作
- const rowIndex=ref()
- function ontable(row) {
- console.log(row)
- code.value=row.员工编号
- time.value=row.日期
- rowIndex.value = tableData.indexOf(row);
- RelatedAllList(time.value.replace(".","").substr(0,6),code.value)
- }
- let temporary = {
- 员工编号: '',
- 员工姓名: '',
- 日期: '',
- 关联系数: '',
- 关联人数: ''
- };
- //获取下列表
- const RelatedAllList = async (date,bh) => {
- const response = await relatedAllList({date:date,code:bh});
- if(response.code==0){
- console.log(response)
- tableData2.splice(0, tableData2.length, ...response.data);
- }
- }
- // 双击表格操作
- function doubleClick(row, column, event) {
- // console.log(row, column, event);
- // // updateCompanyFunc(row);
- // type.value = 'update';
- // dialogFormVisible.value = true
- Setting(time.value,code.value)
- }
- // 导出excel
- function exportExcel() {
- if(tableData.length<1){
- ElMessage({
- type: 'error',
- message: '请确认上方表格内是否存在内容'
- })
- }else{
- exportExcelFile(tableData,tableCols1)
- }
-
- }
- function exportExcel2() {
-
- if(tableData2.length<1){
- ElMessage({
- type: 'error',
- message: '请确认下方表格内是否存在内容'
- })
- }else{
- exportExcelFile(tableData2,tableCols2)
- }
- }
- const exportExcelFile = (tableData, tableCols) => {
- const data = tableData.map(row => {
- const rowData = {};
- tableCols.forEach(column => {
- rowData[column.label] = row[column.prop];
- });
- return rowData;
- });
- const worksheet = XLSX.utils.json_to_sheet(data);
- const workbook = XLSX.utils.book_new();
- XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
- XLSX.writeFile(workbook, 'exported_table.xlsx');
- };
- // 生命周期钩子
- onMounted(async () => {
- });
- </script>
- <style>
- .JKWTree-container {
- display: flex;
- }
- .JKWTree-tree {
- width: 300px;
- background-color: #fff;
- padding: 10px;
- margin-right: 20px;
- }
- .JKWTree-tree h3 {
- font-size: 15px;
- font-weight: 700;
- margin: 10px 0;
- }
- .JKWTree-content {
- flex: 1;
- }
- /* 选中某行时的背景色*/
- .el-table__body tr.current-row>td {
- background: #ff80ff !important;
- /* 背景颜色 */
- }
- </style>
- <style scoped>
- :deep(.el-table td .cell) {
- line-height: 20px !important;
- }
- :deep(.el-tabs__header){
- margin-bottom: 0;
- }
- .search{
- margin-left: 0px !important;
- margin-right: 10px !important;
- }
- .bt{
- margin-left: 2px !important;
- padding: 3px !important;
- font-size: 12px;
- }
- .el-tabs__header{
- margin: 0px !important;
- }
- .gva-table-box{
- padding: 0px !important;
- }
- .mab{
- margin-bottom: 5px;
- }
- </style>
|