form.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  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;
  217. console.log("res", res);
  218. uni.hideLoading();
  219. // getInspecion();
  220. } else {
  221. uni.showToast({
  222. icon: 'none',
  223. title: res.msg,
  224. duration: 2000
  225. })
  226. }
  227. });
  228. }
  229. })
  230. /***************************** 定义了一些方法 *****************************/
  231. //咨询文本
  232. function selectText(item) {
  233. for (var i = 0; i < consul.length; i++) {
  234. if (item.status == consul[i].value) {
  235. return consul[i].text
  236. }
  237. }
  238. }
  239. //打开电子图纸
  240. function handleDrawingMenu() {
  241. var outsourceOrderDetailId = encodeURIComponent(auxiliaryDayworkItem.value.outsourceOrderDetailId);
  242. var lotCode = encodeURIComponent(auxiliaryDayworkItem.value.lot.lotCode);
  243. // 构建查询参数字符串
  244. var queryParam = `param1=${outsourceOrderDetailId}&param2=${lotCode}`;
  245. // 使用模板字符串构建完整的URL
  246. var navigateUrl = `/pages/outsourcedDrawingMenu/index?${queryParam}`;
  247. // 导航到指定页面
  248. uni.navigateTo({
  249. url: navigateUrl
  250. });
  251. }
  252. const rejectNumberChange = () => {
  253. let sumReject = 0
  254. let sumDisqualificationNum = 0
  255. let sumExaminingNum = 0
  256. unfitInfos.value.forEach(v => {
  257. sumReject += (v.rejectNum != null && !isNaN(v.rejectNum) ? Number(v.rejectNum) : 0)
  258. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  259. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  260. // v.qualifiedNum = Number(v.prodNum) - Number(v.rejectNum)
  261. })
  262. auxiliaryDayworkItem.value.rejectNum = sumReject
  263. auxiliaryDayworkItem.value.disqualificationNum = sumDisqualificationNum
  264. auxiliaryDayworkItem.value.examiningNum = sumExaminingNum
  265. console.log(auxiliaryDayworkItem.value)
  266. }
  267. //结束报工按钮
  268. function endWork() {
  269. let unf = unfitInfos.value;
  270. for (var i = 0; i < unfitInfos.value.length; i++) {
  271. if (unf[i].rejectNum > unf[i].prodNum) {
  272. uni.showToast({
  273. icon: 'none',
  274. title: '废品量不能大于合格量'
  275. })
  276. return
  277. }
  278. }
  279. let sumReject = 0
  280. unfitInfos.value.forEach(v => {
  281. sumReject += v.rejectNum != null ? Number(v.rejectNum) : 0
  282. })
  283. auxiliaryDayworkItem.value.rejectNum = sumReject
  284. endSave();
  285. }
  286. // 暂停报工按钮
  287. function pauseWork() {
  288. pauseSave()
  289. }
  290. function endSave() {
  291. const currentTime = Date.now();
  292. // 检查是否已经过去了 2 秒
  293. if (currentTime - lastRequestTimestamp.value < 2000) {
  294. // 如果在 2 秒 内已经点击,那么不执行
  295. uni.showToast({
  296. icon: 'none',
  297. title: `请勿重复点击`,
  298. duration: 2000
  299. })
  300. return;
  301. }
  302. let pages = getCurrentPages();
  303. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  304. auxiliaryDayworkItem.value.user = store.userInfo;
  305. finishedDaywork(auxiliaryDayworkItem.value).then(res => {
  306. if (res.code == 200) {
  307. let index = 0;
  308. for (let i = 0; i < pages.length; i++) {
  309. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  310. index = pages.length - i - 1;
  311. }
  312. }
  313. console.log("index", index);
  314. uni.navigateBack({
  315. delta: index
  316. });
  317. } else {
  318. uni.showToast({
  319. icon: 'none',
  320. title: res.msg,
  321. duration: 2000
  322. })
  323. }
  324. });
  325. }
  326. function pauseSave() {
  327. const currentTime = Date.now();
  328. // 检查是否已经过去了 2 秒
  329. if (currentTime - lastRequestTimestamp.value < 2000) {
  330. // 如果在 2 秒 内已经点击,那么不执行
  331. uni.showToast({
  332. icon: 'none',
  333. title: `请勿重复点击`,
  334. duration: 2000
  335. })
  336. return;
  337. }
  338. let pages = getCurrentPages();
  339. auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
  340. auxiliaryDayworkItem.value.user = store.userInfo;
  341. pauseDaywork(auxiliaryDayworkItem.value).then(res => {
  342. if (res.code == 200) {
  343. let index = 0;
  344. for (let i = 0; i < pages.length; i++) {
  345. if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
  346. index = pages.length - i - 1;
  347. }
  348. }
  349. console.log("index", index);
  350. uni.navigateBack({
  351. delta: index
  352. });
  353. } else {
  354. uni.showToast({
  355. icon: 'none',
  356. title: res.msg,
  357. duration: 2000
  358. })
  359. }
  360. });
  361. }
  362. function addReject(row, index) {
  363. // console.log('reject', row)
  364. currentItem.value = row
  365. dialogRejectRef.value.open(row)
  366. }
  367. function handleResFlushItem(data) {
  368. currentItem.value.rejectList = data.filter(e => e.reason != null && e.reason != '')
  369. let rejectNum = 0
  370. currentItem.value.rejectList.forEach(l => {
  371. rejectNum += l.rejectNum != null ? Number(l.rejectNum) : 0
  372. })
  373. currentItem.value.rejectNum = rejectNum
  374. rejectNumberChange()
  375. // console.log(currentItem.value)
  376. }
  377. </script>
  378. <style lang="scss">
  379. .page-container {
  380. // height: 100%;
  381. background-color: #ececec;
  382. font-size: 28rpx;
  383. >.title {
  384. font-weight: 700;
  385. margin: 24rpx 16rpx;
  386. }
  387. }
  388. .carrier-info {
  389. margin: 32rpx 16rpx 0 16rpx;
  390. padding: 24rpx;
  391. background-color: #ffffff;
  392. border-radius: 8rpx;
  393. .carrier-code {
  394. font-size: 32rpx;
  395. font-weight: 700;
  396. }
  397. .info-row {
  398. margin-top: 16rpx;
  399. color: #767676;
  400. .label {
  401. width: 160rpx;
  402. }
  403. .drawing-btn {
  404. padding: 12rpx 32rpx;
  405. background-color: #0055ff;
  406. color: #ffffff;
  407. border-radius: 12rpx;
  408. margin-left: auto;
  409. font-size: 28rpx;
  410. }
  411. .value {
  412. flex: 1;
  413. textarea {
  414. flex: 1;
  415. border: 1px solid #888888;
  416. box-sizing: border-box;
  417. padding: 16rpx;
  418. }
  419. }
  420. }
  421. }
  422. .unfit-title {
  423. margin-bottom: 24rpx;
  424. justify-content: space-between;
  425. align-items: center;
  426. text {
  427. font-size: 28rpx;
  428. font-weight: 700;
  429. }
  430. .add-btn {
  431. margin-right: 26rpx;
  432. padding: 12rpx 32rpx;
  433. background-color: #a4adb3;
  434. color: #ffffff;
  435. border-radius: 12rpx;
  436. font-size: 24rpx;
  437. }
  438. }
  439. .unfit-container {
  440. padding: 24rpx;
  441. margin: 0 16rpx;
  442. background-color: #ffffff;
  443. border-radius: 12rpx;
  444. .unfit-item-container {
  445. position: relative;
  446. >* {
  447. margin-bottom: 24rpx;
  448. }
  449. .title {
  450. font-weight: 700;
  451. justify-content: space-between;
  452. align-items: center;
  453. image {
  454. width: 40rpx;
  455. height: 40rpx;
  456. }
  457. }
  458. .standard {}
  459. .resu {
  460. width: 100%;
  461. align-items: center;
  462. input {
  463. margin-left: 20rpx;
  464. width: 200rpx;
  465. height: 56rpx;
  466. flex: 1;
  467. border: 1px solid #9f9f9f;
  468. font-size: 28rpx;
  469. }
  470. .label {
  471. width: 160rpx;
  472. }
  473. .value {
  474. flex: 1;
  475. textarea {
  476. flex: 1;
  477. border: 1px solid #888888;
  478. box-sizing: border-box;
  479. padding: 16rpx;
  480. }
  481. }
  482. }
  483. .result {
  484. border-bottom: 1px solid #9f9f9f;
  485. padding-bottom: 32rpx;
  486. align-items: center;
  487. .label {
  488. width: 160rpx;
  489. }
  490. .value {
  491. flex: 1;
  492. textarea {
  493. flex: 1;
  494. border: 1px solid #888888;
  495. box-sizing: border-box;
  496. padding: 16rpx;
  497. }
  498. }
  499. input {
  500. width: 280rpx;
  501. height: 56rpx;
  502. border: 1px solid #9f9f9f;
  503. font-size: 28rpx;
  504. &.number {
  505. width: 104rpx;
  506. text-align: left;
  507. }
  508. }
  509. }
  510. .half-result {
  511. border-bottom: 1px solid #9f9f9f;
  512. padding-bottom: 32rpx;
  513. align-items: center;
  514. .label {
  515. width: 160rpx;
  516. }
  517. .value {
  518. flex: 1;
  519. textarea {
  520. flex: 1;
  521. border: 1px solid #888888;
  522. box-sizing: border-box;
  523. padding: 16rpx;
  524. }
  525. }
  526. input {
  527. width: 140rpx;
  528. height: 56rpx;
  529. border: 1px solid #9f9f9f;
  530. font-size: 28rpx;
  531. &.number {
  532. text-align: left;
  533. }
  534. }
  535. }
  536. }
  537. .unfit-item-container:last-child {
  538. .result {
  539. border-bottom: none;
  540. padding-bottom: 0;
  541. }
  542. }
  543. }
  544. .consultation-container {
  545. margin: 0 16rpx;
  546. padding: 24rpx;
  547. background-color: #ffffff;
  548. border-radius: 8rpx;
  549. .consultation-item-container {
  550. margin-bottom: 24rpx;
  551. border-bottom: 2px solid #888888;
  552. padding-bottom: 24rpx;
  553. }
  554. .consultation-item-container:last-child {
  555. margin-bottom: 0;
  556. border-bottom: 0;
  557. padding-bottom: 0;
  558. }
  559. .question,
  560. .answer {
  561. .label {
  562. justify-content: space-between;
  563. margin-bottom: 16rpx;
  564. font-weight: 700;
  565. }
  566. .content {
  567. line-height: 40rpx;
  568. }
  569. }
  570. .answer {
  571. margin-top: 24rpx;
  572. }
  573. }
  574. .daywork-container {
  575. margin-top: 24rpx;
  576. padding: 24rpx;
  577. background-color: #ffffff;
  578. border: 1px solid #bcbcbc;
  579. .result {
  580. align-items: center;
  581. .label {
  582. width: 112rpx;
  583. }
  584. input {
  585. flex: 1;
  586. height: 56rpx;
  587. border: 1px solid #9f9f9f;
  588. font-size: 28rpx;
  589. text-align: center;
  590. }
  591. }
  592. .half-result {
  593. align-items: center;
  594. .label {
  595. width: 112rpx;
  596. }
  597. input {
  598. width: 20px;
  599. height: 56rpx;
  600. border: 1px solid #9f9f9f;
  601. font-size: 28rpx;
  602. text-align: center;
  603. &.number {
  604. width: 104rpx;
  605. text-align: left;
  606. }
  607. }
  608. }
  609. .remark {
  610. margin-top: 24rpx;
  611. .label {
  612. width: 112rpx;
  613. }
  614. textarea {
  615. flex: 1;
  616. border: 1px solid #9f9f9f;
  617. height: 168rpx;
  618. }
  619. }
  620. .btns-container {
  621. margin-top: 24rpx;
  622. .finished-btn {
  623. display: flex;
  624. flex: 1;
  625. height: 80rpx;
  626. background-color: #fc6565;
  627. color: #ffffff;
  628. text-align: center;
  629. justify-content: center;
  630. align-items: center;
  631. border-radius: 8rpx;
  632. }
  633. .pause-btn {
  634. display: flex;
  635. flex: 1;
  636. height: 80rpx;
  637. background-color: #393cfc;
  638. color: #ffffff;
  639. text-align: center;
  640. justify-content: center;
  641. align-items: center;
  642. border-radius: 8rpx;
  643. }
  644. .question-btn {
  645. width: 80rpx;
  646. align-items: flex-end;
  647. image {
  648. width: 48rpx;
  649. height: 48rpx;
  650. }
  651. text {
  652. font-size: 24rpx;
  653. }
  654. }
  655. }
  656. }
  657. </style>