index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
  3. <view class="xunjian-plan-container">
  4. <!-- 日历组件 -->
  5. <oa-calendar class="uni-calendar--hook" :selected="info.selected" :showMonth="false" @change="change" @monthSwitch="monthSwitch" :currentDate="currentDateList" />
  6. <!-- 分段器组件 -->
  7. <view class="app-subsection">
  8. <u-subsection :list="list" :current="tabPosition" inactiveColor="#303133" :activeColor="proxy.$settingStore.themeColor.color" @change="tabPositionChange" style="width: 100%"></u-subsection>
  9. </view>
  10. <!-- 内容 -->
  11. <oa-timeLine v-if="activities.length > 0" :fontColor="proxy.$settingStore.themeColor.color" :sort="activitiesSort" @activitiesSortChange="activitiesSortChange">
  12. <oa-timeLine-item
  13. v-for="(ac, index) in activities"
  14. :key="index"
  15. :titleValue="ac.planName"
  16. :timeValue="ac.timestamp"
  17. :iconColor="proxy.$settingStore.themeColor.color"
  18. v-show="tabPosition == 0"
  19. >
  20. <view style="display: flex" v-if="ac.planStatus == 1">
  21. <view>
  22. <view style="margin-bottom: 15px">巡检任务执行中,还需完成 {{ ac.undetectedSiteCount }}个 </view>
  23. <view style="padding: 0; font-size: 14px" :style="{ color: proxy.$settingStore.themeColor.color }" @click="reportClick(ac)"> 点击巡检 </view>
  24. </view>
  25. <view style="margin: auto"></view>
  26. <view style="display: flex">
  27. <c-progress-circle style="margin: auto" :progress="ac.completion / 100" :color="proxy.$settingStore.themeColor.color" size="100rpx" boderWidth="100rpx"></c-progress-circle>
  28. </view>
  29. </view>
  30. <view style="display: flex" v-if="ac.planStatus == 2">
  31. <view>
  32. <view style="margin-bottom: 15px">巡检任务结束</view>
  33. <view style="padding: 0; font-size: 14px" :style="{ color: proxy.$settingStore.themeColor.color }" @click="reportClick(ac)"> 点击查看 </view>
  34. </view>
  35. <view style="margin: auto"></view>
  36. <view style="display: flex">
  37. <c-progress-circle style="margin: auto" :progress="ac.completion / 100" :color="proxy.$settingStore.themeColor.color" size="100rpx" boderWidth="100rpx"></c-progress-circle>
  38. </view>
  39. </view>
  40. <view style="display: flex" v-if="ac.planStatus == 3">
  41. <view>
  42. <view style="margin-bottom: 15px">巡检任务结束</view>
  43. <view>
  44. <span style="margin-right: 20px">
  45. 合格:
  46. <span style="color: #00cdac">
  47. {{ ac.patrolledSiteCount }}
  48. </span>
  49. </span>
  50. <span>
  51. 漏检:
  52. <span style="color: #f07d28">
  53. {{ ac.undetectedSiteCount }}
  54. </span>
  55. </span>
  56. </view>
  57. </view>
  58. <view style="margin: auto"></view>
  59. <view style="display: flex">
  60. <c-progress-circle style="margin: auto" :progress="ac.completion / 100" :color="proxy.$settingStore.themeColor.color" size="100rpx" boderWidth="100rpx"></c-progress-circle>
  61. </view>
  62. </view>
  63. </oa-timeLine-item>
  64. <oa-timeLine-item
  65. v-for="(ac, index) in activities"
  66. :key="index"
  67. :titleValue="ac.areaName"
  68. :timeValue="ac.createTime"
  69. :iconColor="proxy.$settingStore.themeColor.color"
  70. v-show="tabPosition == 1"
  71. >
  72. <view style="display: flex">
  73. <view>
  74. <view>已检查{{ ac.contentCount }}项内容</view>
  75. <br />
  76. <view style="padding: 0; font-size: 14px" :style="{ color: proxy.$settingStore.themeColor.color }" @click="reportClick(ac)"> 点击查看 </view>
  77. </view>
  78. <view style="margin: auto"></view>
  79. <view style="display: flex; font-size: 15px; color: #30bb00">
  80. <view style="margin: auto">
  81. {{ ac.siteStatus == 0 ? "未定位" : "已定位" }}
  82. </view>
  83. </view>
  84. </view>
  85. </oa-timeLine-item>
  86. </oa-timeLine>
  87. <view id="planTimeline" style="text-align: center; color: #bdbdbd; font-size: 14px" v-else> 暂无数据 </view>
  88. </view>
  89. <oaMovable v-if="scanArray.length <= 0" :themesColor="proxy.$settingStore.themeColor.color">
  90. <template #content>
  91. <view class="iconfont ucicon-nfc menu-icon" @click="nfcClick()"></view>
  92. <view class="iconfont ucicon-saoyisao menu-icon" @click="scanClick()"></view>
  93. </template>
  94. </oaMovable>
  95. <drawer v-if="scanArray.length > 0" :scanArray="scanArray" :scanBool="scanBool" @scanClose="scanClose"></drawer>
  96. </scroll-view>
  97. </template>
  98. <script setup>
  99. import { onLoad, onShow, onLaunch, onUnload } from "@dcloudio/uni-app";
  100. import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, defineAsyncComponent } from "vue";
  101. import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
  102. import { recordList, recordOption, planList, patrolInspectionPlan, appPlanStatistics } from "@/api/business/mhxf/xunJian/plan.js";
  103. import drawer from "./components/drawer.vue"; // 引入组件
  104. import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
  105. const commonStore = commonStores(); //全局公共Store
  106. const xunJianStore = xunJianStores(); //全局变量值Store
  107. const { proxy } = getCurrentInstance();
  108. const info = ref({
  109. lunar: true,
  110. range: true,
  111. insert: false,
  112. selected: [],
  113. });
  114. /**
  115. * @日期change事件
  116. */
  117. function change(e) {
  118. // console.log("change 返回:", e);
  119. currentDate.value = e.fulldate;
  120. currentApi();
  121. activitiesApi();
  122. }
  123. /**
  124. * @月份切换事件
  125. */
  126. function monthSwitch(e) {
  127. // console.log("monthSwitchs 返回:", e);
  128. }
  129. /**
  130. * @点击巡检
  131. * @点击事件
  132. */
  133. function reportClick(obj) {
  134. xunJianStore.inspectionStatus = null;
  135. if (tabPosition.value == 0) {
  136. xunJianStore.planSonId = obj.id;
  137. uni.navigateTo({
  138. url: "/pages/business/mhxf/xunJian/plan/components/report",
  139. });
  140. } else if (tabPosition.value == 1) {
  141. xunJianStore.siteId = obj.siteId;
  142. xunJianStore.planSonId = obj.planSonId;
  143. xunJianStore.inspectionStatus = 2;
  144. uni.navigateTo({
  145. url: "/pages/business/mhxf/xunJian/plan/components/siteDetails",
  146. });
  147. }
  148. }
  149. /**
  150. * @NFC
  151. */
  152. function nfcClick() {
  153. proxy.$nfc.initNFC();
  154. }
  155. /**
  156. * @扫一扫
  157. * @点击事件
  158. */
  159. const scanArray = ref([]);
  160. const scanBool = ref(false);
  161. function scanClick() {
  162. uni.scanCode({
  163. autoZoom: false,
  164. success: async (e) => {
  165. uni.showToast({
  166. title: "扫码成功",
  167. icon: "none",
  168. });
  169. planListApi(e.result);
  170. },
  171. fail: (err) => {
  172. uni.showToast({
  173. title: "扫码失败",
  174. icon: "none",
  175. });
  176. console.log("扫码失败", err);
  177. },
  178. complete: () => {
  179. console.log("扫码结束");
  180. },
  181. });
  182. }
  183. /**
  184. * @点位查询
  185. * @接口查询
  186. */
  187. function planListApi(value) {
  188. xunJianStore.inspectionStatus = 1;
  189. planList({
  190. siteNubmber: value,
  191. }).then((res) => {
  192. if (res.status == "SUCCESS") {
  193. if (res.data.length > 0) {
  194. scanArray.value = res.data;
  195. scanBool.value = true;
  196. } else {
  197. uni.showToast({
  198. title: "此点位下暂无数据,请切换点位重试!",
  199. icon: "none",
  200. });
  201. }
  202. } else {
  203. }
  204. });
  205. }
  206. /**
  207. * @抽屉emit
  208. * @关闭事件
  209. */
  210. function scanClose(flag) {
  211. scanBool.value = flag;
  212. scanArray.value = [];
  213. }
  214. /**
  215. * @巡检任务
  216. * @巡检记录
  217. * @api接口请求
  218. */
  219. const activities = ref([]);
  220. function activitiesApi() {
  221. activities.value = [];
  222. if (tabPosition.value == 0) {
  223. patrolInspectionPlan({
  224. currentDate: currentDate.value,
  225. sort: activitiesSort.value,
  226. }).then((res) => {
  227. if (res.status == "SUCCESS") {
  228. res.data.forEach((el) => {
  229. activities.value.push({
  230. id: el.id,
  231. planName: el.planName,
  232. timestamp:
  233. (el.startTime == null || el.startTime == "" ? "" : el.startTime.split(":")[0] + ":" + el.startTime.split(":")[1] + "~") +
  234. (el.endTime == null || el.endTime == "" ? "" : el.endTime.split(":")[0] + ":" + el.endTime.split(":")[1]),
  235. planStatus: el.planStatus,
  236. completion: el.completion,
  237. patrolledSiteCount: el.patrolledSiteCount,
  238. undetectedSiteCount: el.undetectedSiteCount,
  239. });
  240. });
  241. } else {
  242. }
  243. });
  244. } else if (tabPosition.value == 1) {
  245. recordList({
  246. currentDate: currentDate.value,
  247. sort: activitiesSort.value,
  248. }).then((res) => {
  249. if (res.status == "SUCCESS") {
  250. res.data.forEach((el) => {
  251. activities.value.push({
  252. siteId: el.siteId,
  253. planSonId: el.planSonId,
  254. areaName: el.areaName,
  255. siteName: el.siteName,
  256. contentCount: el.contentCount,
  257. createTime: el.createTime ? el.createTime.replace("T", " ") : el.createTime,
  258. siteStatus: el.siteStatus,
  259. });
  260. });
  261. } else {
  262. }
  263. });
  264. }
  265. }
  266. /**
  267. * @统计
  268. * @api接口请求
  269. */
  270. const currentDate = ref(commonStore.getDate().year + "-" + commonStore.getDate().month + "-" + commonStore.getDate().dates); //统计时间数据存储
  271. const currentDatevalue = ref(new Date());
  272. const currentDateList = ref({}); //统计list数据存储
  273. function currentApi() {
  274. appPlanStatistics({
  275. currentDate: currentDate.value,
  276. }).then((res) => {
  277. if (res.status == "SUCCESS") {
  278. currentDateList.value = res.data;
  279. } else {
  280. }
  281. });
  282. }
  283. /**
  284. * @排序按钮
  285. */
  286. const activitiesSort = ref("DESC");
  287. function activitiesSortChange(val) {
  288. activitiesSort.value = val;
  289. activitiesApi();
  290. }
  291. /**
  292. * @tabs切换change事件
  293. */
  294. const list = ref(["巡检任务", "巡检记录"]);
  295. const tabPosition = ref(xunJianStore.planTabs);
  296. function tabPositionChange(index) {
  297. tabPosition.value = index;
  298. activitiesApi();
  299. }
  300. onLoad((options) => {
  301. currentApi();
  302. activitiesApi();
  303. // 从详情页返回该页面的获取数据
  304. uni.$on("planSelect", () => {
  305. scanArray.value = [];
  306. currentApi();
  307. activitiesApi();
  308. });
  309. });
  310. onShow(() => {
  311. //调用系统主题颜色
  312. proxy.$settingStore.systemThemeColor([1]);
  313. uni.$on("tagid", function (value) {
  314. planListApi(value);
  315. });
  316. });
  317. onUnload(() => {
  318. uni.$off("tagid"); //将值删除监听器
  319. });
  320. onMounted(() => {});
  321. </script>
  322. <style lang="scss" scoped>
  323. .is-selected {
  324. color: #1989fa;
  325. }
  326. .xunjian-plan-container {
  327. .app-subsection {
  328. display: flex;
  329. margin: 10px;
  330. padding: 10px 5rem;
  331. }
  332. }
  333. </style>