form.vue 25 KB

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