<template>
|
<FYTable
|
:data="data"
|
:total-count="total"
|
@search="onSearch"
|
:extraHeight="tabsHeaderHeight"
|
:defaultPageSize="10"
|
>
|
<template #options>
|
<FYOptionLocation
|
:disabled="true"
|
:checkStrictly="false"
|
:initValue="false"
|
:allOption="false"
|
:level="3"
|
v-model:value="formSearch._locations"
|
></FYOptionLocation>
|
</template>
|
<!-- <template #buttons> </template> -->
|
<template #table-column>
|
<el-table-column
|
fixed="left"
|
sortable
|
prop="ncNum"
|
label="编号"
|
width="100"
|
>
|
</el-table-column>
|
<el-table-column
|
fixed="left"
|
prop="ncItemName"
|
label="项目名称"
|
:show-overflow-tooltip="true"
|
width="400"
|
>
|
</el-table-column>
|
<!-- <el-table-column prop="ncItemUnit" label="业主单位" width="130" /> -->
|
<!-- <el-table-column prop="ncProvinceName" label="省" width="90" />
|
<el-table-column prop="ncCityName" label="市" width="90" /> -->
|
<!-- <el-table-column prop="ncDistrictName" label="区县" width="90" /> -->
|
<!-- <el-table-column prop="townname" label="街道" width="110" /> -->
|
<el-table-column
|
prop="ncConstructionUnit"
|
label="施工单位"
|
min-width="100"
|
/>
|
<el-table-column prop="ncPerson" label="申请人" width="110" />
|
<el-table-column prop="ncApplyContent" label="申请内容" width="110" />
|
<el-table-column prop="ncStartDate" label="申请时间" width="110">
|
<template #default="{ row }">
|
{{ $fm.formatYMD(row.ncCreateTime) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="ncStartDate" label="工期开始" width="110">
|
<template #default="{ row }">
|
{{ $fm.formatYMD(row.ncStartDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="ncEndDate" label="工期结束" width="110">
|
<template #default="{ row }">
|
{{ $fm.formatYMD(row.ncEndDate) }}
|
</template>
|
</el-table-column>
|
<!-- <el-table-column prop="ncCreateTime" label="申请时间" width="110" >
|
<template #default="{row}">
|
{{ $fm.formatYMD(row.ncCreateTime) }}
|
</template>
|
</el-table-column> -->
|
<el-table-column prop="ncUserId" label="匹配用户">
|
<template #default="{ row }">
|
<el-text
|
:loading="row._loading"
|
:type="row._user ? 'primary' : 'danger'"
|
>{{ row._user ? row._user.realname : '未匹配' }}</el-text
|
>
|
</template>
|
</el-table-column>
|
<el-table-column fixed="right" label="操作" width="80">
|
<template #default="{ row }">
|
<el-button
|
:disabled="row._loading"
|
type="default"
|
size="small"
|
@click="itemEdit(row)"
|
>编辑</el-button
|
>
|
</template>
|
</el-table-column>
|
</template>
|
</FYTable>
|
<el-dialog v-model="dialog" destroy-on-close>
|
<CompInfoSearchFysp
|
v-model="selectedSVUser"
|
:area="area"
|
:defaultText="defaultText"
|
searchTextWidth="400px"
|
/>
|
<template #footer>
|
<el-button @click="dialog = false">取消</el-button>
|
<el-button type="primary" @click="submit" :disabled="!selectedSVUser?.svUserId"
|
>确定</el-button
|
>
|
</template>
|
</el-dialog>
|
</template>
|
<script setup>
|
import { ref, inject, computed } from 'vue';
|
import nightConstructionApi from '@/api/fysp/nightConstructionApi';
|
import userApi from '@/api/fysp/userApi';
|
import CompInfoSearchFysp from '@/views/fysp/config/components/CompInfoSearchFysp.vue';
|
import { ElMessage } from 'element-plus';
|
|
const tabsHeaderHeight = inject('tabsHeaderHeight', 0);
|
|
const formSearch = ref({
|
_locations: {
|
pCode: '31',
|
pName: '上海市',
|
cCode: '3100',
|
cName: '上海市',
|
dCode: '310106',
|
dName: '静安区'
|
}
|
});
|
// 夜间施工记录及总数
|
const data = ref([]);
|
const total = ref(0);
|
|
// 夜间施工记录匹配弹窗
|
const dialog = ref(false);
|
const selectedSVUser = ref(null);
|
const selectedRow = ref(null);
|
const area = ref({
|
provincecode: '31',
|
provincename: '上海市',
|
citycode: '3100',
|
cityname: '上海市',
|
districtcode: '310106',
|
districtname: '静安区',
|
scensetypeid: '1'
|
});
|
const defaultText = computed(() => {
|
return selectedRow.value?.ncItemName || undefined;
|
});
|
|
function onSearch(page, callback) {
|
return nightConstructionApi
|
.fetchRecord({
|
cityCode: '3100',
|
districtCode: '310106',
|
page: page.currentPage,
|
perPage: page.pageSize
|
})
|
.then((res) => {
|
if (res.success) {
|
data.value = res.data;
|
data.value.forEach((d) => {
|
d._loading = true;
|
if (d.ncUserId) {
|
userApi
|
.getUserById(d.ncUserId)
|
.then((res1) => {
|
d._user = res1;
|
})
|
.finally(() => {
|
d._loading = false;
|
});
|
} else {
|
d._loading = false;
|
}
|
});
|
total.value = res.head.totalCount;
|
callback();
|
}
|
});
|
}
|
|
function itemEdit(row) {
|
selectedRow.value = row;
|
selectedSVUser.value = {
|
svUserId: row._user?.guid,
|
svUserName: row._user?.realname,
|
...row._user
|
};
|
dialog.value = true;
|
}
|
|
function submit() {
|
if (!selectedSVUser.value) {
|
return ElMessage.error('请选择用户');
|
}
|
nightConstructionApi
|
.updateRecord({
|
recordId: selectedRow.value.ncId,
|
userId: selectedSVUser.value.guid,
|
sceneId: selectedSVUser.value.dguid
|
})
|
.then((res) => {
|
if (res.success) {
|
selectedRow.value.ncUserId = res.data.ncUserId;
|
selectedRow.value.ncSceneId = res.data.ncSceneId;
|
userApi
|
.getUserById(selectedRow.value.ncUserId)
|
.then((res1) => {
|
selectedRow.value._user = res1;
|
})
|
.finally(() => {
|
selectedRow.value._loading = false;
|
});
|
}
|
})
|
.finally(() => {
|
dialog.value = false;
|
selectedRow.value._user = selectedSVUser.value;
|
});
|
}
|
</script>
|