form.vue 17 KB

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