form.vue 25 KB

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