form.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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.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. save();
  245. }
  246. function save() {
  247. let pages = getCurrentPages();
  248. processInspecion.value.dayworkItemConsults = consultations.value;
  249. processInspecion.value.dayworkItemRejects = unfitInfos.value;
  250. processInspecion.value.user = store.userInfo;
  251. saveProcessInspecion(processInspecion.value).then(res => {
  252. if (res.code == 200) {
  253. let index = 0;
  254. for (let i = 0; i < pages.length; i++) {
  255. if (pages[i].$page.fullPath == "/pages/processInspection/index") {
  256. index = pages.length - i - 1;
  257. }
  258. }
  259. console.log("index", index);
  260. uni.navigateBack({
  261. delta: index
  262. });
  263. } else {
  264. uni.showToast({
  265. icon: 'none',
  266. title: res.msg,
  267. duration: 2000
  268. })
  269. }
  270. });
  271. }
  272. //咨询样式
  273. function selectType(item) {
  274. for (var i = 0; i < consul.length; i++) {
  275. if (item.status == consul[i].value) {
  276. return consul[i].type
  277. }
  278. }
  279. }
  280. const addWasteInfo = (data) => {
  281. const info = {
  282. title: data.title,
  283. checkStandard: data.standard
  284. }
  285. unfitInfos.value.push(info)
  286. }
  287. const addConsultation = (data) => {
  288. const info = {
  289. content: data.question,
  290. status: 0
  291. }
  292. consultations.value.push(info)
  293. }
  294. /***************************** 定义了一些事件 *****************************/
  295. // 添加不合格信息
  296. const handleAddWaste = () => {
  297. let info = {}
  298. unfitInfos.value.push(info)
  299. // 监听事件,暂时不用,后续会使用
  300. // uni.$once('addWasteInfoEvent', (data) => {
  301. // addWasteInfo(data)
  302. // })
  303. // uni.navigateTo({
  304. // url: "/pages/processInspection/options"
  305. // })
  306. }
  307. // 删除不合格信息
  308. const handleDelWaste = (index) => {
  309. uni.showModal({
  310. title: '提示',
  311. content: '确定删除该项?',
  312. success: function(res) {
  313. if (res.confirm) {
  314. unfitInfos.value.splice(index, 1)
  315. } else if (res.cancel) {
  316. return
  317. }
  318. }
  319. })
  320. }
  321. // 咨询
  322. const handleAddConsultation = () => {
  323. // 监听事件
  324. uni.$once('addWasteConsultationEvent', (data) => {
  325. addConsultation(data)
  326. })
  327. uni.navigateTo({
  328. url: "/pages/processInspection/consultation",
  329. success: (res) => {
  330. // 通过eventChannel向被打开页面传送数据
  331. res.eventChannel.emit("processInspectionConsultation", {
  332. data: processInspecion.value.lot
  333. })
  334. }
  335. })
  336. // uni.navigateTo({
  337. // url: "/pages/processInspection/consultation"
  338. // })
  339. }
  340. </script>
  341. <style lang="scss">
  342. .page-container {
  343. height: 100%;
  344. background-color: #ececec;
  345. font-size: 28rpx;
  346. >.title {
  347. font-weight: 700;
  348. margin: 24rpx 16rpx;
  349. }
  350. }
  351. .carrier-info {
  352. margin: 32rpx 16rpx 0 16rpx;
  353. padding: 24rpx;
  354. background-color: #ffffff;
  355. border-radius: 8rpx;
  356. .carrier-code {
  357. font-size: 32rpx;
  358. font-weight: 700;
  359. }
  360. .info-row {
  361. margin-top: 16rpx;
  362. color: #767676;
  363. .label {
  364. width: 160rpx;
  365. }
  366. .value {
  367. flex: 1;
  368. textarea {
  369. flex: 1;
  370. border: 1px solid #888888;
  371. box-sizing: border-box;
  372. padding: 16rpx;
  373. }
  374. }
  375. }
  376. }
  377. .unfit-title {
  378. margin-bottom: 24rpx;
  379. justify-content: space-between;
  380. align-items: center;
  381. text {
  382. font-size: 28rpx;
  383. font-weight: 700;
  384. }
  385. .add-btn {
  386. padding: 12rpx 32rpx;
  387. background-color: #a4adb3;
  388. color: #ffffff;
  389. border-radius: 12rpx;
  390. font-size: 24rpx;
  391. }
  392. }
  393. .unfit-container {
  394. padding: 24rpx;
  395. margin: 0 16rpx;
  396. background-color: #ffffff;
  397. border-radius: 12rpx;
  398. .unfit-item-container {
  399. position: relative;
  400. >* {
  401. margin-bottom: 24rpx;
  402. }
  403. .title {
  404. font-weight: 700;
  405. justify-content: space-between;
  406. align-items: center;
  407. image {
  408. width: 40rpx;
  409. height: 40rpx;
  410. }
  411. }
  412. .standard {}
  413. .resu {
  414. width: 100%;
  415. align-items: center;
  416. input {
  417. margin-left: 20rpx;
  418. width: 200rpx;
  419. height: 56rpx;
  420. flex: 1;
  421. border: 1px solid #9f9f9f;
  422. font-size: 28rpx;
  423. }
  424. }
  425. .result {
  426. align-items: center;
  427. border-bottom: 1px solid #9f9f9f;
  428. padding-bottom: 32rpx;
  429. .label {
  430. flex: 1;
  431. }
  432. input {
  433. width: 280rpx;
  434. height: 56rpx;
  435. border: 1px solid #9f9f9f;
  436. font-size: 28rpx;
  437. &.number {
  438. width: 104rpx;
  439. text-align: center;
  440. }
  441. }
  442. }
  443. }
  444. .unfit-item-container:last-child {
  445. .result {
  446. border-bottom: none;
  447. padding-bottom: 0;
  448. }
  449. }
  450. }
  451. .consultation-container {
  452. margin: 0 16rpx;
  453. padding: 24rpx;
  454. background-color: #ffffff;
  455. border-radius: 8rpx;
  456. .consultation-item-container {
  457. margin-bottom: 24rpx;
  458. border-bottom: 2px solid #888888;
  459. padding-bottom: 24rpx;
  460. }
  461. .consultation-item-container:last-child {
  462. margin-bottom: 0;
  463. border-bottom: 0;
  464. padding-bottom: 0;
  465. }
  466. .question,
  467. .answer {
  468. .label {
  469. justify-content: space-between;
  470. margin-bottom: 16rpx;
  471. font-weight: 700;
  472. }
  473. .content {
  474. line-height: 40rpx;
  475. }
  476. }
  477. .answer {
  478. margin-top: 24rpx;
  479. }
  480. }
  481. .daywork-container {
  482. margin-top: 24rpx;
  483. padding: 24rpx;
  484. background-color: #ffffff;
  485. border: 1px solid #bcbcbc;
  486. .result {
  487. align-items: center;
  488. .label {
  489. width: 112rpx;
  490. }
  491. input {
  492. flex: 1;
  493. height: 56rpx;
  494. border: 1px solid #9f9f9f;
  495. font-size: 28rpx;
  496. text-align: center;
  497. }
  498. }
  499. .remark {
  500. margin-top: 24rpx;
  501. .label {
  502. width: 112rpx;
  503. }
  504. textarea {
  505. flex: 1;
  506. border: 1px solid #9f9f9f;
  507. height: 168rpx;
  508. }
  509. }
  510. .btns-container {
  511. margin-top: 24rpx;
  512. .finished-btn {
  513. display: flex;
  514. flex: 1;
  515. height: 80rpx;
  516. background-color: #fc6565;
  517. color: #ffffff;
  518. text-align: center;
  519. justify-content: center;
  520. align-items: center;
  521. border-radius: 8rpx;
  522. }
  523. .question-btn {
  524. width: 80rpx;
  525. align-items: flex-end;
  526. image {
  527. width: 48rpx;
  528. height: 48rpx;
  529. }
  530. text {
  531. font-size: 24rpx;
  532. }
  533. }
  534. }
  535. }
  536. </style>