提交 b7b16f3f authored 作者: lidongxu's avatar lidongxu

feat(post): 添加岗位时-选择考勤规则-开窗显示和查询完成

同上
上级 19c2f90a
<template> <template>
<div> <div>
<el-form ref="form" :model="openForm" inline> <el-form
<el-form-item v-for="(obj, key) in openForm" :key="key" :label="obj.name"> :model="form"
inline>
<el-form-item v-for="(obj, key) in form"
:key="key"
:label="obj.name">
<template v-if="obj.type === 'input'"> <template v-if="obj.type === 'input'">
<el-input prefix-icon="el-icon-search" v-model="obj.value" clearable @input="sel"></el-input> <el-input prefix-icon="Search"
v-model="obj.value"
clearable
@input="sel"></el-input>
</template> </template>
<!-- 添加其他表单类型的模板 --> <!-- 添加其他表单类型的模板 -->
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 添加表格和其他内容 --> <!-- 添加表格和其他内容 -->
<el-table ref="myTable"
:data="tableData"
v-loading="tableLoading"
highlight-selection-row
@select="selectFn"
@select-all="selectAllFn">
<el-table-column v-if="tableData.length > 0"
type="selection"
width="50">
</el-table-column>
<el-table-column v-for="obj in tableHeaderList"
:prop="Object.keys(obj)[0]"
:label="Object.values(obj)[0]"
:formatter="formatterFn"
show-overflow-tooltip
width="130">
</el-table-column>
</el-table>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue';
import { debounce } from '@/utils'; import { debounce } from '@/utils';
const openForm = ref({}); const form = ref({}); // 表单对象
const formOrder = ref([]);
const tableHeaderList = ref([]); const tableHeaderList = ref([]);
const tableData = ref([]); const tableData = ref([]);
const tableLoading = ref(true); const tableLoading = ref(false);
const isOnlyLoadData = ref(false); const isOnlyLoadData = ref(false); // 仅加载数据(因为标签和数据是在一个对象传进来的)
const props = defineProps({ const props = defineProps({
openObj: { // 结构+数据
modelValue: {
type: Object, type: Object,
required: true required: true
}, },
isCheckBox: { // 查询参数
type: Boolean, queryParams: {
default: false type: Object,
}, required: true
nodeKeys: {
type: [String, Number]
} }
}); });
watch(props.openObj, (newValue) => { const emits = defineEmits(['sel', 'update:queryParams']);
console.log('newValue', newValue)
const newObj = {}; watch(() => props.modelValue, (newValue) => {
const order = []; // 加载结构
if (!isOnlyLoadData.value) { if (!isOnlyLoadData.value) {
newValue.boxhead.forEach((obj, index) => { // 准备表单结构
newObj[obj.select_key] = obj; newValue.boxhead.forEach(obj => {
order.push(obj.select_key); form.value[obj.select_key] = obj;
}); });
openForm.value = newObj; tableHeaderList.value = newValue.queryDisplay;
formOrder.value = order;
} }
tableHeaderList.value = newValue.queryDisplay; // 加载数据
tableData.value = newValue.rows; tableData.value = newValue.rows;
tableLoading.value = false; tableLoading.value = false;
}, {
deep: true,
immediate: true
}); });
const formatterFn = (row, column) => { const formatterFn = (row, column) => {
return row[column.property] || '无'; return row[column.property] || '无';
}; };
// 搜索框值变化
const sel = debounce(() => { const sel = debounce(() => {
tableLoading.value = true; tableLoading.value = true;
isOnlyLoadData.value = true; isOnlyLoadData.value = true;
const queryObj = {}; const query = {};
Object.entries(openForm.value).forEach(([key, value]) => { Object.entries(form.value).forEach(([key, value]) => {
if (value.value) { if (value.value) {
queryObj[key] = value.value.trim(); query[key] = value.value.trim();
} }
}); });
emit('sel', queryObj); emits('update:queryParams', query);
emits('sel');
}); });
const selectAllFn = (rows) => { const selectAllFn = (rows) => {
if (!props.isCheckBox) { if (!props.isCheckBox) {
table.clearSelection(); table.clearSelection();
emit('input', []); emits('input', []);
} }
}; };
...@@ -82,7 +108,7 @@ const selectFn = (rows) => { ...@@ -82,7 +108,7 @@ const selectFn = (rows) => {
table.clearSelection(); table.clearSelection();
rows.length > 0 && table.toggleRowSelection(rows[rows.length - 1]); rows.length > 0 && table.toggleRowSelection(rows[rows.length - 1]);
} }
emit('input', rows.length > 0 ? [rows[rows.length - 1]] : []); emits('input', rows.length > 0 ? [rows[rows.length - 1]] : []);
}; };
</script> </script>
......
...@@ -444,4 +444,8 @@ const handleExport = () => { ...@@ -444,4 +444,8 @@ const handleExport = () => {
::v-deep(.el-date-editor) { ::v-deep(.el-date-editor) {
width: 100% !important; width: 100% !important;
} }
::v-deep(.el-select){
width: 100%;
}
</style> </style>
\ No newline at end of file
...@@ -178,7 +178,9 @@ ...@@ -178,7 +178,9 @@
</template> </template>
</el-input-tag> </el-input-tag>
</template> </template>
<open-dialog :openObj="attStruData" /> <open-dialog v-model="attStruData"
v-model:queryParams="attQuery"
@sel="getAttOpenDialog" />
</el-popover> </el-popover>
</el-form-item> </el-form-item>
<el-form-item label="岗位状态" <el-form-item label="岗位状态"
...@@ -258,13 +260,9 @@ ...@@ -258,13 +260,9 @@
// 获取考勤规则-开窗数据+结构 // 获取考勤规则-开窗数据+结构
const getAttOpenDialog = async () => { const getAttOpenDialog = async () => {
const { data } = await attendanceOpenFQAPI(attQuery.value) const { data } = await attendanceOpenFQAPI(attQuery.value)
console.log(data)
attStruData.value = data attStruData.value = data
} }
getAttOpenDialog() getAttOpenDialog()
const attendanceSelFn = () => {
}
/** 取消按钮 */ /** 取消按钮 */
function cancel() { function cancel() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论