form.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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.lot.processAlias }}</view>
  27. </view>
  28. <view class="info-row uni-row">
  29. <view class="label">操作者</view>
  30. <view class="value">{{ processInspecion.lot.nickName }}</view>
  31. </view>
  32. <view class="info-row uni-row">
  33. <view class="label">设备</view>
  34. <view class="value">{{ processInspecion.lot.equipmentDetailCode }}</view>
  35. </view>
  36. <view class="info-row uni-row">
  37. <view class="label">检查载具</view>
  38. <view class="value">{{ processInspecion.lot.inspectionCarrierCode }}
  39. {{ processInspecion.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  40. </view>
  41. </view>
  42. <view class="info-row uni-row">
  43. <view class="drawing-btn" @click="handleDrawingMenu">图纸信息</view>
  44. </view>
  45. </view>
  46. <!-- 废品信息 -->
  47. <view class="title unfit-title uni-row">
  48. <text>检查信息</text>
  49. <view v-if="editable()" class="add-btn" @click="handleAddWaste">添加</view>
  50. </view>
  51. <view class="unfit-container">
  52. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  53. <view class="resu uni-row">
  54. <view class="label">检查标准</view>
  55. <view class="value" style="margin-left:16rpx;width: 400rpx;">{{ item.checkStandard }}</view>
  56. <uni-icons v-if="editable()" type="trash" size="24" style="margin-left: 55rpx;" color="#fc6565"
  57. @click="handleDelWaste(index)" />
  58. </view>
  59. <!-- <view class="result uni-row">
  60. <view class="label">检查结果</view>
  61. <input v-model="item.checkResult" placeholder="请输入检查结果" />
  62. <view class="label" style="text-align: right; padding-right: 16rpx;">数量
  63. </view>
  64. <input class="number" type="number" @blur="rejectNumberChange" v-model="item.rejectNum"
  65. placeholder="" />
  66. </view> -->
  67. <view class="resu uni-row">
  68. <view class="label">检查结果</view>
  69. <input v-if="editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  70. <view v-else class="value" style="margin-left:16rpx;">{{ item.checkResult }}</view>
  71. </view>
  72. <view class="resu uni-row">
  73. <view class="label">超差范围</view>
  74. <input v-if="editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  75. <view v-else class="value" style="margin-left:16rpx;">{{ item.exceedLimits }}</view>
  76. </view>
  77. <view class="resu uni-row">
  78. <view :class="!editable() ? 'label' : ''">检查量</view>
  79. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  80. v-model="item.examiningNum" placeholder="" />
  81. <view v-else class="number value" style="margin-left:16rpx;">{{ item.examiningNum }}</view>
  82. <view :class="!editable() ? 'label' : ''" style="margin-left: 16rpx;">不良品量</view>
  83. <input v-if="editable()" class="number" type="number" @blur="rejectNumberChange"
  84. v-model="item.disqualificationNum" placeholder="" />
  85. <view v-else class="value" style="margin-left:16rpx;">{{ item.disqualificationNum }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 拍照上传部分 -->
  90. <view class="title unfit-title uni-row">
  91. <text>拍照上传</text>
  92. </view>
  93. <view class=" uni-row" style="padding: 24rpx;
  94. margin: 0 16rpx;
  95. background-color: #ffffff;
  96. border-radius: 12rpx;">
  97. <uni-file-picker v-model="photoList" :readonly="!editable()" return-type="array" :image-styles="imageStyles"
  98. @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto"></uni-file-picker>
  99. </view>
  100. <!-- 咨询部分 -->
  101. <view class="title unfit-title uni-row">
  102. <text>咨询</text>
  103. </view>
  104. <view class="consultation-container uni-column">
  105. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  106. <view class="question uni-column">
  107. <view class="label uni-row">
  108. <text>问题描述</text>
  109. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}}
  110. {{ selectText(item) }}</text>
  111. </view>
  112. <view class="content">{{ item.content }}</view>
  113. </view>
  114. <!-- 不需要暂时注释 -->
  115. <!-- <view v-if="item.answer !== ''" class="answer"
  116. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  117. <view class="label">回复</view>
  118. <view class="content">{{ item.answer }}</view>
  119. </view> -->
  120. </view>
  121. </view>
  122. <!-- 报工部分 -->
  123. <view class="daywork-container">
  124. <view class="result uni-row">
  125. <view class="label" style="margin-top: 20rpx; margin-right: 10rpx;">交检状态</view>
  126. <uni-data-checkbox :disabled="!editable()" style="margin-top: 20rpx;"
  127. v-model="processInspecion.inspectionStatus" :localdata="range"
  128. @change="handleChangeInspecionStatus"></uni-data-checkbox>
  129. </view>
  130. <view class="result uni-row">
  131. <view class="label" style="margin-top: 20rpx; margin-right: 10rpx;">放行状态</view>
  132. <uni-data-checkbox :disabled="true" style="margin-top: 20rpx;" v-model="processInspecion.status"
  133. :localdata="range"></uni-data-checkbox>
  134. </view>
  135. <view v-if="editable()">
  136. <view v-if="showTransfer" class="list-title uni-row" style="margin-top: 16rpx;">
  137. <text class="label">是否移交仪器室</text><text>&nbsp;否</text>
  138. <!-- <switch class="switch" @change="switchChange" style="transform:scale(0.7);margin-top: -16rpx;"
  139. color="rgba(255,85,85,1)" /> -->
  140. <zero-switch v-model="processInspecion.flag" @change="switchChange"
  141. active-color="rgba(103, 195, 55, 1.0)" :size="18"
  142. style="transform:scale(0.9);margin-top: -9rpx;"></zero-switch>
  143. <text>是</text>
  144. </view>
  145. <view v-else class="list-title uni-row" style="margin-top: 16rpx;">
  146. <text class="label">已经移交给仪器室</text>
  147. </view>
  148. <view class="list-title uni-row" style="margin-top: 16rpx;">
  149. <text class="label">检测完成</text><text>&nbsp;否</text>
  150. <!-- <switch :checked="isAllChecked" class="switch" :disabled="!showTransfer || processInspecion.flag"
  151. @change="switchAllCheckChange" style="transform:scale(0.7);margin-top: -16rpx;"
  152. color="rgba(255,85,85,1)" /> -->
  153. <zero-switch v-model="isAllChecked" :disabled="!showTransfer || processInspecion.flag"
  154. @change="switchAllCheckChange" active-color="rgba(103, 195, 55, 1.0)" :size="18"
  155. style="transform:scale(0.9);margin-top: -9rpx;"></zero-switch>
  156. <text>是</text>
  157. </view>
  158. </view>
  159. <view class="remark uni-row">
  160. <view class="label">备注</view>
  161. <textarea v-if="editable()" v-model="processInspecion.remark" maxlength="999" />
  162. <view v-else class="value">{{ processInspecion.remark }}</view>
  163. </view>
  164. <view v-if="editable()" class="btns-container uni-row">
  165. <view class="finished-btn" @click="endWork">提交</view>
  166. <view class="question-btn uni-column" @click.stop="handleAddConsultation">
  167. <uni-icons type="headphones" size="24" />
  168. <text>咨询</text>
  169. </view>
  170. </view>
  171. </view>
  172. <dialog-inspectionChamber ref='selectInspectionChamber'
  173. @handleSelectInspectionChamber='handleSelectInspectionChamber'></dialog-inspectionChamber>
  174. </view>
  175. </template>
  176. <script setup>
  177. import {
  178. ref,
  179. onMounted,
  180. getCurrentInstance
  181. } from 'vue'
  182. import {
  183. onLoad,
  184. onReady,
  185. onUnload,
  186. onShow
  187. } from '@dcloudio/uni-app'
  188. import {
  189. store
  190. } from '@/store/index.js'
  191. import {
  192. saveDeliveryInspecion,
  193. selectInspecion,
  194. getInstrumentRoomInspection
  195. } from '@/api/business/processInspection.js'
  196. import {
  197. getInspectionStandardsList
  198. } from '@/api/business/inspectionStandards.js'
  199. import {
  200. getURL
  201. } from '@/api/sys/user.js'
  202. const lot = ref({})
  203. const isEventTriggered = ref(false); // 创建一个标志位
  204. const unfitInfos = ref([]) //废品信息
  205. const consultations = ref([]) //咨询信息
  206. const flag = ref(false)
  207. const showTransfer = ref(true)
  208. const isAllChecked = ref(false)
  209. const selectInspectionChamber = ref(null)
  210. // 创建一个引用来存储最后一次请求的时间戳
  211. const lastRequestTimestamp = ref(0);
  212. const processInspecion = ref({
  213. remark: "",
  214. rejectNum: 0,
  215. examiningNum: 0,
  216. status: 0,
  217. inspectionStatus: 0
  218. })
  219. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  220. const webHost = ref(urlList.baseUrl)
  221. const photoList = ref([])
  222. const selected = ref([]);
  223. const selectedPhotos = ref([])
  224. const imageStyles = {
  225. width: 60,
  226. height: 60
  227. }
  228. const initStatus = ref(0)
  229. const editable = () => {
  230. // if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
  231. // return true
  232. // }
  233. if (initStatus.value == 0) {
  234. return true
  235. }
  236. if (processInspecion.value.firstUpdaterId == store.userInfo.userId) {
  237. return true
  238. }
  239. return false
  240. }
  241. const consul = [{
  242. value: 0,
  243. text: "待确认",
  244. type: "color: #fcab53"
  245. }, {
  246. value: 2,
  247. text: "合格",
  248. type: "color: #55ff7f"
  249. }, {
  250. value: 1,
  251. text: "不合格",
  252. type: "color: #ff0c2c"
  253. }]
  254. const range = [{
  255. value: 0,
  256. text: "待确认",
  257. type: "color: #fcab53"
  258. }, {
  259. value: 1,
  260. text: "合格",
  261. type: "color: #55ff7f"
  262. }, {
  263. value: 2,
  264. text: "不合格",
  265. type: "color: #ff0c2c"
  266. }]
  267. /***************************** 页面生命周期函数 *****************************/
  268. function init() {
  269. const instance = getCurrentInstance().proxy
  270. const eventChannel = instance.getOpenerEventChannel();
  271. eventChannel.on('deliveryInspectionFrom', function(data) {
  272. console.log('acceptDataFromOpenerPage', data)
  273. if (data && data.data) {
  274. processInspecion.value.lot = data.data;
  275. //getOringicalList()
  276. }
  277. })
  278. }
  279. onShow(() => {
  280. uni.$off('addWasteInfoEvent');
  281. })
  282. onLoad(() => {
  283. uni.$off('addWasteInfoEvent');
  284. console.log(store.processInspection)
  285. console.log(flag.value)
  286. if (!flag.value) {
  287. console.log("888")
  288. if (store.processInspection != null) {
  289. uni.showLoading({
  290. title: '加载中'
  291. });
  292. console.log(store.tenantId)
  293. processInspecion.value = store.processInspection
  294. isAllChecked.value = (processInspecion.value.isAllChecked == 1)
  295. selectInspecion(processInspecion.value).then(res => {
  296. if (res.code == 200) {
  297. processInspecion.value = res.data;
  298. processInspecion.value.flag = false
  299. unfitInfos.value = res.data.processInspectionDetails;
  300. initStatus.value = res.data.inspectionStatus
  301. consultations.value = res.data.dayworkItemConsults;
  302. selectedPhotos.value = res.data.processInspectionPictureList
  303. photoList.value = res.data.processInspectionPictureList.map(item => {
  304. return {
  305. ...item,
  306. url: webHost.value + item.url
  307. };
  308. });
  309. console.log("res", res);
  310. console.log(processInspecion.value)
  311. //是否已经移交仪器室
  312. getInstrumentRoomInspectionList()
  313. uni.hideLoading();
  314. // getInspecion();
  315. } else {
  316. uni.showToast({
  317. icon: 'none',
  318. title: res.msg,
  319. duration: 2000
  320. })
  321. }
  322. });
  323. } else {
  324. console.log("99999")
  325. init()
  326. }
  327. }
  328. })
  329. function getOringicalList() {
  330. console.log(processInspecion.value)
  331. //查询该产品,当前工序,当前检查绑定的检查
  332. getInspectionStandardsList({
  333. productId: processInspecion.value.lot.productId,
  334. processId: processInspecion.value.lot.processId,
  335. inspectionCode: "deliveryInspection"
  336. }).then(res => {
  337. unfitInfos.value = res.rows.map(item => {
  338. // 映射新的数组,包含 inspectionStandardsId 和 checkStandard 属性
  339. return {
  340. inspectionStandardsId: item.id, // 从 item 中获取 id
  341. checkStandard: item.standard // 从 item 中获取 standard
  342. };
  343. });
  344. })
  345. }
  346. /***************************** 定义了一些方法 *****************************/
  347. //咨询文本
  348. function selectText(item) {
  349. // for (var i = 0; i < consul.length; i++) {
  350. // if (item.status == consul[i].value) {
  351. // return consul[i].text
  352. // }
  353. // }
  354. if (item.consultResultId == 0) {
  355. return '待确认'
  356. } else {
  357. return item.result
  358. }
  359. }
  360. function upLoadImageHandler(arg) {
  361. return getURL(arg).then(res => {
  362. let data = JSON.parse(res)
  363. selectedPhotos.value.push({
  364. url: data.fileName,
  365. pictureName: data.originalFilename,
  366. tenantId: store.tenantId
  367. })
  368. photoList.value.push({
  369. url: data.fileName,
  370. pictureName: data.originalFilename
  371. })
  372. console.log(selectedPhotos.value)
  373. // uni.showToast({
  374. // icon: 'none',
  375. // title: selectedPhotos.value.length,
  376. // duration: 2000
  377. // })
  378. })
  379. }
  380. function select(e) {
  381. console.log(e)
  382. const {
  383. tempFilePaths,
  384. tempFiles
  385. } = e
  386. uni.showLoading({
  387. title: '图片上传中',
  388. mask: true
  389. });
  390. // tempFiles.forEach((item, index) => {
  391. // upLoadImageHandler({
  392. // filePath: tempFilePaths[index],
  393. // name: item.name
  394. // })
  395. // })
  396. // 创建一个空的Promise数组
  397. let uploadPromises = tempFiles.map((item, index) => {
  398. return upLoadImageHandler({
  399. filePath: tempFilePaths[index],
  400. name: item.name
  401. });
  402. });
  403. // 使用Promise.all等待所有图片上传完成
  404. Promise.all(uploadPromises).then(() => {
  405. // 上传完成后关闭加载提示
  406. uni.hideLoading();
  407. }).catch(() => {
  408. // 如果有错误发生,也关闭加载提示
  409. uni.hideLoading();
  410. });
  411. }
  412. function handleChangeInspecionStatus(e) {
  413. console.log(e.detail.value)
  414. //没有咨询
  415. if (consultations.value && consultations.value.length == 0) {
  416. processInspecion.value.status = e.detail.value
  417. processInspecion.value.adoptStatus = e.detail.value
  418. }
  419. }
  420. function handleDeletedPhoto(e) {
  421. let fileName = selectedPhotos.value.map(info => info.pictureName)
  422. const firstSlashIndex = e.tempFile.url.lastIndexOf('/');
  423. const lastSlashIndex = e.tempFile.url.lastIndexOf('_');
  424. const type = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex)
  425. const pictureName = e.tempFile.url.substring(firstSlashIndex + 1, lastSlashIndex) + e.tempFile.url.substring(e
  426. .tempFile.url.lastIndexOf('.') - 1 + 1);;
  427. let index = -1; // 初始化 index 为 -1,表示未找到
  428. // 首先检查 e.tempFile.name 是否存在
  429. if (fileName.findIndex(name => name === e.tempFile.name) !== -1) {
  430. index = fileName.findIndex(name => name === e.tempFile.name);
  431. }
  432. // 如果 e.tempFile.name 不存在,检查 e.tempFile.pictureName 是否存在
  433. else if (fileName.findIndex(name => name === e.tempFile.pictureName) !== -1) {
  434. index = fileName.findIndex(name => name === e.tempFile.pictureName);
  435. }
  436. // 如果以上两个都不存在,检查 pictureName 是否存在
  437. else if (fileName.findIndex(name => name === pictureName) !== -1) {
  438. index = fileName.findIndex(name => name === pictureName);
  439. }
  440. selectedPhotos.value.splice(index, 1)
  441. }
  442. function handleDrawingMenu() {
  443. // 对 technologicalProcessDetailId 进行URL编码
  444. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  445. var enTechnologicalProcessId = encodeURIComponent(processInspecion.value.lot.technologicalProcessId);
  446. var enprocessCode = encodeURIComponent(processInspecion.value.lot.processCode);
  447. var encodeCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  448. var enProcessAlias = encodeURIComponent(processInspecion.value.lot.processAlias);
  449. var enIsWasteRecycling = encodeURIComponent(processInspecion.value.lot.isWasteRecycling);
  450. var enIsAmend = encodeURIComponent(processInspecion.value.lot.isAmend);
  451. // 构建查询参数字符串
  452. var queryParam =
  453. `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}&param6=${enIsWasteRecycling}&param7=${enIsAmend}`;
  454. // 使用模板字符串构建完整的URL
  455. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  456. // 导航到指定页面
  457. uni.navigateTo({
  458. url: navigateUrl
  459. });
  460. }
  461. function switchChange(event) {
  462. console.log(event)
  463. // if (event.detail.value) {
  464. if (event) {
  465. processInspecion.value.flag = true
  466. processInspecion.value.isAllChecked = 0
  467. isAllChecked.value = false
  468. } else {
  469. processInspecion.value.flag = false
  470. }
  471. }
  472. function switchAllCheckChange(event) {
  473. console.log(event)
  474. // if (event.detail.value) {
  475. if (event) {
  476. processInspecion.value.isAllChecked = 1
  477. } else {
  478. processInspecion.value.isAllChecked = 0
  479. }
  480. }
  481. const rejectNumberChange = () => {
  482. let sumDisqualificationNum = 0
  483. let sumExaminingNum = 0
  484. unfitInfos.value.forEach(v => {
  485. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  486. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  487. })
  488. processInspecion.value.disqualificationNum = sumDisqualificationNum
  489. processInspecion.value.examiningNum = sumExaminingNum
  490. console.log(processInspecion.value)
  491. }
  492. function getInstrumentRoomInspectionList() {
  493. getInstrumentRoomInspection(processInspecion.value).then(res => {
  494. if (res.data.length > 0) {
  495. showTransfer.value = false
  496. // processInspecion.value.flag = true
  497. } else {
  498. showTransfer.value = true
  499. // processInspecion.value.flag = false
  500. }
  501. })
  502. }
  503. //查询咨询列表
  504. function getInspecion() {
  505. processInspecion.value = store.processInspection
  506. selectInspecion(processInspecion.value).then(res => {
  507. console.log("咨询", res);
  508. if (res.code == 200) {
  509. console.log("res", res);
  510. } else {
  511. uni.showToast({
  512. icon: 'none',
  513. title: res.msg,
  514. duration: 2000
  515. })
  516. }
  517. });
  518. }
  519. //结束报工按钮
  520. function endWork() {
  521. let unf = unfitInfos.value;
  522. for (var i = 0; i < unfitInfos.value.length; i++) {
  523. if (unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  524. uni.showToast({
  525. icon: 'none',
  526. title: '检查量,不良品量不能小于0',
  527. duration: 2000
  528. })
  529. return
  530. }
  531. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  532. uni.showToast({
  533. icon: 'none',
  534. title: '检查量不能大于投产量'
  535. })
  536. return
  537. }
  538. }
  539. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  540. uni.showToast({
  541. icon: 'none',
  542. title: '不良品量不能大于投产量'
  543. })
  544. return
  545. }
  546. save();
  547. }
  548. function save() {
  549. const currentTime = Date.now();
  550. // 检查是否已经过去了 2 秒
  551. if (currentTime - lastRequestTimestamp.value < 2000) {
  552. // 如果在 2 秒 内已经点击,那么不执行
  553. uni.showToast({
  554. icon: 'none',
  555. title: `请勿重复点击`,
  556. duration: 2000
  557. })
  558. return;
  559. }
  560. lastRequestTimestamp.value = currentTime;
  561. let pages = getCurrentPages();
  562. processInspecion.value.dayworkItemConsults = consultations.value;
  563. processInspecion.value.processInspectionDetails = unfitInfos.value;
  564. processInspecion.value.user = store.userInfo;
  565. processInspecion.value.tenantId = store.tenantId
  566. processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
  567. processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
  568. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  569. console.log(processInspecion.value)
  570. if (processInspecion.value.flag) {
  571. //打开选择仪器室的弹窗
  572. selectInspectionChamber.value.open()
  573. console.log(processInspecion.value)
  574. } else {
  575. saveDeliveryInspecion(processInspecion.value).then(res => {
  576. if (res.code == 200) {
  577. let index = 0;
  578. for (let i = 0; i < pages.length; i++) {
  579. if (pages[i].$page.fullPath == "/pages/deliveryInspection/index") {
  580. index = pages.length - i - 1;
  581. }
  582. }
  583. console.log("index", index);
  584. uni.navigateBack({
  585. delta: index
  586. });
  587. } else {
  588. uni.showToast({
  589. icon: 'none',
  590. title: res.msg,
  591. duration: 2000
  592. })
  593. }
  594. });
  595. }
  596. }
  597. //仪器室带回
  598. function handleSelectInspectionChamber(data) {
  599. processInspecion.value.inspectionChamberId = data
  600. console.log(processInspecion.value)
  601. saveDeliveryInspecion(processInspecion.value).then(res => {
  602. if (res.code == 200) {
  603. let index = 0;
  604. let pages = getCurrentPages();
  605. for (let i = 0; i < pages.length; i++) {
  606. if (pages[i].$page.fullPath == "/pages/deliveryInspection/index") {
  607. index = pages.length - i - 1;
  608. }
  609. }
  610. console.log("index", index);
  611. uni.navigateBack({
  612. delta: index
  613. });
  614. } else {
  615. uni.showToast({
  616. icon: 'none',
  617. title: res.msg,
  618. duration: 2000
  619. })
  620. }
  621. });
  622. }
  623. //咨询样式
  624. function selectType(item) {
  625. for (var i = 0; i < consul.length; i++) {
  626. if (item.status == consul[i].value) {
  627. return consul[i].type
  628. }
  629. }
  630. }
  631. const addWasteInfo = (data) => {
  632. console.log(data, "55555555")
  633. flag.value = true
  634. var info = {
  635. inspectionStandardsId: data.id,
  636. checkStandard: data.standard
  637. }
  638. unfitInfos.value.push(info)
  639. console.log(data)
  640. }
  641. const addConsultation = (data) => {
  642. let info = data
  643. info.forEach(item => {
  644. item.status = 0
  645. })
  646. consultations.value = consultations.value.concat(info)
  647. isEventTriggered.value = true; // 更新标志位状态
  648. processInspecion.value.status = 0
  649. processInspecion.value.adoptStatus = 0
  650. }
  651. /***************************** 定义了一些事件 *****************************/
  652. // 添加不合格信息
  653. const handleAddWaste = () => {
  654. flag.value = true
  655. // 监听事件,暂时不用,后续会使用
  656. uni.$on('addWasteInfoEvent', (data) => {
  657. addWasteInfo(data)
  658. })
  659. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  660. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  661. // 构建查询参数字符串
  662. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  663. // 使用模板字符串构建完整的URL
  664. var navigateUrl = `/pages/deliveryInspection/options?${queryParam}`;
  665. // 导航到指定页面
  666. uni.navigateTo({
  667. url: navigateUrl
  668. });
  669. }
  670. // 删除不合格信息
  671. const handleDelWaste = (index) => {
  672. uni.showModal({
  673. title: '提示',
  674. content: '确定删除该项?',
  675. success: function(res) {
  676. if (res.confirm) {
  677. unfitInfos.value.splice(index, 1)
  678. } else if (res.cancel) {
  679. return
  680. }
  681. }
  682. })
  683. }
  684. // 咨询
  685. const handleAddConsultation = () => {
  686. console.log("9999")
  687. isEventTriggered.value = false;
  688. // 监听事件
  689. uni.$once('addWasteConsultationEvent', (data) => {
  690. if (!isEventTriggered.value) {
  691. // 如果事件尚未触发,则执行事件触发逻辑
  692. addConsultation(data)
  693. }
  694. })
  695. uni.navigateTo({
  696. url: "/pages/deliveryInspection/consultation",
  697. success: (res) => {
  698. // 通过eventChannel向被打开页面传送数据
  699. res.eventChannel.emit("deliveryInpsectionConsultation", {
  700. data: processInspecion.value.lot
  701. })
  702. }
  703. })
  704. }
  705. </script>
  706. <style lang="scss">
  707. .page-container {
  708. // height: 100%;
  709. background-color: #ececec;
  710. font-size: 28rpx;
  711. >.title {
  712. font-weight: 700;
  713. margin: 24rpx 16rpx;
  714. }
  715. }
  716. .carrier-info {
  717. margin: 32rpx 16rpx 0 16rpx;
  718. padding: 24rpx;
  719. background-color: #ffffff;
  720. border-radius: 8rpx;
  721. .carrier-code {
  722. font-size: 32rpx;
  723. font-weight: 700;
  724. }
  725. .info-row {
  726. margin-top: 16rpx;
  727. color: #767676;
  728. .label {
  729. width: 160rpx;
  730. }
  731. .drawing-btn {
  732. padding: 12rpx 32rpx;
  733. background-color: #0055ff;
  734. color: #ffffff;
  735. border-radius: 12rpx;
  736. margin-left: auto;
  737. font-size: 28rpx;
  738. }
  739. .value {
  740. flex: 1;
  741. textarea {
  742. flex: 1;
  743. border: 1px solid #888888;
  744. box-sizing: border-box;
  745. padding: 16rpx;
  746. }
  747. }
  748. }
  749. }
  750. .unfit-title {
  751. margin-bottom: 24rpx;
  752. justify-content: space-between;
  753. align-items: center;
  754. text {
  755. font-size: 28rpx;
  756. font-weight: 700;
  757. }
  758. .add-btn {
  759. padding: 12rpx 32rpx;
  760. background-color: #a4adb3;
  761. color: #ffffff;
  762. border-radius: 12rpx;
  763. font-size: 24rpx;
  764. }
  765. }
  766. .unfit-container {
  767. padding: 24rpx;
  768. margin: 0 16rpx;
  769. background-color: #ffffff;
  770. border-radius: 12rpx;
  771. .unfit-item-container {
  772. position: relative;
  773. >* {
  774. margin-bottom: 24rpx;
  775. }
  776. .title {
  777. font-weight: 700;
  778. justify-content: space-between;
  779. align-items: center;
  780. image {
  781. width: 40rpx;
  782. height: 40rpx;
  783. }
  784. }
  785. .standard {}
  786. .resu {
  787. width: 100%;
  788. align-items: center;
  789. input {
  790. margin-left: 20rpx;
  791. width: 200rpx;
  792. height: 56rpx;
  793. flex: 1;
  794. border: 1px solid #9f9f9f;
  795. font-size: 28rpx;
  796. }
  797. }
  798. .result {
  799. align-items: center;
  800. border-bottom: 1px solid #9f9f9f;
  801. padding-bottom: 32rpx;
  802. .label {
  803. flex: 1;
  804. }
  805. input {
  806. width: 280rpx;
  807. height: 56rpx;
  808. border: 1px solid #9f9f9f;
  809. font-size: 28rpx;
  810. &.number {
  811. width: 104rpx;
  812. text-align: center;
  813. }
  814. }
  815. }
  816. }
  817. .unfit-item-container:last-child {
  818. .result {
  819. border-bottom: none;
  820. padding-bottom: 0;
  821. }
  822. }
  823. }
  824. .consultation-container {
  825. margin: 0 16rpx;
  826. padding: 24rpx;
  827. background-color: #ffffff;
  828. border-radius: 8rpx;
  829. .consultation-item-container {
  830. margin-bottom: 24rpx;
  831. border-bottom: 2px solid #888888;
  832. padding-bottom: 24rpx;
  833. }
  834. .consultation-item-container:last-child {
  835. margin-bottom: 0;
  836. border-bottom: 0;
  837. padding-bottom: 0;
  838. }
  839. .question,
  840. .answer {
  841. .label {
  842. justify-content: space-between;
  843. margin-bottom: 16rpx;
  844. font-weight: 700;
  845. }
  846. .content {
  847. line-height: 40rpx;
  848. }
  849. }
  850. .answer {
  851. margin-top: 24rpx;
  852. }
  853. }
  854. .daywork-container {
  855. margin-top: 24rpx;
  856. padding: 24rpx;
  857. background-color: #ffffff;
  858. border: 1px solid #bcbcbc;
  859. .result {
  860. align-items: center;
  861. .label {
  862. width: 112rpx;
  863. }
  864. input {
  865. flex: 1;
  866. height: 56rpx;
  867. border: 1px solid #9f9f9f;
  868. font-size: 28rpx;
  869. text-align: center;
  870. }
  871. }
  872. .switch {
  873. margin-top: -8rpx;
  874. align-items: center;
  875. }
  876. .remark {
  877. margin-top: 24rpx;
  878. .label {
  879. width: 112rpx;
  880. }
  881. textarea {
  882. flex: 1;
  883. border: 1px solid #9f9f9f;
  884. height: 168rpx;
  885. }
  886. }
  887. .btns-container {
  888. margin-top: 24rpx;
  889. .finished-btn {
  890. display: flex;
  891. flex: 1;
  892. height: 80rpx;
  893. background-color: #fc6565;
  894. color: #ffffff;
  895. text-align: center;
  896. justify-content: center;
  897. align-items: center;
  898. border-radius: 8rpx;
  899. }
  900. .question-btn {
  901. width: 80rpx;
  902. align-items: flex-end;
  903. image {
  904. width: 48rpx;
  905. height: 48rpx;
  906. }
  907. text {
  908. font-size: 24rpx;
  909. }
  910. }
  911. }
  912. }
  913. input:disabled {
  914. background-color: #aaaaff !important;
  915. color: #ccc !important;
  916. /* 假设您想要设置文本颜色 */
  917. }
  918. .my-files {
  919. display: flex;
  920. justify-content: center;
  921. :deep(.uni-file-picker__container) {
  922. flex-direction: row;
  923. }
  924. }
  925. </style>