list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="getTitle" @clickLeft="back">
  4. </uni-nav-bar>
  5. <view class="top-wrapper">
  6. <view class="tab-bar">
  7. <view class="tab-item" :class="{ active: activeTab === 'mine' }" @click="switchTab('mine')">我的工单</view>
  8. <view class="tab-item" :class="{ active: activeTab === 'all' }" @click="switchTab('all')">全部工单</view>
  9. <view class="tab-item" :class="{ active: activeTab === 'plan' }" @click="switchTab('plan')" >计划</view>
  10. </view>
  11. <uni-section>
  12. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="keyWord" :placeholder="
  13. activeTab === 'plan'
  14. ? '计划单号,计划名称,记录规则名称'
  15. : '工单单号,计划单号,记录规则名称'
  16. ">
  17. </uni-easyinput>
  18. </uni-section>
  19. <button class="search_btn" @click="doSearch">搜索</button>
  20. </view>
  21. <div style="height: 180rpx; width: 475rpx"></div>
  22. <view class="wrapper">
  23. <u-list @scrolltolower="scrolltolower" class="listContent">
  24. <view v-for="(item, index) in tableList" :key="index" style="position: relative">
  25. <myCard :item="item" :index="index + 1" :btnList="
  26. activeTab === 'all'
  27. ? []
  28. : activeTab === 'plan'
  29. ? planBtnList
  30. : btnList
  31. " :columns="activeTab === 'plan' ? planColumns : columns" :title="item.code || item.planCode" :status="
  32. activeTab === 'plan'
  33. ? planStatusMap[item.status]
  34. : statusMap[item.status]
  35. " :showDetail="activeTab !== 'plan'" @goDetail="goDetail(item, 'view')"
  36. @openRedeployOther="openRedeployOther(item)" @edit="goDetail(item, 'edit')"
  37. @dispatch="handleDispatch(item)" @dispatchAll="handleDispatchAll(item)"
  38. @revoke="handleRevoke(item)">
  39. </myCard>
  40. </view>
  41. <view style="width: 100%; height: 40rpx"></view>
  42. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  43. <u-empty iconSize="150" textSize="32" text="暂无数据"> </u-empty>
  44. </view>
  45. </u-list>
  46. </view>
  47. <u-toast ref="uToast"></u-toast>
  48. <workOrderReport ref="workOrderReportRef" :pageName="pageName" @refresh="successInit"></workOrderReport>
  49. <Assign ref="Assign" @refresh="successInit"></Assign>
  50. <batchRevokeDialog ref="batchRevokeDialogRef" @refresh="successInit" :pageName="pageName"></batchRevokeDialog>
  51. <u-popup :show="dispatchAllShow" mode="bottom" :round="20" @close="dispatchAllShow = false">
  52. <view class="popup-content">
  53. <view class="popup-header">
  54. <text class="popup-title">批量派单</text>
  55. <view class="close-btn" @click="dispatchAllShow = false">×</view>
  56. </view>
  57. <view class="popup-body">
  58. <view class="form-item">
  59. <text class="form-label">派单次数 <text class="required">*</text></text>
  60. <uni-easyinput v-model="dispatchQuantity" type="number" placeholder="请输入派单次数" />
  61. </view>
  62. </view>
  63. <view class="popup-footer">
  64. <u-button type="default" @click="dispatchAllShow = false">取消</u-button>
  65. <u-button type="primary" @click="submitDispatchAll">确定</u-button>
  66. </view>
  67. </view>
  68. </u-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import dictMixns from "@/mixins/dictMixins";
  73. import myCard from "./components/myCard.vue";
  74. import Assign from "./components/Assign.vue";
  75. import workOrderReport from "./components/workOrderReport.vue";
  76. import batchRevokeDialog from "./components/batchRevokeDialog.vue";
  77. import {
  78. producetaskrulerecordQueryRecordWorkOrderPage,
  79. recordrulesplanPage,
  80. recordrulesplanRevoke,
  81. dispatchRepeatedly,
  82. recordrulesplanManualDispatchOrder,
  83. getRecordRulesPlanDetail
  84. } from "@/api/recordRules/index";
  85. export default {
  86. components: {
  87. myCard,
  88. workOrderReport,
  89. batchRevokeDialog,
  90. Assign,
  91. },
  92. mixins: [dictMixns],
  93. props: {
  94. pageName: {
  95. default: "",
  96. },
  97. },
  98. data() {
  99. return {
  100. dispatchAllData:null,
  101. dispatchAllShow: false,
  102. dispatchQuantity: "",
  103. statusMap: {
  104. 0: "未报工",
  105. 1: "执行中",
  106. 2: "已执行",
  107. },
  108. planStatusMap: {
  109. 0: "未派单",
  110. 2: "执行中",
  111. 3: "已完成",
  112. 4: "已撤回",
  113. },
  114. planTypeList: {
  115. productionRecords: 2,
  116. steamInjectionInspectionRecord: 3,
  117. solidWasteRecord: 4,
  118. qualityTestRecords: 5,
  119. boilerOperationRecord: 6,
  120. QualityInspection: 7,
  121. HaulSlag: 8,
  122. TransportAsh: 9,
  123. },
  124. btnList: [{
  125. name: "报工",
  126. apiName: "edit",
  127. btnType: "primary",
  128. judge: [{
  129. key: "status",
  130. value: [1],
  131. }, ],
  132. },
  133. {
  134. name: "转派",
  135. apiName: "openRedeployOther",
  136. btnType: "primary",
  137. judge: [{
  138. key: "status",
  139. value: [1],
  140. }, ],
  141. },
  142. ],
  143. planBtnList: [{
  144. name: "派单",
  145. apiName: "dispatch",
  146. btnType: "primary",
  147. judge: [{
  148. fn: (row) =>
  149. row.dispatchType == 1 || (row.status != 2 && row.status != 3),
  150. }, ],
  151. },
  152. {
  153. name: "批量派单",
  154. apiName: "dispatchAll",
  155. btnType: "primary",
  156. judge: [{
  157. fn: (row) => row.dispatchType == 1,
  158. }, ],
  159. },
  160. {
  161. name: "撤回",
  162. apiName: "revoke",
  163. btnType: "warning",
  164. judge: [{
  165. fn: (row) => row.status == 2,
  166. }, ],
  167. },
  168. ],
  169. columns: [
  170. [{
  171. label: "计划单号:",
  172. prop: "planCode",
  173. className: "perce100",
  174. }, ],
  175. [{
  176. label: "记录规则名称:",
  177. prop: "ruleName",
  178. className: "perce100",
  179. }, ],
  180. [{
  181. label: "场站名称:",
  182. className: "perce100",
  183. prop: "productLineName",
  184. }, ],
  185. [{
  186. className: "perce100",
  187. label: "班组:",
  188. prop: "teamName",
  189. }, ],
  190. [{
  191. label: "工单生成时间:",
  192. className: "perce100",
  193. prop: "createTime",
  194. }, ],
  195. [{
  196. label: "检查时间:",
  197. className: "perce100",
  198. prop: "checkStartTime",
  199. }, ],
  200. [{
  201. label: "报工时间:",
  202. className: "perce100",
  203. prop: "checkFinishTime",
  204. }, ],
  205. [{
  206. label: "执行人:",
  207. className: "perce100",
  208. prop: "executeUsers",
  209. formatter: (row) => {
  210. if ((row.type == 1 && row.status == 2) || row.type != 1) {
  211. return (
  212. row.executeUsers &&
  213. row.executeUsers.map((i) => i.userName).join(",")
  214. );
  215. }
  216. },
  217. }, ],
  218. [{
  219. label: "客户:",
  220. prop: "contactName",
  221. className: "perce100",
  222. isNone:
  223. !["productionRecords", "qualityTestRecords"].includes(
  224. this.pageName,
  225. ) || this.pageName == "boilerOperationRecord",
  226. },
  227. {
  228. label: "供应商:",
  229. prop: "supplierName",
  230. className: "perce100",
  231. isNone: [
  232. "productionRecords",
  233. "qualityTestRecords",
  234. "boilerOperationRecord",
  235. ].includes(this.pageName),
  236. },
  237. ],
  238. [{
  239. label: "操作:",
  240. prop: "action",
  241. type: "action",
  242. className: "perce100",
  243. }, ],
  244. ].filter((item) => !item.isNone),
  245. planColumns: [
  246. [{
  247. label: "计划名称:",
  248. prop: "name",
  249. className: "perce100",
  250. }, ],
  251. [{
  252. label: "记录规则名称:",
  253. prop: "ruleName",
  254. className: "perce100",
  255. }, ],
  256. [{
  257. label: "场站名称:",
  258. prop: "productLineName",
  259. className: "perce100",
  260. }, ],
  261. [{
  262. label: "班组:",
  263. prop: "teamName",
  264. className: "perce100",
  265. }, ],
  266. [{
  267. label: "部门:",
  268. prop: "groupNames",
  269. className: "perce100",
  270. formatter: (row) => [
  271. ...new Set(
  272. (row.executeUsers || [])
  273. .map((i) => i.groupName)
  274. .filter((i) => i),
  275. ),
  276. ].join(","),
  277. }, ],
  278. [{
  279. label: "负责人:",
  280. prop: "userNames",
  281. className: "perce100",
  282. formatter: (row) =>
  283. (row.executeUsers || []).map((i) => i.userName).join(","),
  284. }, ],
  285. [{
  286. label: "记录对象:",
  287. prop: "recordObject",
  288. className: "perce100",
  289. formatter: (row) =>
  290. row.associatedObject == 1 ? row.workshopName : row.deviceName,
  291. }, ],
  292. [{
  293. label: "派单类型:",
  294. prop: "dispatchTypeText",
  295. className: "perce100",
  296. formatter: (row) => (row.dispatchType ? "多次" : "单次"),
  297. }, ],
  298. [{
  299. label: "状态:",
  300. prop: "statusText",
  301. className: "perce100",
  302. formatter: (row) => this.planStatusMap[row.status] || "",
  303. }, ],
  304. [{
  305. label: "创建人:",
  306. prop: "createUserName",
  307. className: "perce100",
  308. }, ],
  309. [{
  310. label: "创建时间:",
  311. prop: "createTime",
  312. className: "perce100",
  313. }, ],
  314. [{
  315. label: "操作:",
  316. prop: "action",
  317. type: "action",
  318. className: "perce100",
  319. }, ],
  320. ],
  321. tableList: [],
  322. page: 1,
  323. size: 10,
  324. isEnd: false,
  325. keyWord: "",
  326. userInfo: {},
  327. activeTab: "mine",
  328. };
  329. },
  330. computed: {
  331. getTitle() {
  332. return this.pageName == "productionRecords" ?
  333. "生产记录" :
  334. this.pageName == "steamInjectionInspectionRecord" ?
  335. "注汽检查记录" :
  336. this.pageName == "solidWasteRecord" ?
  337. "固废记录" :
  338. this.pageName == "qualityTestRecords" ?
  339. "质量检查检测记录" :
  340. this.pageName == "HaulSlag" ?
  341. "拉渣记录表" :
  342. this.pageName == "TransportAsh" ?
  343. "拉灰记录表" :
  344. this.pageName == "QualityInspection" ?
  345. "来煤质检记录" :
  346. "锅炉运行记录";
  347. },
  348. },
  349. created() {
  350. this.requestDict("记录规则类型");
  351. },
  352. onLoad() {},
  353. methods: {
  354. goDetail(item, type) {
  355. console.log(item, "item");
  356. this.$refs.workOrderReportRef.open(item, type);
  357. },
  358. openRedeployOther(row) {
  359. this.$refs.Assign.open(row);
  360. },
  361. switchTab(tab) {
  362. if (this.activeTab === tab) return;
  363. this.activeTab = tab;
  364. this.isEnd = false;
  365. this.page = 1;
  366. this.tableList = [];
  367. this.getList();
  368. },
  369. successInit() {
  370. uni.showLoading({
  371. title: "加载中",
  372. });
  373. if (this.activeTab === "plan") {
  374. let data = {
  375. pageNum: 1,
  376. size: this.tableList.length,
  377. keyword: this.keyWord,
  378. planType: this.planTypeList[this.pageName],
  379. };
  380. recordrulesplanPage(data)
  381. .then((res) => {
  382. this.tableList = res.list;
  383. })
  384. .then(() => {
  385. uni.hideLoading();
  386. });
  387. return;
  388. }
  389. let data = {
  390. pageNum: 1,
  391. size: this.tableList.length,
  392. keyword: this.keyWord,
  393. planType: this.planTypeList[this.pageName],
  394. };
  395. if (this.activeTab === "mine") {
  396. data.currentLoginUserId = this.userInfo.userId;
  397. }
  398. producetaskrulerecordQueryRecordWorkOrderPage(data)
  399. .then((res) => {
  400. this.tableList = res.list;
  401. })
  402. .then(() => {
  403. uni.hideLoading();
  404. });
  405. },
  406. doSearch() {
  407. this.isEnd = false;
  408. this.page = 1;
  409. this.getList();
  410. },
  411. //获取列表信息
  412. getList() {
  413. this.userInfo = uni.getStorageSync("userInfo");
  414. if (this.isEnd || !this.userInfo.userId) {
  415. return;
  416. }
  417. uni.showLoading({
  418. title: "加载中",
  419. });
  420. if (this.activeTab === "plan") {
  421. let data = {
  422. pageNum: this.page,
  423. size: this.size,
  424. keyword: this.keyWord,
  425. planType: this.planTypeList[this.pageName],
  426. };
  427. recordrulesplanPage(data)
  428. .then((res) => {
  429. if (this.page === 1) {
  430. this.tableList = res.list;
  431. } else {
  432. this.tableList.push(...res.list);
  433. }
  434. this.page += 1;
  435. this.isEnd = this.tableList.length >= res.count;
  436. })
  437. .then(() => {
  438. uni.hideLoading();
  439. });
  440. return;
  441. }
  442. let data = {
  443. pageNum: this.page,
  444. size: this.size,
  445. keyword: this.keyWord,
  446. planType: this.planTypeList[this.pageName],
  447. };
  448. if (this.activeTab === "mine") {
  449. data.currentLoginUserId = this.userInfo.userId;
  450. }
  451. producetaskrulerecordQueryRecordWorkOrderPage(data)
  452. .then((res) => {
  453. if (this.page === 1) {
  454. this.tableList = res.list;
  455. } else {
  456. this.tableList.push(...res.list);
  457. }
  458. this.page += 1;
  459. this.isEnd = this.tableList.length >= res.count;
  460. })
  461. .then(() => {
  462. uni.hideLoading();
  463. });
  464. },
  465. scrolltolower() {
  466. if (this.isEnd) {
  467. return;
  468. }
  469. this.getList();
  470. },
  471. async handleDispatch(item) {
  472. try {
  473. const data = await getRecordRulesPlanDetail(item.id)
  474. await recordrulesplanManualDispatchOrder(data)
  475. this.$refs.uToast.show({
  476. type: "success",
  477. icon: false,
  478. message: `派单成功`,
  479. });
  480. this.successInit();
  481. } catch (error) {
  482. this.$refs.uToast.show({
  483. type: "error",
  484. icon: false,
  485. message: `派单失败`,
  486. });
  487. }
  488. },
  489. async handleDispatchAll(item) {
  490. this.dispatchAllData = await getRecordRulesPlanDetail(item.id)
  491. this.dispatchQuantity = ""
  492. this.dispatchAllShow = true
  493. },
  494. async submitDispatchAll() {
  495. if (!this.dispatchQuantity || Number(this.dispatchQuantity) <= 0) {
  496. this.$refs.uToast.show({
  497. type: "error",
  498. icon: false,
  499. message: `请输入派单次数`,
  500. });
  501. return;
  502. }
  503. try {
  504. const body = {
  505. ...this.dispatchAllData,
  506. dispatchQuantity: Number(this.dispatchQuantity)
  507. };
  508. await dispatchRepeatedly(body);
  509. this.$refs.uToast.show({
  510. type: "success",
  511. icon: false,
  512. message: `批量派单成功`,
  513. });
  514. this.dispatchAllShow = false;
  515. this.successInit();
  516. } catch (error) {
  517. this.$refs.uToast.show({
  518. type: "error",
  519. icon: false,
  520. message: `批量派单失败`,
  521. });
  522. }
  523. },
  524. async revoke(id) {
  525. await recordrulesplanRevoke({
  526. id
  527. });
  528. this.successInit();
  529. },
  530. handleRevoke(item) {
  531. if (item.dispatchType == 1) {
  532. // 多次派单,打开批量撤回弹窗
  533. this.$refs.batchRevokeDialogRef.open(item.code);
  534. } else {
  535. this.revoke(item.id);
  536. }
  537. },
  538. },
  539. };
  540. </script>
  541. <style lang="scss" scoped>
  542. .mainBox {
  543. background-color: #f3f8fb;
  544. }
  545. // .wrapper{
  546. // }
  547. .top-wrapper {
  548. background-color: #fff;
  549. display: flex;
  550. flex-wrap: wrap;
  551. width: 750rpx;
  552. padding: 16rpx 32rpx;
  553. align-items: center;
  554. position: absolute;
  555. z-index: 999;
  556. .tab-bar {
  557. display: flex;
  558. width: 100%;
  559. margin-bottom: 16rpx;
  560. border-bottom: 2rpx solid #eee;
  561. }
  562. .tab-item {
  563. flex: 1;
  564. text-align: center;
  565. padding: 16rpx 0;
  566. font-size: 30rpx;
  567. color: #666;
  568. position: relative;
  569. &.active {
  570. color: $theme-color;
  571. font-weight: bold;
  572. &::after {
  573. content: "";
  574. position: absolute;
  575. bottom: 0;
  576. left: 50%;
  577. transform: translateX(-50%);
  578. width: 60rpx;
  579. height: 4rpx;
  580. background: $theme-color;
  581. border-radius: 4rpx;
  582. }
  583. }
  584. }
  585. /deep/.uni-section {
  586. margin-top: 0px;
  587. }
  588. /deep/.uni-section-header {
  589. padding: 0px;
  590. }
  591. .search_btn {
  592. width: 120rpx;
  593. height: 70rpx;
  594. line-height: 70rpx;
  595. padding: 0 24rpx;
  596. background: $theme-color;
  597. font-size: 32rpx;
  598. color: #fff;
  599. margin: 0;
  600. margin-left: 26rpx;
  601. }
  602. .menu_icon {
  603. width: 44rpx;
  604. height: 44rpx;
  605. margin-left: 14rpx;
  606. }
  607. }
  608. .popup-content {
  609. width: 100vw;
  610. height: 60vh;
  611. background: #fff;
  612. border-radius: 20rpx 20rpx 0 0;
  613. display: flex;
  614. flex-direction: column;
  615. }
  616. .popup-header {
  617. display: flex;
  618. justify-content: space-between;
  619. align-items: center;
  620. padding: 30rpx;
  621. border-bottom: 1rpx solid #e5e5e5;
  622. .popup-title {
  623. font-size: 36rpx;
  624. font-weight: bold;
  625. color: #333;
  626. }
  627. .close-btn {
  628. width: 60rpx;
  629. height: 60rpx;
  630. display: flex;
  631. align-items: center;
  632. justify-content: center;
  633. font-size: 60rpx;
  634. color: #999;
  635. line-height: 1;
  636. }
  637. }
  638. .popup-body {
  639. flex: 1;
  640. padding: 28rpx;
  641. }
  642. .form-item {
  643. margin-bottom: 24rpx;
  644. .form-label {
  645. font-size: 28rpx;
  646. color: #333;
  647. margin-bottom: 16rpx;
  648. display: block;
  649. .required {
  650. color: #ff4d4f;
  651. }
  652. }
  653. }
  654. .popup-footer {
  655. display: flex;
  656. padding: 20rpx 30rpx;
  657. border-top: 1rpx solid #e5e5e5;
  658. gap: 20rpx;
  659. /deep/ .u-button {
  660. flex: 1;
  661. }
  662. }
  663. </style>