index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="检查中"
  8. @clickLeft="back"
  9. ></uni-nav-bar>
  10. <!-- <view class="top-wrapper">
  11. <uni-section>
  12. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="keyWords" placeholder="请输入">
  13. </uni-easyinput>
  14. </uni-section>
  15. <button class="search_btn" @click="doSearch">搜索</button>
  16. <image class="menu_icon" src="~@/static/pda/menu.svg"></image>
  17. </view> -->
  18. <view class="check-content">
  19. <view class="title">
  20. {{ equiName }}
  21. <text>{{ equiCode }}</text>
  22. </view>
  23. <!-- 选择状态栏 -->
  24. <view class="select-bar" v-if="showSelectBar">
  25. <view class="select-actions">
  26. <view class="select-all" @click="selectAll">
  27. <checkbox :checked="allSelected" color="#157a2c" />
  28. <text>{{ allSelected ? "取消全选" : "全选" }}</text>
  29. </view>
  30. <view class="selected-count">
  31. <text>已选择 {{ selectedCount }} 项</text>
  32. </view>
  33. </view>
  34. <view
  35. class="batch-btn"
  36. @click="openBatchDialog"
  37. :class="{ disabled: selectedCount === 0 }"
  38. >
  39. <text>批量操作</text>
  40. </view>
  41. <view class="close-select" @click="closeSelectBar">
  42. <text>取消选择</text>
  43. </view>
  44. </view>
  45. <view class="batch-trigger" @click="openSelectBar" v-if="!showSelectBar">
  46. <text>批量操作</text>
  47. </view>
  48. <view class="check-list" ref="scrollContainer">
  49. <view v-for="(item, index) in filterList">
  50. <CheckCard
  51. :item="item"
  52. class="mb20"
  53. :index="index"
  54. ref="CheckCardRef"
  55. ></CheckCard>
  56. </view>
  57. </view>
  58. <view class="footer">
  59. <view class="btn" @click="back">返回</view>
  60. <view class="btn primary" @click="handleSave">保存</view>
  61. </view>
  62. </view>
  63. <!-- 批量操作弹窗 -->
  64. <uni-popup ref="batchPopup" type="bottom">
  65. <view class="batch-popup-content">
  66. <view class="popup-header">
  67. <text class="header-title">批量操作</text>
  68. <view class="close-btn" @click="closeBatchPopup">
  69. <text class="close-icon">×</text>
  70. </view>
  71. </view>
  72. <view class="popup-body">
  73. <view class="select-info">
  74. <text>已选择 {{ selectedCount }} 项</text>
  75. </view>
  76. <view class="action-btn status-btn" @click="batchSetStatus(1)">
  77. <text class="status-icon normal-icon">✓</text>
  78. <text>批量设为正常</text>
  79. </view>
  80. <view class="action-btn status-btn" @click="batchSetStatus(-1)">
  81. <text class="status-icon abnormal-icon">✗</text>
  82. <text>批量设为异常</text>
  83. </view>
  84. </view>
  85. </view>
  86. </uni-popup>
  87. <uni-popup ref="inputDialog" type="dialog">
  88. <uni-popup-dialog
  89. ref="inputClose"
  90. mode="input"
  91. title="您当前已超出计划完成时间,请填写原因"
  92. placeholder="请输入内容"
  93. :before-close="true"
  94. @close="handleClose"
  95. @confirm="timeoutCauseConfirm"
  96. ></uni-popup-dialog>
  97. </uni-popup>
  98. </view>
  99. </template>
  100. <script>
  101. import { getDeviceInfo, mattersChecked } from "@/api/myTicket/index.js";
  102. import { post, postJ } from "@/utils/api.js";
  103. import CheckCard from "./components/CheckCard.vue";
  104. export default {
  105. components: {
  106. CheckCard,
  107. },
  108. data() {
  109. return {
  110. keyWords: "",
  111. id: "",
  112. pageId: "",
  113. page: 1,
  114. equipList: [],
  115. filterList: [],
  116. isEnd: false,
  117. equiName: "",
  118. equiCode: "",
  119. workOrderId: "",
  120. workOrderCode: "",
  121. showSelectBar: false,
  122. allSelected: false,
  123. };
  124. },
  125. computed: {
  126. selectedCount() {
  127. return this.equipList.filter((item) => item.checked).length;
  128. },
  129. },
  130. onLoad(options) {
  131. this.id = options.id;
  132. this.keyWords = options.codes;
  133. this.getList();
  134. // this.pageId = options.id
  135. // this.equiName = options.equiName
  136. // this.equiCode = options.equiCode
  137. // this.workOrderId = +options.workOrderId
  138. // this.workOrderCode = options.workOrderCode
  139. },
  140. // onReachBottom() {
  141. // if (this.isEnd) return
  142. // this.page++
  143. // this.getList()
  144. // },
  145. methods: {
  146. back() {
  147. uni.navigateBack({
  148. delta: 1,
  149. });
  150. },
  151. doSearch() {
  152. if (!this.keyWords) {
  153. this.filterList = this.equipList;
  154. } else {
  155. this.filterList = this.equipList.filter((item) =>
  156. item.categoryCode.includes(this.keyWords),
  157. );
  158. }
  159. },
  160. handleSave() {
  161. let isAllPass = true;
  162. isAllPass = this.equipList.every((item) => item.status > -1);
  163. let params = {
  164. id: this.equipList[0].id,
  165. executeStatus: isAllPass ? 1 : 2,
  166. isAbnormal: isAllPass ? 1 : 0,
  167. workItems: this.equipList.map((item) => {
  168. return {
  169. content: item.content,
  170. name: item.name,
  171. norm: item.norm,
  172. operationGuide: item.operationGuide,
  173. result: item.result,
  174. serialNum: item.serialNum,
  175. status: item.status == -1 ? -1 : 1,
  176. photoList: item.photoList || [],
  177. };
  178. }),
  179. };
  180. mattersChecked(params).then((data) => {
  181. uni.showToast({
  182. duration: 2000,
  183. title: "保存成功!",
  184. });
  185. this.back();
  186. });
  187. // let _this = this
  188. // const params = {
  189. // itemList: this.equipList,
  190. // planEquiId: this.pageId,
  191. // workOrderId: +this.workOrderId,
  192. // workOrderType: 1
  193. // }
  194. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  195. // if (res?.success) {
  196. // if (res.data) {
  197. // uni.showModal({
  198. // title: '提示',
  199. // content: '所有设备已执行完,是否报工?',
  200. // cancelText: '取消', // 取消按钮的文字
  201. // confirmText: '报工', // 确认按钮的文字
  202. // showCancel: true, // 是否显示取消按钮,默认为 true
  203. // success: res => {
  204. // if (res.confirm) {
  205. // _this._report()
  206. // } else {
  207. // _this.back()
  208. // }
  209. // }
  210. // })
  211. // } else {
  212. // uni.showToast({
  213. // duration: 2000,
  214. // title: '保存成功!'
  215. // })
  216. // this.back()
  217. // }
  218. // }
  219. // })
  220. },
  221. handleClose() {
  222. this.$refs.inputDialog.close();
  223. },
  224. timeoutCauseConfirm(value) {
  225. if (!value) {
  226. uni.showToast({
  227. title: "请输入超时原因",
  228. icon: "none",
  229. });
  230. return;
  231. }
  232. this.$refs.inputDialog.close();
  233. this._report(value);
  234. },
  235. _report(timeoutCause = "") {
  236. let _this = this;
  237. post(
  238. this.apiUrl + "/workOrder/reportWork",
  239. {
  240. workOrderId: this.workOrderId,
  241. timeoutCause,
  242. },
  243. true,
  244. false,
  245. )
  246. .then((res) => {
  247. if (res?.success) {
  248. let data = res.data;
  249. if (data.length) {
  250. uni.showModal({
  251. title: "提示",
  252. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  253. cancelText: "取消", // 取消按钮的文字
  254. confirmText: "报修", // 确认按钮的文字
  255. showCancel: true, // 是否显示取消按钮,默认为 true
  256. success: (res) => {
  257. if (res.confirm) {
  258. if (data.length > 1) {
  259. uni.navigateTo({
  260. url: `/pages/tour_tally/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`,
  261. });
  262. } else {
  263. uni.navigateTo({
  264. url: `/pages/repair/repair/index?source=5&workOrderCode=${this.workOrderCode}&equiCode=${data[0].equiCode}&equiId=${data[0].equiId}&workOrderId=${this.pageId}&equiName=${data[0].equiName}&equiModel=${data[0].equiModel}&equiLocation=${data[0].equiLocation}`,
  265. });
  266. }
  267. } else {
  268. _this.back();
  269. }
  270. },
  271. });
  272. } else {
  273. uni.showToast({
  274. icon: "success",
  275. title: "操作成功!",
  276. duration: 2000,
  277. });
  278. _this.back();
  279. }
  280. }
  281. })
  282. .catch((res) => {
  283. if (res.code === "4444") {
  284. this.$refs.inputDialog.open();
  285. }
  286. });
  287. },
  288. // 打开选择栏
  289. openSelectBar() {
  290. this.showSelectBar = true;
  291. },
  292. // 关闭选择栏
  293. closeSelectBar() {
  294. this.showSelectBar = false;
  295. this.equipList.forEach((item) => {
  296. item.checked = false;
  297. });
  298. this.allSelected = false;
  299. },
  300. // 全选/取消全选
  301. selectAll() {
  302. this.allSelected = !this.allSelected;
  303. this.equipList.forEach((item) => {
  304. item.checked = this.allSelected;
  305. });
  306. },
  307. // 打开批量操作弹窗
  308. openBatchDialog() {
  309. if (this.selectedCount === 0) {
  310. uni.showToast({
  311. title: "请先选择要操作的项目",
  312. icon: "none",
  313. });
  314. return;
  315. }
  316. this.$refs.batchPopup.open();
  317. },
  318. // 关闭批量操作弹窗
  319. closeBatchPopup() {
  320. this.$refs.batchPopup.close();
  321. },
  322. // 批量设置状态
  323. batchSetStatus(status) {
  324. const statusText = status === 1 ? "正常" : "异常";
  325. uni.showModal({
  326. title: "确认提示",
  327. content: `确认将选中的 ${this.selectedCount} 项设置为${statusText}吗?`,
  328. success: (res) => {
  329. if (res.confirm) {
  330. this.equipList.forEach((item) => {
  331. if (item.checked) {
  332. item.status = status;
  333. item.result = statusText;
  334. }
  335. });
  336. uni.showToast({
  337. title: "批量设置成功",
  338. icon: "success",
  339. });
  340. this.closeBatchPopup();
  341. this.closeSelectBar();
  342. }
  343. },
  344. });
  345. },
  346. getList() {
  347. getDeviceInfo({
  348. id: this.id,
  349. }).then((data) => {
  350. this.equiName = data.name;
  351. this.equiCode = data.code;
  352. this.equipList = data.workItems.map((item) => {
  353. return {
  354. ...item,
  355. id: data.id,
  356. status: 1,
  357. result: "正常",
  358. executeStatus: 1,
  359. checked: false,
  360. };
  361. });
  362. this.doSearch();
  363. });
  364. // const { page } = this
  365. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: this.workOrderId }, true).then(res => {
  366. // if (res?.success) {
  367. // res.data.records.forEach(item => {
  368. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  369. // })
  370. // if (page === 1) {
  371. // this.equipList = res.data.records
  372. // } else {
  373. // this.equipList.push(...res.data.records)
  374. // }
  375. // this.isEnd = this.equipList.length >= res.data.total
  376. // }
  377. // })
  378. },
  379. },
  380. };
  381. </script>
  382. <style lang="scss" scoped>
  383. .top-wrapper {
  384. background-color: #fff;
  385. display: flex;
  386. width: 750rpx;
  387. height: 88rpx;
  388. padding: 16rpx 32rpx;
  389. align-items: center;
  390. gap: 16rpx;
  391. /deep/.uni-section {
  392. margin-top: 0px;
  393. }
  394. /deep/.uni-section-header {
  395. padding: 0px;
  396. }
  397. .search_btn {
  398. width: 120rpx;
  399. height: 70rpx;
  400. line-height: 70rpx;
  401. padding: 0 24rpx;
  402. background: $theme-color;
  403. font-size: 32rpx;
  404. color: #fff;
  405. margin: 0;
  406. margin-left: 26rpx;
  407. }
  408. .menu_icon {
  409. width: 44rpx;
  410. height: 44rpx;
  411. margin-left: 14rpx;
  412. }
  413. }
  414. .check-content {
  415. box-sizing: border-box;
  416. // height: calc(100vh - 88rpx);
  417. display: flex;
  418. flex-direction: column;
  419. padding-bottom: 100rpx;
  420. .title {
  421. line-height: 80rpx;
  422. display: flex;
  423. justify-content: space-between;
  424. padding: 0 30rpx;
  425. }
  426. .check-list {
  427. flex: 1;
  428. overflow: auto;
  429. padding: 0 30rpx 30rpx;
  430. }
  431. .footer {
  432. height: 100rpx;
  433. display: flex;
  434. border: 1rpx solid $j-primary-border-green;
  435. position: fixed;
  436. bottom: 0;
  437. width: 100vw;
  438. background: #fff;
  439. .btn {
  440. display: flex;
  441. flex: 1;
  442. justify-content: center;
  443. align-items: center;
  444. border-radius: 0;
  445. &.primary {
  446. background-color: $j-primary-border-green;
  447. color: #fff;
  448. }
  449. }
  450. }
  451. .mb20 {
  452. margin-bottom: 20rpx;
  453. }
  454. .batch-trigger {
  455. padding: 20rpx 30rpx;
  456. text-align: right;
  457. text {
  458. background-color: #157a2c;
  459. color: #fff;
  460. padding: 10rpx 30rpx;
  461. border-radius: 8rpx;
  462. font-size: 28rpx;
  463. }
  464. }
  465. .select-bar {
  466. background-color: #f5f5f5;
  467. padding: 20rpx 30rpx;
  468. display: flex;
  469. justify-content: space-between;
  470. align-items: center;
  471. border-bottom: 1rpx solid #e0e0e0;
  472. .select-actions {
  473. display: flex;
  474. align-items: center;
  475. flex: 1;
  476. .select-all {
  477. display: flex;
  478. align-items: center;
  479. margin-right: 20rpx;
  480. text {
  481. margin-left: 10rpx;
  482. font-size: 28rpx;
  483. }
  484. }
  485. .selected-count {
  486. font-size: 28rpx;
  487. color: #666;
  488. }
  489. }
  490. .batch-btn {
  491. background-color: #157a2c;
  492. color: #fff;
  493. padding: 10rpx 30rpx;
  494. border-radius: 8rpx;
  495. font-size: 28rpx;
  496. margin: 0 10rpx;
  497. &.disabled {
  498. background-color: #ccc;
  499. opacity: 0.6;
  500. }
  501. }
  502. .close-select {
  503. padding: 10rpx 20rpx;
  504. background-color: #fff;
  505. border-radius: 8rpx;
  506. font-size: 28rpx;
  507. }
  508. }
  509. }
  510. .batch-popup-content {
  511. background-color: #fff;
  512. border-radius: 20rpx 20rpx 0 0;
  513. padding: 30rpx;
  514. z-index: 1000;
  515. .popup-header {
  516. display: flex;
  517. justify-content: space-between;
  518. align-items: center;
  519. padding-bottom: 30rpx;
  520. border-bottom: 1rpx solid #e0e0e0;
  521. .header-title {
  522. font-size: 36rpx;
  523. font-weight: bold;
  524. color: #333;
  525. }
  526. .close-btn {
  527. width: 60rpx;
  528. height: 60rpx;
  529. display: flex;
  530. align-items: center;
  531. justify-content: center;
  532. .close-icon {
  533. font-size: 60rpx;
  534. color: #999;
  535. line-height: 1;
  536. }
  537. }
  538. }
  539. .popup-body {
  540. padding: 30rpx 0;
  541. .select-info {
  542. padding: 20rpx 0;
  543. text-align: center;
  544. color: #666;
  545. font-size: 28rpx;
  546. }
  547. .action-btn {
  548. display: flex;
  549. align-items: center;
  550. padding: 25rpx 30rpx;
  551. margin: 0 0 20rpx 0;
  552. background-color: #f5f5f5;
  553. border-radius: 12rpx;
  554. font-size: 30rpx;
  555. &:active {
  556. background-color: #e0e0e0;
  557. }
  558. text {
  559. margin-left: 20rpx;
  560. }
  561. }
  562. .status-btn {
  563. .status-icon {
  564. width: 40rpx;
  565. height: 40rpx;
  566. border-radius: 50%;
  567. display: flex;
  568. align-items: center;
  569. justify-content: center;
  570. font-size: 28rpx;
  571. color: #fff;
  572. margin-left: 0;
  573. }
  574. .normal-icon {
  575. background-color: #157a2c;
  576. }
  577. .abnormal-icon {
  578. background-color: #ff4444;
  579. }
  580. }
  581. }
  582. }
  583. </style>