form.vue 13 KB

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