form.vue 26 KB

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