form.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  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 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(103, 195, 55, 1.0)" />
  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. onShow(() => {
  369. uni.$off('addWasteInfoEvent');
  370. })
  371. onLoad(() => {
  372. navigateOnce.value = 0
  373. uni.$off('addWasteInfoEvent');
  374. if (!flag.value) {
  375. if (store.processInspection != null) {
  376. uni.showLoading({
  377. title: '加载中'
  378. });
  379. console.log(store.processInspection)
  380. processInspecion.value = {
  381. ...store.processInspection,
  382. lot: {}
  383. }
  384. selectOutsourcedInspecion(processInspecion.value).then(res => {
  385. console.log("res", res);
  386. if (res.code == 200) {
  387. processInspecion.value = res.data;
  388. initStatus.value = res.data.status
  389. unfitInfos.value = res.data.rejects;
  390. oldUnfitInfos.value = res.data.oldRejects;
  391. consultations.value = res.data.dayworkItemConsults;
  392. selectedPhotos.value = res.data.processInspectionPictureList
  393. photoList.value = res.data.processInspectionPictureList.map(item => {
  394. return {
  395. ...item,
  396. url: webHost.value + item.url
  397. };
  398. });
  399. if (editable() && !processInspecion.value.relateList.some(t => t.isMaster ===
  400. 1)) {
  401. editRelate.value = true
  402. } else {
  403. editRelate.value = false
  404. }
  405. console.log()
  406. console.log(editRelate.value)
  407. console.log("res", res);
  408. //判断是否移交到了仪器室
  409. getInstrumentRoomInspectionList()
  410. uni.hideLoading();
  411. // getInspecion();
  412. } else {
  413. uni.showToast({
  414. icon: 'none',
  415. title: res.msg,
  416. duration: 2000
  417. })
  418. }
  419. });
  420. }
  421. }
  422. })
  423. /***************************** 定义了一些方法 *****************************/
  424. //咨询文本
  425. function selectText(item) {
  426. for (var i = 0; i < consul.length; i++) {
  427. if (item.status == consul[i].value) {
  428. return consul[i].text
  429. }
  430. }
  431. }
  432. function upLoadImageHandler(arg) {
  433. getURL(arg).then(res => {
  434. let data = JSON.parse(res)
  435. selectedPhotos.value.push({
  436. url: data.fileName,
  437. pictureName: data.originalFilename,
  438. tenantId: store.tenantId
  439. })
  440. console.log(selectedPhotos.value)
  441. })
  442. }
  443. function select(e) {
  444. console.log(e)
  445. const {
  446. tempFilePaths,
  447. tempFiles
  448. } = e
  449. tempFiles.forEach((item, index) => {
  450. upLoadImageHandler({
  451. filePath: tempFilePaths[index],
  452. name: item.name
  453. })
  454. })
  455. }
  456. function handleDeletedPhoto(e) {
  457. let fileName = selectedPhotos.value.map(info => info.pictureName)
  458. const firstSlashIndex = e.tempFile.url.lastIndexOf('/');
  459. const lastSlashIndex = e.tempFile.url.lastIndexOf('_');
  460. const type = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex)
  461. const pictureName = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex) + e.tempFile.url.substring(e
  462. .tempFile.url.lastIndexOf('.') - 1 + 1);;
  463. let index = -1; // 初始化 index 为 -1,表示未找到
  464. // 首先检查 e.tempFile.name 是否存在
  465. if (fileName.findIndex(name => name === e.tempFile.name) !== -1) {
  466. index = fileName.findIndex(name => name === e.tempFile.name);
  467. }
  468. // 如果 e.tempFile.name 不存在,检查 e.tempFile.pictureName 是否存在
  469. else if (fileName.findIndex(name => name === e.tempFile.pictureName) !== -1) {
  470. index = fileName.findIndex(name => name === e.tempFile.pictureName);
  471. }
  472. // 如果以上两个都不存在,检查 pictureName 是否存在
  473. else if (fileName.findIndex(name => name === pictureName) !== -1) {
  474. index = fileName.findIndex(name => name === pictureName);
  475. }
  476. selectedPhotos.value.splice(index, 1)
  477. }
  478. //打开电子图纸
  479. function handleDrawingMenu() {
  480. var outsourceOrderDetailId = encodeURIComponent(processInspecion.value.outsourceOrderDetailId);
  481. var lotCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  482. var technologyVersion = encodeURIComponent(processInspecion.value.lot.technologyVersion)
  483. // 构建查询参数字符串
  484. var queryParam =
  485. `param1=${outsourceOrderDetailId}&param2=${lotCode}&param3=${processInspecion.value.lot.productId}&param4=${technologyVersion}`;
  486. // 使用模板字符串构建完整的URL
  487. var navigateUrl = `/pages/outsourcedDrawingMenu/index?${queryParam}`;
  488. // 导航到指定页面
  489. uni.navigateTo({
  490. url: navigateUrl
  491. });
  492. }
  493. function getInstrumentRoomInspectionList() {
  494. getInstrumentRoomInspection(processInspecion.value).then(res => {
  495. if (res.data.length > 0) {
  496. showTransfer.value = false
  497. } else {
  498. showTransfer.value = true
  499. }
  500. })
  501. }
  502. function switchChange(event) {
  503. if (event.detail.value) {
  504. processInspecion.value.flag = true
  505. } else {
  506. processInspecion.value.flag = false
  507. }
  508. }
  509. const rejectNumberChange = () => {
  510. let sumReject = 0
  511. let sumDisqualificationNum = 0
  512. let sumExaminingNum = 0
  513. unfitInfos.value.forEach(v => {
  514. sumReject += (v.rejectNum != null ? Number(v.rejectNum) : 0)
  515. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  516. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  517. })
  518. processInspecion.value.rejectNum = sumReject
  519. processInspecion.value.disqualificationNum = sumDisqualificationNum
  520. processInspecion.value.examiningNum = sumExaminingNum
  521. console.log(processInspecion.value)
  522. }
  523. //查询咨询列表
  524. function getInspecion() {
  525. processInspecion.value = store.processInspection
  526. selectInspecion(processInspecion.value).then(res => {
  527. console.log("咨询", res);
  528. if (res.code == 200) {
  529. console.log("res", res);
  530. } else {
  531. uni.showToast({
  532. icon: 'none',
  533. title: res.msg,
  534. duration: 2000
  535. })
  536. }
  537. });
  538. }
  539. //结束报工按钮
  540. function endWork() {
  541. let unf = unfitInfos.value;
  542. for (var i = 0; i < unfitInfos.value.length; i++) {
  543. console.log("废品信息");
  544. // if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].rejectNum) {
  545. // uni.showToast({
  546. // icon: 'none',
  547. // title: "废品信息不能为空",
  548. // duration: 2000
  549. // })
  550. // return;
  551. // }
  552. if (unf[i].checkStandard == '' || unf[i].checkStandard == null) {
  553. uni.showToast({
  554. icon: 'none',
  555. title: "检查标准不能为空",
  556. duration: 2000
  557. })
  558. return;
  559. }
  560. // if (unf[i].checkResult == '' || unf[i].checkResult == null) {
  561. // uni.showToast({
  562. // icon: 'none',
  563. // title: "检查结果不能为空",
  564. // duration: 2000
  565. // })
  566. // return;
  567. // }
  568. if (unf[i].rejectNum == null) {
  569. uni.showToast({
  570. icon: 'none',
  571. title: "废品量不能为空",
  572. duration: 2000
  573. })
  574. return;
  575. }
  576. if (unf[i].rejectNum < 0 || unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  577. uni.showToast({
  578. icon: 'none',
  579. title: '检查量,不良品量,废品量不能小于0',
  580. duration: 2000
  581. })
  582. return
  583. }
  584. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  585. uni.showToast({
  586. icon: 'none',
  587. title: '检查量不能大于投产量'
  588. })
  589. return
  590. }
  591. }
  592. let sumReject = 0
  593. unfitInfos.value.forEach(v => {
  594. sumReject += Number(v.rejectNum)
  595. })
  596. if (processInspecion.value.rejectNum != sumReject) {
  597. uni.showToast({
  598. icon: 'none',
  599. title: "废品量与废品信息不一致",
  600. duration: 2000
  601. })
  602. return;
  603. }
  604. if (processInspecion.value.rejectNum > processInspecion.value.lot.pudName) {
  605. uni.showToast({
  606. icon: 'none',
  607. title: '废品量不能大于投产量'
  608. })
  609. return
  610. }
  611. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  612. uni.showToast({
  613. icon: 'none',
  614. title: '不良品量不能大于投产量'
  615. })
  616. return
  617. }
  618. save();
  619. }
  620. function save() {
  621. const currentTime = Date.now();
  622. // 检查是否已经过去了 2 秒
  623. if (currentTime - lastRequestTimestamp.value < 2000) {
  624. // 如果在 2 秒 内已经点击,那么不执行
  625. uni.showToast({
  626. icon: 'none',
  627. title: `请勿重复点击`,
  628. duration: 2000
  629. })
  630. return;
  631. }
  632. let pages = getCurrentPages();
  633. processInspecion.value.dayworkItemConsults = consultations.value;
  634. processInspecion.value.dayworkItemRejects = unfitInfos.value;
  635. processInspecion.value.user = store.userInfo;
  636. processInspecion.value.tenantId = store.tenantId
  637. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  638. if (processInspecion.value.flag) {
  639. //打开选择仪器室的弹窗
  640. selectInspectionChamber.value.open()
  641. console.log(processInspecion.value)
  642. } else {
  643. saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
  644. if (res.code == 200) {
  645. // let index = 0;
  646. // for (let i = 0; i < pages.length; i++) {
  647. // if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  648. // index = pages.length - i - 1;
  649. // }
  650. // }
  651. // console.log("index", index);
  652. // uni.navigateBack(
  653. // {
  654. // delta: index
  655. // }
  656. // );
  657. if (navigateOnce.value == 0) {
  658. navigateOnce.value = 1
  659. uni.navigateBack()
  660. }
  661. } else {
  662. uni.showToast({
  663. icon: 'none',
  664. title: res.msg,
  665. duration: 2000
  666. })
  667. }
  668. });
  669. }
  670. }
  671. function handleSelectInspectionChamber(data) {
  672. processInspecion.value.inspectionChamberId = data
  673. console.log(processInspecion.value)
  674. saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
  675. if (res.code == 200) {
  676. // let index = 0;
  677. // let pages = getCurrentPages();
  678. // for (let i = 0; i < pages.length; i++) {
  679. // if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
  680. // index = pages.length - i - 1;
  681. // }
  682. // }
  683. // console.log("index", index);
  684. // uni.navigateBack(
  685. // {
  686. // delta: index
  687. // }
  688. // );
  689. if (navigateOnce.value == 0) {
  690. navigateOnce.value = 1
  691. uni.navigateBack()
  692. }
  693. } else {
  694. uni.showToast({
  695. icon: 'none',
  696. title: res.msg,
  697. duration: 2000
  698. })
  699. }
  700. });
  701. }
  702. //咨询样式
  703. function selectType(item) {
  704. for (var i = 0; i < consul.length; i++) {
  705. if (item.status == consul[i].value) {
  706. return consul[i].type
  707. }
  708. }
  709. }
  710. // const addWasteInfo = (data) => {
  711. // const info = {
  712. // title: data.title,
  713. // checkStandard: data.standard
  714. // }
  715. // unfitInfos.value.push(info)
  716. // }
  717. const addConsultation = (data) => {
  718. console.log(data)
  719. let info = data
  720. info.forEach(item => {
  721. item.status = 0
  722. })
  723. consultations.value = consultations.value.concat(info)
  724. isEventTriggered.value = true; // 更新标志位状态
  725. uni.$off('wasteConsultationEvent')
  726. }
  727. /***************************** 定义了一些事件 *****************************/
  728. // 添加不合格信息
  729. // const handleAddWaste = () => {
  730. // let info = {}
  731. // unfitInfos.value.push(info)
  732. // // 监听事件,暂时不用,后续会使用
  733. // // uni.$once('addWasteInfoEvent', (data) => {
  734. // // addWasteInfo(data)
  735. // // })
  736. // // uni.navigateTo({
  737. // // url: "/pages/processInspection/options"
  738. // // })
  739. // }
  740. const handleAddWaste = () => {
  741. flag.value = true
  742. // 监听事件,暂时不用,后续会使用
  743. uni.$on('addWasteInfoEvent', (data) => {
  744. addWasteInfo(data)
  745. })
  746. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  747. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  748. // 构建查询参数字符串
  749. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  750. // 使用模板字符串构建完整的URL
  751. var navigateUrl = `/pages/outsourcedInspection/options?${queryParam}`;
  752. // 导航到指定页面
  753. uni.navigateTo({
  754. url: navigateUrl
  755. });
  756. }
  757. const addWasteInfo = (data) => {
  758. console.log(data, "55555555")
  759. flag.value = true
  760. var info = {
  761. inspectionStandardsId: data.id,
  762. checkStandard: data.standard
  763. }
  764. unfitInfos.value.push(info)
  765. console.log(data)
  766. // uni.$off('addWasteInfoEvent')
  767. }
  768. // 删除不合格信息
  769. const handleDelWaste = (index) => {
  770. uni.showModal({
  771. title: '提示',
  772. content: '确定删除该项?',
  773. success: function(res) {
  774. if (res.confirm) {
  775. unfitInfos.value.splice(index, 1)
  776. rejectNumberChange()
  777. } else if (res.cancel) {
  778. return
  779. }
  780. }
  781. })
  782. }
  783. const addRelate = (relates) => {
  784. isEventTriggered.value = true;
  785. processInspecion.value.relateList = relates
  786. // uni.$off('relateEvent')
  787. }
  788. const handleAddLot = () => {
  789. console.log('添加关联')
  790. isEventTriggered.value = false;
  791. uni.$once('relateEvent', (data) => {
  792. if (!isEventTriggered.value) {
  793. // 如果事件尚未触发,则执行事件触发逻辑
  794. addRelate(data)
  795. }
  796. // uni.$off('relateEvent')
  797. })
  798. uni.navigateTo({
  799. url: "/pages/outsourcedInspection/relate",
  800. success: (res) => {
  801. res.eventChannel.emit("outsourcedInspectionRelation",
  802. processInspecion.value
  803. )
  804. }
  805. })
  806. }
  807. // 咨询
  808. const handleAddConsultation = () => {
  809. isEventTriggered.value = false;
  810. // 监听事件
  811. uni.$once('wasteConsultationEvent', (data) => {
  812. if (!isEventTriggered.value) {
  813. // 如果事件尚未触发,则执行事件触发逻辑
  814. addConsultation(data)
  815. }
  816. // uni.$off('wasteConsultationEvent')
  817. })
  818. uni.navigateTo({
  819. url: "/pages/outsourcedInspection/consultation",
  820. success: (res) => {
  821. // 通过eventChannel向被打开页面传送数据
  822. res.eventChannel.emit("outsourcedInspectionConsultation", {
  823. data: processInspecion.value.lot
  824. })
  825. }
  826. })
  827. }
  828. </script>
  829. <style lang="scss">
  830. .buttonOp {
  831. margin-top: 5px;
  832. }
  833. .page-container {
  834. // height: 100%;
  835. background-color: #ececec;
  836. font-size: 28rpx;
  837. >.title {
  838. font-weight: 700;
  839. margin: 24rpx 16rpx;
  840. }
  841. }
  842. .carrier-info {
  843. margin: 32rpx 16rpx 0 16rpx;
  844. padding: 24rpx;
  845. background-color: #ffffff;
  846. border-radius: 8rpx;
  847. .carrier-code {
  848. font-size: 32rpx;
  849. font-weight: 700;
  850. }
  851. .info-row {
  852. margin-top: 16rpx;
  853. color: #767676;
  854. .label {
  855. width: 160rpx;
  856. }
  857. .drawing-btn {
  858. padding: 12rpx 32rpx;
  859. background-color: #0055ff;
  860. color: #ffffff;
  861. border-radius: 12rpx;
  862. margin-left: auto;
  863. font-size: 28rpx;
  864. }
  865. .value {
  866. flex: 1;
  867. textarea {
  868. flex: 1;
  869. border: 1px solid #888888;
  870. box-sizing: border-box;
  871. padding: 16rpx;
  872. }
  873. }
  874. }
  875. }
  876. .unfit-title {
  877. margin-bottom: 24rpx;
  878. justify-content: space-between;
  879. align-items: center;
  880. text {
  881. font-size: 28rpx;
  882. font-weight: 700;
  883. }
  884. .add-btn {
  885. margin-right: 26rpx;
  886. padding: 12rpx 32rpx;
  887. background-color: #a4adb3;
  888. color: #ffffff;
  889. border-radius: 12rpx;
  890. font-size: 24rpx;
  891. }
  892. }
  893. .unfit-container {
  894. padding: 24rpx;
  895. margin: 0 16rpx;
  896. background-color: #ffffff;
  897. border-radius: 12rpx;
  898. .unfit-item-container {
  899. position: relative;
  900. >* {
  901. margin-bottom: 24rpx;
  902. }
  903. .title {
  904. font-weight: 700;
  905. justify-content: space-between;
  906. align-items: center;
  907. image {
  908. width: 40rpx;
  909. height: 40rpx;
  910. }
  911. }
  912. .standard {}
  913. .resu {
  914. width: 100%;
  915. align-items: center;
  916. input {
  917. margin-left: 20rpx;
  918. width: 200rpx;
  919. height: 56rpx;
  920. flex: 1;
  921. border: 1px solid #9f9f9f;
  922. font-size: 28rpx;
  923. }
  924. .label {
  925. width: 160rpx;
  926. }
  927. .value {
  928. flex: 1;
  929. textarea {
  930. flex: 1;
  931. border: 1px solid #888888;
  932. box-sizing: border-box;
  933. padding: 16rpx;
  934. }
  935. }
  936. }
  937. .result {
  938. border-bottom: 1px solid #9f9f9f;
  939. padding-bottom: 32rpx;
  940. align-items: center;
  941. .label {
  942. width: 160rpx;
  943. }
  944. .value {
  945. flex: 1;
  946. textarea {
  947. flex: 1;
  948. border: 1px solid #888888;
  949. box-sizing: border-box;
  950. padding: 16rpx;
  951. }
  952. }
  953. input {
  954. width: 280rpx;
  955. height: 56rpx;
  956. border: 1px solid #9f9f9f;
  957. font-size: 28rpx;
  958. &.number {
  959. width: 104rpx;
  960. text-align: center;
  961. }
  962. }
  963. }
  964. }
  965. .unfit-item-container:last-child {
  966. .result {
  967. border-bottom: none;
  968. padding-bottom: 0;
  969. }
  970. }
  971. }
  972. .consultation-container {
  973. margin: 0 16rpx;
  974. padding: 24rpx;
  975. background-color: #ffffff;
  976. border-radius: 8rpx;
  977. .consultation-item-container {
  978. margin-bottom: 24rpx;
  979. border-bottom: 2px solid #888888;
  980. padding-bottom: 24rpx;
  981. }
  982. .consultation-item-container:last-child {
  983. margin-bottom: 0;
  984. border-bottom: 0;
  985. padding-bottom: 0;
  986. }
  987. .question,
  988. .answer {
  989. .label {
  990. justify-content: space-between;
  991. margin-bottom: 16rpx;
  992. font-weight: 700;
  993. }
  994. .content {
  995. line-height: 40rpx;
  996. }
  997. }
  998. .answer {
  999. margin-top: 24rpx;
  1000. }
  1001. }
  1002. .daywork-container {
  1003. margin-top: 24rpx;
  1004. padding: 24rpx;
  1005. background-color: #ffffff;
  1006. border: 1px solid #bcbcbc;
  1007. .result {
  1008. align-items: center;
  1009. .label {
  1010. width: 112rpx;
  1011. }
  1012. input {
  1013. flex: 1;
  1014. height: 56rpx;
  1015. border: 1px solid #9f9f9f;
  1016. font-size: 28rpx;
  1017. text-align: center;
  1018. }
  1019. }
  1020. .remark {
  1021. margin-top: 24rpx;
  1022. .label {
  1023. width: 112rpx;
  1024. }
  1025. textarea {
  1026. flex: 1;
  1027. border: 1px solid #9f9f9f;
  1028. height: 168rpx;
  1029. }
  1030. }
  1031. .btns-container {
  1032. margin-top: 24rpx;
  1033. .finished-btn {
  1034. display: flex;
  1035. flex: 1;
  1036. height: 80rpx;
  1037. background-color: #fc6565;
  1038. color: #ffffff;
  1039. text-align: center;
  1040. justify-content: center;
  1041. align-items: center;
  1042. border-radius: 8rpx;
  1043. }
  1044. .question-btn {
  1045. width: 80rpx;
  1046. align-items: flex-end;
  1047. image {
  1048. width: 48rpx;
  1049. height: 48rpx;
  1050. }
  1051. text {
  1052. font-size: 24rpx;
  1053. }
  1054. }
  1055. }
  1056. }
  1057. .uni-input-input:disabled {
  1058. background-color: #f5f7fa;
  1059. }
  1060. .my-files {
  1061. display: flex;
  1062. justify-content: center;
  1063. :deep(.uni-file-picker__container) {
  1064. flex-direction: row;
  1065. }
  1066. }
  1067. .consultation-container {
  1068. margin: 0 16rpx;
  1069. padding: 24rpx;
  1070. background-color: #ffffff;
  1071. border-radius: 8rpx;
  1072. .consultation-item-container {
  1073. margin-bottom: 24rpx;
  1074. border-bottom: 2px solid #888888;
  1075. padding-bottom: 24rpx;
  1076. }
  1077. .consultation-item-container:last-child {
  1078. margin-bottom: 0;
  1079. border-bottom: 0;
  1080. padding-bottom: 0;
  1081. }
  1082. .question,
  1083. .answer {
  1084. .label {
  1085. justify-content: space-between;
  1086. margin-bottom: 16rpx;
  1087. font-weight: 700;
  1088. }
  1089. .content {
  1090. line-height: 40rpx;
  1091. }
  1092. }
  1093. .answer {
  1094. margin-top: 24rpx;
  1095. }
  1096. }
  1097. .zb-table .item-tr {
  1098. flex-direction: row;
  1099. }
  1100. .zb-table .item-tr .item-td {
  1101. overflow-x: auto;
  1102. }
  1103. </style>