form.vue 13 KB

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