123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- <template>
- <scroll-view scroll-y>
- <view class="grayBackgroundColor">
- <view>
- <el-calendar
- id="calendar"
- ref="calendar"
- v-model="currentDatevalue"
- @touchstart="touchStart"
- @touchend="touchEnd"
- >
- <template #header="{ date }">
- <view style="display: flex; width: 100%">
- <view>{{ date }}</view>
- <view style="margin: auto"></view>
- <view style="display: flex">
- <view style="margin: 0px 10px">
- <span style="margin-right: 5px">合格</span>
- <span style="color: #00cdac">{{
- JSON.stringify(currentDateList) === "{}"
- ? 0
- : currentDateList.patrolledCount
- }}</span>
- </view>
- <view class="margin-left-xs">
- <span style="margin-right: 5px">漏检</span>
- <span style="color: #f07d28">{{
- JSON.stringify(currentDateList) === "{}"
- ? 0
- : currentDateList.undetectedCount
- }}</span>
- </view>
- </view>
- </view>
- </template>
- <template #dateCell="{ data }">
- <view @click="calendarClick(data)">
- <p :class="data.isSelected ? 'is-selected' : ''">
- {{ data.day.split("-").slice(2).join("-") }}
- </p>
- <view v-if="data.isSelected" class="filter"></view>
- </view>
- </template>
- </el-calendar>
- </view>
- <view>
- <view class="padding-sm" style="display: flex; margin: 10px">
- <el-radio-group
- v-model="tabPosition"
- style="margin: auto"
- @change="tabPositionChange()"
- >
- <el-radio-button label="task">巡检任务</el-radio-button>
- <el-radio-button label="record">巡检记录</el-radio-button>
- </el-radio-group>
- </view>
- <view>
- <el-timeline id="planTimeline" v-if="activities.length > 0">
- <view>
- <el-button
- type="primary"
- style="margin: 0px -7.5px"
- link
- @click="activitiesSortClick()"
- >
- 排序
- </el-button>
- </view>
- <view v-if="tabPosition == 'task'">
- <el-timeline-item
- v-for="(activity, index) in activities"
- :key="index"
- :icon="activity.icon"
- :type="activity.type"
- :color="activity.color"
- :size="activity.size"
- :hollow="activity.hollow"
- >
- <view style="display: flex">
- <view style="font-size: 15px"> {{ activity.planName }}</view>
- <view style="margin: auto"> </view>
- <view style="color: #b5b5b5"> {{ activity.timestamp }}</view>
- </view>
- <view
- style="
- margin-top: 15px;
- padding: 15px;
- background-color: #fff;
- border-radius: 10px;
- "
- >
- <view style="display: flex" v-if="activity.planStatus == 2">
- <view>
- <view>巡检任务结束</view>
- <br />
- <view>
- <el-button
- type="primary"
- link
- style="padding: 0"
- @click="reportClick(activity.id)"
- >
- 点击查看
- </el-button>
- </view>
- </view>
- <view style="margin: auto"></view>
- <view>
- <el-progress
- type="circle"
- :percentage="activity.completion"
- :width="50"
- />
- </view>
- </view>
- <view style="display: flex" v-if="activity.planStatus == 1">
- <view>
- <view
- >巡检任务执行中,还需完成
- {{ activity.undetectedSiteCount }}个
- </view>
- <br />
- <view>
- <el-button
- type="primary"
- link
- style="padding: 0"
- @click="reportClick(activity.id)"
- >
- 点击巡检
- </el-button>
- </view>
- </view>
- <view style="margin: auto"></view>
- <view>
- <el-progress
- type="circle"
- :percentage="activity.completion"
- :width="50"
- />
- </view>
- </view>
- <view style="display: flex" v-if="activity.planStatus == 3">
- <view>
- <view>巡检任务结束</view>
- <br />
- <view>
- <span style="margin-right: 20px">
- 合格:
- <span style="color: #00cdac">
- {{ activity.patrolledSiteCount }}
- </span>
- </span>
- <span>
- 漏检:
- <span style="color: #f07d28">
- {{ activity.undetectedSiteCount }}
- </span>
- </span>
- </view>
- </view>
- <view style="margin: auto"></view>
- <view>
- <el-progress
- type="circle"
- :percentage="activity.completion"
- :width="50"
- />
- </view>
- </view>
- </view>
- </el-timeline-item>
- </view>
- <view v-if="tabPosition == 'record'">
- <el-timeline-item
- v-for="(activity, index) in activities"
- :key="index"
- :icon="activity.icon"
- :type="activity.type"
- :color="activity.color"
- :size="activity.size"
- :hollow="activity.hollow"
- >
- <view style="display: flex">
- <view style="font-size: 15px"> {{ activity.siteName }}</view>
- <view style="margin: auto"> </view>
- <view style="color: #b5b5b5"> {{ activity.createTime }}</view>
- </view>
- <view
- style="
- margin-top: 15px;
- padding: 15px;
- background-color: #fff;
- border-radius: 10px;
- "
- >
- <view>已检查{{ activity.contentCount }}项内容</view>
- <view
- :style="{
- color:
- activity.siteStatus == 0
- ? '#f07d28'
- : activity.siteStatus == 1
- ? '#00cdac'
- : '',
- textAlign: 'right',
- }"
- >
- {{
- activity.siteStatus == 0
- ? "未定位"
- : activity.siteStatus == 1
- ? "已定位"
- : ""
- }}
- </view>
- <view>
- <el-button type="primary" link style="padding: 0">
- 点击查看
- </el-button>
- </view>
- </view>
- </el-timeline-item>
- </view>
- </el-timeline>
- <view
- id="planTimeline"
- style="text-align: center; color: #bdbdbd; font-size: 14px"
- v-else
- >
- 暂无数据
- </view>
- </view>
- </view>
- </view>
- <img
- src="@/static/inspection/plan-scan.png"
- alt=""
- style="position: fixed; right: 0; bottom: 50px"
- @click="scanClick()"
- />
- <drawer
- v-if="scanArray.length > 0"
- :scanArray="scanArray"
- :scanBool="scanBool"
- @scanClose="scanClose"
- ></drawer>
- </scroll-view>
- </template>
- <script setup>
- import drawer from "./components/drawer.vue";
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import { ref, onMounted, inject, shallowRef } from "vue";
- const myRequest = inject("$myRequest");
- import useXunJianStore from "@/store/modules/xunJian";
- const settingsStore = useXunJianStore();
- import { MoreFilled } from "@element-plus/icons-vue";
- function reportClick(id) {
- settingsStore.planSonId1 = id;
- uni.navigateTo({
- url: "/pages/xunJian/plan/components/report",
- });
- }
- const scanArray = ref([]);
- const scanBool = ref(false);
- async function scanClick() {
- uni.scanCode({
- success: (res) => {
- console.log("扫码成功", res);
- },
- fail: (err) => {
- console.log("扫码失败", err);
- },
- complete: () => {
- console.log("扫码结束");
- },
- });
- settingsStore.inspectionStatus = 1;
- let res = await myRequest({
- url: "/service-fire/appPatrolInspection/planList",
- header: {
- "Content-Type": "application/json;charset=utf-8",
- },
- method: "GET",
- data: {
- siteNubmber: "0000000000",
- },
- });
- if (res.data.status == "SUCCESS") {
- if (res.data.data.length > 0) {
- scanArray.value = res.data.data;
- scanBool.value = true;
- } else {
- uni.showToast({
- title: "此点位下暂无数据,请切换点位重试!",
- icon: "none",
- });
- }
- } else {
- }
- }
- function scanClose(flag) {
- scanBool.value = flag;
- }
- const activities = ref([]);
- async function activitiesApi() {
- activities.value = [];
- if (tabPosition.value == "task") {
- let res = await myRequest({
- url: "/service-fire/appPatrolInspection/patrolInspectionPlan",
- header: {
- "Content-Type": "application/json;charset=utf-8",
- },
- method: "GET",
- data: {
- currentDate: currentDate.value,
- sort: activitiesSort.value,
- },
- });
- if (res.data.status == "SUCCESS") {
- res.data.data.forEach((el) => {
- activities.value.push({
- id: el.id,
- planName: el.planName,
- timestamp:
- (el.startTime == null || el.startTime == ""
- ? ""
- : el.startTime.split(":")[0] +
- ":" +
- el.startTime.split(":")[1] +
- "~") +
- (el.endTime == null || el.endTime == ""
- ? ""
- : el.endTime.split(":")[0] + ":" + el.endTime.split(":")[1]),
- planStatus: el.planStatus,
- completion: el.completion,
- patrolledSiteCount: el.patrolledSiteCount,
- undetectedSiteCount: el.undetectedSiteCount,
- });
- });
- } else {
- }
- } else if (tabPosition.value == "record") {
- let res = await myRequest({
- url: "/service-fire/appPatrolInspection/recordList",
- header: {
- "Content-Type": "application/json;charset=utf-8",
- },
- method: "GET",
- data: {
- currentDate: currentDate.value,
- sort: activitiesSort.value,
- },
- });
- if (res.data.status == "SUCCESS") {
- res.data.data.forEach((el) => {
- activities.value.push({
- siteName: el.siteName,
- contentCount: el.contentCount,
- createTime:
- el.createTime.split("T")[0] + " " + el.createTime.split("T")[1],
- siteStatus: el.siteStatus,
- });
- });
- } else {
- }
- }
- activities.value.forEach((el) => {
- el.size = "large";
- el.type = "primary";
- el.icon = shallowRef(MoreFilled);
- });
- }
- const currentDate = ref(
- settingsStore.getDate().year +
- "-" +
- settingsStore.getDate().month +
- "-" +
- settingsStore.getDate().dates
- );
- const currentDatevalue = ref(new Date());
- const currentDateList = ref({});
- async function currentApi() {
- const res = await myRequest({
- url: "/service-fire/appPatrolInspection/appPlanStatistics",
- header: {
- "Content-Type": "application/json;charset=utf-8",
- },
- method: "GET",
- data: {
- currentDate: currentDate.value,
- },
- });
- if (res.data.status == "SUCCESS") {
- currentDateList.value = res.data.data;
- } else {
- }
- }
- const activitiesSort = ref("ASC");
- function activitiesSortClick() {
- if (activitiesSort.value == "ASC") {
- activitiesSort.value = "DESC";
- } else {
- activitiesSort.value = "ASC";
- }
- activitiesApi();
- }
- const tabPosition = ref(settingsStore.planTabs);
- function tabPositionChange() {
- activitiesApi();
- }
- const calendar = ref();
- function calendarClick(data) {
- currentDate.value = data.day;
- currentApi();
- activitiesApi();
- }
- let touchStartX = 0;
- let touchStartY = 0;
- function touchStart(e) {
- console.log("触摸开始");
- touchStartX = e.touches[0].clientX;
- touchStartY = e.touches[0].clientY;
- }
- function touchEnd(e) {
- console.log("触摸结束");
- let deltaX = e.changedTouches[0].clientX - touchStartX;
- let deltaY = e.changedTouches[0].clientY - touchStartY;
- if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
- if (deltaX >= 0) {
- console.log("左滑");
- calendar.value.selectDate("prev-month");
- } else {
- console.log("右滑");
- calendar.value.selectDate("next-month");
- }
- } else if (Math.abs(deltaY) > 50 && Math.abs(deltaX) < Math.abs(deltaY)) {
- if (deltaY < 0) {
- console.log("上滑");
- } else {
- console.log("下滑");
- }
- } else {
- console.log("可能是误触!");
- }
- }
- onLoad((options) => {
- currentApi();
- activitiesApi();
- });
- onMounted(() => {});
- </script>
- <style lang="scss">
- .is-selected {
- color: #1989fa;
- }
- </style>
- <style scoped>
- uni-page-body,
- uni-page-refresh,
- .grayBackgroundColor {
- background: rgb(241, 241, 241);
- }
- </style>
|