form.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="carrier-info uni-column">
  4. <view class="carrier-code uni-row">
  5. <text>箱号</text>
  6. <text style="margin-left: 24rpx;">{{auxiliaryDayworkItem.carrierName}}</text>
  7. </view>
  8. <view class="info-row uni-row">
  9. <view class="label">批次号</view>
  10. <view class="value">{{ auxiliaryDayworkItem.lotCode }}</view>
  11. </view>
  12. <view class="info-row uni-row">
  13. <view class="label">产品描述</view>
  14. <view class="value">{{ auxiliaryDayworkItem.product.description }}</view>
  15. </view>
  16. <view class="info-row uni-row">
  17. <view class="label">生产工序</view>
  18. <view class="value">{{ auxiliaryDayworkItem.process.processAlias }}</view>
  19. </view>
  20. <view class="info-row uni-row">
  21. <view class="label">辅助工序</view>
  22. <view class="value">{{ auxiliaryDayworkItem.auxiliaryProcess.name }}</view>
  23. </view>
  24. <view class="info-row uni-row">
  25. <view class="label">投产数量</view>
  26. <view class="value">{{ auxiliaryDayworkItem.prodNum }}</view>
  27. </view>
  28. </view>
  29. <!-- 废品信息 -->
  30. <view class="title unfit-title uni-row">
  31. <text>报工信息</text>
  32. </view>
  33. <view class="unfit-container">
  34. <view class="unfit-item-container uni-column" v-for="(item, index) in oldUnfitInfos" :key="index">
  35. <view class="resu uni-row">
  36. <view class="label">检查标准</view>
  37. <view class="value">{{ item.checkStandard }}</view>
  38. </view>
  39. <view class="resu uni-row">
  40. <view class="label">检查结果</view>
  41. <view class="value">{{ item.checkResult }}</view>
  42. </view>
  43. <view class="resu uni-row">
  44. <view class="label">超差范围</view>
  45. <view class="value">{{ item.exceedLimits }}</view>
  46. </view>
  47. <view class="resu uni-row">
  48. <view :class="'label'">检查量</view>
  49. <view class="number value">{{ item.examiningNum }}</view>
  50. <view :class="'label'">不良品量</view>
  51. <view class="value">{{ item.disqualificationNum }}</view>
  52. <view :class="'label'">废品量</view>
  53. <view class="value">{{ item.rejectNum }}</view>
  54. </view>
  55. </view>
  56. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  57. <view style="position: absolute; top: 10rpx; right: 10rpx;">
  58. <view class="add-btn" v-if="editable()"
  59. style="background-color: #256bda; color: #fff; padding: 6rpx 10rpx; border-radius: 4rpx; "
  60. @click="() => addReject(item, index)">添加</view>
  61. </view>
  62. <view class="resu uni-row">
  63. <view class="label">报工人</view>
  64. <view class="value">{{ item.dayworkItem.nickName }}</view>
  65. </view>
  66. <view class="resu uni-row">
  67. <view class="label">开始时间</view>
  68. <view class="value">{{ item.dayworkItem.startTime }}</view>
  69. </view>
  70. <view class="resu uni-row">
  71. <view class="label">结束时间</view>
  72. <view class="value">{{ item.dayworkItem.endTime }}</view>
  73. </view>
  74. <view class="resu uni-row">
  75. <!-- <view :class="!editable() ? 'label' : ''">投产数量</view>
  76. <view class="number value">{{ item.prodNum }}</view> -->
  77. <view :class="!editable() ? 'label' : ''">合格数量</view>
  78. <view class="value">{{ item.qualifiedNum }}</view>
  79. <view :class="!editable() ? 'label' : ''">废品量</view>
  80. <!-- <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  81. v-model="item.rejectNum" placeholder="" /> -->
  82. <view class="value">{{ item.rejectNum }}</view>
  83. </view>
  84. <view v-if="index < (unfitInfos.length - 1)"
  85. style="height: 1px; width: 100%; background-color: burlywood;"></view>
  86. </view>
  87. </view>
  88. <!-- 报工部分 -->
  89. <view class="daywork-container uni-column unfit-item-container">
  90. <view class="result uni-row">
  91. <view class="label">废品总数</view>
  92. <view class="value" style="margin-left: 10px;">{{ auxiliaryDayworkItem.rejectNum }}</view>
  93. </view>
  94. <view class="half-result uni-row">
  95. <view class="label">合格数量</view>
  96. <input v-if="editable()" class="number" type="number" v-model="auxiliaryDayworkItem.qualifiedNum"
  97. placeholder="" style="width: 140rpx" />
  98. <view v-else class="value">{{ auxiliaryDayworkItem.qualifiedNum }}</view>
  99. </view>
  100. <view class="remark uni-row">
  101. <view class="label">备注</view>
  102. <textarea v-if="editable()" v-model="auxiliaryDayworkItem.remark" />
  103. <view v-else class="value">{{ auxiliaryDayworkItem.remark }}</view>
  104. </view>
  105. <view class="btns-container uni-row">
  106. <view v-if="editable()" class="finished-btn" @click="endWork">结束报工</view>
  107. <view v-if="editable()" class="pause-btn" @click="pauseWork">暂停报工</view>
  108. </view>
  109. </view>
  110. <dialog-reject ref="dialogRejectRef" @resflushItem="handleResFlushItem"></dialog-reject>
  111. </view>
  112. </template>
  113. <script setup>
  114. import {
  115. ref,
  116. onMounted,
  117. getCurrentInstance
  118. } from 'vue'
  119. import {
  120. onLoad,
  121. onReady,
  122. onUnload,
  123. onShow
  124. } from '@dcloudio/uni-app'
  125. import {
  126. store
  127. } from '@/store/index.js'
  128. import {
  129. getAuxiliaryDayworkItemById,
  130. finishedDaywork,
  131. pauseDaywork
  132. } from '@/api/business/auxiliaryDaywork.js'
  133. const lot = ref({})
  134. const unfitInfos = ref([]) //废品信息
  135. const oldUnfitInfos = ref([])
  136. const isEventTriggered = ref(false); // 创建一个标志位
  137. // 创建一个引用来存储最后一次请求的时间戳
  138. const lastRequestTimestamp = ref(0);
  139. const currentItem = ref(null)
  140. const dialogRejectRef = ref(null)
  141. const consultations = ref([]) //咨询信息
  142. const auxiliaryDayworkItem = ref({
  143. remark: "",
  144. rejectNum: 0,
  145. examiningNum: 0,
  146. status: 0,
  147. product: {},
  148. process: {},
  149. auxiliaryProcess: {}
  150. })
  151. const initStatus = ref(0)
  152. const editable = () => {
  153. // if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
  154. // return true
  155. // }
  156. if (initStatus.value == 0 || initStatus.value == 1) {
  157. if (auxiliaryDayworkItem.value.creatorId == store.userInfo.userId) {
  158. return true
  159. }
  160. }
  161. // if (auxiliaryDayworkItem.value.firstUpdaterId == store.userInfo.userId) {
  162. // return true
  163. // }
  164. return false
  165. }
  166. const consul = [{
  167. value: 0,
  168. text: "待确认",
  169. type: "color: #fcab53"
  170. }, {
  171. value: 2,
  172. text: "合格",
  173. type: "color: #55ff7f"
  174. }, {
  175. value: 1,
  176. text: "不合格",
  177. type: "color: #ff0c2c"
  178. }]
  179. const range = [{
  180. value: 0,
  181. text: "待确认",
  182. type: "color: #fcab53"
  183. }, {
  184. value: 1,
  185. text: "合格",
  186. type: "color: #55ff7f"
  187. }, {
  188. value: 2,
  189. text: "不合格",
  190. type: "color: #ff0c2c"
  191. }]
  192. /***************************** 页面生命周期函数 *****************************/
  193. onMounted(() => {
  194. const instance = getCurrentInstance().proxy
  195. const eventChannel = instance.getOpenerEventChannel();
  196. eventChannel.on('outsourcedInspectionFrom', function(data) {
  197. console.log('outsourcedInspectionFrom', data)
  198. if (data && data.data) {
  199. auxiliaryDayworkItem.value.lot = data.data;
  200. }
  201. })
  202. })
  203. onShow(() => {
  204. if (store.auxiliaryDaywork != null) {
  205. uni.showLoading({
  206. title: '加载中'
  207. });
  208. auxiliaryDayworkItem.value = store.auxiliaryDaywork
  209. getAuxiliaryDayworkItemById(auxiliaryDayworkItem.value).then(res => {
  210. console.log("res", res);
  211. if (res.code == 200) {
  212. auxiliaryDayworkItem.value = res.data;
  213. initStatus.value = res.data.status
  214. unfitInfos.value = res.data.rejectList;
  215. console.log("res", res);
  216. uni.hideLoading();
  217. // getInspecion();
  218. } else {
  219. uni.showToast({
  220. icon: 'none',
  221. title: res.msg,
  222. duration: 2000
  223. })
  224. }
  225. });
  226. }
  227. })
  228. /***************************** 定义了一些方法 *****************************/
  229. //咨询文本
  230. function selectText(item) {
  231. for (var i = 0; i < consul.length; i++) {
  232. if (item.status == consul[i].value) {
  233. return consul[i].text
  234. }
  235. }
  236. }
  237. //打开电子图纸
  238. function handleDrawingMenu() {
  239. var outsourceOrderDetailId = encodeURIComponent(auxiliaryDayworkItem.value.outsourceOrderDetailId);
  240. var lotCode = encodeURIComponent(auxiliaryDayworkItem.value.lot.lotCode);
  241. // 构建查询参数字符串
  242. var queryParam = `param1=${outsourceOrderDetailId}&param2=${lotCode}`;
  243. // 使用模板字符串构建完整的URL
  244. var navigateUrl = `/pages/outsourcedDrawingMenu/index?${queryParam}`;
  245. // 导航到指定页面
  246. uni.navigateTo({
  247. url: navigateUrl
  248. });
  249. }
  250. const rejectNumberChange = () => {
  251. let sumReject = 0
  252. let sumDisqualificationNum = 0
  253. let sumExaminingNum = 0
  254. unfitInfos.value.forEach(v => {
  255. sumReject += (v.rejectNum != null && !isNaN(v.rejectNum) ? Number(v.rejectNum) : 0)
  256. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  257. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  258. // v.qualifiedNum = Number(v.prodNum) - Number(v.rejectNum)
  259. })
  260. auxiliaryDayworkItem.value.rejectNum = sumReject
  261. auxiliaryDayworkItem.value.disqualificationNum = sumDisqualificationNum
  262. auxiliaryDayworkItem.value.examiningNum = sumExaminingNum
  263. console.log(auxiliaryDayworkItem.value)
  264. }
  265. //结束报工按钮
  266. function endWork() {
  267. let unf = unfitInfos.value;
  268. for (var i = 0; i < unfitInfos.value.length; i++) {
  269. if (unf[i].rejectNum > unf[i].prodNum) {
  270. uni.showToast({
  271. icon: 'none',
  272. title: '废品量不能大于合格量'
  273. })
  274. return
  275. }
  276. }
  277. let sumReject = 0
  278. unfitInfos.value.forEach(v => {
  279. sumReject += Number(v.rejectNum)
  280. })
  281. auxiliaryDayworkItem.value.rejectNum = sumReject
  282. endSave();
  283. }
  284. // 暂停报工按钮
  285. function pauseWork() {
  286. pauseSave()
  287. }
  288. function endSave() {
  289. const currentTime = Date.now();
  290. // 检查是否已经过去了 2 秒
  291. if (currentTime - lastRequestTimestamp.value < 2000) {
  292. // 如果在 2 秒 内已经点击,那么不执行
  293. uni.showToast({
  294. icon: 'none',
  295. title: `请勿重复点击`,
  296. duration: 2000
  297. })
  298. return;
  299. }
  300. let pages = getCurrentPages();
  301. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  302. auxiliaryDayworkItem.value.user = store.userInfo;
  303. finishedDaywork(auxiliaryDayworkItem.value).then(res => {
  304. if (res.code == 200) {
  305. let index = 0;
  306. for (let i = 0; i < pages.length; i++) {
  307. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  308. index = pages.length - i - 1;
  309. }
  310. }
  311. console.log("index", index);
  312. uni.navigateBack({
  313. delta: index
  314. });
  315. } else {
  316. uni.showToast({
  317. icon: 'none',
  318. title: res.msg,
  319. duration: 2000
  320. })
  321. }
  322. });
  323. }
  324. function pauseSave() {
  325. const currentTime = Date.now();
  326. // 检查是否已经过去了 2 秒
  327. if (currentTime - lastRequestTimestamp.value < 2000) {
  328. // 如果在 2 秒 内已经点击,那么不执行
  329. uni.showToast({
  330. icon: 'none',
  331. title: `请勿重复点击`,
  332. duration: 2000
  333. })
  334. return;
  335. }
  336. let pages = getCurrentPages();
  337. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  338. auxiliaryDayworkItem.value.user = store.userInfo;
  339. pauseDaywork(auxiliaryDayworkItem.value).then(res => {
  340. if (res.code == 200) {
  341. let index = 0;
  342. for (let i = 0; i < pages.length; i++) {
  343. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  344. index = pages.length - i - 1;
  345. }
  346. }
  347. console.log("index", index);
  348. uni.navigateBack({
  349. delta: index
  350. });
  351. } else {
  352. uni.showToast({
  353. icon: 'none',
  354. title: res.msg,
  355. duration: 2000
  356. })
  357. }
  358. });
  359. }
  360. function addReject(row, index) {
  361. // console.log('reject', row)
  362. currentItem.value = row
  363. dialogRejectRef.value.open(row)
  364. }
  365. function handleResFlushItem(data) {
  366. currentItem.value.rejectList = data.filter(e => e.reason != null && e.reason != '')
  367. let rejectNum = 0
  368. currentItem.value.rejectList.forEach(l => {
  369. rejectNum += Number(l.rejectNum)
  370. })
  371. currentItem.value.rejectNum = rejectNum
  372. rejectNumberChange()
  373. // console.log(currentItem.value)
  374. }
  375. </script>
  376. <style lang="scss">
  377. .page-container {
  378. // height: 100%;
  379. background-color: #ececec;
  380. font-size: 28rpx;
  381. >.title {
  382. font-weight: 700;
  383. margin: 24rpx 16rpx;
  384. }
  385. }
  386. .carrier-info {
  387. margin: 32rpx 16rpx 0 16rpx;
  388. padding: 24rpx;
  389. background-color: #ffffff;
  390. border-radius: 8rpx;
  391. .carrier-code {
  392. font-size: 32rpx;
  393. font-weight: 700;
  394. }
  395. .info-row {
  396. margin-top: 16rpx;
  397. color: #767676;
  398. .label {
  399. width: 160rpx;
  400. }
  401. .drawing-btn {
  402. padding: 12rpx 32rpx;
  403. background-color: #0055ff;
  404. color: #ffffff;
  405. border-radius: 12rpx;
  406. margin-left: auto;
  407. font-size: 28rpx;
  408. }
  409. .value {
  410. flex: 1;
  411. textarea {
  412. flex: 1;
  413. border: 1px solid #888888;
  414. box-sizing: border-box;
  415. padding: 16rpx;
  416. }
  417. }
  418. }
  419. }
  420. .unfit-title {
  421. margin-bottom: 24rpx;
  422. justify-content: space-between;
  423. align-items: center;
  424. text {
  425. font-size: 28rpx;
  426. font-weight: 700;
  427. }
  428. .add-btn {
  429. margin-right: 26rpx;
  430. padding: 12rpx 32rpx;
  431. background-color: #a4adb3;
  432. color: #ffffff;
  433. border-radius: 12rpx;
  434. font-size: 24rpx;
  435. }
  436. }
  437. .unfit-container {
  438. padding: 24rpx;
  439. margin: 0 16rpx;
  440. background-color: #ffffff;
  441. border-radius: 12rpx;
  442. .unfit-item-container {
  443. position: relative;
  444. >* {
  445. margin-bottom: 24rpx;
  446. }
  447. .title {
  448. font-weight: 700;
  449. justify-content: space-between;
  450. align-items: center;
  451. image {
  452. width: 40rpx;
  453. height: 40rpx;
  454. }
  455. }
  456. .standard {}
  457. .resu {
  458. width: 100%;
  459. align-items: center;
  460. input {
  461. margin-left: 20rpx;
  462. width: 200rpx;
  463. height: 56rpx;
  464. flex: 1;
  465. border: 1px solid #9f9f9f;
  466. font-size: 28rpx;
  467. }
  468. .label {
  469. width: 160rpx;
  470. }
  471. .value {
  472. flex: 1;
  473. textarea {
  474. flex: 1;
  475. border: 1px solid #888888;
  476. box-sizing: border-box;
  477. padding: 16rpx;
  478. }
  479. }
  480. }
  481. .result {
  482. border-bottom: 1px solid #9f9f9f;
  483. padding-bottom: 32rpx;
  484. align-items: center;
  485. .label {
  486. width: 160rpx;
  487. }
  488. .value {
  489. flex: 1;
  490. textarea {
  491. flex: 1;
  492. border: 1px solid #888888;
  493. box-sizing: border-box;
  494. padding: 16rpx;
  495. }
  496. }
  497. input {
  498. width: 280rpx;
  499. height: 56rpx;
  500. border: 1px solid #9f9f9f;
  501. font-size: 28rpx;
  502. &.number {
  503. width: 104rpx;
  504. text-align: left;
  505. }
  506. }
  507. }
  508. .half-result {
  509. border-bottom: 1px solid #9f9f9f;
  510. padding-bottom: 32rpx;
  511. align-items: center;
  512. .label {
  513. width: 160rpx;
  514. }
  515. .value {
  516. flex: 1;
  517. textarea {
  518. flex: 1;
  519. border: 1px solid #888888;
  520. box-sizing: border-box;
  521. padding: 16rpx;
  522. }
  523. }
  524. input {
  525. width: 140rpx;
  526. height: 56rpx;
  527. border: 1px solid #9f9f9f;
  528. font-size: 28rpx;
  529. &.number {
  530. text-align: left;
  531. }
  532. }
  533. }
  534. }
  535. .unfit-item-container:last-child {
  536. .result {
  537. border-bottom: none;
  538. padding-bottom: 0;
  539. }
  540. }
  541. }
  542. .consultation-container {
  543. margin: 0 16rpx;
  544. padding: 24rpx;
  545. background-color: #ffffff;
  546. border-radius: 8rpx;
  547. .consultation-item-container {
  548. margin-bottom: 24rpx;
  549. border-bottom: 2px solid #888888;
  550. padding-bottom: 24rpx;
  551. }
  552. .consultation-item-container:last-child {
  553. margin-bottom: 0;
  554. border-bottom: 0;
  555. padding-bottom: 0;
  556. }
  557. .question,
  558. .answer {
  559. .label {
  560. justify-content: space-between;
  561. margin-bottom: 16rpx;
  562. font-weight: 700;
  563. }
  564. .content {
  565. line-height: 40rpx;
  566. }
  567. }
  568. .answer {
  569. margin-top: 24rpx;
  570. }
  571. }
  572. .daywork-container {
  573. margin-top: 24rpx;
  574. padding: 24rpx;
  575. background-color: #ffffff;
  576. border: 1px solid #bcbcbc;
  577. .result {
  578. align-items: center;
  579. .label {
  580. width: 112rpx;
  581. }
  582. input {
  583. flex: 1;
  584. height: 56rpx;
  585. border: 1px solid #9f9f9f;
  586. font-size: 28rpx;
  587. text-align: center;
  588. }
  589. }
  590. .half-result {
  591. align-items: center;
  592. .label {
  593. width: 112rpx;
  594. }
  595. input {
  596. width: 20px;
  597. height: 56rpx;
  598. border: 1px solid #9f9f9f;
  599. font-size: 28rpx;
  600. text-align: center;
  601. &.number {
  602. width: 104rpx;
  603. text-align: left;
  604. }
  605. }
  606. }
  607. .remark {
  608. margin-top: 24rpx;
  609. .label {
  610. width: 112rpx;
  611. }
  612. textarea {
  613. flex: 1;
  614. border: 1px solid #9f9f9f;
  615. height: 168rpx;
  616. }
  617. }
  618. .btns-container {
  619. margin-top: 24rpx;
  620. .finished-btn {
  621. display: flex;
  622. flex: 1;
  623. height: 80rpx;
  624. background-color: #fc6565;
  625. color: #ffffff;
  626. text-align: center;
  627. justify-content: center;
  628. align-items: center;
  629. border-radius: 8rpx;
  630. }
  631. .pause-btn {
  632. display: flex;
  633. flex: 1;
  634. height: 80rpx;
  635. background-color: #393cfc;
  636. color: #ffffff;
  637. text-align: center;
  638. justify-content: center;
  639. align-items: center;
  640. border-radius: 8rpx;
  641. }
  642. .question-btn {
  643. width: 80rpx;
  644. align-items: flex-end;
  645. image {
  646. width: 48rpx;
  647. height: 48rpx;
  648. }
  649. text {
  650. font-size: 24rpx;
  651. }
  652. }
  653. }
  654. }
  655. </style>