form.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. selectOutsourcedInspecion
  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. if (store.processInspection != null) {
  176. uni.showLoading({
  177. title: '加载中'
  178. });
  179. processInspecion.value = store.processInspection
  180. selectOutsourcedInspecion(processInspecion.value).then(res => {
  181. console.log("res", res);
  182. if (res.code == 200) {
  183. processInspecion.value = res.data;
  184. unfitInfos.value = res.data.dayworkItemRejects;
  185. consultations.value = res.data.dayworkItemConsults;
  186. console.log("res", res);
  187. uni.hideLoading();
  188. // getInspecion();
  189. } else {
  190. uni.showToast({
  191. icon: 'none',
  192. title: res.msg,
  193. duration: 2000
  194. })
  195. }
  196. });
  197. }
  198. })
  199. /***************************** 定义了一些方法 *****************************/
  200. //咨询文本
  201. function selectText(item) {
  202. for (var i = 0; i < consul.length; i++) {
  203. if (item.status == consul[i].value) {
  204. return consul[i].text
  205. }
  206. }
  207. }
  208. const rejectNumberChange = () => {
  209. let sumReject = 0
  210. unfitInfos.value.forEach(v => {
  211. sumReject += Number(v.rejectNum)
  212. })
  213. processInspecion.value.rejectNum = sumReject
  214. console.log(processInspecion.value)
  215. }
  216. //查询咨询列表
  217. function getInspecion() {
  218. processInspecion.value = store.processInspection
  219. selectInspecion(processInspecion.value).then(res => {
  220. console.log("咨询", res);
  221. if (res.code == 200) {
  222. console.log("res", res);
  223. } else {
  224. uni.showToast({
  225. icon: 'none',
  226. title: res.msg,
  227. duration: 2000
  228. })
  229. }
  230. });
  231. }
  232. //结束报工按钮
  233. function endWork() {
  234. let unf = unfitInfos.value;
  235. for (var i = 0; i < unfitInfos.value.length; i++) {
  236. console.log("废品信息");
  237. if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].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. console.log("咨询事件监听");
  340. addConsultation(data)
  341. })
  342. uni.navigateTo({
  343. url: "/pages/outsourcedInspection/consultation",
  344. success: (res) => {
  345. // 通过eventChannel向被打开页面传送数据
  346. res.eventChannel.emit("outsourcedInspectionConsultation", {
  347. data: processInspecion.value.lot
  348. })
  349. }
  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>