查询条件修改
This commit is contained in:
@@ -78,7 +78,10 @@
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">所属区域:</text>
|
||||
<uni-data-select v-model="formData.filterSelectDeptIds" :localdata="executeDeptOptions" placeholder="请选择所属区域" @change="onExecuteDeptChange"></uni-data-select>
|
||||
<uni-data-picker ref="picker" class="picker" placeholder="请选择所属区域" popup-title="请选择所属区域" :localdata="regions" v-model="formData.deptTags"
|
||||
@change="onchange" >
|
||||
</uni-data-picker>
|
||||
<!-- <uni-data-select v-model="formData.filterSelectDeptIds" :localdata="executeDeptOptions" placeholder="请选择所属区域" @change="onExecuteDeptChange"></uni-data-select> -->
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">帮扶时间:</text>
|
||||
@@ -255,6 +258,9 @@ const getBackgroundStyle = (imageName) => ({
|
||||
backgroundPosition: 'center', // 居中
|
||||
backgroundRepeat: 'no-repeat'
|
||||
});
|
||||
// 所属区域选项(可根据实际替换为动态数据)
|
||||
const regions = ref([])
|
||||
const picker = ref(null)
|
||||
function listNotParam(){
|
||||
let header={
|
||||
'Authorization':uni.getStorageSync('Padmin-Token'),
|
||||
@@ -263,14 +269,15 @@ function listNotParam(){
|
||||
let params={}
|
||||
$api.myRequest('/dispatch/dept/listNotParam',params,'get',9100,header).then((resData) => {
|
||||
if(resData && resData.code == 200){
|
||||
resData.data.forEach(item=>{
|
||||
const obj = {
|
||||
value: item.deptId,
|
||||
text: item.deptName,
|
||||
ancestors:item.ancestors
|
||||
}
|
||||
executeDeptOptions.value.push(obj)
|
||||
})
|
||||
loadLevelData(resData.data[0].parentId);
|
||||
// resData.data.forEach(item=>{
|
||||
// const obj = {
|
||||
// value: item.deptId,
|
||||
// text: item.deptName,
|
||||
// ancestors:item.ancestors
|
||||
// }
|
||||
// executeDeptOptions.value.push(obj)
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -348,7 +355,8 @@ function onExecuteDeptChange(e){
|
||||
formData.executeDeptId=e
|
||||
}
|
||||
function handleSearch(){
|
||||
formData.pageSize=1
|
||||
formData.pageNum=1
|
||||
console.log("formData",formData)
|
||||
dataList.value=[]
|
||||
getDataList()
|
||||
}
|
||||
@@ -358,6 +366,7 @@ function getDataList(){
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
$api.myRequest('/dispatch/assist/records/pageRecords',formData,'get',9100,header).then((resData) => {
|
||||
console.log("resData",resData)
|
||||
resData.rows.forEach(item=>{
|
||||
item.task_type=getabelByValue(item.task_type,taskTypeOptions)
|
||||
})
|
||||
@@ -422,6 +431,86 @@ function scrollBottom(){
|
||||
formData.pageNum++
|
||||
getDataList()
|
||||
}
|
||||
}
|
||||
// 加载某一级的数据(parentId 为空表示根)
|
||||
async function loadLevelData(parentId,node) {
|
||||
let header = {
|
||||
'Authorization': uni.getStorageSync('Padmin-Token'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
};
|
||||
let params = { parentId };
|
||||
|
||||
try {
|
||||
const resData = await $api.myRequest('/dispatch/dept/list', params, 'get', 9100, header);
|
||||
if(resData.data.length==0){
|
||||
picker.value.hide()
|
||||
return
|
||||
}
|
||||
const formatted = (resData.data || []).map(item => ({
|
||||
text: item.deptName,
|
||||
value: item.tags,
|
||||
deptId: item.deptId,
|
||||
children: []
|
||||
}));
|
||||
if(node){
|
||||
injectChildren(parentId, formatted);
|
||||
}else{
|
||||
regions.value=formatted
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("加载部门数据失败:", error);
|
||||
// uni.showToast({ title: '加载失败', icon: 'none' });
|
||||
}
|
||||
}
|
||||
// 将子级数据注入到对应的父节点
|
||||
function injectChildren(parentValue, childrenData) {
|
||||
const findAndInject = (nodes) => {
|
||||
for (let node of nodes) {
|
||||
if (node.deptId === parentValue) {
|
||||
// 如果 children 已存在且非空,避免重复加载
|
||||
if (!node.children || node.children.length === 0) {
|
||||
node.children = childrenData;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
if (findAndInject(node.children)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
findAndInject(regions.value);
|
||||
// 强制更新
|
||||
}
|
||||
// 当用户选择时触发(注意:change 在每级选择后都会触发)
|
||||
function onchange(e) {
|
||||
const selectedValues = e.detail.value;
|
||||
// formData.deptId=selectedValues.map(item => item.value).join(',');
|
||||
if (selectedValues.length === 0) return;
|
||||
// 获取最后一级选中的 value
|
||||
const lastSelectedValue = selectedValues[selectedValues.length - 1];
|
||||
// 查找该节点是否有 children,如果没有则尝试加载
|
||||
const node = findNodeByValue(regions.value, lastSelectedValue);
|
||||
if (node && (!node.children || node.children.length === 0)) {
|
||||
// 检查接口是否还有下一级(可通过接口返回判断,或先尝试加载)
|
||||
// 这里我们直接尝试加载下一级
|
||||
loadLevelData(node.deptId , node);
|
||||
picker.value.show()
|
||||
}
|
||||
}
|
||||
// 工具函数:根据 value 查找节点
|
||||
function findNodeByValue(nodes, value) {
|
||||
for (let node of nodes) {
|
||||
if (node.value === value.value) {
|
||||
return node;
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
const found = findNodeByValue(node.children, value);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
onShow(()=>{
|
||||
})
|
||||
|
||||
@@ -28,7 +28,10 @@
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">所属区域:</text>
|
||||
<uni-data-select v-model="formData.deptTags" :localdata="taskTypeOptions" placeholder="请选择所属区域" @change="onTaskTypeChange"></uni-data-select>
|
||||
<uni-data-picker ref="picker" class="picker" placeholder="请选择所属区域" popup-title="请选择所属区域" :localdata="regions" v-model="formData.deptTags"
|
||||
@change="onchange" >
|
||||
</uni-data-picker>
|
||||
<!-- <uni-data-select v-model="formData.deptTags" :localdata="taskTypeOptions" placeholder="请选择所属区域" @change="onTaskTypeChange"></uni-data-select> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -221,6 +224,109 @@ const getBackgroundStyle = (imageName) => ({
|
||||
backgroundRepeat: 'no-repeat'
|
||||
});
|
||||
const emit = defineEmits(['update:showVue'])
|
||||
// 所属区域选项(可根据实际替换为动态数据)
|
||||
const regions = ref([])
|
||||
const picker = ref(null)
|
||||
function listNotParam(){
|
||||
let header={
|
||||
'Authorization':uni.getStorageSync('Padmin-Token'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
let params={}
|
||||
$api.myRequest('/dispatch/dept/listNotParam',params,'get',9100,header).then((resData) => {
|
||||
if(resData && resData.code == 200){
|
||||
loadLevelData(resData.data[0].parentId);
|
||||
// resData.data.forEach(item=>{
|
||||
// const obj = {
|
||||
// value: item.deptId,
|
||||
// text: item.deptName,
|
||||
// ancestors:item.ancestors
|
||||
// }
|
||||
// executeDeptOptions.value.push(obj)
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
// 加载某一级的数据(parentId 为空表示根)
|
||||
async function loadLevelData(parentId,node) {
|
||||
let header = {
|
||||
'Authorization': uni.getStorageSync('Padmin-Token'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
};
|
||||
let params = { parentId };
|
||||
|
||||
try {
|
||||
const resData = await $api.myRequest('/dispatch/dept/list', params, 'get', 9100, header);
|
||||
if(resData.data.length==0){
|
||||
picker.value.hide()
|
||||
return
|
||||
}
|
||||
const formatted = (resData.data || []).map(item => ({
|
||||
text: item.deptName,
|
||||
value: item.tags,
|
||||
deptId: item.deptId,
|
||||
children: []
|
||||
}));
|
||||
if(node){
|
||||
injectChildren(parentId, formatted);
|
||||
}else{
|
||||
regions.value=formatted
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("加载部门数据失败:", error);
|
||||
// uni.showToast({ title: '加载失败', icon: 'none' });
|
||||
}
|
||||
}
|
||||
// 将子级数据注入到对应的父节点
|
||||
function injectChildren(parentValue, childrenData) {
|
||||
const findAndInject = (nodes) => {
|
||||
for (let node of nodes) {
|
||||
if (node.deptId === parentValue) {
|
||||
// 如果 children 已存在且非空,避免重复加载
|
||||
if (!node.children || node.children.length === 0) {
|
||||
node.children = childrenData;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
if (findAndInject(node.children)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
findAndInject(regions.value);
|
||||
// 强制更新
|
||||
}
|
||||
// 当用户选择时触发(注意:change 在每级选择后都会触发)
|
||||
function onchange(e) {
|
||||
const selectedValues = e.detail.value;
|
||||
// formData.deptId=selectedValues.map(item => item.value).join(',');
|
||||
if (selectedValues.length === 0) return;
|
||||
// 获取最后一级选中的 value
|
||||
const lastSelectedValue = selectedValues[selectedValues.length - 1];
|
||||
// 查找该节点是否有 children,如果没有则尝试加载
|
||||
const node = findNodeByValue(regions.value, lastSelectedValue);
|
||||
if (node && (!node.children || node.children.length === 0)) {
|
||||
// 检查接口是否还有下一级(可通过接口返回判断,或先尝试加载)
|
||||
// 这里我们直接尝试加载下一级
|
||||
loadLevelData(node.deptId , node);
|
||||
picker.value.show()
|
||||
}
|
||||
}
|
||||
// 工具函数:根据 value 查找节点
|
||||
function findNodeByValue(nodes, value) {
|
||||
for (let node of nodes) {
|
||||
if (node.value === value.value) {
|
||||
return node;
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
const found = findNodeByValue(node.children, value);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getDictionary(){
|
||||
$api.myRequest('/system/public/dict/data/type/person_database_status').then((resData) => {
|
||||
if(resData && resData.code == 200){
|
||||
@@ -348,6 +454,7 @@ function scrollBottom(){
|
||||
}
|
||||
}
|
||||
onLoad((options) => {
|
||||
listNotParam()
|
||||
if(options.allocationId){
|
||||
formData.allocationId=options.allocationId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user