|
|
@@ -16,7 +16,7 @@
|
|
|
<div class="gva-table-box">
|
|
|
<el-form>
|
|
|
<el-form-item>
|
|
|
- <el-input v-model="searchInfo" placeholder="输入员工编号" style="width: 180px;" />
|
|
|
+ <el-input v-model="searchInfo" placeholder="输入员工编号" style="width: 180px;" @keyup.enter.native="onSearch"/>
|
|
|
<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>
|
|
|
@@ -238,6 +238,16 @@
|
|
|
</el-table>
|
|
|
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <!-- 员工选择 -->
|
|
|
+ <el-dialog v-model="dialogSelectVisible_Yg" title="选择" destroy-on-close width="300px"
|
|
|
+ @keydown="selectGX_Yg($event)">
|
|
|
+ <el-table tooltip-effect="dark" :data="selectData_Yg" row-key="ID" highlight-current-row="true"
|
|
|
+ border style="width:100%" @row-dblclick="handleSelectClick_Yg" ref="table_Yg">
|
|
|
+ <el-table-column prop="员工编号" label="员工编号" width="100" />
|
|
|
+ <el-table-column prop="ygxm" label="员工姓名" width="200" />
|
|
|
+ </el-table>
|
|
|
+ </el-dialog>
|
|
|
|
|
|
</el-main>
|
|
|
</el-container>
|
|
|
@@ -675,16 +685,77 @@
|
|
|
}
|
|
|
//获取员工信息
|
|
|
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.关联人员工号)
|
|
|
+ const response = await getYg({ sczl_bh: formData.value.关联人员工号 });
|
|
|
+ if (response.code == 0) {
|
|
|
+ if (response.data.length == 1) {
|
|
|
+ formData.value.关联人员姓名 = response.data[0].ygxm
|
|
|
+ formData.value.关联人员工号 = response.data[0].员工编号
|
|
|
+ } else if (response.data.length > 1) {
|
|
|
+ selectData_Yg.splice(0, selectData_Yg.length, ...response.data)
|
|
|
+ setGXCurrent_Yg(selectData_Yg[0])
|
|
|
+ dialogSelectVisible_Yg.value = true
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ type: 'warning',
|
|
|
+ message: '未查询到该员工'
|
|
|
+ })
|
|
|
+ formData.value.关联人员姓名 = ''
|
|
|
+ formData.value.关联人员工号 = ''
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formData.value.关联人员姓名 = ''
|
|
|
+ formData.value.关联人员工号 = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const dialogSelectVisible_Yg = ref(false)
|
|
|
+ const selectData_Yg = reactive([])
|
|
|
+ // 处理选择框
|
|
|
+ const handleSelectClick_Yg = (row, column, event) => {
|
|
|
+ if(dialogFormVisible.value){
|
|
|
+ formData.value.关联人员姓名 = row.ygxm
|
|
|
+ formData.value.关联人员工号 = row.员工编号
|
|
|
+ }else{
|
|
|
+ searchInfo.value = row.员工编号
|
|
|
+ Relatedsearch()
|
|
|
+ }
|
|
|
+ dialogSelectVisible_Yg.value = false
|
|
|
+ }
|
|
|
+ const currentIndex_Yg = ref(0);
|
|
|
+ const GXCurrent_Yg = ref(0);
|
|
|
+ const selectGX_Yg = (event) => {
|
|
|
+ if (event.keyCode === 40) { // 向下箭头
|
|
|
+ if (currentIndex_Yg.value < selectData_Yg.length - 1) {
|
|
|
+ currentIndex_Yg.value++;
|
|
|
+ setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]);
|
|
|
+ } else {
|
|
|
+ currentIndex_Yg.value = 0;
|
|
|
+ setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]); // 到达最后一行时回到第一行
|
|
|
+ }
|
|
|
+ } else if (event.keyCode === 38) { // 向上箭头
|
|
|
+ if (currentIndex_Yg.value > 0) {
|
|
|
+ currentIndex_Yg.value--;
|
|
|
+ setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]);
|
|
|
+ } else {
|
|
|
+ currentIndex_Yg.value = selectData_Yg.length - 1;
|
|
|
+ setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]); // 到达第一行时回到最后一行
|
|
|
+ }
|
|
|
+ } else if (event.keyCode === 13) { // 回车键
|
|
|
+ dialogSelectVisible_Yg.value = false;
|
|
|
}
|
|
|
}
|
|
|
+ const table_Yg = ref()
|
|
|
+ const setGXCurrent_Yg = (row) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ table_Yg.value?.setCurrentRow(row)
|
|
|
+ if(dialogFormVisible.value){
|
|
|
+ formData.value.关联人员姓名 = row.ygxm
|
|
|
+ formData.value.关联人员工号 = row.员工编号
|
|
|
+ }else{
|
|
|
+ searchInfo.value = row.员工编号
|
|
|
+ Relatedsearch()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
function onflushed() {
|
|
|
Setting(formData.value.日期, formData.value.关联人员工号)
|
|
|
@@ -930,18 +1001,34 @@
|
|
|
|
|
|
// 搜索
|
|
|
const onSearch = () => {
|
|
|
- console.log(params.date)
|
|
|
- console.log(searchInfo.value)
|
|
|
- console.log(params.sys_id)
|
|
|
- if (params.date && searchInfo.value && params.sys_id) {
|
|
|
+ if (!params.date || !params.sys_id){
|
|
|
+ ElMessage({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请先选择车间'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (searchInfo.value) {
|
|
|
+ getYg({ sczl_bh: searchInfo.value}).then(response=>{
|
|
|
+ if (response.code == 0) {
|
|
|
+ if (response.data.length == 1) {
|
|
|
+ searchInfo.value = response.data[0].员工编号
|
|
|
+ Relatedsearch()
|
|
|
+ } else if (response.data.length > 1) {
|
|
|
+ selectData_Yg.splice(0, selectData_Yg.length, ...response.data)
|
|
|
+ setGXCurrent_Yg(selectData_Yg[0])
|
|
|
+ dialogSelectVisible_Yg.value = true
|
|
|
+ } else {
|
|
|
+ Relatedsearch()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Relatedsearch()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
Relatedsearch()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- //定位
|
|
|
- const fillTableData = (data) => {
|
|
|
- tableData.splice(0, tableData.length, ...data);
|
|
|
- };
|
|
|
|
|
|
const Relatedsearch = async () => {
|
|
|
const response = await relatedsearch({
|
|
|
@@ -949,14 +1036,32 @@
|
|
|
search: searchInfo.value,
|
|
|
department: params.sys_id
|
|
|
});
|
|
|
- if (response.code === 0) {
|
|
|
- const filledData = response.data.map((item) => {
|
|
|
- return item;
|
|
|
+
|
|
|
+ if(response.code==0){
|
|
|
+ if(!response.data.length){
|
|
|
+ tableData.splice(0, tableData.length, ...[]);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- // Update table data using await to ensure data is updated before proceeding
|
|
|
- await fillTableData(filledData);
|
|
|
+ //插入最后一个员工的合计
|
|
|
+ combinedData.push(summaryData[0]);
|
|
|
+ // 更新表格数据
|
|
|
+ tableData.splice(0, tableData.length, ...combinedData);
|
|
|
}
|
|
|
+
|
|
|
};
|
|
|
// ============== 表格控制部分结束 ===============
|
|
|
|