form.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  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.processNames }}</view>
  27. </view>
  28. <view class="info-row uni-row">
  29. <view class="label">投产数量</view>
  30. <view class="value">{{ processInspecion.lot.pudName }}</view>
  31. </view>
  32. <view class="info-row uni-row">
  33. <view class="label">检查载具</view>
  34. <view class="value">{{ processInspecion.inspectionCarrierCode }}
  35. {{ processInspecion.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  36. </view>
  37. </view>
  38. <view class="info-row uni-row">
  39. <view class="drawing-btn" @click="handleDrawingMenu">图纸信息</view>
  40. </view>
  41. </view>
  42. <!-- 废品信息 -->
  43. <view class="title unfit-title uni-row">
  44. <text>检查信息</text>
  45. <view v-if="editable()" class="add-btn" @click="handleAddWaste">添加</view>
  46. </view>
  47. <view class="unfit-container">
  48. <view class="unfit-item-container uni-column" v-for="(item, index) in oldUnfitInfos" :key="index">
  49. <view class="resu uni-row">
  50. <view class="label">检查标准</view>
  51. <view class="value">{{ item.checkStandard }}</view>
  52. </view>
  53. <view class="resu uni-row">
  54. <view class="label">检查结果</view>
  55. <view class="value">{{ item.checkResult }}</view>
  56. </view>
  57. <view class="resu uni-row">
  58. <view class="label">超差范围</view>
  59. <view class="value">{{ item.exceedLimits }}</view>
  60. </view>
  61. <view class="resu uni-row">
  62. <view :class="'label'">检查量</view>
  63. <view class="number value">{{ item.examiningNum }}</view>
  64. <view :class="'label'">不良品量</view>
  65. <view class="value">{{ item.disqualificationNum }}</view>
  66. <view :class="'label'">废品量</view>
  67. <view class="value">{{ item.rejectNum }}</view>
  68. </view>
  69. </view>
  70. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  71. <!-- 暂时注释,后续会使用 -->
  72. <!-- <view class="title uni-row">
  73. <text>检查项-{{ item.title }}</text>
  74. <uni-icons type="trash" size="24" color="#fc6565" @click="handleDelWaste(index)" />
  75. </view> -->
  76. <!-- <view class="standard">检查标准:{{ item.standard }}</view> -->
  77. <view class="resu uni-row">
  78. <view class="label">检查标准</view>
  79. <view class="value" style="margin-left:16rpx;width: 400rpx;">{{ item.checkStandard }}</view>
  80. <uni-icons v-if="editable()" type="trash" size="24" style="margin-left: 55rpx;" color="#fc6565"
  81. @click="handleDelWaste(index)" />
  82. </view>
  83. <!-- <view class="result uni-row">
  84. <view class="label">检查结果</view>
  85. <input v-model="item.checkResult" placeholder="请输入检查结果" />
  86. <view class="label" style="text-align: right; padding-right: 16rpx;">数量
  87. </view>
  88. <input class="number" type="number" @blur="rejectNumberChange" v-model="item.rejectNum"
  89. placeholder="" />
  90. </view> -->
  91. <view class="resu uni-row">
  92. <view class="label">检查结果</view>
  93. <input v-if="editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  94. <view v-else class="value" style="margin-left:16rpx;">{{ item.checkResult }}</view>
  95. </view>
  96. <view class="resu uni-row">
  97. <view class="label">超差范围</view>
  98. <input v-if="editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  99. <view v-else class="value" style="margin-left:16rpx;">{{ item.exceedLimits }}</view>
  100. </view>
  101. <view class="resu uni-row">
  102. <view :class="!editable() ? 'label' : ''">检查量</view>
  103. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  104. v-model="item.examiningNum" placeholder="" />
  105. <view v-else class="number value" style="margin-left:16rpx;">{{ item.examiningNum }}</view>
  106. <view :class="!editable() ? 'label' : ''">不良品量</view>
  107. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  108. v-model="item.disqualificationNum" placeholder="" />
  109. <view v-else class="number value" style="margin-left:16rpx;">{{ item.disqualificationNum }}</view>
  110. <view :class="!editable() ? 'label' : ''">废品量</view>
  111. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  112. v-model="item.rejectNum" placeholder="" />
  113. <view v-else class="number value" style="margin-left:16rpx;">{{ item.rejectNum }}</view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 拍照上传部分 -->
  118. <view class="title unfit-title uni-row">
  119. <text>拍照上传</text>
  120. </view>
  121. <view class=" uni-row" style="padding: 24rpx;
  122. margin: 0 16rpx;
  123. background-color: #ffffff;
  124. border-radius: 12rpx;">
  125. <uni-file-picker v-model="photoList" :readonly="!editable()" return-type="array" :image-styles="imageStyles"
  126. @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto"></uni-file-picker>
  127. </view>
  128. <!-- 咨询部分 -->
  129. <view class="title">咨询</view>
  130. <view class="consultation-container uni-column">
  131. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  132. <view class="question uni-column">
  133. <view class="label uni-row">
  134. <text>问题描述</text>
  135. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}}
  136. {{ selectText(item) }}</text>
  137. </view>
  138. <view class="content">{{ item.content }}</view>
  139. </view>
  140. <!-- 不需要暂时注释 -->
  141. <!-- <view v-if="item.answer !== ''" class="answer"
  142. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  143. <view class="label">回复</view>
  144. <view class="content">{{ item.answer }}</view>
  145. </view> -->
  146. </view>
  147. </view>
  148. <view class="title">快速关联</view>
  149. <view class="consultation-container ">
  150. <view class="title unfit-title uni-row" style="justify-content: flex-start;">
  151. <view v-if="editRelate" class="add-btn" style="background-color: #409eff;" @click="handleAddLot">关联批次
  152. </view>
  153. </view>
  154. <view>
  155. <zb-table :columns="getRelateList()" :stripe="true" :fit="true" @dele="dele"
  156. :data="processInspecion.relateList"></zb-table>
  157. </view>
  158. </view>
  159. <!-- 报工部分 -->
  160. <view class="daywork-container">
  161. <!-- 此处后续要加上条件限制,当状态为合格或不合格的时候不能修改状态,需要有权限的人来进行修改 -->
  162. <!-- <view class="result uni-row">
  163. <view class="label">检测量</view>
  164. <input type="number" v-model="processInspecion.examiningNum" placeholder="请输入检测量" />
  165. <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
  166. <input type="number" v-model="processInspecion.rejectNum" placeholder="请输入废品量" />
  167. </view> -->
  168. <view class="result resu uni-row" style="margin-top: 20rpx;">
  169. <view class="label" style="width: 170rpx;">外协检状态</view>
  170. <uni-data-checkbox :disabled="!editable()" style="margin-top: 20rpx;"
  171. v-model="processInspecion.inspectionStatus" :localdata="range"
  172. @change="handleChangeInspecionStatus"></uni-data-checkbox>
  173. <!-- <uni-data-checkbox v-if="editable()" v-model="processInspecion.inspectionStatus"
  174. :localdata="range" @change="handleChangeInspecionStatus"></uni-data-checkbox>
  175. <view v-else class="value">{{ processInspecion.inspectionStatus == 1 ? '合格' : '不合格' }}
  176. </view> -->
  177. </view>
  178. <view class="result uni-row">
  179. <view class="label" style="margin-top: 20rpx;width: 170rpx;">放行状态</view>
  180. <uni-data-checkbox :disabled="true" style="margin-top: 20rpx;" v-model="processInspecion.status"
  181. :localdata="range"></uni-data-checkbox>
  182. </view>
  183. <view v-if="editable() && editRelate">
  184. <view v-if="showTransfer" class="list-title uni-row" style="margin-top: 16rpx;">
  185. <text class="label">是否移交仪器室</text><text>&nbsp;否</text>
  186. <switch class="switch" @change="switchChange" style="transform:scale(0.7);margin-top: -16rpx;"
  187. color="rgba(103, 195, 55, 1.0)" />
  188. <text>是</text>
  189. </view>
  190. <view v-else class="list-title uni-row" style="margin-top: 16rpx;">
  191. <text class="label">已经移交给仪器室</text>
  192. </view>
  193. </view>
  194. <view class="result uni-row">
  195. <view class="label">废品总数</view>
  196. <view class="value" style="margin-left: 10px;">{{ processInspecion.rejectNum }}</view>
  197. </view>
  198. <view class="remark uni-row">
  199. <view class="label">备注</view>
  200. <textarea v-if="editable()" v-model="processInspecion.remark" maxlength="999" />
  201. <view v-else class="value">{{ processInspecion.remark }}</view>
  202. </view>
  203. <view class="btns-container uni-row">
  204. <view v-if="editable() && navigateOnce== 0" class="finished-btn" @click="endWork">结束报工</view>
  205. <view v-if="editable()" class="question-btn uni-column" @click.stop="handleAddConsultation">
  206. <uni-icons type="headphones" size="24" />
  207. <text>咨询</text>
  208. </view>
  209. </view>
  210. </view>
  211. <dialog-inspectionChamber ref='selectInspectionChamber'
  212. @handleSelectInspectionChamber='handleSelectInspectionChamber'></dialog-inspectionChamber>
  213. </view>
  214. </template>
  215. <script setup>
  216. import {
  217. ref,
  218. onMounted,
  219. getCurrentInstance
  220. } from 'vue'
  221. import {
  222. onLoad,
  223. onReady,
  224. onUnload,
  225. onShow
  226. } from '@dcloudio/uni-app'
  227. import {
  228. store
  229. } from '@/store/index.js'
  230. import {
  231. saveOutsourcedInspecion,
  232. getInstrumentRoomInspection,
  233. selectOutsourcedInspecion,
  234. saveOutsourceInspectionWithRelate
  235. } from '@/api/business/processInspection.js'
  236. import {
  237. getURL
  238. } from '@/api/sys/user.js'
  239. const lot = ref({})
  240. const unfitInfos = ref([]) //废品信息
  241. const oldUnfitInfos = ref([])
  242. const isEventTriggered = ref(false); // 创建一个标志位
  243. // 创建一个引用来存储最后一次请求的时间戳
  244. const lastRequestTimestamp = ref(0);
  245. const selectInspectionChamber = ref(null)
  246. const consultations = ref([]) //咨询信息
  247. const flag = ref(false)
  248. const showTransfer = ref(true)
  249. const navigateOnce = ref(0)
  250. const processInspecion = ref({
  251. remark: "",
  252. rejectNum: 0,
  253. examiningNum: 0,
  254. status: 0,
  255. inspectionStatus: 0,
  256. lot: {}
  257. })
  258. const editRelate = ref(false)
  259. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  260. const webHost = ref(urlList.baseUrl)
  261. const photoList = ref([])
  262. const selected = ref([]);
  263. const selectedPhotos = ref([])
  264. const imageStyles = {
  265. width: 60,
  266. height: 60
  267. }
  268. const relateColumn = ref([{
  269. name: 'lotCode',
  270. label: '批号',
  271. align: 'center',
  272. width: 100
  273. },
  274. {
  275. name: 'allCarriers',
  276. label: '箱号',
  277. align: 'center',
  278. width: 80
  279. },
  280. {
  281. name: 'isMaster',
  282. label: '主检查单',
  283. align: 'center',
  284. width: 60,
  285. filters: {
  286. 0: '否',
  287. 1: '是'
  288. }
  289. },
  290. {
  291. name: 'operation',
  292. type: 'operation',
  293. label: '关联',
  294. align: 'center',
  295. width: 60,
  296. renders: [{
  297. name: '删除',
  298. type: 'warn',
  299. func: "dele",
  300. class: "buttonOp"
  301. }, ]
  302. },
  303. ])
  304. const initStatus = ref(0)
  305. function dele(ite, index) {
  306. if (ite.isMaster == 1) {
  307. uni.showToast({
  308. icon: 'none',
  309. title: '主检查单,不可删除'
  310. })
  311. } else {
  312. processInspecion.value.relateList.splice(index, 1);
  313. }
  314. }
  315. const editable = () => {
  316. if (processInspecion.value.auditStatus == 1) {
  317. return false
  318. }
  319. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
  320. return true
  321. }
  322. if (initStatus.value == 0) {
  323. return true
  324. }
  325. if (processInspecion.value.firstUpdaterId == store.userInfo.userId) {
  326. return true
  327. }
  328. return false
  329. }
  330. function getRelateList() {
  331. // console.log('getRelateList')
  332. if (editRelate.value) {
  333. // console.log(relateColumn.value)
  334. return relateColumn.value
  335. } else {
  336. // console.log(relateColumn.value.slice(0, 3))
  337. return relateColumn.value.slice(0, 3)
  338. }
  339. }
  340. const consul = [{
  341. value: 0,
  342. text: "待确认",
  343. type: "color: #fcab53"
  344. }, {
  345. value: 2,
  346. text: "合格",
  347. type: "color: #55ff7f"
  348. }, {
  349. value: 1,
  350. text: "不合格",
  351. type: "color: #ff0c2c"
  352. }]
  353. const range = [{
  354. value: 0,
  355. text: "待确认",
  356. type: "color: #fcab53"
  357. }, {
  358. value: 1,
  359. text: "合格",
  360. type: "color: #55ff7f"
  361. }, {
  362. value: 2,
  363. text: "不合格",
  364. type: "color: #ff0c2c"
  365. }]
  366. /***************************** 页面生命周期函数 *****************************/
  367. onMounted(() => {
  368. const instance = getCurrentInstance().proxy
  369. const eventChannel = instance.getOpenerEventChannel();
  370. eventChannel.on('outsourcedInspectionFrom', function(data) {
  371. console.log('outsourcedInspectionFrom', data)
  372. if (data && data.data) {
  373. processInspecion.value.lot = data.data;
  374. }
  375. })
  376. })
  377. onShow(() => {
  378. uni.$off('addWasteInfoEvent');
  379. })
  380. onLoad(() => {
  381. navigateOnce.value = 0
  382. uni.$off('addWasteInfoEvent');
  383. if (!flag.value) {
  384. if (store.processInspection != null) {
  385. uni.showLoading({
  386. title: '加载中'
  387. });
  388. console.log(store.processInspection)
  389. processInspecion.value = {
  390. ...store.processInspection,
  391. lot: {}
  392. }
  393. selectOutsourcedInspecion(processInspecion.value).then(res => {
  394. console.log("res", res);
  395. if (res.code == 200) {
  396. processInspecion.value = res.data;
  397. initStatus.value = res.data.inspectionStatus
  398. unfitInfos.value = res.data.rejects;
  399. oldUnfitInfos.value = res.data.oldRejects;
  400. consultations.value = res.data.dayworkItemConsults;
  401. selectedPhotos.value = res.data.processInspectionPictureList
  402. photoList.value = res.data.processInspectionPictureList.map(item => {
  403. return {
  404. ...item,
  405. url: webHost.value + item.url
  406. };
  407. });
  408. if (editable() && !processInspecion.value.relateList.some(t => t.isMaster ===
  409. 1)) {
  410. editRelate.value = true
  411. } else {
  412. editRelate.value = false
  413. }
  414. console.log()
  415. console.log(editRelate.value)
  416. console.log("res", res);
  417. //判断是否移交到了仪器室
  418. getInstrumentRoomInspectionList()
  419. uni.hideLoading();
  420. // getInspecion();
  421. } else {
  422. uni.showToast({
  423. icon: 'none',
  424. title: res.msg,
  425. duration: 2000
  426. })
  427. }
  428. });
  429. }
  430. }
  431. })
  432. /***************************** 定义了一些方法 *****************************/
  433. //咨询文本
  434. function selectText(item) {
  435. // for (var i = 0; i < consul.length; i++) {
  436. // if (item.status == consul[i].value) {
  437. // return consul[i].text
  438. // }
  439. // }
  440. if (item.consultResultId == 0) {
  441. return '待确认'
  442. } else {
  443. return item.result
  444. }
  445. }
  446. function upLoadImageHandler(arg) {
  447. return getURL(arg).then(res => {
  448. let data = JSON.parse(res)
  449. selectedPhotos.value.push({
  450. url: data.fileName,
  451. pictureName: data.originalFilename,
  452. tenantId: store.tenantId
  453. })
  454. photoList.value.push({
  455. url: data.fileName,
  456. pictureName: data.originalFilename
  457. })
  458. console.log(selectedPhotos.value)
  459. // uni.showToast({
  460. // icon: 'none',
  461. // title: selectedPhotos.value.length,
  462. // duration: 2000
  463. // })
  464. })
  465. }
  466. function select(e) {
  467. console.log(e)
  468. const {
  469. tempFilePaths,
  470. tempFiles
  471. } = e
  472. uni.showLoading({
  473. title: '图片上传中',
  474. mask: true
  475. });
  476. // tempFiles.forEach((item, index) => {
  477. // upLoadImageHandler({
  478. // filePath: tempFilePaths[index],
  479. // name: item.name
  480. // })
  481. // })
  482. // 创建一个空的Promise数组
  483. let uploadPromises = tempFiles.map((item, index) => {
  484. return upLoadImageHandler({
  485. filePath: tempFilePaths[index],
  486. name: item.name
  487. });
  488. });
  489. // 使用Promise.all等待所有图片上传完成
  490. Promise.all(uploadPromises).then(() => {
  491. // 上传完成后关闭加载提示
  492. uni.hideLoading();
  493. }).catch(() => {
  494. // 如果有错误发生,也关闭加载提示
  495. uni.hideLoading();
  496. });
  497. }
  498. function handleDeletedPhoto(e) {
  499. let fileName = selectedPhotos.value.map(info => info.pictureName)
  500. const firstSlashIndex = e.tempFile.url.lastIndexOf('/');
  501. const lastSlashIndex = e.tempFile.url.lastIndexOf('_');
  502. const type = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex)
  503. const pictureName = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex) + e.tempFile.url.substring(e
  504. .tempFile.url.lastIndexOf('.') - 1 + 1);;
  505. let index = -1; // 初始化 index 为 -1,表示未找到
  506. // 首先检查 e.tempFile.name 是否存在
  507. if (fileName.findIndex(name => name === e.tempFile.name) !== -1) {
  508. index = fileName.findIndex(name => name === e.tempFile.name);
  509. }
  510. // 如果 e.tempFile.name 不存在,检查 e.tempFile.pictureName 是否存在
  511. else if (fileName.findIndex(name => name === e.tempFile.pictureName) !== -1) {
  512. index = fileName.findIndex(name => name === e.tempFile.pictureName);
  513. }
  514. // 如果以上两个都不存在,检查 pictureName 是否存在
  515. else if (fileName.findIndex(name => name === pictureName) !== -1) {
  516. index = fileName.findIndex(name => name === pictureName);
  517. }
  518. selectedPhotos.value.splice(index, 1)
  519. }
  520. //打开电子图纸
  521. function handleDrawingMenu() {
  522. var outsourceOrderDetailId = encodeURIComponent(processInspecion.value.outsourceOrderDetailId);
  523. var lotCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  524. var technologyVersion = encodeURIComponent(processInspecion.value.lot.technologyVersion)
  525. // 构建查询参数字符串
  526. var queryParam =
  527. `param1=${outsourceOrderDetailId}&param2=${lotCode}&param3=${processInspecion.value.lot.productId}&param4=${technologyVersion}`;
  528. // 使用模板字符串构建完整的URL
  529. var navigateUrl = `/pages/outsourcedDrawingMenu/index?${queryParam}`;
  530. // 导航到指定页面
  531. uni.navigateTo({
  532. url: navigateUrl
  533. });
  534. }
  535. function getInstrumentRoomInspectionList() {
  536. getInstrumentRoomInspection(processInspecion.value).then(res => {
  537. if (res.data.length > 0) {
  538. showTransfer.value = false
  539. } else {
  540. showTransfer.value = true
  541. }
  542. })
  543. }
  544. function switchChange(event) {
  545. if (event.detail.value) {
  546. processInspecion.value.flag = true
  547. } else {
  548. processInspecion.value.flag = false
  549. }
  550. }
  551. const rejectNumberChange = () => {
  552. let sumReject = 0
  553. let sumDisqualificationNum = 0
  554. let sumExaminingNum = 0
  555. unfitInfos.value.forEach(v => {
  556. sumReject += (v.rejectNum != null ? Number(v.rejectNum) : 0)
  557. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  558. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  559. })
  560. processInspecion.value.rejectNum = sumReject
  561. processInspecion.value.disqualificationNum = sumDisqualificationNum
  562. processInspecion.value.examiningNum = sumExaminingNum
  563. console.log(processInspecion.value)
  564. }
  565. //查询咨询列表
  566. function getInspecion() {
  567. processInspecion.value = store.processInspection
  568. selectInspecion(processInspecion.value).then(res => {
  569. console.log("咨询", res);
  570. if (res.code == 200) {
  571. console.log("res", res);
  572. } else {
  573. uni.showToast({
  574. icon: 'none',
  575. title: res.msg,
  576. duration: 2000
  577. })
  578. }
  579. });
  580. }
  581. //结束报工按钮
  582. function endWork() {
  583. let unf = unfitInfos.value;
  584. for (var i = 0; i < unfitInfos.value.length; i++) {
  585. console.log("废品信息");
  586. // if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].rejectNum) {
  587. // uni.showToast({
  588. // icon: 'none',
  589. // title: "废品信息不能为空",
  590. // duration: 2000
  591. // })
  592. // return;
  593. // }
  594. if (unf[i].checkStandard == '' || unf[i].checkStandard == null) {
  595. uni.showToast({
  596. icon: 'none',
  597. title: "检查标准不能为空",
  598. duration: 2000
  599. })
  600. return;
  601. }
  602. // if (unf[i].checkResult == '' || unf[i].checkResult == null) {
  603. // uni.showToast({
  604. // icon: 'none',
  605. // title: "检查结果不能为空",
  606. // duration: 2000
  607. // })
  608. // return;
  609. // }
  610. if (unf[i].rejectNum == null) {
  611. uni.showToast({
  612. icon: 'none',
  613. title: "废品量不能为空",
  614. duration: 2000
  615. })
  616. return;
  617. }
  618. if (unf[i].rejectNum < 0 || unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  619. uni.showToast({
  620. icon: 'none',
  621. title: '检查量,不良品量,废品量不能小于0',
  622. duration: 2000
  623. })
  624. return
  625. }
  626. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  627. uni.showToast({
  628. icon: 'none',
  629. title: '检查量不能大于投产量'
  630. })
  631. return
  632. }
  633. }
  634. let sumReject = 0
  635. unfitInfos.value.forEach(v => {
  636. sumReject += Number(v.rejectNum)
  637. })
  638. if (processInspecion.value.rejectNum != sumReject) {
  639. uni.showToast({
  640. icon: 'none',
  641. title: "废品量与废品信息不一致",
  642. duration: 2000
  643. })
  644. return;
  645. }
  646. if (processInspecion.value.rejectNum > processInspecion.value.lot.pudName) {
  647. uni.showToast({
  648. icon: 'none',
  649. title: '废品量不能大于投产量'
  650. })
  651. return
  652. }
  653. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  654. uni.showToast({
  655. icon: 'none',
  656. title: '不良品量不能大于投产量'
  657. })
  658. return
  659. }
  660. save();
  661. }
  662. function save() {
  663. const currentTime = Date.now();
  664. // 检查是否已经过去了 2 秒
  665. if (currentTime - lastRequestTimestamp.value < 2000) {
  666. // 如果在 2 秒 内已经点击,那么不执行
  667. uni.showToast({
  668. icon: 'none',
  669. title: `请勿重复点击`,
  670. duration: 2000
  671. })
  672. return;
  673. }
  674. lastRequestTimestamp.value = currentTime;
  675. let pages = getCurrentPages();
  676. processInspecion.value.dayworkItemConsults = consultations.value;
  677. processInspecion.value.dayworkItemRejects = unfitInfos.value;
  678. processInspecion.value.user = store.userInfo;
  679. processInspecion.value.tenantId = store.tenantId
  680. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  681. if (processInspecion.value.flag) {
  682. //打开选择仪器室的弹窗
  683. selectInspectionChamber.value.open()
  684. console.log(processInspecion.value)
  685. } else {
  686. saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
  687. if (res.code == 200) {
  688. // let index = 0;
  689. // for (let i = 0; i < pages.length; i++) {
  690. // if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  691. // index = pages.length - i - 1;
  692. // }
  693. // }
  694. // console.log("index", index);
  695. // uni.navigateBack(
  696. // {
  697. // delta: index
  698. // }
  699. // );
  700. if (navigateOnce.value == 0) {
  701. navigateOnce.value = 1
  702. uni.navigateBack()
  703. }
  704. } else {
  705. uni.showToast({
  706. icon: 'none',
  707. title: res.msg,
  708. duration: 2000
  709. })
  710. }
  711. });
  712. }
  713. }
  714. function handleSelectInspectionChamber(data) {
  715. processInspecion.value.inspectionChamberId = data
  716. console.log(processInspecion.value)
  717. saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
  718. if (res.code == 200) {
  719. // let index = 0;
  720. // let pages = getCurrentPages();
  721. // for (let i = 0; i < pages.length; i++) {
  722. // if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  723. // index = pages.length - i - 1;
  724. // }
  725. // }
  726. // console.log("index", index);
  727. // uni.navigateBack(
  728. // {
  729. // delta: index
  730. // }
  731. // );
  732. if (navigateOnce.value == 0) {
  733. navigateOnce.value = 1
  734. uni.navigateBack()
  735. }
  736. } else {
  737. uni.showToast({
  738. icon: 'none',
  739. title: res.msg,
  740. duration: 2000
  741. })
  742. }
  743. });
  744. }
  745. //咨询样式
  746. function selectType(item) {
  747. for (var i = 0; i < consul.length; i++) {
  748. if (item.status == consul[i].value) {
  749. return consul[i].type
  750. }
  751. }
  752. }
  753. // const addWasteInfo = (data) => {
  754. // const info = {
  755. // title: data.title,
  756. // checkStandard: data.standard
  757. // }
  758. // unfitInfos.value.push(info)
  759. // }
  760. const addConsultation = (data) => {
  761. console.log(data)
  762. let info = data
  763. info.forEach(item => {
  764. item.status = 0
  765. })
  766. consultations.value = consultations.value.concat(info)
  767. isEventTriggered.value = true; // 更新标志位状态
  768. processInspecion.value.status = 0
  769. uni.$off('wasteConsultationEvent')
  770. }
  771. /***************************** 定义了一些事件 *****************************/
  772. // 添加不合格信息
  773. // const handleAddWaste = () => {
  774. // let info = {}
  775. // unfitInfos.value.push(info)
  776. // // 监听事件,暂时不用,后续会使用
  777. // // uni.$once('addWasteInfoEvent', (data) => {
  778. // // addWasteInfo(data)
  779. // // })
  780. // // uni.navigateTo({
  781. // // url: "/pages/processInspection/options"
  782. // // })
  783. // }
  784. const handleAddWaste = () => {
  785. flag.value = true
  786. // 监听事件,暂时不用,后续会使用
  787. uni.$on('addWasteInfoEvent', (data) => {
  788. addWasteInfo(data)
  789. })
  790. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  791. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  792. // 构建查询参数字符串
  793. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  794. // 使用模板字符串构建完整的URL
  795. var navigateUrl = `/pages/outsourcedInspection/options?${queryParam}`;
  796. // 导航到指定页面
  797. uni.navigateTo({
  798. url: navigateUrl
  799. });
  800. }
  801. const addWasteInfo = (data) => {
  802. console.log(data, "55555555")
  803. flag.value = true
  804. var info = {
  805. inspectionStandardsId: data.id,
  806. checkStandard: data.standard
  807. }
  808. unfitInfos.value.push(info)
  809. console.log(data)
  810. // uni.$off('addWasteInfoEvent')
  811. }
  812. // 删除不合格信息
  813. const handleDelWaste = (index) => {
  814. uni.showModal({
  815. title: '提示',
  816. content: '确定删除该项?',
  817. success: function(res) {
  818. if (res.confirm) {
  819. unfitInfos.value.splice(index, 1)
  820. rejectNumberChange()
  821. } else if (res.cancel) {
  822. return
  823. }
  824. }
  825. })
  826. }
  827. const addRelate = (relates) => {
  828. isEventTriggered.value = true;
  829. processInspecion.value.relateList = relates
  830. // uni.$off('relateEvent')
  831. }
  832. function handleChangeInspecionStatus(e) {
  833. console.log(e.detail.value)
  834. //没有咨询
  835. if (consultations.value && consultations.value.length == 0) {
  836. processInspecion.value.status = e.detail.value
  837. }
  838. }
  839. const handleAddLot = () => {
  840. console.log('添加关联')
  841. isEventTriggered.value = false;
  842. uni.$once('relateEvent', (data) => {
  843. if (!isEventTriggered.value) {
  844. // 如果事件尚未触发,则执行事件触发逻辑
  845. addRelate(data)
  846. }
  847. // uni.$off('relateEvent')
  848. })
  849. uni.navigateTo({
  850. url: "/pages/outsourcedInspection/relate",
  851. success: (res) => {
  852. res.eventChannel.emit("outsourcedInspectionRelation",
  853. processInspecion.value
  854. )
  855. }
  856. })
  857. }
  858. // 咨询
  859. const handleAddConsultation = () => {
  860. isEventTriggered.value = false;
  861. // 监听事件
  862. uni.$once('wasteConsultationEvent', (data) => {
  863. if (!isEventTriggered.value) {
  864. // 如果事件尚未触发,则执行事件触发逻辑
  865. addConsultation(data)
  866. }
  867. // uni.$off('wasteConsultationEvent')
  868. })
  869. uni.navigateTo({
  870. url: "/pages/outsourcedInspection/consultation",
  871. success: (res) => {
  872. // 通过eventChannel向被打开页面传送数据
  873. res.eventChannel.emit("outsourcedInspectionConsultation", {
  874. data: processInspecion.value.lot
  875. })
  876. }
  877. })
  878. }
  879. </script>
  880. <style lang="scss">
  881. .buttonOp {
  882. margin-top: 5px;
  883. }
  884. .page-container {
  885. // height: 100%;
  886. background-color: #ececec;
  887. font-size: 28rpx;
  888. >.title {
  889. font-weight: 700;
  890. margin: 24rpx 16rpx;
  891. }
  892. }
  893. .carrier-info {
  894. margin: 32rpx 16rpx 0 16rpx;
  895. padding: 24rpx;
  896. background-color: #ffffff;
  897. border-radius: 8rpx;
  898. .carrier-code {
  899. font-size: 32rpx;
  900. font-weight: 700;
  901. }
  902. .info-row {
  903. margin-top: 16rpx;
  904. color: #767676;
  905. .label {
  906. width: 160rpx;
  907. }
  908. .drawing-btn {
  909. padding: 12rpx 32rpx;
  910. background-color: #0055ff;
  911. color: #ffffff;
  912. border-radius: 12rpx;
  913. margin-left: auto;
  914. font-size: 28rpx;
  915. }
  916. .value {
  917. flex: 1;
  918. textarea {
  919. flex: 1;
  920. border: 1px solid #888888;
  921. box-sizing: border-box;
  922. padding: 16rpx;
  923. }
  924. }
  925. }
  926. }
  927. .unfit-title {
  928. margin-bottom: 24rpx;
  929. justify-content: space-between;
  930. align-items: center;
  931. text {
  932. font-size: 28rpx;
  933. font-weight: 700;
  934. }
  935. .add-btn {
  936. margin-right: 26rpx;
  937. padding: 12rpx 32rpx;
  938. background-color: #a4adb3;
  939. color: #ffffff;
  940. border-radius: 12rpx;
  941. font-size: 24rpx;
  942. }
  943. }
  944. .unfit-container {
  945. padding: 24rpx;
  946. margin: 0 16rpx;
  947. background-color: #ffffff;
  948. border-radius: 12rpx;
  949. .unfit-item-container {
  950. position: relative;
  951. >* {
  952. margin-bottom: 24rpx;
  953. }
  954. .title {
  955. font-weight: 700;
  956. justify-content: space-between;
  957. align-items: center;
  958. image {
  959. width: 40rpx;
  960. height: 40rpx;
  961. }
  962. }
  963. .standard {}
  964. .resu {
  965. width: 100%;
  966. align-items: center;
  967. input {
  968. margin-left: 20rpx;
  969. width: 200rpx;
  970. height: 56rpx;
  971. flex: 1;
  972. border: 1px solid #9f9f9f;
  973. font-size: 28rpx;
  974. }
  975. .label {
  976. width: 160rpx;
  977. }
  978. .value {
  979. flex: 1;
  980. textarea {
  981. flex: 1;
  982. border: 1px solid #888888;
  983. box-sizing: border-box;
  984. padding: 16rpx;
  985. }
  986. }
  987. }
  988. .result {
  989. border-bottom: 1px solid #9f9f9f;
  990. padding-bottom: 32rpx;
  991. align-items: center;
  992. .label {
  993. width: 160rpx;
  994. }
  995. .value {
  996. flex: 1;
  997. textarea {
  998. flex: 1;
  999. border: 1px solid #888888;
  1000. box-sizing: border-box;
  1001. padding: 16rpx;
  1002. }
  1003. }
  1004. input {
  1005. width: 280rpx;
  1006. height: 56rpx;
  1007. border: 1px solid #9f9f9f;
  1008. font-size: 28rpx;
  1009. &.number {
  1010. width: 104rpx;
  1011. text-align: center;
  1012. }
  1013. }
  1014. }
  1015. }
  1016. .unfit-item-container:last-child {
  1017. .result {
  1018. border-bottom: none;
  1019. padding-bottom: 0;
  1020. }
  1021. }
  1022. }
  1023. .consultation-container {
  1024. margin: 0 16rpx;
  1025. padding: 24rpx;
  1026. background-color: #ffffff;
  1027. border-radius: 8rpx;
  1028. .consultation-item-container {
  1029. margin-bottom: 24rpx;
  1030. border-bottom: 2px solid #888888;
  1031. padding-bottom: 24rpx;
  1032. }
  1033. .consultation-item-container:last-child {
  1034. margin-bottom: 0;
  1035. border-bottom: 0;
  1036. padding-bottom: 0;
  1037. }
  1038. .question,
  1039. .answer {
  1040. .label {
  1041. justify-content: space-between;
  1042. margin-bottom: 16rpx;
  1043. font-weight: 700;
  1044. }
  1045. .content {
  1046. line-height: 40rpx;
  1047. }
  1048. }
  1049. .answer {
  1050. margin-top: 24rpx;
  1051. }
  1052. }
  1053. .daywork-container {
  1054. margin-top: 24rpx;
  1055. padding: 24rpx;
  1056. background-color: #ffffff;
  1057. border: 1px solid #bcbcbc;
  1058. .result {
  1059. align-items: center;
  1060. .label {
  1061. width: 112rpx;
  1062. }
  1063. input {
  1064. flex: 1;
  1065. height: 56rpx;
  1066. border: 1px solid #9f9f9f;
  1067. font-size: 28rpx;
  1068. text-align: center;
  1069. }
  1070. }
  1071. .remark {
  1072. margin-top: 24rpx;
  1073. .label {
  1074. width: 112rpx;
  1075. }
  1076. textarea {
  1077. flex: 1;
  1078. border: 1px solid #9f9f9f;
  1079. height: 168rpx;
  1080. }
  1081. }
  1082. .btns-container {
  1083. margin-top: 24rpx;
  1084. .finished-btn {
  1085. display: flex;
  1086. flex: 1;
  1087. height: 80rpx;
  1088. background-color: #fc6565;
  1089. color: #ffffff;
  1090. text-align: center;
  1091. justify-content: center;
  1092. align-items: center;
  1093. border-radius: 8rpx;
  1094. }
  1095. .question-btn {
  1096. width: 80rpx;
  1097. align-items: flex-end;
  1098. image {
  1099. width: 48rpx;
  1100. height: 48rpx;
  1101. }
  1102. text {
  1103. font-size: 24rpx;
  1104. }
  1105. }
  1106. }
  1107. }
  1108. .uni-input-input:disabled {
  1109. background-color: #f5f7fa;
  1110. }
  1111. .my-files {
  1112. display: flex;
  1113. justify-content: center;
  1114. :deep(.uni-file-picker__container) {
  1115. flex-direction: row;
  1116. }
  1117. }
  1118. .consultation-container {
  1119. margin: 0 16rpx;
  1120. padding: 24rpx;
  1121. background-color: #ffffff;
  1122. border-radius: 8rpx;
  1123. .consultation-item-container {
  1124. margin-bottom: 24rpx;
  1125. border-bottom: 2px solid #888888;
  1126. padding-bottom: 24rpx;
  1127. }
  1128. .consultation-item-container:last-child {
  1129. margin-bottom: 0;
  1130. border-bottom: 0;
  1131. padding-bottom: 0;
  1132. }
  1133. .question,
  1134. .answer {
  1135. .label {
  1136. justify-content: space-between;
  1137. margin-bottom: 16rpx;
  1138. font-weight: 700;
  1139. }
  1140. .content {
  1141. line-height: 40rpx;
  1142. }
  1143. }
  1144. .answer {
  1145. margin-top: 24rpx;
  1146. }
  1147. }
  1148. .zb-table .item-tr .item-td {
  1149. overflow-x: auto;
  1150. }
  1151. </style>