form.vue 30 KB

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