form.vue 25 KB

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