form.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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.nickName }}</view>
  31. </view>
  32. <view class="info-row uni-row">
  33. <view class="label">设备</view>
  34. <view class="value">{{ processInspecion.lot.equipmentDetailCode }}</view>
  35. </view>
  36. <view class="info-row uni-row">
  37. <view class="label">检查载具</view>
  38. <view class="value">{{ processInspecion.lot.inspectionCarrierCode }}
  39. {{ processInspecion.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  40. </view>
  41. </view>
  42. <view class="info-row uni-row">
  43. <view class="drawing-btn" @click="handleDrawingMenu">图纸信息</view>
  44. </view>
  45. </view>
  46. <!-- 废品信息 -->
  47. <view class="title unfit-title uni-row">
  48. <text>检查信息</text>
  49. <view v-if="editable()" class="add-btn" @click="handleAddWaste">添加</view>
  50. </view>
  51. <view class="unfit-container">
  52. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  53. <view class="resu uni-row">
  54. <view class="label">检查标准</view>
  55. <view class="value" style="margin-left:16rpx;width: 400rpx;">{{ item.checkStandard }}</view>
  56. <uni-icons v-if="editable()" type="trash" size="24" style="margin-left: 55rpx;" color="#fc6565"
  57. @click="handleDelWaste(index)" />
  58. </view>
  59. <view class="resu uni-row">
  60. <view class="label">检查结果</view>
  61. <input :disabled="!editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  62. <!-- <view v-else class="value">{{ item.checkResult }}</view> -->
  63. </view>
  64. <view class="resu uni-row">
  65. <view class="label">超差范围</view>
  66. <input :disabled="!editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  67. <!-- <view v-else class="value">{{ item.exceedLimits }}</view> -->
  68. </view>
  69. <view class="resu uni-row">
  70. <view :class="!editable() ? 'label' : ''">检查量</view>
  71. <input :disabled="!editable()" class="number" type="number" @blur="rejectNumberChange"
  72. v-model="item.examiningNum" placeholder="" />
  73. <!-- <view v-else class="number value">{{ item.examiningNum }}</view> -->
  74. <view :class="!editable() ? 'label' : ''">不良品量</view>
  75. <input :disabled="!editable()" class="number" type="number" @blur="rejectNumberChange"
  76. v-model="item.disqualificationNum" placeholder="" />
  77. <!-- <view v-else class="value">{{ item.disqualificationNum }}</view> -->
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 咨询部分 -->
  82. <view class="title unfit-title uni-row">
  83. <text>咨询</text>
  84. </view>
  85. <view class="consultation-container uni-column">
  86. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  87. <view class="question uni-column">
  88. <view class="label uni-row">
  89. <text>问题描述</text>
  90. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}} {{ selectText(item) }}</text>
  91. </view>
  92. <view class="content">{{ item.content }}</view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 报工部分 -->
  97. <view class="daywork-container">
  98. <view class="result uni-row">
  99. <view class="label" style="margin-top: 20rpx;width: 170rpx;">仪器室检状态</view>
  100. <uni-data-checkbox :disabled="!editable()" style="margin-top: 20rpx;" v-model="processInspecion.status"
  101. :localdata="range"></uni-data-checkbox>
  102. </view>
  103. <view class="remark uni-row">
  104. <view class="label">备注</view>
  105. <textarea :disabled="!editable()" v-model="processInspecion.remark" />
  106. </view>
  107. <view v-if="editable()" class="btns-container uni-row">
  108. <view class="finished-btn" @click="endWork">提交</view>
  109. <view class="question-btn uni-column" @click.stop="handleAddConsultation">
  110. <uni-icons type="headphones" size="24" />
  111. <text>咨询</text>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </template>
  117. <script setup>
  118. import {
  119. ref,
  120. onMounted,
  121. getCurrentInstance
  122. } from 'vue'
  123. import {
  124. onLoad,
  125. onReady,
  126. onUnload,
  127. onShow
  128. } from '@dcloudio/uni-app'
  129. import {
  130. store
  131. } from '@/store/index.js'
  132. import {
  133. saveInstrumentRoomInspection,
  134. selectInspecion
  135. } from '@/api/business/processInspection.js'
  136. import {
  137. getInspectionStandardsList
  138. } from '@/api/business/inspectionStandards.js'
  139. const lot = ref({})
  140. const isEventTriggered = ref(false); // 创建一个标志位
  141. const unfitInfos = ref([]) //废品信息
  142. const consultations = ref([]) //咨询信息
  143. const flag = ref(false)
  144. // 创建一个引用来存储最后一次请求的时间戳
  145. const lastRequestTimestamp = ref(0);
  146. const processInspecion = ref({
  147. remark: "",
  148. rejectNum: 0,
  149. examiningNum: 0,
  150. status: 0,
  151. })
  152. const initStatus = ref(0)
  153. const editable = () => {
  154. // if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
  155. // return true
  156. // }
  157. if (initStatus.value == 0) {
  158. return true
  159. }
  160. if (processInspecion.value.firstUpdaterId == store.userInfo.userId) {
  161. return true
  162. }
  163. return false
  164. }
  165. const consul = [{
  166. value: 0,
  167. text: "待确认",
  168. type: "color: #fcab53"
  169. }, {
  170. value: 2,
  171. text: "合格",
  172. type: "color: #55ff7f"
  173. }, {
  174. value: 1,
  175. text: "不合格",
  176. type: "color: #ff0c2c"
  177. }]
  178. const range = [{
  179. value: 0,
  180. text: "待确认",
  181. type: "color: #fcab53"
  182. }, {
  183. value: 1,
  184. text: "合格",
  185. type: "color: #55ff7f"
  186. }, {
  187. value: 2,
  188. text: "不合格",
  189. type: "color: #ff0c2c"
  190. }]
  191. /***************************** 页面生命周期函数 *****************************/
  192. onShow(() => {
  193. uni.$off('addWasteInfoEvent');
  194. console.log(store.processInspection)
  195. console.log(flag.value)
  196. if(!flag.value){
  197. if (store.processInspection != null) {
  198. uni.showLoading({
  199. title: '加载中'
  200. });
  201. processInspecion.value = store.processInspection
  202. selectInspecion(processInspecion.value).then(res => {
  203. if (res.code == 200) {
  204. processInspecion.value = res.data;
  205. processInspecion.value.flag = false
  206. unfitInfos.value = res.data.processInspectionDetails;
  207. initStatus.value = res.data.status
  208. consultations.value = res.data.dayworkItemConsults;
  209. console.log("res", res);
  210. console.log(processInspecion.value)
  211. uni.hideLoading();
  212. // getInspecion();
  213. } else {
  214. uni.showToast({
  215. icon: 'none',
  216. title: res.msg,
  217. duration: 2000
  218. })
  219. }
  220. });
  221. }
  222. }
  223. })
  224. function getOringicalList() {
  225. console.log(processInspecion.value)
  226. //查询该产品,当前工序,当前检查绑定的检查
  227. getInspectionStandardsList({
  228. productId:processInspecion.value.lot.productId,
  229. processId:processInspecion.value.lot.processId,
  230. inspectionCode:"instrumentRoomInspection"
  231. }).then(res =>{
  232. unfitInfos.value = res.rows.map(item => {
  233. // 映射新的数组,包含 inspectionStandardsId 和 checkStandard 属性
  234. return {
  235. inspectionStandardsId: item.id, // 从 item 中获取 id
  236. checkStandard: item.standard // 从 item 中获取 standard
  237. };
  238. });
  239. })
  240. }
  241. /***************************** 定义了一些方法 *****************************/
  242. //咨询文本
  243. function selectText(item) {
  244. for (var i = 0; i < consul.length; i++) {
  245. if (item.status == consul[i].value) {
  246. return consul[i].text
  247. }
  248. }
  249. }
  250. function handleDrawingMenu(){
  251. // 对 technologicalProcessDetailId 进行URL编码
  252. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  253. var enTechnologicalProcessId = encodeURIComponent(processInspecion.value.lot.technologicalProcessId);
  254. var enprocessCode = encodeURIComponent(processInspecion.value.lot.processCode);
  255. var encodeCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  256. var enProcessAlias = encodeURIComponent(processInspecion.value.lot.processAlias);
  257. // 构建查询参数字符串
  258. var queryParam = `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}`;
  259. // 使用模板字符串构建完整的URL
  260. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  261. // 导航到指定页面
  262. uni.navigateTo({
  263. url: navigateUrl
  264. });
  265. }
  266. const rejectNumberChange = () => {
  267. let sumDisqualificationNum = 0
  268. let sumExaminingNum = 0
  269. unfitInfos.value.forEach(v => {
  270. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  271. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  272. })
  273. processInspecion.value.disqualificationNum = sumDisqualificationNum
  274. processInspecion.value.examiningNum = sumExaminingNum
  275. console.log(processInspecion.value)
  276. }
  277. //查询咨询列表
  278. function getInspecion() {
  279. processInspecion.value = store.processInspection
  280. selectInspecion(processInspecion.value).then(res => {
  281. console.log("咨询", res);
  282. if (res.code == 200) {
  283. console.log("res", res);
  284. } else {
  285. uni.showToast({
  286. icon: 'none',
  287. title: res.msg,
  288. duration: 2000
  289. })
  290. }
  291. });
  292. }
  293. //结束报工按钮
  294. function endWork() {
  295. let unf = unfitInfos.value;
  296. for (var i = 0; i < unfitInfos.value.length; i++) {
  297. if (unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  298. uni.showToast({
  299. icon: 'none',
  300. title: '检查量,不良品量不能小于0',
  301. duration: 2000
  302. })
  303. return
  304. }
  305. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  306. uni.showToast({
  307. icon: 'none',
  308. title: '检查量不能大于投产量'
  309. })
  310. return
  311. }
  312. }
  313. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  314. uni.showToast({
  315. icon: 'none',
  316. title: '不良品量不能大于投产量'
  317. })
  318. return
  319. }
  320. save();
  321. }
  322. function save() {
  323. const currentTime = Date.now();
  324. // 检查是否已经过去了 2 秒
  325. if (currentTime - lastRequestTimestamp.value < 2000) {
  326. // 如果在 2 秒 内已经点击,那么不执行
  327. uni.showToast({
  328. icon: 'none',
  329. title: `请勿重复点击`,
  330. duration: 2000
  331. })
  332. return;
  333. }
  334. let pages = getCurrentPages();
  335. processInspecion.value.dayworkItemConsults = consultations.value;
  336. processInspecion.value.processInspectionDetails = unfitInfos.value;
  337. processInspecion.value.user = store.userInfo;
  338. processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
  339. processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
  340. console.log(processInspecion.value)
  341. saveInstrumentRoomInspection(processInspecion.value).then(res => {
  342. if (res.code == 200) {
  343. let index = 0;
  344. for (let i = 0; i < pages.length; i++) {
  345. if (pages[i].$page.fullPath == "/pages/instrumentRoomInspection/index") {
  346. index = pages.length - i - 1;
  347. }
  348. }
  349. console.log("index", index);
  350. uni.navigateBack({
  351. delta: index
  352. });
  353. } else {
  354. uni.showToast({
  355. icon: 'none',
  356. title: res.msg,
  357. duration: 2000
  358. })
  359. }
  360. });
  361. }
  362. //咨询样式
  363. function selectType(item) {
  364. for (var i = 0; i < consul.length; i++) {
  365. if (item.status == consul[i].value) {
  366. return consul[i].type
  367. }
  368. }
  369. }
  370. const addWasteInfo = (data) => {
  371. console.log(data,"55555555")
  372. flag.value = true
  373. var info = {
  374. inspectionStandardsId: data.id,
  375. checkStandard: data.standard
  376. }
  377. unfitInfos.value.push(info)
  378. console.log(data)
  379. }
  380. const addConsultation = (data) => {
  381. let info = data
  382. info.forEach(item =>{
  383. item.status = 0
  384. })
  385. consultations.value = consultations.value.concat(info)
  386. isEventTriggered.value = true; // 更新标志位状态
  387. }
  388. /***************************** 定义了一些事件 *****************************/
  389. // 添加不合格信息
  390. const handleAddWaste = () => {
  391. // 监听事件,暂时不用,后续会使用
  392. uni.$once('addWasteInfoEvent', (data) => {
  393. if (!isEventTriggered.value) {
  394. addWasteInfo(data)
  395. }
  396. })
  397. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  398. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  399. // 构建查询参数字符串
  400. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  401. // 使用模板字符串构建完整的URL
  402. var navigateUrl = `/pages/instrumentRoomInspection/options?${queryParam}`;
  403. // 导航到指定页面
  404. uni.navigateTo({
  405. url: navigateUrl
  406. });
  407. }
  408. // 删除不合格信息
  409. const handleDelWaste = (index) => {
  410. uni.showModal({
  411. title: '提示',
  412. content: '确定删除该项?',
  413. success: function(res) {
  414. if (res.confirm) {
  415. unfitInfos.value.splice(index, 1)
  416. } else if (res.cancel) {
  417. return
  418. }
  419. }
  420. })
  421. }
  422. // 咨询
  423. const handleAddConsultation = () => {
  424. console.log("9999")
  425. isEventTriggered.value = false;
  426. // 监听事件
  427. uni.$once('addWasteConsultationEvent', (data) => {
  428. if (!isEventTriggered.value) {
  429. // 如果事件尚未触发,则执行事件触发逻辑
  430. addConsultation(data)
  431. }
  432. })
  433. uni.navigateTo({
  434. url: "/pages/instrumentRoomInspection/consultation",
  435. success: (res) => {
  436. // 通过eventChannel向被打开页面传送数据
  437. res.eventChannel.emit("instrumentRoomInspectionConsultation", {
  438. data: processInspecion.value.lot
  439. })
  440. }
  441. })
  442. }
  443. </script>
  444. <style lang="scss">
  445. .page-container {
  446. // height: 100%;
  447. background-color: #ececec;
  448. font-size: 28rpx;
  449. >.title {
  450. font-weight: 700;
  451. margin: 24rpx 16rpx;
  452. }
  453. }
  454. .carrier-info {
  455. margin: 32rpx 16rpx 0 16rpx;
  456. padding: 24rpx;
  457. background-color: #ffffff;
  458. border-radius: 8rpx;
  459. .carrier-code {
  460. font-size: 32rpx;
  461. font-weight: 700;
  462. }
  463. .info-row {
  464. margin-top: 16rpx;
  465. color: #767676;
  466. .label {
  467. width: 160rpx;
  468. }
  469. .drawing-btn {
  470. padding: 12rpx 32rpx;
  471. background-color: #0055ff;
  472. color: #ffffff;
  473. border-radius: 12rpx;
  474. margin-left: auto;
  475. font-size: 28rpx;
  476. }
  477. .value {
  478. flex: 1;
  479. textarea {
  480. flex: 1;
  481. border: 1px solid #888888;
  482. box-sizing: border-box;
  483. padding: 16rpx;
  484. }
  485. }
  486. }
  487. }
  488. .unfit-title {
  489. margin-bottom: 24rpx;
  490. justify-content: space-between;
  491. align-items: center;
  492. text {
  493. font-size: 28rpx;
  494. font-weight: 700;
  495. }
  496. .add-btn {
  497. padding: 12rpx 32rpx;
  498. background-color: #a4adb3;
  499. color: #ffffff;
  500. border-radius: 12rpx;
  501. font-size: 24rpx;
  502. }
  503. }
  504. .unfit-container {
  505. padding: 24rpx;
  506. margin: 0 16rpx;
  507. background-color: #ffffff;
  508. border-radius: 12rpx;
  509. .unfit-item-container {
  510. position: relative;
  511. >* {
  512. margin-bottom: 24rpx;
  513. }
  514. .title {
  515. font-weight: 700;
  516. justify-content: space-between;
  517. align-items: center;
  518. image {
  519. width: 40rpx;
  520. height: 40rpx;
  521. }
  522. }
  523. .standard {}
  524. .resu {
  525. width: 100%;
  526. align-items: center;
  527. input {
  528. margin-left: 20rpx;
  529. width: 200rpx;
  530. height: 56rpx;
  531. flex: 1;
  532. border: 1px solid #9f9f9f;
  533. font-size: 28rpx;
  534. }
  535. }
  536. .result {
  537. align-items: center;
  538. border-bottom: 1px solid #9f9f9f;
  539. padding-bottom: 32rpx;
  540. .label {
  541. flex: 1;
  542. }
  543. input {
  544. width: 280rpx;
  545. height: 56rpx;
  546. border: 1px solid #9f9f9f;
  547. font-size: 28rpx;
  548. &.number {
  549. width: 104rpx;
  550. text-align: center;
  551. }
  552. }
  553. }
  554. }
  555. .unfit-item-container:last-child {
  556. .result {
  557. border-bottom: none;
  558. padding-bottom: 0;
  559. }
  560. }
  561. }
  562. .consultation-container {
  563. margin: 0 16rpx;
  564. padding: 24rpx;
  565. background-color: #ffffff;
  566. border-radius: 8rpx;
  567. .consultation-item-container {
  568. margin-bottom: 24rpx;
  569. border-bottom: 2px solid #888888;
  570. padding-bottom: 24rpx;
  571. }
  572. .consultation-item-container:last-child {
  573. margin-bottom: 0;
  574. border-bottom: 0;
  575. padding-bottom: 0;
  576. }
  577. .question,
  578. .answer {
  579. .label {
  580. justify-content: space-between;
  581. margin-bottom: 16rpx;
  582. font-weight: 700;
  583. }
  584. .content {
  585. line-height: 40rpx;
  586. }
  587. }
  588. .answer {
  589. margin-top: 24rpx;
  590. }
  591. }
  592. .daywork-container {
  593. margin-top: 24rpx;
  594. padding: 24rpx;
  595. background-color: #ffffff;
  596. border: 1px solid #bcbcbc;
  597. .result {
  598. align-items: center;
  599. .label {
  600. width: 112rpx;
  601. }
  602. input {
  603. flex: 1;
  604. height: 56rpx;
  605. border: 1px solid #9f9f9f;
  606. font-size: 28rpx;
  607. text-align: center;
  608. }
  609. }
  610. .remark {
  611. margin-top: 24rpx;
  612. .label {
  613. width: 112rpx;
  614. }
  615. textarea {
  616. flex: 1;
  617. border: 1px solid #9f9f9f;
  618. height: 168rpx;
  619. }
  620. }
  621. .btns-container {
  622. margin-top: 24rpx;
  623. .finished-btn {
  624. display: flex;
  625. flex: 1;
  626. height: 80rpx;
  627. background-color: #fc6565;
  628. color: #ffffff;
  629. text-align: center;
  630. justify-content: center;
  631. align-items: center;
  632. border-radius: 8rpx;
  633. }
  634. .question-btn {
  635. width: 80rpx;
  636. align-items: flex-end;
  637. image {
  638. width: 48rpx;
  639. height: 48rpx;
  640. }
  641. text {
  642. font-size: 24rpx;
  643. }
  644. }
  645. }
  646. }
  647. </style>