form.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="lot-info uni-column">
  4. <view class="lot-code uni-row">
  5. <text>批次号</text>
  6. <text style="margin-left: 24rpx;">{{ dayworkItem.lotCode }}</text>
  7. </view>
  8. <view class="product-info">
  9. 产品描述: {{ dayworkItem.productDescription }}
  10. </view>
  11. <view class="product-info">
  12. 原材料厂家: {{ dayworkInfo.furnaceNoInfo.factory }}
  13. </view>
  14. <view class="product-info">
  15. 投产数量: {{ dayworkItem.prodNum }}
  16. </view>
  17. <view class="product-info">
  18. 设备: {{ dayworkItem.equipmentDetailCode }}
  19. </view>
  20. </view>
  21. <!-- 不合格信息 -->
  22. <view class="title unfit-title uni-row">
  23. <text>不合格信息</text>
  24. <view v-if="Number(dayworkItem.status) < 3" class="add-btn" @click="handleAddUnfit">添加</view>
  25. </view>
  26. <view class="unfit-container">
  27. <view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
  28. <view class="title uni-row">
  29. <text>检查标准-{{ item.checkStandard }}</text>
  30. <uni-icons v-if="Number(dayworkItem.status) < 3" type="trash" size="24" color="#fc6565"
  31. @click="handleDelUnfit(index)" />
  32. </view>
  33. <!-- <view class="standard">检查标准:{{ item.checkStandard }}</view> -->
  34. <view class="result uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
  35. <!-- align-items: flex-start; -->
  36. <view class="label" style="padding-right: 16rpx;flex: 0 1 auto; min-width: 118rpx;">
  37. 检查结果</view>
  38. <input v-if="Number(dayworkItem.status) < 3" v-model="item.reason" placeholder="请输入检查结果" />
  39. <span v-else style="flex-grow: 1;">{{ item.reason }}</span>
  40. <view class="label"
  41. style="text-align: right; padding-right: 16rpx;flex: 0 1 auto; min-width: 68rpx;">数量</view>
  42. <input v-if="Number(dayworkItem.status) < 3" class="number" type="number" v-model="item.rejectNum"
  43. @blur="rejectNumberChange" />
  44. <span v-else>{{ item.rejectNum }}</span>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 咨询部分 -->
  49. <view class="title">咨询</view>
  50. <view class="consultation-container uni-column">
  51. <view class="consultation-item-container" v-for="(item, index) in consultations" :key="index">
  52. <view class="question uni-column">
  53. <view class="label uni-row">
  54. <text>问题描述</text>
  55. <text :style="{ color: showStatusColor(item.status) }">{{item.consultDepartment == 0?'技术':'品管'}}
  56. {{ selectText(item) }}</text>
  57. </view>
  58. <view class="content">{{ item.content }}</view>
  59. </view>
  60. <!-- <view v-if="item.answer !== ''" class="answer"
  61. style="margin-top: 24rpx; padding-top: 24rpx; border-top: 1px dotted #aaaaaa;">
  62. <view class="label">回复</view>
  63. <view class="content">{{ item.answer }}</view>
  64. </view> -->
  65. </view>
  66. </view>
  67. <!-- 零存库部分 -->
  68. <view class="title">零存库</view>
  69. <view class="consultation-container ">
  70. <view class="title unfit-title uni-row">
  71. <view class="title">零取</view>
  72. <view class="add-btn" v-if="Number(dayworkItem.status) < 3" style="background-color: #409eff;"
  73. @click="handleAddLot">添加</view>
  74. </view>
  75. <view style="flex-direction: row;">
  76. <zb-table v-if="Number(dayworkItem.status) < 3" :columns="column1" :stripe="true" :fit="true"
  77. @dele="dele" :data="retrievalInfo"></zb-table>
  78. <zb-table v-else :columns="column2" :stripe="true" :fit="true" @dele="dele"
  79. :data="retrievalInfo"></zb-table>
  80. <!-- <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" >
  81. <uni-tr >
  82. <uni-th style="font-size: 25rpx;" width="atuo" align="center">批次号</uni-th>
  83. <uni-th style="font-size: 25rpx;" width="120" align="center">数量</uni-th>
  84. <uni-th v-if="Number(dayworkItem.status) < 3" style="font-size: 25rpx;" width="80" align="center">操作</uni-th>
  85. </uni-tr>
  86. <uni-tr v-for="(item, index) in retrievalInfo" :key="index">
  87. <uni-th style="font-size: 24rpx;" width="auto" align="center">{{ item.lotCode }}</uni-th>
  88. <uni-th style="font-size: 25rpx;" width="120" align="center">
  89. {{ item.storageNum }}
  90. </uni-th>
  91. <uni-th v-if="Number(dayworkItem.status) < 3 && item.status == 0" align="center" width="80">
  92. <uni-icons type="closeempty" size="22" @click="handleDelete(item)"></uni-icons>
  93. </uni-th>
  94. </uni-tr>
  95. </uni-table> -->
  96. </view>
  97. <view v-if="saveFlag" class='middle'>
  98. <view class='segment'></view>
  99. <view class='segment'></view>
  100. </view>
  101. <view v-if="saveFlag" class="title unfit-title uni-row">
  102. <view class="title">零存</view>
  103. </view>
  104. <view v-if="saveFlag" class="save uni-row">
  105. <text class="label">存入数量</text>
  106. <input class="number" type="number"
  107. v-if="!(Object.keys(storageInfo).length > 0 || storageInfo.status == 1 || Number(dayworkItem.status) >= 3)"
  108. placeholder="请输入" v-model="storageNum" />
  109. <span style="margin-left: 56rpx;flex: 1;" v-else>{{ storageNum }}</span>
  110. </view>
  111. </view>
  112. <!-- 报工部分 -->
  113. <view class="daywork-container">
  114. <view class="result uni-row">
  115. <view class="label">合格量</view>
  116. <input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入合格量"
  117. v-model="dayworkItem.qualifiedNum" />
  118. <span v-else>{{ dayworkItem.qualifiedNum }}</span>
  119. <view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
  120. <input v-if="Number(dayworkItem.status) < 3" :disabled="true" type="number" placeholder="请输入废品量"
  121. v-model="dayworkItem.rejectNum" />
  122. <span v-else>{{ dayworkItem.rejectNum }}</span>
  123. </view>
  124. <view class="remark uni-row">
  125. <view class="label">备注</view>
  126. <textarea v-if="Number(dayworkItem.status) < 3" v-model="dayworkItem.remark" maxlength="999" />
  127. <span v-else>{{ dayworkItem.remark }}</span>
  128. </view>
  129. <view class="btns-container uni-row">
  130. <!-- 最后一步完成不能更换载具 -->
  131. <view v-if="dayworkItem.daywork != null && dayworkItem.daywork.status != 2" class="bottom-btn left-btn "
  132. @click="handleChangeCarrier">
  133. 更换载具</view>
  134. <view v-if="checkFinishable()&&Number(dayworkItem.status) < 3" class="finished-btn"
  135. @click.stop="handleFinishDaywork">结束报工</view>
  136. <view v-if="Number(dayworkItem.status) < 3" class="pause-btn" @click.stop="handleUpdateDaywork">暂停
  137. </view>
  138. <view v-if="Number(dayworkItem.status) < 3" class="question-btn uni-column"
  139. @click.stop="handleAddConsultation">
  140. <uni-icons type="headphones" size="24" />
  141. <text>咨询</text>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <script setup>
  148. import {
  149. ref
  150. } from 'vue'
  151. import {
  152. onMounted,
  153. getCurrentInstance
  154. } from 'vue';
  155. import {
  156. getSortingDayworkItem,
  157. saveConsult,
  158. finish,
  159. update,
  160. selectInstructionList
  161. } from '@/api/business/sortDaywork.js'
  162. import {
  163. getTakeStockPeriod
  164. } from '@/api/business/taksStackLot.js'
  165. import {
  166. getDictInfoByType
  167. } from '@/api/dict/dict.js'
  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. timestampToTime,
  179. toHHmmss
  180. } from '@/utils/common.js'
  181. const isEventTriggered = ref(false); // 创建一个标志位
  182. const unfitInfos = ref([])
  183. const consultations = ref([])
  184. const dayworkInfo = ref({})
  185. const retrievalInfo = ref([])
  186. // 创建一个引用来存储最后一次请求的时间戳
  187. const lastRequestTimestamp = ref(0);
  188. const dayworkItem = ref({})
  189. const saveFlag = ref(false)
  190. const storageNum = ref('')
  191. const storageInfo = ref(null)
  192. const qualifiedNumRatio = ref(0)
  193. const isFinish = ref(false)
  194. const column1 = [{
  195. name: 'lotCode',
  196. label: '批次号',
  197. align: 'center'
  198. },
  199. {
  200. name: 'storageNum',
  201. label: '数量',
  202. align: 'center'
  203. },
  204. {
  205. name: 'operation',
  206. type: 'operation',
  207. label: '操作',
  208. align: 'center',
  209. renders: [{
  210. name: '删除',
  211. type: 'warn',
  212. func: "dele",
  213. class: "buttonOp"
  214. }, ]
  215. },
  216. ]
  217. const column2 = [{
  218. name: 'lotCode',
  219. label: '批次号',
  220. align: 'center'
  221. },
  222. {
  223. name: 'storageNum',
  224. label: '数量',
  225. align: 'center'
  226. },
  227. ]
  228. /***************************** 页面生命周期函数 *****************************/
  229. onLoad(() => {})
  230. onShow(() => {
  231. uni.$off('addInfoEvent');
  232. uni.$off('addUnfitInfoEvent')
  233. })
  234. onMounted(() => {
  235. const instance = getCurrentInstance().proxy
  236. const eventChannel = instance.getOpenerEventChannel();
  237. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  238. if (data && data.data) {
  239. dayworkInfo.value = data.data
  240. init({
  241. id: data.data.id
  242. })
  243. } else {
  244. let reqParam = {
  245. id: dayworkInfo.value.id
  246. }
  247. init(reqParam);
  248. }
  249. })
  250. })
  251. /***************************** 定义了一些方法 *****************************/
  252. const init = (data) => {
  253. //获取当前跟选报工合格数最大值
  254. // getDictInfoByType("sort_report_limit").then(res => {
  255. // console.log(res.data && res.data.length >0)
  256. // if(res.data && res.data.length >0) {
  257. // qualifiedNumRatio.value =parseInt(res.data[0].dictValue)
  258. // }
  259. // }).catch(err => {
  260. // console.log(err)
  261. // console.log('369 err')
  262. // })
  263. console.log("dayworkInfo", dayworkInfo.value);
  264. // 获取当前报工信息
  265. getSortingDayworkItem(data).then(res => {
  266. console.log(res)
  267. if (res.code === 200) {
  268. dayworkItem.value = res.data
  269. //判断是否显示零存
  270. if (dayworkItem.value.processStepNumber == dayworkInfo.value.processSequence[dayworkInfo.value
  271. .processSequence.length - 1].processStepNumber) {
  272. saveFlag.value = true
  273. } else {
  274. saveFlag.value = false
  275. }
  276. console.log(dayworkItem.value)
  277. if (dayworkItem.value.status == 0 && dayworkItem.value.qualifiedNum === 0 && dayworkItem.value
  278. .rejectNum === 0) {
  279. dayworkItem.value.qualifiedNum = res.data.prodNum
  280. }
  281. retrievalInfo.value = res.data.retrievalInfo
  282. storageInfo.value = res.data.storageInfo
  283. console.log(Object.keys(storageInfo.value).length === 0)
  284. if (Object.keys(storageInfo.value).length !== 0) {
  285. storageNum.value = storageInfo.value.storageNum
  286. }
  287. console.log(storageNum.value)
  288. consultations.value = res.data.consults
  289. unfitInfos.value = res.data.rejectList
  290. } else {
  291. uni.showToast({
  292. icon: 'none',
  293. title: res.message
  294. })
  295. }
  296. })
  297. }
  298. const addInfo = (data) => {
  299. data.forEach(item => {
  300. console.log(retrievalInfo.value)
  301. retrievalInfo.value.push(item)
  302. })
  303. console.log(data)
  304. uni.$off('addInfoEvent');
  305. }
  306. //添加零取批次
  307. function handleAddLot() {
  308. console.log('調用 handleAddLot')
  309. uni.$on('addInfoEvent', (data) => {
  310. addInfo(data.data)
  311. })
  312. console.log(dayworkItem.value)
  313. const info = {
  314. deptId: dayworkItem.value.deptId,
  315. productId: dayworkItem.value.daywork.productId,
  316. drawingNumber: dayworkItem.value.drawingNumber,
  317. technologyVersion: dayworkItem.value.technologyVersion,
  318. retrievalLotId: dayworkItem.value.lotId,
  319. hasAddedList: retrievalInfo.value
  320. }
  321. // 将 info 对象转换为 JSON 字符串
  322. const serializedData = JSON.stringify(info);
  323. // 对 JSON 字符串进行 URL 编码
  324. const encodedData = encodeURIComponent(serializedData);
  325. // 构建 URL,确保使用正确编码的数据
  326. uni.navigateTo({
  327. url: `/pages/sorting/storageRetrieval?data=${encodedData}`
  328. });
  329. }
  330. const addUnfitInfo = (data) => {
  331. console.log(data)
  332. if (data && data.length > 0) {
  333. for (var i = 0; i < data.length; i++) {
  334. const info = {
  335. inspectionInstructionId: data[i].id,
  336. title: data[i].title,
  337. standard: data[i].standard,
  338. checkStandard: data[i].standard,
  339. type: data[i].type,
  340. reason: ''
  341. }
  342. unfitInfos.value.push(info)
  343. }
  344. }
  345. }
  346. function dele(ite, index) {
  347. if (ite.status == 1) {
  348. uni.showToast({
  349. icon: 'none',
  350. title: '已被领取,不能删除'
  351. })
  352. } else {
  353. retrievalInfo.value.splice(index, 1);
  354. }
  355. }
  356. const addConsultation = (data) => {
  357. const info = {
  358. dayworkItemId: dayworkItem.value.id,
  359. content: data.content,
  360. userId: store.userInfo.userId,
  361. nickName: store.userInfo.nickName,
  362. dayworkId: dayworkItem.value.dayworkId,
  363. productionPlandetailId: dayworkItem.value.productionPlandetailId,
  364. productionPlanDetailSubDetailId: dayworkItem.value.productionPlanDetailSubDetailId,
  365. lotId: dayworkItem.value.lotId,
  366. lotCode: dayworkItem.value.lotCode,
  367. productId: dayworkItem.value.productId,
  368. productDescription: dayworkItem.value.productDescription,
  369. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  370. technologicalProcessDetailId: dayworkItem.value.technologicalProcessDetailId,
  371. processId: dayworkItem.value.processId,
  372. processAlias: dayworkItem.value.process.processAlias,
  373. // technicianId: dayworkItem.value.technicianId,
  374. technicianId: data.technicianId,
  375. departments: data.departments,
  376. pictures: data.pictures
  377. }
  378. saveConsult(info).then(res => {
  379. if (res.code === 200) {
  380. consultations.value = res.data
  381. console.log(consultations.value)
  382. } else {
  383. uni.showToast({
  384. icon: 'none',
  385. title: res.message
  386. })
  387. }
  388. })
  389. isEventTriggered.value = true; // 更新标志位状态
  390. consultations.value.push(info)
  391. }
  392. /***************************** 定义了一些事件 *****************************/
  393. // 添加不合格信息
  394. async function handleAddUnfit() {
  395. // 监听事件
  396. uni.$once('addUnfitInfoEvent', (data) => {
  397. addUnfitInfo(data)
  398. })
  399. const hasInstruction = await getHasInstruction();
  400. console.log(hasInstruction); // 这将打印 true 或 false
  401. if (!hasInstruction) {
  402. uni.navigateTo({
  403. url: "/pages/sorting/specialOptions",
  404. success: (res) => {
  405. // 通过eventChannel向被打开页面传送数据
  406. res.eventChannel.emit('acceptDataFromOpenerPage', {
  407. data: dayworkItem.value,
  408. query: {
  409. productId: dayworkItem.value.daywork.productId,
  410. processId: dayworkItem.value.process.id,
  411. // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
  412. technologyVersion: dayworkItem.value.technologyVersion
  413. },
  414. index: unfitInfos.value.length
  415. })
  416. }
  417. })
  418. } else {
  419. console.log(dayworkItem.value)
  420. uni.navigateTo({
  421. url: "/pages/sorting/options",
  422. success: (res) => {
  423. // 通过eventChannel向被打开页面传送数据
  424. res.eventChannel.emit('acceptDataFromOpenerPage', {
  425. data: dayworkItem.value,
  426. query: {
  427. productId: dayworkItem.value.daywork.productId,
  428. processCode: dayworkItem.value.process.processCode,
  429. // technologyVersion: dayworkItem.value.technologicalProcessDetail.technologyVersion
  430. technologyVersion: dayworkItem.value.technologyVersion
  431. },
  432. index: unfitInfos.value.length
  433. })
  434. }
  435. })
  436. }
  437. }
  438. async function getHasInstruction() {
  439. console.log(dayworkItem.value)
  440. const res = await selectInstructionList({
  441. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  442. processCode: dayworkItem.value.process.processCode,
  443. lotId: dayworkItem.value.lotId
  444. })
  445. return res.data
  446. // .then(res=> {
  447. // console.log(res.data)
  448. // return res.data
  449. // })
  450. }
  451. // 删除不合格信息
  452. const handleDelUnfit = (index) => {
  453. let tempInfo = unfitInfos.value[index]
  454. console.log(tempInfo)
  455. uni.showModal({
  456. title: '提示',
  457. content: '确定删除该项?',
  458. success: function(res) {
  459. if (res.confirm) {
  460. dayworkItem.value.rejectNum = dayworkItem.value.rejectNum - tempInfo.rejectNum
  461. dayworkItem.value.qualifiedNum = parseInt(dayworkItem.value.qualifiedNum) + parseInt(
  462. tempInfo.rejectNum)
  463. unfitInfos.value.splice(index, 1)
  464. } else if (res.cancel) {
  465. return
  466. }
  467. }
  468. })
  469. }
  470. /* 更换载具*/
  471. function handleChangeCarrier(item) {
  472. // uni.$once('refreshQuickReport', () => {
  473. // init()
  474. // })
  475. store.dayworkInfo = null
  476. uni.navigateTo({
  477. url: "/pages/changeBox/index",
  478. success: function(res) {
  479. // 通过eventChannel向被打开页面传送数据
  480. res.eventChannel.emit('sortingFromOpenerPage', {
  481. data: dayworkItem.value
  482. })
  483. }
  484. })
  485. }
  486. // 添加咨询信息
  487. const handleAddConsultation = () => {
  488. isEventTriggered.value = false; // 更新标志位状态
  489. // 监听事件
  490. uni.$once('addConsulttationEvent', (data) => {
  491. if (!isEventTriggered.value) {
  492. // 如果事件尚未触发,则执行事件触发逻辑
  493. addConsultation(data)
  494. }
  495. })
  496. uni.navigateTo({
  497. url: "/pages/sorting/consultation",
  498. success: (res) => {
  499. // 通过eventChannel向被打开页面传送数据
  500. res.eventChannel.emit('acceptDataFromOpenerPage', {
  501. data: dayworkItem.value
  502. })
  503. }
  504. })
  505. }
  506. const checkFinishable = () => {
  507. if (consultations.value.findIndex(v => v.status === 0) >= 0) {
  508. return false
  509. } else {
  510. return true
  511. }
  512. }
  513. const showStatus = (status) => {
  514. // console.log(status)
  515. switch (status) {
  516. case 0:
  517. return '未确认'
  518. case 1:
  519. return '不合格'
  520. case 2:
  521. return '合格'
  522. default:
  523. return ''
  524. }
  525. }
  526. function selectText(item) {
  527. // for (var i = 0; i < consul.length; i++) {
  528. // if (item.status == consul[i].value) {
  529. // return consul[i].text
  530. // }
  531. // }
  532. if (item.consultResultId == 0) {
  533. return '待确认'
  534. } else {
  535. return item.result
  536. }
  537. }
  538. const showStatusColor = (status) => {
  539. // console.log(status)
  540. switch (status) {
  541. case 0:
  542. return '#fcab53'
  543. case 1:
  544. return '#fc044f'
  545. case 2:
  546. return '#1deb19'
  547. default:
  548. return ''
  549. }
  550. }
  551. const rejectNumberChange = () => {
  552. let sumReject = 0
  553. unfitInfos.value.forEach(v => {
  554. sumReject += v.rejectNum == null ? 0 : Number(v.rejectNum)
  555. })
  556. dayworkItem.value.rejectNum = sumReject
  557. dayworkItem.value.qualifiedNum = dayworkItem.value.prodNum - sumReject
  558. console.log(dayworkItem.value)
  559. }
  560. const validHandle = () => {
  561. console.log(storageNum.value == "")
  562. if (storageNum.value != null && storageNum.value != "" && storageNum.value <= 0) {
  563. uni.showToast({
  564. icon: 'none',
  565. title: "存入数量应大于0",
  566. duration: 2000
  567. })
  568. return false;
  569. }
  570. for (let i = 0; i < unfitInfos.value.length; i++) {
  571. const e = unfitInfos.value[i]
  572. if (e.rejectNum == null || e.rejectNum == 0) {
  573. uni.showToast({
  574. icon: 'none',
  575. title: `第${i + 1}条不合格信息未输入不合格数量`
  576. })
  577. return false
  578. }
  579. }
  580. if (dayworkItem.value.qualifiedNum === null || dayworkItem.value.qualifiedNum === "") {
  581. uni.showToast({
  582. icon: 'none',
  583. title: "合格数不能为空",
  584. duration: 2000
  585. })
  586. return false;
  587. }
  588. if (isFinish.value && dayworkItem.value.qualifiedNum == 0) {
  589. uni.showToast({
  590. icon: 'none',
  591. title: "合格数不能为0",
  592. duration: 2000
  593. })
  594. return false;
  595. }
  596. if (dayworkItem.value.qualifiedNum < 0) {
  597. uni.showToast({
  598. icon: 'none',
  599. title: "合格数不能为负数,请检查不合格信息后提交",
  600. duration: 2000
  601. })
  602. return false;
  603. }
  604. //只在结束报工的时候判断
  605. // if(isFinish.value &&dayworkItem.value.qualifiedNum > (dayworkItem.value.prodNum * (qualifiedNumRatio.value/100))){
  606. // uni.showToast({
  607. // icon: 'none',
  608. // title: "合格数不能超过投产量的"+qualifiedNumRatio.value+"%",
  609. // duration: 2000
  610. // })
  611. // return false;
  612. // }
  613. return true
  614. // unfitInfos.value.forEach((e, i) => {
  615. // if (e.name)
  616. // })
  617. }
  618. async function handleCheckStock() {
  619. let currentProcessStepNumber = dayworkInfo.value.currentProcess.processStepNumber;
  620. let lastProcess = dayworkInfo.value.processSequence[dayworkInfo.value.processSequence.length - 1];
  621. // 判断当前工序是否是最后一道序
  622. if (currentProcessStepNumber === lastProcess.processStepNumber) {
  623. // 等待 getTakeStockPeriod() 的 Promise 完成
  624. const res = await getTakeStockPeriod({
  625. dayworkId: dayworkInfo.value.id
  626. });
  627. console.log(res.data.length);
  628. if (res.data.length > 0) {
  629. uni.showToast({
  630. icon: 'none',
  631. title: "此次盘点未结束,不能结束报工",
  632. duration: 2000
  633. });
  634. return false; // 如果盘点未结束,返回 false
  635. }
  636. }
  637. // 如果不是最后一道工序或盘点已结束,返回 true
  638. return true;
  639. }
  640. async function handleFinishDaywork() {
  641. isFinish.value = true
  642. if (!validHandle()) {
  643. return
  644. }
  645. //判断当前批次是否在盘点,如果盘点未结束,则不能结束报工
  646. let checkStockResult = await handleCheckStock();
  647. console.log(checkStockResult)
  648. if (!checkStockResult) {
  649. return;
  650. }
  651. //零存数据
  652. if (storageNum.value != null && storageNum.value != "") {
  653. if (Object.keys(storageInfo.value).length === 0) {
  654. storageInfo.value = {
  655. productionPlanDetailId: dayworkItem.value.productionPlanDetailId,
  656. productDescription: dayworkItem.value.productDescription,
  657. drawingNumber: dayworkItem.value.drawingNumber,
  658. lotId: dayworkItem.value.lotId,
  659. lotCode: dayworkItem.value.lotCode,
  660. deptId: dayworkItem.value.deptId,
  661. productId: dayworkItem.value.daywork.productId,
  662. technologyVersion: dayworkItem.value.technologyVersion,
  663. storageNum: storageNum.value,
  664. storagerId: store.userInfo.userId,
  665. }
  666. } else {
  667. storageInfo.value.storageNum = storageNum.value
  668. }
  669. } else {
  670. storageInfo.value = null
  671. }
  672. //零取数据
  673. if (retrievalInfo.value.length > 0) {
  674. retrievalInfo.value.forEach(item => {
  675. item.retrievalLotId = dayworkItem.value.lotId,
  676. item.retrievalLotCode = dayworkItem.value.lotCode,
  677. item.retrievalerId = store.userInfo.userId,
  678. item.retrievalTime = timestampToTime(new Date())
  679. })
  680. }
  681. const saveData = {
  682. rejectList: unfitInfos.value,
  683. consult: consultations.value,
  684. id: dayworkItem.value.id,
  685. prodNum: dayworkItem.value.prodNum,
  686. rejectNum: dayworkItem.value.rejectNum,
  687. qualifiedNum: dayworkItem.value.qualifiedNum,
  688. equipmentDetailId: dayworkItem.value.equipmentDetailId,
  689. equipmentDetailCode: dayworkItem.value.equipmentDetailCode,
  690. remark: dayworkItem.value.remark,
  691. storageInfo: storageInfo.value,
  692. retrievalInfo: retrievalInfo.value
  693. }
  694. const currentTime = Date.now();
  695. // 检查是否已经过去了 2 秒
  696. if (currentTime - lastRequestTimestamp.value < 2000) {
  697. // 如果在 2 秒 内已经点击,那么不执行
  698. uni.showToast({
  699. icon: 'none',
  700. title: `请勿重复点击`,
  701. duration: 2000
  702. })
  703. return;
  704. }
  705. lastRequestTimestamp.value = currentTime;
  706. console.log(saveData)
  707. finish(saveData).then(res => {
  708. if (res.code === 200) {
  709. uni.navigateBack()
  710. } else {
  711. uni.showToast({
  712. icon: 'none',
  713. title: res.message
  714. })
  715. }
  716. })
  717. }
  718. const handleUpdateDaywork = () => {
  719. isFinish.value = false
  720. if (!validHandle()) {
  721. return
  722. }
  723. //零存数据
  724. if (storageNum.value != null && storageNum.value != "") {
  725. if (Object.keys(storageInfo.value).length === 0) {
  726. storageInfo.value = {
  727. productionPlanDetailId: dayworkItem.value.productionPlanDetailId,
  728. productDescription: dayworkItem.value.productDescription,
  729. drawingNumber: dayworkItem.value.drawingNumber,
  730. lotId: dayworkItem.value.lotId,
  731. lotCode: dayworkItem.value.lotCode,
  732. deptId: dayworkItem.value.deptId,
  733. productId: dayworkItem.value.daywork.productId,
  734. technologyVersion: dayworkItem.value.technologyVersion,
  735. storageNum: storageNum.value,
  736. storagerId: store.userInfo.userId,
  737. }
  738. } else {
  739. storageInfo.value.storageNum = storageNum.value
  740. }
  741. } else {
  742. storageInfo.value = null
  743. }
  744. //零取数据
  745. if (retrievalInfo.value.length > 0) {
  746. retrievalInfo.value.forEach(item => {
  747. item.retrievalLotId = dayworkItem.value.lotId,
  748. item.retrievalLotCode = dayworkItem.value.lotCode,
  749. item.retrievalerId = store.userInfo.userId,
  750. item.retrievalTime = timestampToTime(new Date())
  751. })
  752. }
  753. const saveData = {
  754. rejectList: unfitInfos.value,
  755. consult: consultations.value,
  756. id: dayworkItem.value.id,
  757. prodNum: dayworkItem.value.prodNum,
  758. rejectNum: dayworkItem.value.rejectNum,
  759. equipmentDetailId: dayworkItem.value.equipmentDetailId,
  760. equipmentDetailCode: dayworkItem.value.equipmentDetailCode,
  761. qualifiedNum: dayworkItem.value.qualifiedNum,
  762. remark: dayworkItem.value.remark,
  763. storageInfo: storageInfo.value,
  764. retrievalInfo: retrievalInfo.value
  765. }
  766. console.log(saveData)
  767. update(saveData).then(res => {
  768. if (res.code === 200) {
  769. uni.$emit("formBack")
  770. uni.navigateBack()
  771. } else {
  772. uni.showToast({
  773. icon: 'none',
  774. title: res.message
  775. })
  776. }
  777. })
  778. }
  779. </script>
  780. <style lang="scss">
  781. .buttonOp {
  782. margin-top: 5px;
  783. }
  784. .page-container {
  785. // height: 100%;
  786. background-color: #ececec;
  787. font-size: 28rpx;
  788. overflow: auto;
  789. >.title {
  790. font-weight: 700;
  791. margin: 24rpx 16rpx;
  792. }
  793. }
  794. .add-btn {
  795. padding: 12rpx 32rpx;
  796. background-color: #a4adb3;
  797. color: #ffffff;
  798. border-radius: 12rpx;
  799. font-size: 24rpx;
  800. }
  801. .lot-info {
  802. margin: 32rpx 16rpx 0 16rpx;
  803. padding: 24rpx;
  804. background-color: #ffffff;
  805. border-radius: 8rpx;
  806. .lot-code {
  807. font-size: 32rpx;
  808. font-weight: 700;
  809. margin-bottom: 16rpx;
  810. }
  811. .product-info {
  812. font-size: 28rpx;
  813. color: #9f9f9f;
  814. }
  815. }
  816. .middle {
  817. display: flex;
  818. flex-direction: row;
  819. align-items: center;
  820. justify-content: center
  821. }
  822. .segment {
  823. width: 80%;
  824. background-color: rgba(213, 213, 213, 1);
  825. border: 1rpx solid rgba(213, 213, 213, 1);
  826. margin: 16px 0;
  827. }
  828. .unfit-title {
  829. margin-bottom: 24rpx;
  830. justify-content: space-between;
  831. align-items: center;
  832. text {
  833. font-size: 28rpx;
  834. font-weight: 700;
  835. }
  836. .add-btn {
  837. padding: 12rpx 32rpx;
  838. background-color: #a4adb3;
  839. color: #ffffff;
  840. border-radius: 12rpx;
  841. font-size: 24rpx;
  842. }
  843. }
  844. .save {
  845. align-items: center;
  846. padding-bottom: 32rpx;
  847. justify-content: space-between;
  848. input {
  849. height: 56rpx;
  850. border: 1px solid #9f9f9f;
  851. font-size: 28rpx;
  852. &.number {
  853. width: 60%;
  854. text-align: center;
  855. }
  856. }
  857. }
  858. .unfit-container {
  859. padding: 24rpx;
  860. margin: 0 16rpx;
  861. background-color: #ffffff;
  862. border-radius: 12rpx;
  863. .unfit-item-container {
  864. position: relative;
  865. >* {
  866. margin-bottom: 24rpx;
  867. }
  868. .title {
  869. font-weight: 700;
  870. justify-content: space-between;
  871. align-items: center;
  872. image {
  873. width: 40rpx;
  874. height: 40rpx;
  875. }
  876. }
  877. .standard {}
  878. .result {
  879. align-items: center;
  880. border-bottom: 1px solid #9f9f9f;
  881. padding-bottom: 32rpx;
  882. .label {
  883. flex: 1;
  884. }
  885. input {
  886. width: 280rpx;
  887. height: 56rpx;
  888. border: 1px solid #9f9f9f;
  889. font-size: 28rpx;
  890. &.number {
  891. width: 104rpx;
  892. text-align: center;
  893. }
  894. }
  895. }
  896. }
  897. .unfit-item-container:last-child {
  898. .result {
  899. border-bottom: none;
  900. padding-bottom: 0;
  901. }
  902. }
  903. }
  904. .consultation-container {
  905. margin: 0 16rpx;
  906. padding: 24rpx;
  907. background-color: #ffffff;
  908. border-radius: 8rpx;
  909. .consultation-item-container {
  910. margin-bottom: 24rpx;
  911. border-bottom: 2px solid #888888;
  912. padding-bottom: 24rpx;
  913. }
  914. .consultation-item-container:last-child {
  915. margin-bottom: 0;
  916. border-bottom: 0;
  917. padding-bottom: 0;
  918. }
  919. .question,
  920. .answer {
  921. .label {
  922. justify-content: space-between;
  923. margin-bottom: 16rpx;
  924. font-weight: 700;
  925. }
  926. .content {
  927. line-height: 40rpx;
  928. }
  929. }
  930. .answer {
  931. margin-top: 24rpx;
  932. }
  933. }
  934. .daywork-container {
  935. margin-top: 24rpx;
  936. padding: 24rpx;
  937. background-color: #ffffff;
  938. border: 1px solid #bcbcbc;
  939. .result {
  940. align-items: center;
  941. .label {
  942. width: 112rpx;
  943. }
  944. input {
  945. flex: 1;
  946. height: 56rpx;
  947. border: 1px solid #9f9f9f;
  948. font-size: 28rpx;
  949. text-align: center;
  950. }
  951. }
  952. .remark {
  953. margin-top: 24rpx;
  954. .label {
  955. width: 112rpx;
  956. }
  957. textarea {
  958. flex: 1;
  959. border: 1px solid #9f9f9f;
  960. height: 168rpx;
  961. }
  962. }
  963. .btns-container {
  964. margin-top: 24rpx;
  965. .bottom-btn {
  966. display: flex;
  967. flex: 1;
  968. height: 80rpx;
  969. background-color: #5555ff;
  970. color: #ffffff;
  971. text-align: center;
  972. justify-content: center;
  973. align-items: center;
  974. border-radius: 8rpx;
  975. margin-right: 10rpx;
  976. &.left-btn {
  977. background-color: rgba(85, 85, 255, 1.0);
  978. }
  979. &.right-btn {
  980. margin-left: 24rpx;
  981. }
  982. }
  983. .finished-btn {
  984. display: flex;
  985. flex: 1;
  986. height: 80rpx;
  987. background-color: #fc6565;
  988. color: #ffffff;
  989. text-align: center;
  990. justify-content: center;
  991. align-items: center;
  992. border-radius: 8rpx;
  993. }
  994. .pause-btn {
  995. display: flex;
  996. flex: 1;
  997. height: 80rpx;
  998. background-color: #55d90d;
  999. color: #ffffff;
  1000. text-align: center;
  1001. justify-content: center;
  1002. align-items: center;
  1003. border-radius: 8rpx;
  1004. margin-left: 12rpx;
  1005. }
  1006. .question-btn {
  1007. width: 80rpx;
  1008. align-items: flex-end;
  1009. image {
  1010. width: 48rpx;
  1011. height: 48rpx;
  1012. }
  1013. text {
  1014. font-size: 24rpx;
  1015. }
  1016. }
  1017. }
  1018. }
  1019. .zb-table .item-tr[data-v-336e291f] {
  1020. flex-direction: row;
  1021. }
  1022. </style>