form.vue 27 KB

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