dialog-reject.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <dialog-base ref="baseDialog" title="结束报工">
  3. <view class="list-container">
  4. <view class="list-title uni-row">
  5. <text class="label">废品信息</text>
  6. <view class="uni-row" style="justify-content: flex-end;"><text class="label" style="color: blue;"
  7. @click="handleAddWasteInfo">+添加</text></view>
  8. </view>
  9. <view class="list-title uni-row" v-for="(item, index) in wasteInfo">
  10. <input class="input" @input="handleInputRejectNum(item)" style="width: 20%;" v-model="item.rejectNum"
  11. placeholder="废品量" />
  12. <uni-data-select style="margin-left: 40rpx;width: 70%;" v-model="item.reason" :localdata="reasonList"
  13. @change="handleReasonChange(item)" :clear="false"></uni-data-select>
  14. <!-- <zxz-uni-data-select v-model="item.reason" filterable :localdata="reasonList" placeholder="请选择废品原因"
  15. @change="handleReasonChange(item)"></zxz-uni-data-select> -->
  16. <uni-icons class="icon-gear" type="close" size="40" color="red"
  17. @click="handleDeleteWasteInfo(index)"></uni-icons>
  18. </view>
  19. </view>
  20. <view class="add-btn-container uni-row">
  21. <button type="default" class="btn" @click="submitReject">提交</button>
  22. </view>
  23. </dialog-base>
  24. </template>
  25. <script setup>
  26. import {
  27. ref,
  28. getCurrentInstance
  29. } from 'vue'
  30. import {
  31. onLoad
  32. } from '@dcloudio/uni-app'
  33. import {
  34. updateDayWorkItem,
  35. saveDayWorkItem
  36. } from "@/api/business/dayWorkItem.js"
  37. import {
  38. getDayworkCarrierList
  39. } from '@/api/business/dayworkCarrier.js'
  40. import {
  41. store
  42. } from '@/store/index.js'
  43. import {
  44. timestampToTime,
  45. toHHmmss
  46. } from '@/utils/common.js'
  47. import {
  48. getDictInfoByType
  49. } from '@/api/dict/dict.js'
  50. import {
  51. getSpecialDeptProcessList
  52. } from '@/api/business/deptProcess.js'
  53. import {
  54. debounce
  55. } from '@/utils/common.js'
  56. import {
  57. getDayWorkItemList,
  58. listItem,
  59. getIsFirstOrder,
  60. } from '@/api/business/dayWorkItem.js'
  61. const baseDialog = ref(null)
  62. const workInfo = ref({})
  63. const wasteInfo = ref([])
  64. const reasonList = ref([])
  65. const emit = defineEmits(['resflushItem'])
  66. const showCarrierList = ref(false) // 工序是否完成显示载具列表
  67. const bindList = ref([])
  68. const confirmCarrierList = ref([])
  69. const isFirstOrder = ref(true); //是否为首序
  70. const endFlag = ref(0)
  71. const specialDeptProcessList = ref([])
  72. const temp = ref(0) // 保存workInfo.value.qualifiedNum的值(还原用)
  73. const lotPreSumReject = ref(0)
  74. const lotPreSumQualifiedNum = ref(0)
  75. const remainingQualifiedNum = ref(0) // 当前的合格量还能最大添加多少(剩余数量)
  76. const dayworkItemInfo = ref(null)
  77. onLoad(() => {})
  78. function open(data, itemListData) {
  79. // console.log(store.isPreProcess)
  80. // console.log("777")
  81. resetPage();
  82. workInfo.value = {
  83. ...data,
  84. };
  85. dayworkItemInfo.value = data
  86. // wasteInfo.value = data.rejectList == null ? [] : data.rejectList
  87. // wasteInfo.value = [{
  88. // reason: '2',
  89. // rejectNum: 2
  90. // }]
  91. // console.log(data)
  92. // console.log("数据data", workInfo);
  93. //查看是否为首序
  94. // console.log(store.dayworkInfo.id)
  95. // getIsFirst(data.dayworkId);
  96. workInfo.value.qualifiedNum = 0;
  97. init();
  98. baseDialog.value.open()
  99. }
  100. function close() {
  101. baseDialog.value.close()
  102. }
  103. function getIsFirst(dayworkId) {
  104. console.log("getIsFirst")
  105. getIsFirstOrder(dayworkId).then(res => {
  106. if (res.code == 200) {
  107. isFirstOrder.value = res.data.isFirstOrder;
  108. console.log(res)
  109. }
  110. }).catch(err => {
  111. console.log(err)
  112. })
  113. }
  114. function resetPage() {
  115. workInfo.value.qualifiedNum = null;
  116. workInfo.value = {};
  117. wasteInfo.value = [];
  118. reasonList.value = [];
  119. showCarrierList.value = false;
  120. bindList.value = [];
  121. confirmCarrierList.value = [];
  122. endFlag.value = 0;
  123. lotPreSumReject.value = 0;
  124. lotPreSumQualifiedNum.value = 0;
  125. remainingQualifiedNum.value = 0;
  126. }
  127. function init() {
  128. // console.log('init')
  129. getDictInfoByType("waste_causes").then(res => {
  130. // console.log('waste_causes')
  131. for (let i = 0; i < res.data.length; i++) {
  132. reasonList.value[i] = {
  133. value: res.data[i].dictValue,
  134. text: res.data[i].dictLabel
  135. }
  136. }
  137. wasteInfo.value = dayworkItemInfo.value.rejectList == null ? [] : dayworkItemInfo.value.rejectList.map(
  138. e => ({
  139. ...e
  140. }))
  141. }).catch(err => {
  142. console.log('189 err')
  143. })
  144. }
  145. function handleInputQualifiedNum() {
  146. workInfo.value.qualifiedNum = workInfo.value.qualifiedNum.replace(/^-+|[^\d]/g, '');
  147. }
  148. function handleInputRejectNum(item) {
  149. item.rejectNum = item.rejectNum.replace(/^0+|^-|[^\d]/g, '');
  150. // 合格数随着投产数
  151. //let sumRejectNum = 0;
  152. // for (let i = 0; i < wasteInfo.value.length; i++) {
  153. // wasteInfo.value[i].rejectNum = wasteInfo.value[i].rejectNum.replace(/^0+|^-|[^\d]/g, '');
  154. // // sumRejectNum += Number(wasteInfo.value[i].rejectNum);
  155. // }
  156. // if (temp.value > 0) {
  157. // debounce(function() {
  158. // workInfo.value.qualifiedNum = temp.value;
  159. // workInfo.value.qualifiedNum -= sumRejectNum;
  160. // }, 500)
  161. // }
  162. }
  163. /*
  164. function handleScanCode() {
  165. // 引入原生插件
  166. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  167. if (mpaasScanModule) {
  168. //调用插件的 mpaasScan 方法
  169. mpaasScanModule.mpaasScan({
  170. // 扫码识别类型,参数可多选,qrCode、barCode,
  171. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  172. scanType: ["qrCode", "barCode"],
  173. // 是否隐藏相册,默认false不隐藏
  174. hideAlbum: false,
  175. },
  176. (ret) => {
  177. let vehicleObj = JSON.parse(ret.resp_result);
  178. let hasInFlag = false
  179. for (let i = 0; i < bindList.value.length; i++) {
  180. if (vehicleObj.carrierCode == bindList.value[i].carrierCode) {
  181. hasInFlag = true
  182. if (!bindList.value[i].flag) {
  183. endFlag.value += 1;
  184. }
  185. bindList.value[i].flag = true;
  186. }
  187. }
  188. if(!hasInFlag) {
  189. uni.showToast({
  190. icon: 'none',
  191. title: '该批次没有绑定此箱',
  192. duration: 2000
  193. })
  194. }
  195. if (endFlag.value < bindList.value.length && hasInFlag) {
  196. setTimeout(() => {
  197. handleScanCode();
  198. }, 700);
  199. }
  200. }
  201. );
  202. }
  203. }
  204. */
  205. function handleAddWasteInfo() {
  206. if (wasteInfo.value.length > 0) {
  207. if (wasteInfo.value.some(item => item.rejectNum == '' || item.reason == '')) {
  208. uni.showToast({
  209. icon: 'none',
  210. title: '请填写废品量或废品原因再点击添加'
  211. })
  212. } else {
  213. wasteInfo.value.push({
  214. rejectNum: '',
  215. reason: ''
  216. })
  217. }
  218. } else {
  219. wasteInfo.value.push({
  220. rejectNum: 0,
  221. reason: ''
  222. })
  223. }
  224. }
  225. function handleDeleteWasteInfo(index) {
  226. wasteInfo.value.splice(index, 1);
  227. }
  228. function submitReject() {
  229. // 提交到父组件
  230. emit('resflushItem', wasteInfo.value);
  231. close()
  232. }
  233. function handleReasonChange(item) {
  234. // console.log(typeof item)
  235. // console.log(item)
  236. if (wasteInfo.value.filter(waste => waste.reason == item.reason).length > 1) {
  237. wasteInfo.value.splice(wasteInfo.value.indexOf(item), 1);
  238. uni.showToast({
  239. icon: 'none',
  240. title: '请勿重复选择废品原因',
  241. duration: 2000
  242. })
  243. }
  244. }
  245. defineExpose({
  246. open
  247. })
  248. </script>
  249. <style lang="scss">
  250. .dialog-body {
  251. .list-container {
  252. width: 100%;
  253. display: flex;
  254. align-items: flex-start;
  255. padding: 0 4rpx;
  256. .list-title {
  257. width: 100%;
  258. margin-top: 16rpx;
  259. height: 64rpx;
  260. line-height: 64rpx;
  261. align-items: center;
  262. .label {
  263. flex: 1;
  264. font-size: 32rpx;
  265. }
  266. .input {
  267. width: 40%;
  268. height: 66rpx;
  269. padding-left: 10rpx;
  270. font-size: 22rpx;
  271. border: 1rpx solid #e1e1e1;
  272. border-radius: 8rpx;
  273. }
  274. .icon-gear {
  275. font-size: 56rpx;
  276. }
  277. }
  278. .switch {
  279. margin-top: -8rpx;
  280. align-items: center;
  281. transform: scale(0.7);
  282. }
  283. .confirmCarrier {
  284. .label {
  285. padding-top: 20rpx;
  286. font-size: 32rpx;
  287. }
  288. .vehicleList {
  289. justify-content: baseline;
  290. align-content: flex-start;
  291. flex-wrap: wrap;
  292. width: 100%;
  293. height: 120rpx;
  294. overflow: auto;
  295. .vehicleNo {
  296. padding: 0 10rpx;
  297. margin: 10rpx 20rpx 0 0;
  298. justify-content: space-between;
  299. align-items: center;
  300. width: auto;
  301. height: 60rpx;
  302. border: 2rpx solid rgba(213, 213, 213, 1);
  303. border-radius: 6rpx;
  304. }
  305. .blueBorder {
  306. background-color: #1684fc;
  307. color: #FFFFFF;
  308. }
  309. }
  310. }
  311. }
  312. .add-btn-container {
  313. margin-top: 32rpx;
  314. .btn {
  315. flex: 1;
  316. background-color: rgba(255, 85, 85, 1);
  317. color: #FFFFFF;
  318. margin-left: 5rpx;
  319. padding: 0;
  320. }
  321. .btnScan {
  322. flex: 1;
  323. color: #FFFFFF;
  324. margin-right: 5rpx;
  325. padding: 0;
  326. }
  327. }
  328. }
  329. </style>