form.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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;">{{processInspecion.lot.allCarrierName}}</text>
  7. </view>
  8. <view class="info-row uni-row">
  9. <view class="label">图号</view>
  10. <view class="value">{{ processInspecion.lot.drawingNumber }}</view>
  11. </view>
  12. <view class="info-row uni-row">
  13. <view class="label">批次号</view>
  14. <view class="value">{{ processInspecion.lot.lotCode }}</view>
  15. </view>
  16. <view class="info-row uni-row">
  17. <view class="label">工艺版本</view>
  18. <view class="value">{{ processInspecion.lot.technologyVersion }}</view>
  19. </view>
  20. <view class="info-row uni-row">
  21. <view class="label">产品描述</view>
  22. <view class="value">{{processInspecion.lot. productDescription }}</view>
  23. </view>
  24. <view class="info-row uni-row">
  25. <view class="label">当前工序</view>
  26. <view class="value">{{ processInspecion.lot.processAlias }}</view>
  27. </view>
  28. <view class="info-row uni-row">
  29. <view class="label">投产数量</view>
  30. <view class="value">{{ processInspecion.lot.pudName }}</view>
  31. </view>
  32. </view>
  33. <!-- 废品信息 -->
  34. <view class="title unfit-title uni-row">
  35. <text>废品信息</text>
  36. <view class="add-btn" @click="handleAddWaste">添加</view>
  37. </view>
  38. <view class="unfit-container">
  39. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  40. <!-- 暂时注释,后续会使用 -->
  41. <!-- <view class="title uni-row">
  42. <text>检查项-{{ item.title }}</text>
  43. <uni-icons type="trash" size="24" color="#fc6565" @click="handleDelWaste(index)" />
  44. </view> -->
  45. <!-- <view class="standard">检查标准:{{ item.standard }}</view> -->
  46. <view class="resu uni-row">
  47. <view class="label">检查标准</view>
  48. <input v-model="item.checkStandard" placeholder="请输入检查标准" />
  49. <uni-icons type="trash" size="24" style="margin-left: 55rpx;" color="#fc6565"
  50. @click="handleDelWaste(index)" />
  51. </view>
  52. <view class="result uni-row">
  53. <view class="label">检查结果</view>
  54. <input v-model="item.checkResult" placeholder="请输入检查结果" />
  55. <view class="label" style="text-align: right; padding-right: 16rpx;">数量
  56. </view>
  57. <input class="number" type="number" @blur="rejectNumberChange" v-model="item.rejectNum"
  58. placeholder="" />
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 咨询部分 -->
  63. <view class="title">咨询</view>
  64. <view class="consultation-container uni-column">
  65. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  66. <view class="question uni-column">
  67. <view class="label uni-row">
  68. <text>问题描述</text>
  69. <text :style="selectType(item)">{{ selectText(item) }}</text>
  70. </view>
  71. <view class="content">{{ item.content }}</view>
  72. </view>
  73. <!-- 不需要暂时注释 -->
  74. <!-- <view v-if="item.answer !== ''" class="answer"
  75. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  76. <view class="label">回复</view>
  77. <view class="content">{{ item.answer }}</view>
  78. </view> -->
  79. </view>
  80. </view>
  81. <!-- 报工部分 -->
  82. <view class="daywork-container">
  83. <!-- 此处后续要加上条件限制,当状态为合格或不合格的时候不能修改状态,需要有权限的人来进行修改 -->
  84. <view class="result uni-row">
  85. <view class="label">检测量</view>
  86. <input type="number" v-model="processInspecion.examiningNum" placeholder="请输入检测量" />
  87. <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
  88. <input type="number" v-model="processInspecion.rejectNum" placeholder="请输入废品量" />
  89. </view>
  90. <view class="result uni-row">
  91. <view class="label" style="margin-top: 20rpx; margin-right: 10rpx;">序检状态</view>
  92. <uni-data-checkbox style="margin-top: 20rpx;" v-model="processInspecion.status"
  93. :localdata="range"></uni-data-checkbox>
  94. <!-- @change="change" -->
  95. </view>
  96. <view class="remark uni-row">
  97. <view class="label">备注</view>
  98. <textarea v-model="processInspecion.remark" />
  99. </view>
  100. <view class="btns-container uni-row">
  101. <view class="finished-btn" @click="endWork">结束报工</view>
  102. <view class="question-btn uni-column" @click.stop="handleAddConsultation">
  103. <uni-icons type="headphones" size="24" />
  104. <text>咨询</text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script setup>
  111. import {
  112. ref,
  113. onMounted,
  114. getCurrentInstance
  115. } from 'vue'
  116. import {
  117. onLoad,
  118. onReady,
  119. onUnload,
  120. onShow
  121. } from '@dcloudio/uni-app'
  122. import {
  123. store
  124. } from '@/store/index.js'
  125. import {
  126. saveProcessInspecion,
  127. selectInspecion
  128. } from '@/api/business/processInspection.js'
  129. const lot = ref({})
  130. const unfitInfos = ref([]) //废品信息
  131. const consultations = ref([]) //咨询信息
  132. // 创建一个引用来存储最后一次请求的时间戳
  133. const lastRequestTimestamp = ref(0);
  134. const processInspecion = ref({
  135. remark: "",
  136. rejectNum: 0,
  137. examiningNum: 0,
  138. status: 0,
  139. })
  140. const consul = [{
  141. value: 0,
  142. text: "待确认",
  143. type: "color: #fcab53"
  144. }, {
  145. value: 2,
  146. text: "合格",
  147. type: "color: #55ff7f"
  148. }, {
  149. value: 1,
  150. text: "不合格",
  151. type: "color: #ff0c2c"
  152. }]
  153. const range = [{
  154. value: 0,
  155. text: "待确认",
  156. type: "color: #fcab53"
  157. }, {
  158. value: 1,
  159. text: "合格",
  160. type: "color: #55ff7f"
  161. }, {
  162. value: 2,
  163. text: "不合格",
  164. type: "color: #ff0c2c"
  165. }]
  166. /***************************** 页面生命周期函数 *****************************/
  167. onMounted(() => {
  168. const instance = getCurrentInstance().proxy
  169. const eventChannel = instance.getOpenerEventChannel();
  170. eventChannel.on('processInspectionFrom', function(data) {
  171. console.log('acceptDataFromOpenerPage', data)
  172. if (data && data.data) {
  173. processInspecion.value.lot = data.data;
  174. }
  175. })
  176. })
  177. onShow(() => {
  178. if (store.processInspection != null) {
  179. uni.showLoading({
  180. title: '加载中'
  181. });
  182. processInspecion.value = store.processInspection
  183. selectInspecion(processInspecion.value).then(res => {
  184. if (res.code == 200) {
  185. processInspecion.value = res.data;
  186. unfitInfos.value = res.data.dayworkItemRejects;
  187. consultations.value = res.data.dayworkItemConsults;
  188. console.log("res", res);
  189. uni.hideLoading();
  190. // getInspecion();
  191. } else {
  192. uni.showToast({
  193. icon: 'none',
  194. title: res.msg,
  195. duration: 2000
  196. })
  197. }
  198. });
  199. }
  200. })
  201. /***************************** 定义了一些方法 *****************************/
  202. //咨询文本
  203. function selectText(item) {
  204. for (var i = 0; i < consul.length; i++) {
  205. if (item.status == consul[i].value) {
  206. return consul[i].text
  207. }
  208. }
  209. }
  210. const rejectNumberChange = () => {
  211. let sumReject = 0
  212. unfitInfos.value.forEach(v => {
  213. sumReject += Number(v.rejectNum)
  214. })
  215. processInspecion.value.rejectNum = sumReject
  216. console.log(processInspecion.value)
  217. }
  218. //查询咨询列表
  219. function getInspecion() {
  220. processInspecion.value = store.processInspection
  221. selectInspecion(processInspecion.value).then(res => {
  222. console.log("咨询", res);
  223. if (res.code == 200) {
  224. console.log("res", res);
  225. } else {
  226. uni.showToast({
  227. icon: 'none',
  228. title: res.msg,
  229. duration: 2000
  230. })
  231. }
  232. });
  233. }
  234. //结束报工按钮
  235. function endWork() {
  236. let unf = unfitInfos.value;
  237. for (var i = 0; i < unfitInfos.value.length; i++) {
  238. if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].rejectNum) {
  239. uni.showToast({
  240. icon: 'none',
  241. title: "废品信息不能为空",
  242. duration: 2000
  243. })
  244. return;
  245. }
  246. }
  247. let sumReject = 0
  248. unfitInfos.value.forEach(v => {
  249. sumReject += Number(v.rejectNum)
  250. })
  251. if (processInspecion.value.rejectNum != sumReject) {
  252. uni.showToast({
  253. icon: 'none',
  254. title: "废品量与废品信息不一致",
  255. duration: 2000
  256. })
  257. return;
  258. }
  259. save();
  260. }
  261. function save() {
  262. const currentTime = Date.now();
  263. // 检查是否已经过去了 2 秒
  264. if (currentTime - lastRequestTimestamp.value < 2000) {
  265. // 如果在 2 秒 内已经点击,那么不执行
  266. uni.showToast({
  267. icon: 'none',
  268. title: `请勿重复点击`,
  269. duration: 2000
  270. })
  271. return;
  272. }
  273. let pages = getCurrentPages();
  274. processInspecion.value.dayworkItemConsults = consultations.value;
  275. processInspecion.value.dayworkItemRejects = unfitInfos.value;
  276. processInspecion.value.user = store.userInfo;
  277. saveProcessInspecion(processInspecion.value).then(res => {
  278. if (res.code == 200) {
  279. let index = 0;
  280. for (let i = 0; i < pages.length; i++) {
  281. if (pages[i].$page.fullPath == "/pages/processInspection/index") {
  282. index = pages.length - i - 1;
  283. }
  284. }
  285. console.log("index", index);
  286. uni.navigateBack({
  287. delta: index
  288. });
  289. } else {
  290. uni.showToast({
  291. icon: 'none',
  292. title: res.msg,
  293. duration: 2000
  294. })
  295. }
  296. });
  297. }
  298. //咨询样式
  299. function selectType(item) {
  300. for (var i = 0; i < consul.length; i++) {
  301. if (item.status == consul[i].value) {
  302. return consul[i].type
  303. }
  304. }
  305. }
  306. const addWasteInfo = (data) => {
  307. const info = {
  308. title: data.title,
  309. checkStandard: data.standard
  310. }
  311. unfitInfos.value.push(info)
  312. }
  313. const addConsultation = (data) => {
  314. const info = {
  315. content: data.question,
  316. status: 0
  317. }
  318. consultations.value.push(info)
  319. }
  320. /***************************** 定义了一些事件 *****************************/
  321. // 添加不合格信息
  322. const handleAddWaste = () => {
  323. let info = {}
  324. unfitInfos.value.push(info)
  325. // 监听事件,暂时不用,后续会使用
  326. // uni.$once('addWasteInfoEvent', (data) => {
  327. // addWasteInfo(data)
  328. // })
  329. // uni.navigateTo({
  330. // url: "/pages/processInspection/options"
  331. // })
  332. }
  333. // 删除不合格信息
  334. const handleDelWaste = (index) => {
  335. uni.showModal({
  336. title: '提示',
  337. content: '确定删除该项?',
  338. success: function(res) {
  339. if (res.confirm) {
  340. unfitInfos.value.splice(index, 1)
  341. } else if (res.cancel) {
  342. return
  343. }
  344. }
  345. })
  346. }
  347. // 咨询
  348. const handleAddConsultation = () => {
  349. // 监听事件
  350. uni.$once('addWasteConsultationEvent', (data) => {
  351. addConsultation(data)
  352. })
  353. uni.navigateTo({
  354. url: "/pages/processInspection/consultation",
  355. success: (res) => {
  356. // 通过eventChannel向被打开页面传送数据
  357. res.eventChannel.emit("processInspectionConsultation", {
  358. data: processInspecion.value.lot
  359. })
  360. }
  361. })
  362. }
  363. </script>
  364. <style lang="scss">
  365. .page-container {
  366. height: 100%;
  367. background-color: #ececec;
  368. font-size: 28rpx;
  369. >.title {
  370. font-weight: 700;
  371. margin: 24rpx 16rpx;
  372. }
  373. }
  374. .carrier-info {
  375. margin: 32rpx 16rpx 0 16rpx;
  376. padding: 24rpx;
  377. background-color: #ffffff;
  378. border-radius: 8rpx;
  379. .carrier-code {
  380. font-size: 32rpx;
  381. font-weight: 700;
  382. }
  383. .info-row {
  384. margin-top: 16rpx;
  385. color: #767676;
  386. .label {
  387. width: 160rpx;
  388. }
  389. .value {
  390. flex: 1;
  391. textarea {
  392. flex: 1;
  393. border: 1px solid #888888;
  394. box-sizing: border-box;
  395. padding: 16rpx;
  396. }
  397. }
  398. }
  399. }
  400. .unfit-title {
  401. margin-bottom: 24rpx;
  402. justify-content: space-between;
  403. align-items: center;
  404. text {
  405. font-size: 28rpx;
  406. font-weight: 700;
  407. }
  408. .add-btn {
  409. padding: 12rpx 32rpx;
  410. background-color: #a4adb3;
  411. color: #ffffff;
  412. border-radius: 12rpx;
  413. font-size: 24rpx;
  414. }
  415. }
  416. .unfit-container {
  417. padding: 24rpx;
  418. margin: 0 16rpx;
  419. background-color: #ffffff;
  420. border-radius: 12rpx;
  421. .unfit-item-container {
  422. position: relative;
  423. >* {
  424. margin-bottom: 24rpx;
  425. }
  426. .title {
  427. font-weight: 700;
  428. justify-content: space-between;
  429. align-items: center;
  430. image {
  431. width: 40rpx;
  432. height: 40rpx;
  433. }
  434. }
  435. .standard {}
  436. .resu {
  437. width: 100%;
  438. align-items: center;
  439. input {
  440. margin-left: 20rpx;
  441. width: 200rpx;
  442. height: 56rpx;
  443. flex: 1;
  444. border: 1px solid #9f9f9f;
  445. font-size: 28rpx;
  446. }
  447. }
  448. .result {
  449. align-items: center;
  450. border-bottom: 1px solid #9f9f9f;
  451. padding-bottom: 32rpx;
  452. .label {
  453. flex: 1;
  454. }
  455. input {
  456. width: 280rpx;
  457. height: 56rpx;
  458. border: 1px solid #9f9f9f;
  459. font-size: 28rpx;
  460. &.number {
  461. width: 104rpx;
  462. text-align: center;
  463. }
  464. }
  465. }
  466. }
  467. .unfit-item-container:last-child {
  468. .result {
  469. border-bottom: none;
  470. padding-bottom: 0;
  471. }
  472. }
  473. }
  474. .consultation-container {
  475. margin: 0 16rpx;
  476. padding: 24rpx;
  477. background-color: #ffffff;
  478. border-radius: 8rpx;
  479. .consultation-item-container {
  480. margin-bottom: 24rpx;
  481. border-bottom: 2px solid #888888;
  482. padding-bottom: 24rpx;
  483. }
  484. .consultation-item-container:last-child {
  485. margin-bottom: 0;
  486. border-bottom: 0;
  487. padding-bottom: 0;
  488. }
  489. .question,
  490. .answer {
  491. .label {
  492. justify-content: space-between;
  493. margin-bottom: 16rpx;
  494. font-weight: 700;
  495. }
  496. .content {
  497. line-height: 40rpx;
  498. }
  499. }
  500. .answer {
  501. margin-top: 24rpx;
  502. }
  503. }
  504. .daywork-container {
  505. margin-top: 24rpx;
  506. padding: 24rpx;
  507. background-color: #ffffff;
  508. border: 1px solid #bcbcbc;
  509. .result {
  510. align-items: center;
  511. .label {
  512. width: 112rpx;
  513. }
  514. input {
  515. flex: 1;
  516. height: 56rpx;
  517. border: 1px solid #9f9f9f;
  518. font-size: 28rpx;
  519. text-align: center;
  520. }
  521. }
  522. .remark {
  523. margin-top: 24rpx;
  524. .label {
  525. width: 112rpx;
  526. }
  527. textarea {
  528. flex: 1;
  529. border: 1px solid #9f9f9f;
  530. height: 168rpx;
  531. }
  532. }
  533. .btns-container {
  534. margin-top: 24rpx;
  535. .finished-btn {
  536. display: flex;
  537. flex: 1;
  538. height: 80rpx;
  539. background-color: #fc6565;
  540. color: #ffffff;
  541. text-align: center;
  542. justify-content: center;
  543. align-items: center;
  544. border-radius: 8rpx;
  545. }
  546. .question-btn {
  547. width: 80rpx;
  548. align-items: flex-end;
  549. image {
  550. width: 48rpx;
  551. height: 48rpx;
  552. }
  553. text {
  554. font-size: 24rpx;
  555. }
  556. }
  557. }
  558. }
  559. </style>