form.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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 :disabled="!editable()" v-model="item.checkResult" placeholder="请输入检查结果" maxlength="50" />
  62. <!-- <view v-else class="value">{{ item.checkResult }}</view> -->
  63. </view>
  64. <view class="resu uni-row">
  65. <view class="label">超差范围</view>
  66. <input :disabled="!editable()" v-model="item.exceedLimits" placeholder="请输入超差范围" maxlength="50" />
  67. <!-- <view v-else class="value">{{ item.exceedLimits }}</view> -->
  68. </view>
  69. <view class="resu uni-row">
  70. <view :class="!editable() ? 'label' : ''">检查量</view>
  71. <input :disabled="!editable()" class="number" type="number" @blur="rejectNumberChange"
  72. v-model="item.examiningNum" placeholder="" />
  73. <!-- <view v-else class="number value">{{ item.examiningNum }}</view> -->
  74. <view :class="!editable() ? 'label' : ''">不良品量</view>
  75. <input :disabled="!editable()" class="number" type="number" @blur="rejectNumberChange"
  76. v-model="item.disqualificationNum" placeholder="" />
  77. <!-- <view v-else class="value">{{ 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="consultation-container uni-column">
  86. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  87. <view class="question uni-column">
  88. <view class="label uni-row">
  89. <text>问题描述</text>
  90. <text :style="selectType(item)">{{item.consultDepartment == 0?'技术':'品管'}} {{ selectText(item) }}</text>
  91. </view>
  92. <view class="content">{{ item.content }}</view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 报工部分 -->
  97. <view class="daywork-container">
  98. <view class="result uni-row">
  99. <view class="label" style="margin-top: 20rpx;width: 170rpx;">出厂检状态</view>
  100. <uni-data-checkbox :disabled="!editable()" style="margin-top: 20rpx;" v-model="processInspecion.status"
  101. :localdata="range"></uni-data-checkbox>
  102. </view>
  103. <view class="remark uni-row">
  104. <view class="label">备注</view>
  105. <textarea :disabled="!editable()" v-model="processInspecion.remark" />
  106. </view>
  107. <view v-if="editable()" class="btns-container uni-row">
  108. <view class="finished-btn" @click="endWork">提交</view>
  109. <view class="question-btn uni-column" @click.stop="handleAddConsultation">
  110. <uni-icons type="headphones" size="24" />
  111. <text>咨询</text>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </template>
  117. <script setup>
  118. import {
  119. ref,
  120. onMounted,
  121. getCurrentInstance
  122. } from 'vue'
  123. import {
  124. onLoad,
  125. onReady,
  126. onUnload,
  127. onShow
  128. } from '@dcloudio/uni-app'
  129. import {
  130. store
  131. } from '@/store/index.js'
  132. import {
  133. saveFactoryInspecion,
  134. selectInspecion
  135. } from '@/api/business/processInspection.js'
  136. import {
  137. getInspectionStandardsList
  138. } from '@/api/business/inspectionStandards.js'
  139. const lot = ref({})
  140. const isEventTriggered = ref(false); // 创建一个标志位
  141. const unfitInfos = ref([]) //废品信息
  142. const consultations = ref([]) //咨询信息
  143. const flag = ref(false)
  144. const showTransfer = ref(true)
  145. // 创建一个引用来存储最后一次请求的时间戳
  146. const lastRequestTimestamp = ref(0);
  147. const processInspecion = ref({
  148. remark: "",
  149. rejectNum: 0,
  150. examiningNum: 0,
  151. status: 0,
  152. })
  153. const initStatus = ref(0)
  154. const editable = () => {
  155. if(store.userInfo.roles.some(item =>item.roleKey == 'factoryInspection')) {
  156. return true
  157. }else{
  158. return false
  159. }
  160. }
  161. const consul = [{
  162. value: 0,
  163. text: "待确认",
  164. type: "color: #fcab53"
  165. }, {
  166. value: 2,
  167. text: "合格",
  168. type: "color: #55ff7f"
  169. }, {
  170. value: 1,
  171. text: "不合格",
  172. type: "color: #ff0c2c"
  173. }]
  174. const range = [{
  175. value: 0,
  176. text: "待确认",
  177. type: "color: #fcab53"
  178. }, {
  179. value: 1,
  180. text: "合格",
  181. type: "color: #55ff7f"
  182. }, {
  183. value: 2,
  184. text: "不合格",
  185. type: "color: #ff0c2c"
  186. }]
  187. /***************************** 页面生命周期函数 *****************************/
  188. function init(){
  189. const instance = getCurrentInstance().proxy
  190. const eventChannel = instance.getOpenerEventChannel();
  191. eventChannel.on('factoryInspectionFrom', function(data) {
  192. console.log('acceptDataFromOpenerPage', data)
  193. if (data && data.data) {
  194. processInspecion.value.lot = data.data;
  195. getOringicalList()
  196. }
  197. })
  198. }
  199. onShow(() => {
  200. console.log(store.processInspection)
  201. console.log(flag.value)
  202. if(!flag.value){
  203. console.log("888")
  204. if (store.processInspection != null) {
  205. uni.showLoading({
  206. title: '加载中'
  207. });
  208. processInspecion.value = store.processInspection
  209. selectInspecion(processInspecion.value).then(res => {
  210. if (res.code == 200) {
  211. processInspecion.value = res.data;
  212. processInspecion.value.flag = false
  213. unfitInfos.value = res.data.processInspectionDetails;
  214. initStatus.value = res.data.status
  215. consultations.value = res.data.dayworkItemConsults;
  216. console.log("res", res);
  217. console.log(processInspecion.value)
  218. uni.hideLoading();
  219. // getInspecion();
  220. } else {
  221. uni.showToast({
  222. icon: 'none',
  223. title: res.msg,
  224. duration: 2000
  225. })
  226. }
  227. });
  228. }else{
  229. init()
  230. }
  231. }
  232. })
  233. /***************************** 定义了一些方法 *****************************/
  234. //咨询文本
  235. function selectText(item) {
  236. for (var i = 0; i < consul.length; i++) {
  237. if (item.status == consul[i].value) {
  238. return consul[i].text
  239. }
  240. }
  241. }
  242. function handleDrawingMenu(){
  243. // 对 technologicalProcessDetailId 进行URL编码
  244. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  245. var enTechnologicalProcessId = encodeURIComponent(processInspecion.value.lot.technologicalProcessId);
  246. var enprocessCode = encodeURIComponent(processInspecion.value.lot.processCode);
  247. var encodeCode = encodeURIComponent(processInspecion.value.lot.lotCode);
  248. var enProcessAlias = encodeURIComponent(processInspecion.value.lot.processAlias);
  249. // 构建查询参数字符串
  250. var queryParam = `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}`;
  251. // 使用模板字符串构建完整的URL
  252. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  253. // 导航到指定页面
  254. uni.navigateTo({
  255. url: navigateUrl
  256. });
  257. }
  258. function getOringicalList() {
  259. console.log(processInspecion.value)
  260. //查询该产品,当前工序,当前检查绑定的检查
  261. getInspectionStandardsList({
  262. productId:processInspecion.value.lot.productId,
  263. processId:processInspecion.value.lot.processId,
  264. inspectionCode:"factoryInspection"
  265. }).then(res =>{
  266. unfitInfos.value = res.rows.map(item => {
  267. // 映射新的数组,包含 inspectionStandardsId 和 checkStandard 属性
  268. return {
  269. inspectionStandardsId: item.id, // 从 item 中获取 id
  270. checkStandard: item.standard // 从 item 中获取 standard
  271. };
  272. });
  273. })
  274. }
  275. const rejectNumberChange = () => {
  276. let sumDisqualificationNum = 0
  277. let sumExaminingNum = 0
  278. unfitInfos.value.forEach(v => {
  279. sumDisqualificationNum += (v.disqualificationNum != null ? Number(v.disqualificationNum) : 0)
  280. sumExaminingNum += (v.examiningNum != null ? Number(v.examiningNum) : 0)
  281. })
  282. processInspecion.value.disqualificationNum = sumDisqualificationNum
  283. processInspecion.value.examiningNum = sumExaminingNum
  284. console.log(processInspecion.value)
  285. }
  286. function getInstrumentRoomInspectionList() {
  287. getInstrumentRoomInspection(processInspecion.value).then(res =>{
  288. if(res.data.length >0) {
  289. showTransfer.value = false
  290. }else {
  291. showTransfer.value = true
  292. }
  293. })
  294. }
  295. //查询咨询列表
  296. function getInspecion() {
  297. processInspecion.value = store.processInspection
  298. selectInspecion(processInspecion.value).then(res => {
  299. console.log("咨询", res);
  300. if (res.code == 200) {
  301. console.log("res", res);
  302. } else {
  303. uni.showToast({
  304. icon: 'none',
  305. title: res.msg,
  306. duration: 2000
  307. })
  308. }
  309. });
  310. }
  311. //结束报工按钮
  312. function endWork() {
  313. let unf = unfitInfos.value;
  314. for (var i = 0; i < unfitInfos.value.length; i++) {
  315. if (unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
  316. uni.showToast({
  317. icon: 'none',
  318. title: '检查量,不良品量不能小于0',
  319. duration: 2000
  320. })
  321. return
  322. }
  323. if (unf[i].examiningNum > processInspecion.value.lot.pudName) {
  324. uni.showToast({
  325. icon: 'none',
  326. title: '检查量不能大于投产量'
  327. })
  328. return
  329. }
  330. }
  331. if (processInspecion.value.disqualificationNum > processInspecion.value.lot.pudName) {
  332. uni.showToast({
  333. icon: 'none',
  334. title: '不良品量不能大于投产量'
  335. })
  336. return
  337. }
  338. save();
  339. }
  340. function save() {
  341. const currentTime = Date.now();
  342. // 检查是否已经过去了 2 秒
  343. if (currentTime - lastRequestTimestamp.value < 2000) {
  344. // 如果在 2 秒 内已经点击,那么不执行
  345. uni.showToast({
  346. icon: 'none',
  347. title: `请勿重复点击`,
  348. duration: 2000
  349. })
  350. return;
  351. }
  352. let pages = getCurrentPages();
  353. processInspecion.value.dayworkItemConsults = consultations.value;
  354. processInspecion.value.processInspectionDetails = unfitInfos.value;
  355. processInspecion.value.user = store.userInfo;
  356. processInspecion.value.reviewerId = store.userInfo.userId
  357. processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
  358. processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
  359. console.log(processInspecion.value)
  360. saveFactoryInspecion(processInspecion.value).then(res => {
  361. if (res.code == 200) {
  362. let index = 0;
  363. for (let i = 0; i < pages.length; i++) {
  364. if (pages[i].$page.fullPath == "/pages/factoryInspection/index") {
  365. index = pages.length - i - 1;
  366. }
  367. }
  368. console.log("index", index);
  369. uni.navigateBack({
  370. delta: index
  371. });
  372. } else {
  373. uni.showToast({
  374. icon: 'none',
  375. title: res.msg,
  376. duration: 2000
  377. })
  378. }
  379. });
  380. }
  381. //咨询样式
  382. function selectType(item) {
  383. for (var i = 0; i < consul.length; i++) {
  384. if (item.status == consul[i].value) {
  385. return consul[i].type
  386. }
  387. }
  388. }
  389. const addWasteInfo = (data) => {
  390. console.log(data,"55555555")
  391. flag.value = true
  392. var info = {
  393. inspectionStandardsId: data.id,
  394. checkStandard: data.standard
  395. }
  396. unfitInfos.value.push(info)
  397. console.log(data)
  398. }
  399. const addConsultation = (data) => {
  400. let info = data
  401. info.forEach(item =>{
  402. item.status = 0
  403. })
  404. consultations.value = info
  405. isEventTriggered.value = true; // 更新标志位状态
  406. }
  407. /***************************** 定义了一些事件 *****************************/
  408. // 添加不合格信息
  409. const handleAddWaste = () => {
  410. // 监听事件,暂时不用,后续会使用
  411. uni.$once('addWasteInfoEvent', (data) => {
  412. addWasteInfo(data)
  413. })
  414. var encodedId = encodeURIComponent(processInspecion.value.lot.productId);
  415. var enprocessId = encodeURIComponent(processInspecion.value.lot.processId);
  416. // 构建查询参数字符串
  417. var queryParam = `param1=${encodedId}&param2=${enprocessId}`;
  418. // 使用模板字符串构建完整的URL
  419. var navigateUrl = `/pages/factoryInspection/options?${queryParam}`;
  420. // 导航到指定页面
  421. uni.navigateTo({
  422. url: navigateUrl
  423. });
  424. }
  425. // 删除不合格信息
  426. const handleDelWaste = (index) => {
  427. uni.showModal({
  428. title: '提示',
  429. content: '确定删除该项?',
  430. success: function(res) {
  431. if (res.confirm) {
  432. unfitInfos.value.splice(index, 1)
  433. } else if (res.cancel) {
  434. return
  435. }
  436. }
  437. })
  438. }
  439. // 咨询
  440. const handleAddConsultation = () => {
  441. console.log("9999")
  442. isEventTriggered.value = false;
  443. // 监听事件
  444. uni.$once('addWasteConsultationEvent', (data) => {
  445. if (!isEventTriggered.value) {
  446. // 如果事件尚未触发,则执行事件触发逻辑
  447. addConsultation(data)
  448. }
  449. })
  450. uni.navigateTo({
  451. url: "/pages/factoryInspection/consultation",
  452. success: (res) => {
  453. // 通过eventChannel向被打开页面传送数据
  454. res.eventChannel.emit("factoryInpsectionConsultation", {
  455. data: processInspecion.value.lot
  456. })
  457. }
  458. })
  459. }
  460. </script>
  461. <style lang="scss">
  462. .page-container {
  463. // height: 100%;
  464. background-color: #ececec;
  465. font-size: 28rpx;
  466. >.title {
  467. font-weight: 700;
  468. margin: 24rpx 16rpx;
  469. }
  470. }
  471. .carrier-info {
  472. margin: 32rpx 16rpx 0 16rpx;
  473. padding: 24rpx;
  474. background-color: #ffffff;
  475. border-radius: 8rpx;
  476. .carrier-code {
  477. font-size: 32rpx;
  478. font-weight: 700;
  479. }
  480. .info-row {
  481. margin-top: 16rpx;
  482. color: #767676;
  483. .label {
  484. width: 160rpx;
  485. }
  486. .drawing-btn {
  487. padding: 12rpx 32rpx;
  488. background-color: #0055ff;
  489. color: #ffffff;
  490. border-radius: 12rpx;
  491. margin-left: auto;
  492. font-size: 28rpx;
  493. }
  494. .value {
  495. flex: 1;
  496. textarea {
  497. flex: 1;
  498. border: 1px solid #888888;
  499. box-sizing: border-box;
  500. padding: 16rpx;
  501. }
  502. }
  503. }
  504. }
  505. .unfit-title {
  506. margin-bottom: 24rpx;
  507. justify-content: space-between;
  508. align-items: center;
  509. text {
  510. font-size: 28rpx;
  511. font-weight: 700;
  512. }
  513. .add-btn {
  514. padding: 12rpx 32rpx;
  515. background-color: #a4adb3;
  516. color: #ffffff;
  517. border-radius: 12rpx;
  518. font-size: 24rpx;
  519. }
  520. }
  521. .unfit-container {
  522. padding: 24rpx;
  523. margin: 0 16rpx;
  524. background-color: #ffffff;
  525. border-radius: 12rpx;
  526. .unfit-item-container {
  527. position: relative;
  528. >* {
  529. margin-bottom: 24rpx;
  530. }
  531. .title {
  532. font-weight: 700;
  533. justify-content: space-between;
  534. align-items: center;
  535. image {
  536. width: 40rpx;
  537. height: 40rpx;
  538. }
  539. }
  540. .standard {}
  541. .resu {
  542. width: 100%;
  543. align-items: center;
  544. input {
  545. margin-left: 20rpx;
  546. width: 200rpx;
  547. height: 56rpx;
  548. flex: 1;
  549. border: 1px solid #9f9f9f;
  550. font-size: 28rpx;
  551. }
  552. }
  553. .result {
  554. align-items: center;
  555. border-bottom: 1px solid #9f9f9f;
  556. padding-bottom: 32rpx;
  557. .label {
  558. flex: 1;
  559. }
  560. input {
  561. width: 280rpx;
  562. height: 56rpx;
  563. border: 1px solid #9f9f9f;
  564. font-size: 28rpx;
  565. &.number {
  566. width: 104rpx;
  567. text-align: center;
  568. }
  569. }
  570. }
  571. }
  572. .unfit-item-container:last-child {
  573. .result {
  574. border-bottom: none;
  575. padding-bottom: 0;
  576. }
  577. }
  578. }
  579. .consultation-container {
  580. margin: 0 16rpx;
  581. padding: 24rpx;
  582. background-color: #ffffff;
  583. border-radius: 8rpx;
  584. .consultation-item-container {
  585. margin-bottom: 24rpx;
  586. border-bottom: 2px solid #888888;
  587. padding-bottom: 24rpx;
  588. }
  589. .consultation-item-container:last-child {
  590. margin-bottom: 0;
  591. border-bottom: 0;
  592. padding-bottom: 0;
  593. }
  594. .question,
  595. .answer {
  596. .label {
  597. justify-content: space-between;
  598. margin-bottom: 16rpx;
  599. font-weight: 700;
  600. }
  601. .content {
  602. line-height: 40rpx;
  603. }
  604. }
  605. .answer {
  606. margin-top: 24rpx;
  607. }
  608. }
  609. .daywork-container {
  610. margin-top: 24rpx;
  611. padding: 24rpx;
  612. background-color: #ffffff;
  613. border: 1px solid #bcbcbc;
  614. .result {
  615. align-items: center;
  616. .label {
  617. width: 112rpx;
  618. }
  619. input {
  620. flex: 1;
  621. height: 56rpx;
  622. border: 1px solid #9f9f9f;
  623. font-size: 28rpx;
  624. text-align: center;
  625. }
  626. }
  627. .switch {
  628. margin-top: -8rpx;
  629. align-items: center;
  630. }
  631. .remark {
  632. margin-top: 24rpx;
  633. .label {
  634. width: 112rpx;
  635. }
  636. textarea {
  637. flex: 1;
  638. border: 1px solid #9f9f9f;
  639. height: 168rpx;
  640. }
  641. }
  642. .btns-container {
  643. margin-top: 24rpx;
  644. .finished-btn {
  645. display: flex;
  646. flex: 1;
  647. height: 80rpx;
  648. background-color: #fc6565;
  649. color: #ffffff;
  650. text-align: center;
  651. justify-content: center;
  652. align-items: center;
  653. border-radius: 8rpx;
  654. }
  655. .question-btn {
  656. width: 80rpx;
  657. align-items: flex-end;
  658. image {
  659. width: 48rpx;
  660. height: 48rpx;
  661. }
  662. text {
  663. font-size: 24rpx;
  664. }
  665. }
  666. }
  667. }
  668. </style>