form.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  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="result uni-row">
  60. <view class="label">检查结果</view>
  61. <input v-model="item.checkResult" placeholder="请输入检查结果" />
  62. <view class="label" style="text-align: right; padding-right: 16rpx;">数量
  63. </view>
  64. <input class="number" type="number" @blur="rejectNumberChange" v-model="item.rejectNum"
  65. placeholder="" />
  66. </view> -->
  67. <view class="resu uni-row">
  68. <view class="label">检查结果</view>
  69. <input v-if="editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  70. <view v-else class="value" style="margin-left:16rpx;">{{ item.checkResult }}</view>
  71. </view>
  72. <view class="resu uni-row">
  73. <view class="label">超差范围</view>
  74. <input v-if="editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  75. <view v-else class="value" style="margin-left:16rpx;">{{ item.exceedLimits }}</view>
  76. </view>
  77. <view class="resu uni-row">
  78. <view :class="!editable() ? 'label' : ''">检查量</view>
  79. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  80. v-model="item.examiningNum" placeholder="" />
  81. <view v-else class="number value" style="margin-left:16rpx;">{{ item.examiningNum }}</view>
  82. <view :class="!editable() ? 'label' : ''" style="margin-left: 16rpx;">不良品量</view>
  83. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  84. v-model="item.disqualificationNum" placeholder="" />
  85. <view v-else class="value" style="margin-left:16rpx;">{{ item.disqualificationNum }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 拍照上传部分 -->
  90. <view class="title unfit-title uni-row">
  91. <text>拍照上传</text>
  92. </view>
  93. <view class=" uni-row" style="padding: 24rpx;
  94. margin: 0 16rpx;
  95. background-color: #ffffff;
  96. border-radius: 12rpx;">
  97. <uni-file-picker v-model="photoList" :readonly="!editable()" return-type="array" :image-styles="imageStyles"
  98. @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto"></uni-file-picker>
  99. </view>
  100. <!-- 咨询部分 -->
  101. <view class="title unfit-title uni-row">
  102. <text>咨询</text>
  103. </view>
  104. <view class="consultation-container uni-column">
  105. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  106. <view class="question uni-column">
  107. <view class="label uni-row">
  108. <text>问题描述</text>
  109. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}}
  110. {{ selectText(item) }}</text>
  111. </view>
  112. <view class="content">{{ item.content }}</view>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- 报工部分 -->
  117. <view class="daywork-container">
  118. <view class="result uni-row">
  119. <view class="label" style="margin-top: 20rpx;width: 170rpx;">首件检状态</view>
  120. <uni-data-checkbox :disabled="!editable()" style="margin-top: 20rpx;"
  121. v-model="processInspecion.inspectionStatus" :localdata="range"
  122. @change="handleChangeInspecionStatus"></uni-data-checkbox>
  123. </view>
  124. <view class="result uni-row">
  125. <view class="label" style="margin-top: 20rpx; margin-right: 10rpx;">放行状态</view>
  126. <uni-data-checkbox :disabled="true" style="margin-top: 20rpx;" v-model="processInspecion.status"
  127. :localdata="range"></uni-data-checkbox>
  128. </view>
  129. <view v-if="editable()">
  130. <view v-if="showTransfer" class="list-title uni-row" style="margin-top: 16rpx;">
  131. <text class="label">是否移交仪器室</text><text>&nbsp;否</text>
  132. <!-- <switch class="switch" @change="switchChange" style="transform:scale(0.7);margin-top: -16rpx;"
  133. color="rgba(255,85,85,1)" /> -->
  134. <zero-switch v-model="processInspecion.flag" @change="switchChange"
  135. active-color="rgba(103, 195, 55, 1.0)" :size="18"
  136. style="transform:scale(0.9);margin-top: -9rpx;"></zero-switch>
  137. <text>是</text>
  138. </view>
  139. <view v-else class="list-title uni-row" style="margin-top: 16rpx;">
  140. <text class="label">已经移交给仪器室</text>
  141. </view>
  142. <view class="list-title uni-row" style="margin-top: 16rpx;">
  143. <text class="label">检测完成</text><text>&nbsp;否</text>
  144. <!-- <switch :checked="isAllChecked" class="switch" :disabled="!showTransfer || processInspecion.flag"
  145. @change="switchAllCheckChange" style="transform:scale(0.7);margin-top: -16rpx;"
  146. color="rgba(255,85,85,1)" /> -->
  147. <zero-switch v-model="isAllChecked" :disabled="!showTransfer || processInspecion.flag"
  148. @change="switchAllCheckChange" active-color="rgba(103, 195, 55, 1.0)" :size="18"
  149. style="transform:scale(0.9);margin-top: -9rpx;"></zero-switch>
  150. <text>是</text>
  151. </view>
  152. </view>
  153. <view class="remark uni-row">
  154. <view class="label">备注</view>
  155. <textarea v-if="editable()" v-model="processInspecion.remark" maxlength="999" />
  156. <view v-else class="value">{{ processInspecion.remark }}</view>
  157. </view>
  158. <view class="btns-container uni-row">
  159. <view class="finished-btn" @click="endWork">提交</view>
  160. <view v-if="editable()" class="question-btn uni-column" @click.stop="handleAddConsultation">
  161. <uni-icons type="headphones" size="24" />
  162. <text>咨询</text>
  163. </view>
  164. </view>
  165. </view>
  166. <dialog-inspectionChamber ref='selectInspectionChamber'
  167. @handleSelectInspectionChamber='handleSelectInspectionChamber'></dialog-inspectionChamber>
  168. </view>
  169. </template>
  170. <script setup>
  171. import {
  172. ref,
  173. onMounted,
  174. getCurrentInstance
  175. } from 'vue'
  176. import {
  177. onLoad,
  178. onReady,
  179. onUnload,
  180. onShow
  181. } from '@dcloudio/uni-app'
  182. import {
  183. store
  184. } from '@/store/index.js'
  185. import {
  186. saveFirstInspection,
  187. selectInspecion,
  188. getInstrumentRoomInspection
  189. } from '@/api/business/processInspection.js'
  190. import {
  191. getInspectionStandardsList
  192. } from '@/api/business/inspectionStandards.js'
  193. import {
  194. getURL
  195. } from '@/api/sys/user.js'
  196. const lot = ref({})
  197. const isEventTriggered = ref(false); // 创建一个标志位
  198. const unfitInfos = ref([]) //废品信息
  199. const consultations = ref([]) //咨询信息
  200. const flag = ref(false)
  201. const showTransfer = ref(true)
  202. const isAllChecked = ref(false)
  203. const selectInspectionChamber = ref(null)
  204. // 创建一个引用来存储最后一次请求的时间戳
  205. const lastRequestTimestamp = ref(0);
  206. const processInspecion = ref({
  207. remark: "",
  208. rejectNum: 0,
  209. examiningNum: 0,
  210. status: 0,
  211. inspectionStatus: 0
  212. })
  213. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  214. const webHost = ref(urlList.baseUrl)
  215. const photoList = ref([])
  216. const selected = ref([]);
  217. const selectedPhotos = ref([])
  218. const imageStyles = {
  219. width: 60,
  220. height: 60
  221. }
  222. const initStatus = ref(0)
  223. const editable = () => {
  224. if (initStatus.value == 0 && store.userInfo.roles.some(item => item.roleKey == 'firstArticleInspection')) {
  225. return true
  226. }
  227. if (store.userInfo.roles.some(item => item.roleKey == 'firstArticleInspection') && processInspecion.value
  228. .firstUpdaterId == store.userInfo.userId) {
  229. return true
  230. } else {
  231. return false
  232. }
  233. }
  234. const consul = [{
  235. value: 0,
  236. text: "待确认",
  237. type: "color: #fcab53"
  238. }, {
  239. value: 2,
  240. text: "合格",
  241. type: "color: #55ff7f"
  242. }, {
  243. value: 1,
  244. text: "不合格",
  245. type: "color: #ff0c2c"
  246. }]
  247. const range = [{
  248. value: 0,
  249. text: "待确认",
  250. type: "color: #fcab53"
  251. }, {
  252. value: 1,
  253. text: "合格",
  254. type: "color: #55ff7f"
  255. }, {
  256. value: 2,
  257. text: "不合格",
  258. type: "color: #ff0c2c"
  259. }]
  260. /***************************** 页面生命周期函数 *****************************/
  261. function init() {
  262. const instance = getCurrentInstance().proxy
  263. const eventChannel = instance.getOpenerEventChannel();
  264. eventChannel.on('firstInspectionFrom', function(data) {
  265. if (data && data.data) {
  266. processInspecion.value.lot = data.data;
  267. getOringicalList()
  268. }
  269. })
  270. }
  271. onShow(() => {
  272. uni.$off('addWasteInfoEvent');
  273. })
  274. onLoad(() => {
  275. uni.$off('addWasteInfoEvent');
  276. if (!flag.value) {
  277. if (store.processInspection != null) {
  278. uni.showLoading({
  279. title: '加载中'
  280. });
  281. processInspecion.value = store.processInspection
  282. isAllChecked.value = (processInspecion.value.isAllChecked == 1)
  283. selectInspecion(processInspecion.value).then(res => {
  284. if (res.code == 200) {
  285. processInspecion.value = res.data;
  286. processInspecion.value.flag = false
  287. unfitInfos.value = res.data.processInspectionDetails;
  288. initStatus.value = res.data.inspectionStatus
  289. selectedPhotos.value = res.data.processInspectionPictureList
  290. photoList.value = res.data.processInspectionPictureList.map(item => {
  291. return {
  292. ...item,
  293. url: webHost.value + item.url
  294. };
  295. });
  296. consultations.value = res.data.dayworkItemConsults;
  297. console.log("res", res);
  298. console.log(processInspecion.value)
  299. //判断是否移交到了仪器室
  300. getInstrumentRoomInspectionList()
  301. uni.hideLoading();
  302. // getInspecion();
  303. } else {
  304. uni.showToast({
  305. icon: 'none',
  306. title: res.msg,
  307. duration: 2000
  308. })
  309. }
  310. });
  311. } else {
  312. init()
  313. }
  314. }
  315. })
  316. function getInstrumentRoomInspectionList() {
  317. getInstrumentRoomInspection(processInspecion.value).then(res => {
  318. if (res.data.length > 0) {
  319. showTransfer.value = false
  320. // processInspecion.value.flag = true
  321. } else {
  322. showTransfer.value = true
  323. // processInspecion.value.flag = false
  324. }
  325. })
  326. }
  327. function switchChange(event) {
  328. console.log(event)
  329. // if (event.detail.value) {
  330. if (event) {
  331. processInspecion.value.flag = true
  332. processInspecion.value.isAllChecked = 0
  333. isAllChecked.value = false
  334. } else {
  335. processInspecion.value.flag = false
  336. }
  337. }
  338. function switchAllCheckChange(event) {
  339. console.log(event)
  340. // if (event.detail.value) {
  341. if (event) {
  342. processInspecion.value.isAllChecked = 1
  343. } else {
  344. processInspecion.value.isAllChecked = 0
  345. }
  346. }
  347. function getOringicalList() {
  348. console.log(processInspecion.value)
  349. //查询该产品,当前工序,当前检查绑定的检查
  350. getInspectionStandardsList({
  351. productId: processInspecion.value.lot.productId,
  352. processId: processInspecion.value.lot.processId,
  353. inspectionCode: "firstArticleInspection"
  354. }).then(res => {
  355. unfitInfos.value = res.rows.map(item => {
  356. // 映射新的数组,包含 inspectionStandardsId 和 checkStandard 属性
  357. return {
  358. inspectionStandardsId: item.id, // 从 item 中获取 id
  359. checkStandard: item.standard // 从 item 中获取 standard
  360. };
  361. });
  362. })
  363. }
  364. /***************************** 定义了一些方法 *****************************/
  365. //咨询文本
  366. function selectText(item) {
  367. // for (var i = 0; i < consul.length; i++) {
  368. // if (item.status == consul[i].value) {
  369. // return consul[i].text
  370. // }
  371. // }
  372. if (item.consultResultId == 0) {
  373. return '待确认'
  374. } else {
  375. return item.result
  376. }
  377. }
  378. function upLoadImageHandler(arg) {
  379. return getURL(arg).then(res => {
  380. let data = JSON.parse(res)
  381. selectedPhotos.value.push({
  382. url: data.fileName,
  383. pictureName: data.originalFilename,
  384. tenantId: store.tenantId
  385. })
  386. photoList.value.push({
  387. url: data.fileName,
  388. pictureName: data.originalFilename
  389. })
  390. console.log(selectedPhotos.value)
  391. // uni.showToast({
  392. // icon: 'none',
  393. // title: selectedPhotos.value.length,
  394. // duration: 2000
  395. // })
  396. })
  397. }
  398. function select(e) {
  399. console.log(e)
  400. const {
  401. tempFilePaths,
  402. tempFiles
  403. } = e
  404. uni.showLoading({
  405. title: '图片上传中',
  406. mask: true
  407. });
  408. // tempFiles.forEach((item, index) => {
  409. // upLoadImageHandler({
  410. // filePath: tempFilePaths[index],
  411. // name: item.name
  412. // })
  413. // })
  414. // 创建一个空的Promise数组
  415. let uploadPromises = tempFiles.map((item, index) => {
  416. return upLoadImageHandler({
  417. filePath: tempFilePaths[index],
  418. name: item.name
  419. });
  420. });
  421. // 使用Promise.all等待所有图片上传完成
  422. Promise.all(uploadPromises).then(() => {
  423. // 上传完成后关闭加载提示
  424. uni.hideLoading();
  425. }).catch(() => {
  426. // 如果有错误发生,也关闭加载提示
  427. uni.hideLoading();
  428. });
  429. }
  430. function handleDeletedPhoto(e) {
  431. let fileName = selectedPhotos.value.map(info => info.pictureName)
  432. const firstSlashIndex = e.tempFile.url.lastIndexOf('/');
  433. const lastSlashIndex = e.tempFile.url.lastIndexOf('_');
  434. const type = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex)
  435. const pictureName = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex) + e.tempFile.url.substring(e
  436. .tempFile.url.lastIndexOf('.') - 1 + 1);;
  437. let index = -1; // 初始化 index 为 -1,表示未找到
  438. // 首先检查 e.tempFile.name 是否存在
  439. if (fileName.findIndex(name => name === e.tempFile.name) !== -1) {
  440. index = fileName.findIndex(name => name === e.tempFile.name);
  441. }
  442. // 如果 e.tempFile.name 不存在,检查 e.tempFile.pictureName 是否存在
  443. else if (fileName.findIndex(name => name === e.tempFile.pictureName) !== -1) {
  444. index = fileName.findIndex(name => name === e.tempFile.pictureName);
  445. }
  446. // 如果以上两个都不存在,检查 pictureName 是否存在
  447. else if (fileName.findIndex(name => name === pictureName) !== -1) {
  448. index = fileName.findIndex(name => name === pictureName);
  449. }
  450. selectedPhotos.value.splice(index, 1)
  451. }
  452. function handleDrawingMenu() {
  453. // 对 technologicalProcessDetailId 进行URL编码
  454. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  455. var enTechnologicalProcessId = encodeURIComponent(processInspecion.value.lot.technologicalProcessId);
  456. var enprocessCode = encodeURIComponent(processInspecion.value.lot.processCode);
  457. var encodeCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  458. var enProcessAlias = encodeURIComponent(processInspecion.value.lot.processAlias);
  459. var enIsWasteRecycling = encodeURIComponent(processInspecion.value.lot.isWasteRecycling);
  460. var enIsAmend = encodeURIComponent(processInspecion.value.lot.isAmend);
  461. // 构建查询参数字符串
  462. var queryParam =
  463. `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}&param6=${enIsWasteRecycling}&param7=${enIsAmend}`;
  464. // 使用模板字符串构建完整的URL
  465. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  466. // 导航到指定页面
  467. uni.navigateTo({
  468. url: navigateUrl
  469. });
  470. }
  471. const rejectNumberChange = () => {
  472. let sumDisqualificationNum = 0
  473. let sumExaminingNum = 0
  474. unfitInfos.value.forEach(v => {
  475. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  476. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  477. })
  478. processInspecion.value.disqualificationNum = sumDisqualificationNum
  479. processInspecion.value.examiningNum = sumExaminingNum
  480. console.log(processInspecion.value)
  481. }
  482. //查询咨询列表
  483. function getInspecion() {
  484. processInspecion.value = store.processInspection
  485. selectInspecion(processInspecion.value).then(res => {
  486. console.log("咨询", res);
  487. if (res.code == 200) {
  488. console.log("res", res);
  489. } else {
  490. uni.showToast({
  491. icon: 'none',
  492. title: res.msg,
  493. duration: 2000
  494. })
  495. }
  496. });
  497. }
  498. //结束报工按钮
  499. function endWork() {
  500. let unf = unfitInfos.value;
  501. if (store.userInfo.roles.some(item => item.roleKey == 'firstArticleInspection')) {
  502. for (var i = 0; i < unfitInfos.value.length; i++) {
  503. if (unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  504. uni.showToast({
  505. icon: 'none',
  506. title: '检查量,不良品量不能小于0',
  507. duration: 2000
  508. })
  509. return
  510. }
  511. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  512. uni.showToast({
  513. icon: 'none',
  514. title: '检查量不能大于投产量'
  515. })
  516. return
  517. }
  518. }
  519. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  520. uni.showToast({
  521. icon: 'none',
  522. title: '不良品量不能大于投产量'
  523. })
  524. return
  525. }
  526. }
  527. save();
  528. }
  529. function save() {
  530. const currentTime = Date.now();
  531. // 检查是否已经过去了 2 秒
  532. if (currentTime - lastRequestTimestamp.value < 2000) {
  533. // 如果在 2 秒 内已经点击,那么不执行
  534. uni.showToast({
  535. icon: 'none',
  536. title: `请勿重复点击`,
  537. duration: 2000
  538. })
  539. return;
  540. }
  541. lastRequestTimestamp.value = currentTime;
  542. let pages = getCurrentPages();
  543. processInspecion.value.dayworkItemConsults = consultations.value;
  544. processInspecion.value.processInspectionDetails = unfitInfos.value;
  545. processInspecion.value.user = store.userInfo;
  546. processInspecion.value.tenantId = store.tenantId
  547. processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
  548. processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
  549. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  550. processInspecion.value.isReviewer = store.isReviewer
  551. console.log(processInspecion.value)
  552. if (processInspecion.value.flag) {
  553. //打开选择仪器室的弹窗
  554. selectInspectionChamber.value.open()
  555. console.log(processInspecion.value)
  556. } else {
  557. saveFirstInspection(processInspecion.value).then(res => {
  558. if (res.code == 200) {
  559. let index = 0;
  560. console.log(store.isReviewer)
  561. for (let i = 0; i < pages.length; i++) {
  562. if (!store.isReviewer && pages[i].$page.fullPath == "/pages/reportingForWork/index") {
  563. index = pages.length - i - 1;
  564. }
  565. if (store.isReviewer && pages[i].$page.fullPath == "/pages/firstInspection/index") {
  566. index = pages.length - i - 1;
  567. }
  568. }
  569. console.log("index", index);
  570. uni.navigateBack({
  571. delta: index
  572. });
  573. } else {
  574. uni.showToast({
  575. icon: 'none',
  576. title: res.msg,
  577. duration: 2000
  578. })
  579. }
  580. });
  581. }
  582. }
  583. function handleSelectInspectionChamber(data) {
  584. processInspecion.value.inspectionChamberId = data
  585. console.log(processInspecion.value)
  586. saveFirstInspection(processInspecion.value).then(res => {
  587. if (res.code == 200) {
  588. let index = 0;
  589. let pages = getCurrentPages();
  590. console.log(store.isReviewer)
  591. for (let i = 0; i < pages.length; i++) {
  592. if (pages[i].$page.fullPath == "/pages/reportingForWork/index") {
  593. index = pages.length - i - 1;
  594. }
  595. }
  596. console.log("index", index);
  597. uni.navigateBack({
  598. delta: index
  599. });
  600. } else {
  601. uni.showToast({
  602. icon: 'none',
  603. title: res.msg,
  604. duration: 2000
  605. })
  606. }
  607. });
  608. }
  609. //咨询样式
  610. function selectType(item) {
  611. for (var i = 0; i < consul.length; i++) {
  612. if (item.status == consul[i].value) {
  613. return consul[i].type
  614. }
  615. }
  616. }
  617. const addWasteInfo = (data) => {
  618. console.log(data, "55555555")
  619. flag.value = true
  620. var info = {
  621. inspectionStandardsId: data.id,
  622. checkStandard: data.standard
  623. }
  624. unfitInfos.value.push(info)
  625. uni.$off('addWasteInfoEvent');
  626. console.log(data)
  627. }
  628. const addConsultation = (data) => {
  629. let info = data
  630. info.forEach(item => {
  631. item.status = 0
  632. })
  633. consultations.value = consultations.value.concat(info)
  634. isEventTriggered.value = true; // 更新标志位状态
  635. processInspecion.value.status = 0
  636. }
  637. /***************************** 定义了一些事件 *****************************/
  638. // 添加不合格信息
  639. const handleAddWaste = () => {
  640. flag.value = true
  641. // 监听事件,暂时不用,后续会使用
  642. uni.$on('addWasteInfoEvent', (data) => {
  643. console.log(data)
  644. addWasteInfo(data)
  645. })
  646. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  647. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  648. // 构建查询参数字符串
  649. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  650. // 使用模板字符串构建完整的URL
  651. var navigateUrl = `/pages/firstInspection/options?${queryParam}`;
  652. // 导航到指定页面
  653. uni.navigateTo({
  654. url: navigateUrl
  655. });
  656. }
  657. function handleChangeInspecionStatus(e) {
  658. console.log(e.detail.value)
  659. console.log(consultations.value)
  660. //没有咨询
  661. if (consultations.value && consultations.value.length == 0) {
  662. processInspecion.value.status = e.detail.value
  663. }
  664. }
  665. // 删除不合格信息
  666. const handleDelWaste = (index) => {
  667. uni.showModal({
  668. title: '提示',
  669. content: '确定删除该项?',
  670. success: function(res) {
  671. if (res.confirm) {
  672. unfitInfos.value.splice(index, 1)
  673. } else if (res.cancel) {
  674. return
  675. }
  676. }
  677. })
  678. }
  679. // 咨询
  680. const handleAddConsultation = () => {
  681. console.log("9999")
  682. isEventTriggered.value = false;
  683. // 监听事件
  684. uni.$once('addWasteConsultationEvent', (data) => {
  685. if (!isEventTriggered.value) {
  686. // 如果事件尚未触发,则执行事件触发逻辑
  687. addConsultation(data)
  688. }
  689. })
  690. uni.navigateTo({
  691. url: "/pages/firstInspection/consultation",
  692. success: (res) => {
  693. // 通过eventChannel向被打开页面传送数据
  694. res.eventChannel.emit("firstInpsectionConsultation", {
  695. data: processInspecion.value.lot
  696. })
  697. }
  698. })
  699. }
  700. </script>
  701. <style lang="scss">
  702. .page-container {
  703. // height: 100%;
  704. background-color: #ececec;
  705. font-size: 28rpx;
  706. >.title {
  707. font-weight: 700;
  708. margin: 24rpx 16rpx;
  709. }
  710. }
  711. .carrier-info {
  712. margin: 32rpx 16rpx 0 16rpx;
  713. padding: 24rpx;
  714. background-color: #ffffff;
  715. border-radius: 8rpx;
  716. .carrier-code {
  717. font-size: 32rpx;
  718. font-weight: 700;
  719. }
  720. .info-row {
  721. margin-top: 16rpx;
  722. color: #767676;
  723. .label {
  724. width: 160rpx;
  725. }
  726. .drawing-btn {
  727. padding: 12rpx 32rpx;
  728. background-color: #0055ff;
  729. color: #ffffff;
  730. border-radius: 12rpx;
  731. margin-left: auto;
  732. font-size: 28rpx;
  733. }
  734. .value {
  735. flex: 1;
  736. textarea {
  737. flex: 1;
  738. border: 1px solid #888888;
  739. box-sizing: border-box;
  740. padding: 16rpx;
  741. }
  742. }
  743. }
  744. }
  745. .unfit-title {
  746. margin-bottom: 24rpx;
  747. justify-content: space-between;
  748. align-items: center;
  749. text {
  750. font-size: 28rpx;
  751. font-weight: 700;
  752. }
  753. .add-btn {
  754. padding: 12rpx 32rpx;
  755. background-color: #a4adb3;
  756. color: #ffffff;
  757. border-radius: 12rpx;
  758. font-size: 24rpx;
  759. }
  760. }
  761. .unfit-container {
  762. padding: 24rpx;
  763. margin: 0 16rpx;
  764. background-color: #ffffff;
  765. border-radius: 12rpx;
  766. .unfit-item-container {
  767. position: relative;
  768. >* {
  769. margin-bottom: 24rpx;
  770. }
  771. .title {
  772. font-weight: 700;
  773. justify-content: space-between;
  774. align-items: center;
  775. image {
  776. width: 40rpx;
  777. height: 40rpx;
  778. }
  779. }
  780. .standard {}
  781. .resu {
  782. width: 100%;
  783. align-items: center;
  784. input {
  785. margin-left: 20rpx;
  786. width: 200rpx;
  787. height: 56rpx;
  788. flex: 1;
  789. border: 1px solid #9f9f9f;
  790. font-size: 28rpx;
  791. }
  792. }
  793. .uni-input-input:disabled {
  794. background-color: #f5f7fa;
  795. }
  796. .result {
  797. align-items: center;
  798. border-bottom: 1px solid #9f9f9f;
  799. padding-bottom: 32rpx;
  800. .label {
  801. flex: 1;
  802. }
  803. input {
  804. width: 280rpx;
  805. height: 56rpx;
  806. border: 1px solid #9f9f9f;
  807. font-size: 28rpx;
  808. &.number {
  809. width: 104rpx;
  810. text-align: center;
  811. }
  812. }
  813. }
  814. }
  815. .unfit-item-container:last-child {
  816. .result {
  817. border-bottom: none;
  818. padding-bottom: 0;
  819. }
  820. }
  821. }
  822. .consultation-container {
  823. margin: 0 16rpx;
  824. padding: 24rpx;
  825. background-color: #ffffff;
  826. border-radius: 8rpx;
  827. .consultation-item-container {
  828. margin-bottom: 24rpx;
  829. border-bottom: 2px solid #888888;
  830. padding-bottom: 24rpx;
  831. }
  832. .consultation-item-container:last-child {
  833. margin-bottom: 0;
  834. border-bottom: 0;
  835. padding-bottom: 0;
  836. }
  837. .question,
  838. .answer {
  839. .label {
  840. justify-content: space-between;
  841. margin-bottom: 16rpx;
  842. font-weight: 700;
  843. }
  844. .content {
  845. line-height: 40rpx;
  846. }
  847. }
  848. .answer {
  849. margin-top: 24rpx;
  850. }
  851. }
  852. .daywork-container {
  853. margin-top: 24rpx;
  854. padding: 24rpx;
  855. background-color: #ffffff;
  856. border: 1px solid #bcbcbc;
  857. .switch {
  858. margin-top: -4px;
  859. //align-items: center;
  860. }
  861. .result {
  862. align-items: center;
  863. .label {
  864. width: 112rpx;
  865. }
  866. input {
  867. flex: 1;
  868. height: 56rpx;
  869. border: 1px solid #9f9f9f;
  870. font-size: 28rpx;
  871. text-align: center;
  872. }
  873. }
  874. .remark {
  875. margin-top: 24rpx;
  876. .label {
  877. width: 112rpx;
  878. }
  879. textarea {
  880. flex: 1;
  881. border: 1px solid #9f9f9f;
  882. height: 168rpx;
  883. }
  884. }
  885. .btns-container {
  886. margin-top: 24rpx;
  887. .finished-btn {
  888. display: flex;
  889. flex: 1;
  890. height: 80rpx;
  891. background-color: #fc6565;
  892. color: #ffffff;
  893. text-align: center;
  894. justify-content: center;
  895. align-items: center;
  896. border-radius: 8rpx;
  897. }
  898. .question-btn {
  899. width: 80rpx;
  900. align-items: flex-end;
  901. image {
  902. width: 48rpx;
  903. height: 48rpx;
  904. }
  905. text {
  906. font-size: 24rpx;
  907. }
  908. }
  909. }
  910. .switch {
  911. margin-top: -8rpx;
  912. align-items: center;
  913. transform: scale(0.7);
  914. }
  915. }
  916. input:disabled {
  917. background-color: #00ff00;
  918. }
  919. .my-files {
  920. display: flex;
  921. justify-content: center;
  922. :deep(.uni-file-picker__container) {
  923. flex-direction: row;
  924. }
  925. }
  926. </style>