form.vue 29 KB

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