form.vue 26 KB

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