form.vue 30 KB

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