form.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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. // 检查是否已经过去了 2 秒
  303. if (currentTime - lastRequestTimestamp.value < 2000) {
  304. // 如果在 2 秒 内已经点击,那么不执行
  305. uni.showToast({
  306. icon: 'none',
  307. title: `请勿重复点击`,
  308. duration: 2000
  309. })
  310. return;
  311. }
  312. let pages = getCurrentPages();
  313. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  314. auxiliaryDayworkItem.value.user = store.userInfo;
  315. finishedDaywork(auxiliaryDayworkItem.value).then(res => {
  316. if (res.code == 200) {
  317. let index = 0;
  318. for (let i = 0; i < pages.length; i++) {
  319. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  320. index = pages.length - i - 1;
  321. }
  322. }
  323. console.log("index", index);
  324. uni.navigateBack({
  325. delta: index
  326. });
  327. } else {
  328. uni.showToast({
  329. icon: 'none',
  330. title: res.msg,
  331. duration: 2000
  332. })
  333. }
  334. });
  335. }
  336. function pauseSave() {
  337. const currentTime = Date.now();
  338. // 检查是否已经过去了 2 秒
  339. if (currentTime - lastRequestTimestamp.value < 2000) {
  340. // 如果在 2 秒 内已经点击,那么不执行
  341. uni.showToast({
  342. icon: 'none',
  343. title: `请勿重复点击`,
  344. duration: 2000
  345. })
  346. return;
  347. }
  348. let pages = getCurrentPages();
  349. console.log(unfitInfos.value)
  350. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  351. auxiliaryDayworkItem.value.user = store.userInfo;
  352. pauseDaywork(auxiliaryDayworkItem.value).then(res => {
  353. if (res.code == 200) {
  354. let index = 0;
  355. for (let i = 0; i < pages.length; i++) {
  356. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  357. index = pages.length - i - 1;
  358. }
  359. }
  360. console.log("index", index);
  361. uni.navigateBack({
  362. delta: index
  363. });
  364. } else {
  365. uni.showToast({
  366. icon: 'none',
  367. title: res.msg,
  368. duration: 2000
  369. })
  370. }
  371. });
  372. }
  373. function addReject(row, index) {
  374. // console.log('reject', row)
  375. currentItem.value = row
  376. dialogRejectRef.value.open(row)
  377. }
  378. function handleResFlushItem(data) {
  379. currentItem.value.rejectList = data.filter(e => e.reason != null && e.reason != '')
  380. let rejectNum = 0
  381. currentItem.value.rejectList.forEach(l => {
  382. rejectNum += l.rejectNum != null ? Number(l.rejectNum) : 0
  383. })
  384. currentItem.value.rejectNum = rejectNum
  385. rejectNumberChange()
  386. // console.log(currentItem.value)
  387. }
  388. </script>
  389. <style lang="scss">
  390. .page-container {
  391. // height: 100%;
  392. background-color: #ececec;
  393. font-size: 28rpx;
  394. >.title {
  395. font-weight: 700;
  396. margin: 24rpx 16rpx;
  397. }
  398. }
  399. .carrier-info {
  400. margin: 32rpx 16rpx 0 16rpx;
  401. padding: 24rpx;
  402. background-color: #ffffff;
  403. border-radius: 8rpx;
  404. .carrier-code {
  405. font-size: 32rpx;
  406. font-weight: 700;
  407. }
  408. .info-row {
  409. margin-top: 16rpx;
  410. color: #767676;
  411. .label {
  412. width: 160rpx;
  413. }
  414. .drawing-btn {
  415. padding: 12rpx 32rpx;
  416. background-color: #0055ff;
  417. color: #ffffff;
  418. border-radius: 12rpx;
  419. margin-left: auto;
  420. font-size: 28rpx;
  421. }
  422. .value {
  423. flex: 1;
  424. textarea {
  425. flex: 1;
  426. border: 1px solid #888888;
  427. box-sizing: border-box;
  428. padding: 16rpx;
  429. }
  430. }
  431. }
  432. }
  433. .unfit-title {
  434. margin-bottom: 24rpx;
  435. justify-content: space-between;
  436. align-items: center;
  437. text {
  438. font-size: 28rpx;
  439. font-weight: 700;
  440. }
  441. .add-btn {
  442. margin-right: 26rpx;
  443. padding: 12rpx 32rpx;
  444. background-color: #a4adb3;
  445. color: #ffffff;
  446. border-radius: 12rpx;
  447. font-size: 24rpx;
  448. }
  449. }
  450. .unfit-container {
  451. padding: 24rpx;
  452. margin: 0 16rpx;
  453. background-color: #ffffff;
  454. border-radius: 12rpx;
  455. .unfit-item-container {
  456. position: relative;
  457. >* {
  458. margin-bottom: 24rpx;
  459. }
  460. .title {
  461. font-weight: 700;
  462. justify-content: space-between;
  463. align-items: center;
  464. image {
  465. width: 40rpx;
  466. height: 40rpx;
  467. }
  468. }
  469. .standard {}
  470. .resu {
  471. width: 100%;
  472. align-items: center;
  473. input {
  474. margin-left: 20rpx;
  475. width: 200rpx;
  476. height: 56rpx;
  477. flex: 1;
  478. border: 1px solid #9f9f9f;
  479. font-size: 28rpx;
  480. }
  481. .label {
  482. width: 160rpx;
  483. }
  484. .value {
  485. flex: 1;
  486. textarea {
  487. flex: 1;
  488. border: 1px solid #888888;
  489. box-sizing: border-box;
  490. padding: 16rpx;
  491. }
  492. }
  493. }
  494. .result {
  495. border-bottom: 1px solid #9f9f9f;
  496. padding-bottom: 32rpx;
  497. align-items: center;
  498. .label {
  499. width: 160rpx;
  500. }
  501. .value {
  502. flex: 1;
  503. textarea {
  504. flex: 1;
  505. border: 1px solid #888888;
  506. box-sizing: border-box;
  507. padding: 16rpx;
  508. }
  509. }
  510. input {
  511. width: 280rpx;
  512. height: 56rpx;
  513. border: 1px solid #9f9f9f;
  514. font-size: 28rpx;
  515. &.number {
  516. width: 104rpx;
  517. text-align: left;
  518. }
  519. }
  520. }
  521. .half-result {
  522. border-bottom: 1px solid #9f9f9f;
  523. padding-bottom: 32rpx;
  524. align-items: center;
  525. .label {
  526. width: 160rpx;
  527. }
  528. .value {
  529. flex: 1;
  530. textarea {
  531. flex: 1;
  532. border: 1px solid #888888;
  533. box-sizing: border-box;
  534. padding: 16rpx;
  535. }
  536. }
  537. input {
  538. width: 140rpx;
  539. height: 56rpx;
  540. border: 1px solid #9f9f9f;
  541. font-size: 28rpx;
  542. &.number {
  543. text-align: left;
  544. }
  545. }
  546. }
  547. }
  548. .unfit-item-container:last-child {
  549. .result {
  550. border-bottom: none;
  551. padding-bottom: 0;
  552. }
  553. }
  554. }
  555. .consultation-container {
  556. margin: 0 16rpx;
  557. padding: 24rpx;
  558. background-color: #ffffff;
  559. border-radius: 8rpx;
  560. .consultation-item-container {
  561. margin-bottom: 24rpx;
  562. border-bottom: 2px solid #888888;
  563. padding-bottom: 24rpx;
  564. }
  565. .consultation-item-container:last-child {
  566. margin-bottom: 0;
  567. border-bottom: 0;
  568. padding-bottom: 0;
  569. }
  570. .question,
  571. .answer {
  572. .label {
  573. justify-content: space-between;
  574. margin-bottom: 16rpx;
  575. font-weight: 700;
  576. }
  577. .content {
  578. line-height: 40rpx;
  579. }
  580. }
  581. .answer {
  582. margin-top: 24rpx;
  583. }
  584. }
  585. .daywork-container {
  586. margin-top: 24rpx;
  587. padding: 24rpx;
  588. background-color: #ffffff;
  589. border: 1px solid #bcbcbc;
  590. .result {
  591. align-items: center;
  592. .label {
  593. width: 112rpx;
  594. }
  595. input {
  596. flex: 1;
  597. height: 56rpx;
  598. border: 1px solid #9f9f9f;
  599. font-size: 28rpx;
  600. text-align: center;
  601. }
  602. }
  603. .half-result {
  604. align-items: center;
  605. .label {
  606. width: 112rpx;
  607. }
  608. input {
  609. width: 20px;
  610. height: 56rpx;
  611. border: 1px solid #9f9f9f;
  612. font-size: 28rpx;
  613. text-align: center;
  614. &.number {
  615. width: 104rpx;
  616. text-align: left;
  617. }
  618. }
  619. }
  620. .remark {
  621. margin-top: 24rpx;
  622. .label {
  623. width: 112rpx;
  624. }
  625. textarea {
  626. flex: 1;
  627. border: 1px solid #9f9f9f;
  628. height: 168rpx;
  629. }
  630. }
  631. .btns-container {
  632. margin-top: 24rpx;
  633. .finished-btn {
  634. display: flex;
  635. flex: 1;
  636. height: 80rpx;
  637. background-color: #fc6565;
  638. color: #ffffff;
  639. text-align: center;
  640. justify-content: center;
  641. align-items: center;
  642. border-radius: 8rpx;
  643. }
  644. .pause-btn {
  645. display: flex;
  646. flex: 1;
  647. height: 80rpx;
  648. background-color: #393cfc;
  649. color: #ffffff;
  650. text-align: center;
  651. justify-content: center;
  652. align-items: center;
  653. border-radius: 8rpx;
  654. }
  655. .question-btn {
  656. width: 80rpx;
  657. align-items: flex-end;
  658. image {
  659. width: 48rpx;
  660. height: 48rpx;
  661. }
  662. text {
  663. font-size: 24rpx;
  664. }
  665. }
  666. }
  667. }
  668. </style>