form.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  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(103, 195, 55, 1.0)"
  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(103, 195, 55, 1.0)" :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. var enIsWasteRecycling = encodeURIComponent(processInspecion.value.lot.isWasteRecycling);
  419. var enIsAmend = encodeURIComponent(processInspecion.value.lot.isAmend);
  420. // 构建查询参数字符串
  421. var queryParam =
  422. `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}&param6=${enIsWasteRecycling}&param7=${enIsAmend}`;
  423. // 使用模板字符串构建完整的URL
  424. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  425. // 导航到指定页面
  426. uni.navigateTo({
  427. url: navigateUrl
  428. });
  429. }
  430. const rejectNumberChange = () => {
  431. let sumDisqualificationNum = 0
  432. let sumExaminingNum = 0
  433. unfitInfos.value.forEach(v => {
  434. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  435. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  436. })
  437. processInspecion.value.disqualificationNum = sumDisqualificationNum
  438. processInspecion.value.examiningNum = sumExaminingNum
  439. console.log(processInspecion.value)
  440. }
  441. //查询咨询列表
  442. function getInspecion() {
  443. processInspecion.value = store.processInspection
  444. selectInspecion(processInspecion.value).then(res => {
  445. console.log("咨询", res);
  446. if (res.code == 200) {
  447. console.log("res", res);
  448. } else {
  449. uni.showToast({
  450. icon: 'none',
  451. title: res.msg,
  452. duration: 2000
  453. })
  454. }
  455. });
  456. }
  457. //结束报工按钮
  458. function endWork() {
  459. let unf = unfitInfos.value;
  460. if (store.userInfo.roles.some(item => item.roleKey == 'firstArticleInspection')) {
  461. for (var i = 0; i < unfitInfos.value.length; i++) {
  462. if (unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  463. uni.showToast({
  464. icon: 'none',
  465. title: '检查量,不良品量不能小于0',
  466. duration: 2000
  467. })
  468. return
  469. }
  470. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  471. uni.showToast({
  472. icon: 'none',
  473. title: '检查量不能大于投产量'
  474. })
  475. return
  476. }
  477. }
  478. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  479. uni.showToast({
  480. icon: 'none',
  481. title: '不良品量不能大于投产量'
  482. })
  483. return
  484. }
  485. }
  486. save();
  487. }
  488. function save() {
  489. const currentTime = Date.now();
  490. // 检查是否已经过去了 2 秒
  491. if (currentTime - lastRequestTimestamp.value < 2000) {
  492. // 如果在 2 秒 内已经点击,那么不执行
  493. uni.showToast({
  494. icon: 'none',
  495. title: `请勿重复点击`,
  496. duration: 2000
  497. })
  498. return;
  499. }
  500. let pages = getCurrentPages();
  501. processInspecion.value.dayworkItemConsults = consultations.value;
  502. processInspecion.value.processInspectionDetails = unfitInfos.value;
  503. processInspecion.value.user = store.userInfo;
  504. processInspecion.value.tenantId = store.tenantId
  505. processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
  506. processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
  507. processInspecion.value.processInspectionPictureList = selectedPhotos.value
  508. processInspecion.value.isReviewer = store.isReviewer
  509. console.log(processInspecion.value)
  510. if (processInspecion.value.flag) {
  511. //打开选择仪器室的弹窗
  512. selectInspectionChamber.value.open()
  513. console.log(processInspecion.value)
  514. } else {
  515. saveFirstInspection(processInspecion.value).then(res => {
  516. if (res.code == 200) {
  517. let index = 0;
  518. console.log(store.isReviewer)
  519. for (let i = 0; i < pages.length; i++) {
  520. if (!store.isReviewer && pages[i].$page.fullPath == "/pages/reportingForWork/index") {
  521. index = pages.length - i - 1;
  522. }
  523. if (store.isReviewer && pages[i].$page.fullPath == "/pages/firstInspection/index") {
  524. index = pages.length - i - 1;
  525. }
  526. }
  527. console.log("index", index);
  528. uni.navigateBack({
  529. delta: index
  530. });
  531. } else {
  532. uni.showToast({
  533. icon: 'none',
  534. title: res.msg,
  535. duration: 2000
  536. })
  537. }
  538. });
  539. }
  540. }
  541. function handleSelectInspectionChamber(data) {
  542. processInspecion.value.inspectionChamberId = data
  543. console.log(processInspecion.value)
  544. saveFirstInspection(processInspecion.value).then(res => {
  545. if (res.code == 200) {
  546. let index = 0;
  547. let pages = getCurrentPages();
  548. console.log(store.isReviewer)
  549. for (let i = 0; i < pages.length; i++) {
  550. if (pages[i].$page.fullPath == "/pages/reportingForWork/index") {
  551. index = pages.length - i - 1;
  552. }
  553. }
  554. console.log("index", index);
  555. uni.navigateBack({
  556. delta: index
  557. });
  558. } else {
  559. uni.showToast({
  560. icon: 'none',
  561. title: res.msg,
  562. duration: 2000
  563. })
  564. }
  565. });
  566. }
  567. //咨询样式
  568. function selectType(item) {
  569. for (var i = 0; i < consul.length; i++) {
  570. if (item.status == consul[i].value) {
  571. return consul[i].type
  572. }
  573. }
  574. }
  575. const addWasteInfo = (data) => {
  576. console.log(data, "55555555")
  577. flag.value = true
  578. var info = {
  579. inspectionStandardsId: data.id,
  580. checkStandard: data.standard
  581. }
  582. unfitInfos.value.push(info)
  583. uni.$off('addWasteInfoEvent');
  584. console.log(data)
  585. }
  586. const addConsultation = (data) => {
  587. let info = data
  588. info.forEach(item => {
  589. item.status = 0
  590. })
  591. consultations.value = consultations.value.concat(info)
  592. isEventTriggered.value = true; // 更新标志位状态
  593. }
  594. /***************************** 定义了一些事件 *****************************/
  595. // 添加不合格信息
  596. const handleAddWaste = () => {
  597. flag.value = true
  598. // 监听事件,暂时不用,后续会使用
  599. uni.$on('addWasteInfoEvent', (data) => {
  600. console.log(data)
  601. addWasteInfo(data)
  602. })
  603. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  604. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  605. // 构建查询参数字符串
  606. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  607. // 使用模板字符串构建完整的URL
  608. var navigateUrl = `/pages/firstInspection/options?${queryParam}`;
  609. // 导航到指定页面
  610. uni.navigateTo({
  611. url: navigateUrl
  612. });
  613. }
  614. // 删除不合格信息
  615. const handleDelWaste = (index) => {
  616. uni.showModal({
  617. title: '提示',
  618. content: '确定删除该项?',
  619. success: function(res) {
  620. if (res.confirm) {
  621. unfitInfos.value.splice(index, 1)
  622. } else if (res.cancel) {
  623. return
  624. }
  625. }
  626. })
  627. }
  628. // 咨询
  629. const handleAddConsultation = () => {
  630. console.log("9999")
  631. isEventTriggered.value = false;
  632. // 监听事件
  633. uni.$once('addWasteConsultationEvent', (data) => {
  634. if (!isEventTriggered.value) {
  635. // 如果事件尚未触发,则执行事件触发逻辑
  636. addConsultation(data)
  637. }
  638. })
  639. uni.navigateTo({
  640. url: "/pages/firstInspection/consultation",
  641. success: (res) => {
  642. // 通过eventChannel向被打开页面传送数据
  643. res.eventChannel.emit("firstInpsectionConsultation", {
  644. data: processInspecion.value.lot
  645. })
  646. }
  647. })
  648. }
  649. </script>
  650. <style lang="scss">
  651. .page-container {
  652. // height: 100%;
  653. background-color: #ececec;
  654. font-size: 28rpx;
  655. >.title {
  656. font-weight: 700;
  657. margin: 24rpx 16rpx;
  658. }
  659. }
  660. .carrier-info {
  661. margin: 32rpx 16rpx 0 16rpx;
  662. padding: 24rpx;
  663. background-color: #ffffff;
  664. border-radius: 8rpx;
  665. .carrier-code {
  666. font-size: 32rpx;
  667. font-weight: 700;
  668. }
  669. .info-row {
  670. margin-top: 16rpx;
  671. color: #767676;
  672. .label {
  673. width: 160rpx;
  674. }
  675. .drawing-btn {
  676. padding: 12rpx 32rpx;
  677. background-color: #0055ff;
  678. color: #ffffff;
  679. border-radius: 12rpx;
  680. margin-left: auto;
  681. font-size: 28rpx;
  682. }
  683. .value {
  684. flex: 1;
  685. textarea {
  686. flex: 1;
  687. border: 1px solid #888888;
  688. box-sizing: border-box;
  689. padding: 16rpx;
  690. }
  691. }
  692. }
  693. }
  694. .unfit-title {
  695. margin-bottom: 24rpx;
  696. justify-content: space-between;
  697. align-items: center;
  698. text {
  699. font-size: 28rpx;
  700. font-weight: 700;
  701. }
  702. .add-btn {
  703. padding: 12rpx 32rpx;
  704. background-color: #a4adb3;
  705. color: #ffffff;
  706. border-radius: 12rpx;
  707. font-size: 24rpx;
  708. }
  709. }
  710. .unfit-container {
  711. padding: 24rpx;
  712. margin: 0 16rpx;
  713. background-color: #ffffff;
  714. border-radius: 12rpx;
  715. .unfit-item-container {
  716. position: relative;
  717. >* {
  718. margin-bottom: 24rpx;
  719. }
  720. .title {
  721. font-weight: 700;
  722. justify-content: space-between;
  723. align-items: center;
  724. image {
  725. width: 40rpx;
  726. height: 40rpx;
  727. }
  728. }
  729. .standard {}
  730. .resu {
  731. width: 100%;
  732. align-items: center;
  733. input {
  734. margin-left: 20rpx;
  735. width: 200rpx;
  736. height: 56rpx;
  737. flex: 1;
  738. border: 1px solid #9f9f9f;
  739. font-size: 28rpx;
  740. }
  741. }
  742. .uni-input-input:disabled {
  743. background-color: #f5f7fa;
  744. }
  745. .result {
  746. align-items: center;
  747. border-bottom: 1px solid #9f9f9f;
  748. padding-bottom: 32rpx;
  749. .label {
  750. flex: 1;
  751. }
  752. input {
  753. width: 280rpx;
  754. height: 56rpx;
  755. border: 1px solid #9f9f9f;
  756. font-size: 28rpx;
  757. &.number {
  758. width: 104rpx;
  759. text-align: center;
  760. }
  761. }
  762. }
  763. }
  764. .unfit-item-container:last-child {
  765. .result {
  766. border-bottom: none;
  767. padding-bottom: 0;
  768. }
  769. }
  770. }
  771. .consultation-container {
  772. margin: 0 16rpx;
  773. padding: 24rpx;
  774. background-color: #ffffff;
  775. border-radius: 8rpx;
  776. .consultation-item-container {
  777. margin-bottom: 24rpx;
  778. border-bottom: 2px solid #888888;
  779. padding-bottom: 24rpx;
  780. }
  781. .consultation-item-container:last-child {
  782. margin-bottom: 0;
  783. border-bottom: 0;
  784. padding-bottom: 0;
  785. }
  786. .question,
  787. .answer {
  788. .label {
  789. justify-content: space-between;
  790. margin-bottom: 16rpx;
  791. font-weight: 700;
  792. }
  793. .content {
  794. line-height: 40rpx;
  795. }
  796. }
  797. .answer {
  798. margin-top: 24rpx;
  799. }
  800. }
  801. .daywork-container {
  802. margin-top: 24rpx;
  803. padding: 24rpx;
  804. background-color: #ffffff;
  805. border: 1px solid #bcbcbc;
  806. .switch {
  807. margin-top: -4px;
  808. //align-items: center;
  809. }
  810. .result {
  811. align-items: center;
  812. .label {
  813. width: 112rpx;
  814. }
  815. input {
  816. flex: 1;
  817. height: 56rpx;
  818. border: 1px solid #9f9f9f;
  819. font-size: 28rpx;
  820. text-align: center;
  821. }
  822. }
  823. .remark {
  824. margin-top: 24rpx;
  825. .label {
  826. width: 112rpx;
  827. }
  828. textarea {
  829. flex: 1;
  830. border: 1px solid #9f9f9f;
  831. height: 168rpx;
  832. }
  833. }
  834. .btns-container {
  835. margin-top: 24rpx;
  836. .finished-btn {
  837. display: flex;
  838. flex: 1;
  839. height: 80rpx;
  840. background-color: #fc6565;
  841. color: #ffffff;
  842. text-align: center;
  843. justify-content: center;
  844. align-items: center;
  845. border-radius: 8rpx;
  846. }
  847. .question-btn {
  848. width: 80rpx;
  849. align-items: flex-end;
  850. image {
  851. width: 48rpx;
  852. height: 48rpx;
  853. }
  854. text {
  855. font-size: 24rpx;
  856. }
  857. }
  858. }
  859. .switch {
  860. margin-top: -8rpx;
  861. align-items: center;
  862. transform: scale(0.7);
  863. }
  864. }
  865. input:disabled {
  866. background-color: #00ff00;
  867. }
  868. .my-files {
  869. display: flex;
  870. justify-content: center;
  871. :deep(.uni-file-picker__container) {
  872. flex-direction: row;
  873. }
  874. }
  875. </style>