| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- <template>
- <view class="page report-page">
- <view class="mode-tabs">
- <view
- v-for="item in modeOptions"
- :key="item.value"
- class="mode-tab"
- :class="{ active: currentMode === item.value }"
- @click="switchMode(item.value)">
- {{ item.label }}
- </view>
- </view>
- <z-paging
- ref="paging"
- v-model="dataList"
- class="report-paging"
- :fixed="false"
- :default-page-size="10"
- @query="queryList">
- <view class="report-list">
- <view class="report-card" v-for="item in dataList" :key="item.id">
- <view class="card-header">
- <view>
- <view class="card-date">{{ formatDate(item.createTime) }}</view>
- </view>
- <view class="status-tag">
- {{ rdStatusDict[item.rdStatus] || item.rdStatus || "--" }}
- </view>
- </view>
- <view class="card-body">
- <view class="field-row">
- <text class="field-label">施工队伍</text>
- <text class="field-value">{{ item.deptName || "--" }}</text>
- </view>
- <view class="field-row">
- <text class="field-label">任务</text>
- <text class="field-value">{{ item.taskName || "--" }}</text>
- </view>
- <view class="field-row brief-row">
- <text class="field-label">施工简报</text>
- <UniTooltip
- :content="item.constructionBrief || '--'"
- placement="top">
- <text class="field-value brief-text">{{
- item.constructionBrief || "--"
- }}</text>
- </UniTooltip>
- </view>
- </view>
- <view v-if="item.lastGroupIdFlag" class="summary-panel">
- <view class="summary-header" @click="toggleSummary(item.id)">
- <text>组汇总</text>
- <uni-icons
- :type="isSummaryExpanded(item.id) ? 'up' : 'down'"
- color="#004098"
- size="16" />
- </view>
- <view v-if="isSummaryExpanded(item.id)" class="summary-grid">
- <view
- class="summary-item"
- v-for="field in summaryFields"
- :key="field.key">
- <text class="summary-label">{{ field.label }}</text>
- <text class="summary-value">{{
- formatValue(item[field.key])
- }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </z-paging>
- <UniFab
- :pattern="fabPattern"
- horizontal="right"
- vertical="bottom"
- direction="horizontal"
- :popMenu="false"
- @fabClick="openFilterPopup" />
- <uni-popup
- ref="filterPopup"
- type="bottom"
- background-color="#fff"
- border-radius="10px 10px 0 0">
- <view class="filter-popup">
- <view class="filter-header">
- <text class="filter-action" @click="closeFilterPopup">取消</text>
- <text class="filter-title">筛选条件</text>
- <text class="filter-action primary" @click="applyFilter">确定</text>
- </view>
- <view class="filter-body">
- <view class="filter-item">
- <view class="filter-label">项目</view>
- <uni-easyinput
- v-model="filterForm.contractName"
- :inputBorder="false"
- :styles="inputStyles"
- placeholder="请输入项目" />
- </view>
- <view v-if="currentMode === 'team'" class="filter-item">
- <view class="filter-label">任务</view>
- <uni-easyinput
- v-model="filterForm.taskName"
- :inputBorder="false"
- :styles="inputStyles"
- placeholder="请输入任务" />
- </view>
- <view class="filter-item">
- <view class="filter-label">创建时间</view>
- <uni-datetime-picker
- v-model="filterForm.createTime"
- type="datetimerange"
- return-type="string"
- :border="false"
- placeholder="请选择" />
- </view>
- <view v-if="currentMode === 'well'" class="filter-item well-tree-item">
- <view class="filter-label">井</view>
- <uni-easyinput
- v-model="wellSearchKey"
- :inputBorder="false"
- :styles="inputStyles"
- placeholder="请输入井名" />
- <view class="dept-selected">
- {{ selectedWellText || "请选择" }}
- </view>
- <view class="tree well-tree">
- <DaTree
- :key="wellTreeRenderKey"
- :data="wellTreeData"
- labelField="label"
- valueField="value"
- childrenField="children"
- defaultExpandAll
- checkedDisabled
- :filterValue="wellSearchKey"
- :defaultCheckedKeys="selectedWellKey"
- @change="handleWellTreeChange" />
- </view>
- </view>
- <view v-if="currentMode === 'team'" class="filter-item dept-item">
- <view class="filter-label">队伍</view>
- <view class="dept-selected">
- {{ selectedDeptName || "请选择" }}
- </view>
- <view class="tree">
- <DaTree
- :data="treeData"
- labelField="name"
- valueField="id"
- disabledField="disabled"
- defaultExpandAll
- checkedDisabled
- :defaultCheckedKeys="filterForm.deptId"
- @change="handleTreeChange" />
- </view>
- </view>
- </view>
- <view class="filter-footer">
- <button class="filter-button reset" @click="resetFilter">重置</button>
- <button class="filter-button" type="primary" @click="applyFilter"
- >搜索</button
- >
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script setup>
- import { computed, onMounted, reactive, ref } from "vue";
- import dayjs from "dayjs";
- import DaTree from "@/components/da-tree/index.vue";
- import UniFab from "@/uni_modules/uni-fab/components/uni-fab/uni-fab.vue";
- import UniTooltip from "@/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue";
- import {
- getTaskWellNames,
- getRuiduReportTeamPage,
- getRuiduReportWellPage,
- } from "@/api/ruiduReport";
- import { specifiedSimpleDepts } from "@/api";
- import { getDeptId } from "@/utils/auth";
- import { useDataDictStore } from "@/store/modules/dataDict";
- const paging = ref(null);
- const filterPopup = ref(null);
- const dataList = ref([]);
- const deptOptions = ref([]);
- const treeData = ref([]);
- const wellTreeData = ref([]);
- const wellTreeRenderKey = ref(0);
- const selectedWellKey = ref("");
- const wellSearchKey = ref("");
- const expandedSummaryIds = ref([]);
- const currentMode = ref("well");
- const dictStore = useDataDictStore();
- const rdStatusDict = reactive({});
- const modeOptions = [
- { label: "井", value: "well" },
- { label: "队伍", value: "team" },
- ];
- const summaryFields = [
- { label: "桥塞", key: "groupIdBridgePlug" },
- { label: "趟数", key: "groupIdRunCount" },
- { label: "井数", key: "groupIdCumulativeWorkingWell" },
- { label: "小时H", key: "groupIdHourCount" },
- { label: "油耗L", key: "groupIdFuel" },
- { label: "水方量", key: "groupIdWaterVolume" },
- { label: "泵车台次", key: "groupIdPumpTrips" },
- { label: "段数", key: "groupIdCumulativeWorkingLayers" },
- { label: "仪表/混砂", key: "groupIdMixSand" },
- ];
- const inputStyles = reactive({
- backgroundColor: "#f7f8fa",
- color: "#333",
- });
- const fabPattern = reactive({
- color: "#fff",
- backgroundColor: "#fff",
- selectedColor: "#fff",
- buttonColor: "#004098",
- iconColor: "#fff",
- icon: "search",
- });
- const getDefaultCreateTime = () => {
- const end = dayjs().endOf("day").format("YYYY-MM-DD HH:mm:ss");
- const start = dayjs().subtract(6, "day").startOf("day").format("YYYY-MM-DD HH:mm:ss");
- return [start, end];
- };
- const filterForm = reactive({
- contractName: "",
- taskName: "",
- wellName: "",
- deptId: getDeptId(),
- createTime: getDefaultCreateTime(),
- });
- const selectedDeptName = computed(() => {
- const current = deptOptions.value.find(
- (item) => String(item.value) === String(filterForm.deptId)
- );
- return current?.text || "";
- });
- const selectedWellText = computed(() => {
- if (filterForm.wellName) return `井号:${filterForm.wellName}`;
- if (filterForm.contractName) return `项目:${filterForm.contractName}`;
- return "";
- });
- const handleTree = (
- data,
- id = "id",
- parentId = "parentId",
- children = "children"
- ) => {
- if (!Array.isArray(data)) return [];
- const childrenListMap = {};
- const nodeIds = {};
- const tree = [];
- for (const item of data) {
- const itemParentId = item[parentId];
- if (childrenListMap[itemParentId] == null) {
- childrenListMap[itemParentId] = [];
- }
- nodeIds[item[id]] = item;
- childrenListMap[itemParentId].push(item);
- }
- for (const item of data) {
- if (nodeIds[item[parentId]] == null) {
- tree.push(item);
- }
- }
- const adaptToChildrenList = (node) => {
- if (childrenListMap[node[id]] != null) {
- node[children] = childrenListMap[node[id]];
- }
- if (node[children]) {
- node[children].forEach(adaptToChildrenList);
- }
- };
- tree.forEach(adaptToChildrenList);
- return tree;
- };
- const sortDeptTree = (nodes) => {
- if (!Array.isArray(nodes)) return [];
- return [...nodes]
- .sort((a, b) => (a.sort ?? 999999) - (b.sort ?? 999999))
- .map((node) => ({
- ...node,
- children: sortDeptTree(node.children),
- }));
- };
- const loadDeptOptions = async () => {
- try {
- const response = await specifiedSimpleDepts(getDeptId());
- const list = response?.data || [];
- deptOptions.value = list.map((item) => ({
- text: item.name,
- value: item.id,
- }));
- treeData.value = sortDeptTree(handleTree(list));
- } catch (error) {
- treeData.value = [];
- deptOptions.value = [];
- }
- };
- const loadWellOptions = async () => {
- try {
- const response = await getTaskWellNames({
- companyId: 163,
- wellName: "",
- });
- const list = response?.data || [];
- const parentMap = new Map();
- const tree = [];
- list.forEach((item) => {
- if (item.type === "1") {
- const node = {
- label: item.projectName,
- value: `project-${item.projectId}`,
- type: "1",
- rawData: item,
- children: [],
- };
- parentMap.set(item.projectId, node);
- tree.push(node);
- }
- });
- list.forEach((item) => {
- if (item.type === "2") {
- const parent = parentMap.get(item.projectId);
- const node = {
- label: item.wellName,
- value: `well-${item.projectId}-${item.wellName}`,
- type: "2",
- rawData: item,
- };
- if (parent) {
- parent.children.push(node);
- }
- }
- });
- wellTreeData.value = tree;
- } catch (error) {
- wellTreeData.value = [];
- }
- };
- const queryList = (pageNo, pageSize) => {
- const request =
- currentMode.value === "well"
- ? getRuiduReportTeamPage({
- pageNo,
- pageSize,
- contractName: filterForm.contractName,
- taskName: filterForm.wellName,
- createTime: filterForm.createTime,
- })
- : getRuiduReportWellPage({
- pageNo,
- pageSize,
- deptId: filterForm.deptId,
- contractName: filterForm.contractName,
- taskName: filterForm.taskName,
- createTime: filterForm.createTime,
- });
- request
- .then((res) => {
- const list = res.data?.list || [];
- const summaryIds = list
- .filter((item) => item.lastGroupIdFlag)
- .map((item) => String(item.id));
- expandedSummaryIds.value =
- pageNo === 1
- ? summaryIds
- : Array.from(new Set([...expandedSummaryIds.value, ...summaryIds]));
- paging.value?.complete(list);
- })
- .catch(() => {
- paging.value?.complete(false);
- });
- };
- const switchMode = (mode, reload = true) => {
- if (currentMode.value === mode) return;
- currentMode.value = mode;
- expandedSummaryIds.value = [];
- if (reload) {
- paging.value?.reload();
- }
- };
- const openFilterPopup = () => {
- filterPopup.value?.open();
- };
- const closeFilterPopup = () => {
- filterPopup.value?.close();
- };
- const applyFilter = () => {
- closeFilterPopup();
- paging.value?.reload();
- };
- const resetFilter = () => {
- filterForm.contractName = "";
- filterForm.taskName = "";
- filterForm.wellName = "";
- filterForm.deptId = getDeptId();
- filterForm.createTime = getDefaultCreateTime();
- selectedWellKey.value = "";
- wellSearchKey.value = "";
- wellTreeRenderKey.value += 1;
- };
- const handleTreeChange = (value) => {
- filterForm.deptId = value;
- };
- const handleWellTreeChange = (value, item) => {
- const node = item?.originItem;
- selectedWellKey.value = value;
- if (node?.type === "1") {
- filterForm.contractName = node.rawData?.projectName || node.label || "";
- filterForm.wellName = "";
- return;
- }
- if (node?.type === "2") {
- filterForm.wellName = node.rawData?.wellName || node.label || "";
- filterForm.contractName = "";
- }
- };
- const toggleSummary = (id) => {
- const key = String(id);
- if (expandedSummaryIds.value.includes(key)) {
- expandedSummaryIds.value = expandedSummaryIds.value.filter(
- (item) => item !== key
- );
- return;
- }
- expandedSummaryIds.value = [...expandedSummaryIds.value, key];
- };
- const isSummaryExpanded = (id) => {
- return expandedSummaryIds.value.includes(String(id));
- };
- const formatDate = (time) => {
- return time ? dayjs(time).format("YYYY-MM-DD") : "--";
- };
- const formatValue = (value) => {
- if (value === 0) return "0";
- return value ?? "--";
- };
- const loadRdStatusDict = async () => {
- if (dictStore.dataDict.length <= 0) {
- await dictStore.loadDataDictList();
- }
- dictStore.getStrDictOptions("rdStatus").forEach((item) => {
- rdStatusDict[item.value] = item.label;
- });
- };
- onMounted(() => {
- loadDeptOptions();
- loadWellOptions();
- loadRdStatusDict();
- });
- </script>
- <style lang="scss" scoped>
- .report-page {
- display: flex;
- flex-direction: column;
- min-height: 0;
- padding: 10px !important;
- overflow: hidden;
- }
- .mode-tabs {
- flex-shrink: 0;
- height: 42px;
- padding: 4px;
- margin-bottom: 8px;
- display: flex;
- gap: 4px;
- background: #ffffff;
- border-radius: 8px;
- box-sizing: border-box;
- }
- .mode-tab {
- flex: 1;
- height: 34px;
- line-height: 34px;
- text-align: center;
- color: #5c6675;
- font-size: 14px;
- border-radius: 6px;
- &.active {
- color: #ffffff;
- background: #004098;
- font-weight: 600;
- }
- }
- .report-paging {
- flex: 1;
- min-height: 0;
- height: auto;
- }
- .report-list {
- padding: 8px 6px;
- box-sizing: border-box;
- }
- .report-card {
- margin-bottom: 14px;
- overflow: hidden;
- background: #ffffff;
- border: 1px solid rgba(0, 64, 152, 0.08);
- border-radius: 8px;
- box-shadow: 0 6px 18px rgba(35, 54, 79, 0.08);
- }
- .card-header {
- min-height: 52px;
- padding: 14px 16px 10px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- border-bottom: 1px solid #edf1f7;
- }
- .card-date {
- color: #000000;
- font-weight: 700;
- font-size: 18px;
- line-height: 24px;
- }
- .status-tag {
- max-width: 112px;
- height: 24px;
- line-height: 24px;
- padding: 0 9px;
- border-radius: 12px;
- background: #004098;
- color: #ffffff;
- font-size: 12px;
- font-weight: 600;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- box-sizing: border-box;
- }
- .card-body {
- padding: 12px 16px 6px;
- box-sizing: border-box;
- }
- .field-row {
- display: flex;
- align-items: flex-start;
- min-height: 30px;
- font-size: 14px;
- }
- .field-label {
- width: 70px;
- flex-shrink: 0;
- color: #000000;
- font-weight: 600;
- font-size: 13px;
- line-height: 22px;
- }
- .field-value {
- min-width: 0;
- flex: 1;
- color: #233044;
- font-weight: 500;
- font-size: 14px;
- line-height: 22px;
- }
- .summary-grid {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: 8px;
- }
- .summary-item {
- min-width: 0;
- padding: 9px 10px;
- border-radius: 6px;
- background: #f7f8fa;
- box-sizing: border-box;
- }
- .summary-label {
- display: block;
- color: #7a8494;
- font-size: 12px;
- line-height: 17px;
- }
- .summary-value {
- display: block;
- margin-top: 4px;
- color: #233044;
- font-weight: 700;
- font-size: 15px;
- line-height: 20px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .brief-row {
- padding-top: 4px;
- }
- .brief-row :deep(.uni-tooltip) {
- min-width: 0;
- flex: 1;
- display: block;
- }
- .brief-text {
- display: block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .summary-panel {
- margin: 0 16px 14px;
- border: 1px solid rgba(0, 64, 152, 0.12);
- border-radius: 8px;
- overflow: hidden;
- }
- .summary-header {
- height: 38px;
- padding: 0 12px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #004098;
- font-weight: 600;
- font-size: 14px;
- background: #eef5ff;
- box-sizing: border-box;
- }
- .summary-grid {
- padding: 10px;
- background: #ffffff;
- }
- .filter-popup {
- height: 86vh;
- max-height: 86vh;
- display: flex;
- flex-direction: column;
- background: #fff;
- padding-bottom: env(safe-area-inset-bottom);
- }
- .filter-header {
- height: 48px;
- padding: 0 16px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-bottom: 1px solid #f0f0f0;
- box-sizing: border-box;
- }
- .filter-title {
- font-weight: 600;
- color: #333;
- font-size: 16px;
- }
- .filter-action {
- min-width: 48px;
- color: #666;
- font-size: 14px;
- &.primary {
- color: #004098;
- text-align: right;
- }
- }
- .filter-body {
- flex: 1;
- overflow-y: auto;
- padding: 12px 16px;
- box-sizing: border-box;
- }
- .filter-item {
- margin-bottom: 14px;
- }
- .filter-label {
- margin-bottom: 8px;
- color: #333;
- font-weight: 500;
- font-size: 14px;
- }
- .dept-selected {
- min-height: 36px;
- line-height: 36px;
- padding: 0 10px;
- margin-bottom: 8px;
- background: #f7f8fa;
- color: #666;
- border-radius: 4px;
- box-sizing: border-box;
- }
- .tree {
- height: 360px;
- overflow: hidden;
- border: 1px solid #f0f0f0;
- border-radius: 4px;
- }
- .filter-footer {
- display: flex;
- gap: 10px;
- padding: 10px 16px 14px;
- border-top: 1px solid #f0f0f0;
- box-sizing: border-box;
- }
- .filter-button {
- flex: 1;
- height: 38px;
- line-height: 38px;
- font-size: 14px;
- margin: 0;
- &.reset {
- color: #004098;
- background: #fff;
- border: 1px solid #004098;
- }
- }
- </style>
|