form.vue 27 KB

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