form.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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" style="justify-content: flex-start;">
  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 isEventTriggered = ref(false); // 创建一个标志位
  244. // 创建一个引用来存储最后一次请求的时间戳
  245. const lastRequestTimestamp = ref(0);
  246. const selectInspectionChamber = ref(null)
  247. const consultations = ref([]) //咨询信息
  248. const flag = ref(false)
  249. const showTransfer = ref(true)
  250. const navigateOnce = ref(0)
  251. const isLoading = ref(false);
  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 .item-td {
  1145. overflow-x: auto;
  1146. }
  1147. .mask {
  1148. position: fixed;
  1149. top: 0;
  1150. left: 0;
  1151. right: 0;
  1152. bottom: 0;
  1153. background-color: rgba(0, 0, 0, 0.5);
  1154. z-index: 2000;
  1155. display: flex;
  1156. justify-content: center;
  1157. align-items: center;
  1158. }
  1159. .mask .loading-text {
  1160. color: #fff;
  1161. font-size: 36rpx;
  1162. }
  1163. </style>