form.vue 32 KB

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