form.vue 31 KB

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