form.vue 26 KB

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