form.vue 14 KB

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