dialog-lotReporting.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <dialog-base class="dialog-body" ref="baseDialog" title="添加批次报工">
  3. <view style="overflow: auto;">
  4. <!-- <view v-for="(item, index) in lotData" :key="index" class="list-item"> -->
  5. <view class="item-info uni-row">
  6. <text class="label">批次号</text>
  7. <text class="label right">{{ lotData.map(v => v.lotCode).join(",") }}</text>
  8. </view>
  9. <!-- <view class="item-info uni-row">
  10. <text class="label">生产计划单号</text>
  11. <text class="label right">{{ item['productionPlanNo'] }}</text>
  12. </view> -->
  13. <view class="item-info uni-row">
  14. <text class="label">产品描述</text>
  15. <text class="label right">{{ item['productDescription'] }}</text>
  16. </view>
  17. <view class="item-info uni-row">
  18. <text class="label">箱号</text>
  19. <text class="label right">{{ item['carrierName'] }}</text>
  20. </view>
  21. <view class="item-info uni-row">
  22. <text class="label">当前序</text>
  23. <view class="label right uni-row" style="display: flex; flex-direction: row; flex-wrap: wrap;">
  24. <view>{{ item['process'] ? item['process'].processAlias : '-' }}
  25. </view>
  26. <view style="color: #1684fc;" @click.stop="handleClickProcessList(item)">(&nbsp;工艺列表&nbsp;)
  27. </view>
  28. </view>
  29. </view>
  30. <view class="item-info uni-row">
  31. <text class="label">下序</text>
  32. <view class="label right uni-row">{{ item['nextProcess'] ? item['nextProcess'].processAlias : '-' }}
  33. </view>
  34. </view>
  35. <!-- <view class='middle'>
  36. <view class='segment'></view>
  37. <uni-icons type="paperclip" size="30" style="margin: 10rpx;"></uni-icons>
  38. <view class='segment'></view>
  39. </view> -->
  40. <!-- </view> -->
  41. </view>
  42. <view class="list-item">
  43. <view class="item-info uni-row">
  44. <text class="label">下序车间</text>
  45. <uni-data-select v-model="curDaywork.workshopId" :localdata="workshopList"
  46. @change="handleChangeWorkshop" :clear="false"
  47. style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  48. </view>
  49. <view class="item-info uni-row">
  50. <text class="label">下序工段</text>
  51. <uni-data-select v-model="curDaywork.deptId" :localdata="deptList" :clear="false"
  52. style="outline: 2rpx solid #999999;border-radius: 10rpx;" @change="handleDeptChange"></uni-data-select>
  53. </view>
  54. <view v-if="!isWx" class="item-info uni-row" style="margin-top: 12rpx;">
  55. <text class="label" style="width: 250rpx;" >下序是否包装</text><text style="margin-left: 24rpx;" class="label right">否</text>
  56. <switch class="switch" @change="switchChange" :checked="normalStatus" style="transform: scale(0.8);align-items: center;font-size:32rpx ;" color="rgba(103, 195, 55, 1.0)" />
  57. <text class=" label right">是</text>
  58. </view>
  59. </view>
  60. <!-- 抽屉 -->
  61. <view>
  62. </view>
  63. <view style="z-index: 99999;">
  64. <!-- <uni-drawer ref="showRight" mode="right" :mask-click="true">
  65. <view class="scroll-view">
  66. <scroll-view class="scroll-view-box" style="height:100%;">
  67. <view style="width: 100%;text-align: center;;font-size: 48rpx;margin: 48rpx 0 24rpx 0;">工艺列表
  68. </view>
  69. <view style="font-size: 24rpx;width: 100%;text-align: center;color: red;margin-bottom: 48rpx;">
  70. 仅显示当前工序后面工艺</view>
  71. <view class="info-content" v-for="(item,index) in curProcessAfte" :key="index"
  72. style="width: 100%;margin: 8rpx 0 8rpx 14%;">
  73. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  74. </view>
  75. </scroll-view>
  76. </view>
  77. </uni-drawer> -->
  78. <uni-drawer ref="showRight" mode="right" :mask-click="true">
  79. <view style="text-align: center; font-size: 48rpx; padding: 48rpx 0 24rpx 0;">工艺列表</view>
  80. <view style="font-size: 24rpx;text-align: center;color: red; margin-bottom: 16rpx;">
  81. 仅显示当前工序后面工艺
  82. </view>
  83. <scroll-view scroll-y="true" style="height: 80%;" @touchmove.stop>
  84. <view v-for="(item,index) in curProcessAfte" :key="index"
  85. style="padding: 8rpx 5% 8rpx 14%; border-top: 1px solid #cccccc">
  86. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  87. </view>
  88. </scroll-view>
  89. <view><button v-if="!editStatus" class="start-batch-btn" style="margin-bottom: 10rpx;" type="primary" @click="handleOpenDrawing">查看本工序图纸</button></view>
  90. </uni-drawer>
  91. </view>
  92. <view class="add-btn-container uni-row">
  93. <button type="default" class="leftBtn" @click="handleFinishScan">结束扫码</button>
  94. <button type="default" class="rightBtn" @click="handleContinueScan">继续扫码</button>
  95. </view>
  96. </dialog-base>
  97. </template>
  98. <script setup>
  99. import {
  100. ref,
  101. getCurrentInstance,
  102. toRef
  103. } from 'vue'
  104. import {
  105. getDictInfoByType
  106. } from '@/api/dict/dict.js'
  107. import {
  108. getQuickDayworkList,
  109. finishQuick,
  110. getDayworkByCarrierId,
  111. reportDaywork
  112. } from '@/api/business/quickDaywork'
  113. const props = defineProps({
  114. getList: {
  115. type: Function,
  116. default: () => {}
  117. }
  118. })
  119. const emit = defineEmits();
  120. const baseDialog = ref(null)
  121. const lotData = ref(null)
  122. const curDaywork = ref({})
  123. const productId = ref("")
  124. const isWx = ref(false)
  125. const normalStatus = ref(false)
  126. const processCode = ref("")
  127. const technologicalProcessId = ref("")
  128. const currentLotCode = ref("")
  129. const workshopList = ref([])
  130. const processAlias = ref("")
  131. const curProcessAfte = ref([])
  132. const deptList = ref([])
  133. const item = ref({})
  134. const lastRequestTimestamp = ref(0);
  135. const editStatus = ref(false)
  136. const showRight = ref(null) // 抽屉
  137. function open(data) {
  138. // if (data === 'test') {
  139. // baseDialog.value.open()
  140. // lotData.value = [{
  141. // lotCode: '测试',
  142. // process: { processAlias: '测试长数据结果' }
  143. // }, {
  144. // lotCode: '测试',
  145. // process: { processAlias: '测试长数据结果' }
  146. // }, {
  147. // lotCode: '测试',
  148. // process: { processAlias: '测试长数据结果' }
  149. // }]
  150. // item.value = {
  151. // lotCode: '测试',
  152. // process: { processAlias: '测试长数据结果' }
  153. // }
  154. // } else {
  155. lotData.value = data.items
  156. item.value = data.items[0]
  157. // lotData.value.map(v => v.lotCode).join(",")
  158. baseDialog.value.open()
  159. workshopList.value = data.workShops.map(v => ({
  160. value: v.id,
  161. text: v.name,
  162. deptList: v.depts
  163. }))
  164. console.log(workshopList.value)
  165. curDaywork.value = {}
  166. deptList.value = []
  167. init()
  168. // }
  169. }
  170. function init() {
  171. //查询车间
  172. }
  173. function handleClickProcessList(item) {
  174. console.log(item,7979)
  175. if(item.isWasteRecycling ==1 || item.isAmend ==1){
  176. editStatus.value = true
  177. }else{
  178. editStatus.value = false
  179. }
  180. var filteredProcess = item.processSequence.filter(i => i.processStepNumber == item.process.processStepNumber);
  181. processCode.value = filteredProcess[0].processCode
  182. processAlias.value = filteredProcess[0].processAlias
  183. productId.value = item.daywork.productId
  184. technologicalProcessId.value = item.technologicalProcessId
  185. currentLotCode.value = item.lotCode
  186. curProcessAfte.value = lotData.value[0].nextProcesses;
  187. showRight.value.open();
  188. }
  189. //切换车间
  190. function handleChangeWorkshop(arg) {
  191. // console.log(arg)
  192. deptList.value = workshopList.value.find(v => v.value === arg).deptList.map(v => ({
  193. value: v.deptId,
  194. text: v.deptName,
  195. isSortPackaging:v.isSortPackaging,
  196. code:v.deptCode
  197. }))
  198. normalStatus.value = false
  199. isWx.value = false
  200. }
  201. //结束扫码
  202. function handleFinishScan() {
  203. const currentTime = Date.now();
  204. // 检查是否已经过去了 2 秒
  205. if (currentTime - lastRequestTimestamp.value < 2000) {
  206. // 如果在 2 秒 内已经点击,那么不执行
  207. uni.showToast({
  208. icon: 'none',
  209. title: `请勿重复点击`,
  210. duration: 2000
  211. })
  212. return;
  213. }
  214. lastRequestTimestamp.value = currentTime;
  215. // 保存新报工信息
  216. // 然后关闭dialog
  217. // console.log(props)
  218. addDayworkItem(() => {
  219. baseDialog.value.close()
  220. props.getList()
  221. })
  222. }
  223. //打开电子图纸
  224. function handleOpenDrawing(){
  225. // 对 technologicalProcessDetailId 进行URL编码
  226. var encodedId = encodeURIComponent(productId.value);
  227. var enTechnologicalProcessId = encodeURIComponent(technologicalProcessId.value);
  228. var enprocessCode = encodeURIComponent(processCode.value);
  229. var encodeCode = encodeURIComponent(currentLotCode.value);
  230. var enProcessAlias = encodeURIComponent(processAlias.value);
  231. // 构建查询参数字符串
  232. var queryParam = `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}`;
  233. // 使用模板字符串构建完整的URL
  234. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  235. // 导航到指定页面
  236. uni.navigateTo({
  237. url: navigateUrl
  238. });
  239. }
  240. function handleDeptChange() {
  241. console.log(deptList.value)
  242. let deptInfo = deptList.value.find(item =>item.value == curDaywork.value.deptId)
  243. console.log(deptInfo)
  244. if(deptInfo.code =='170000') {
  245. isWx.value = true
  246. }else{
  247. isWx.value = false
  248. }
  249. if(deptInfo.isSortPackaging == 1){
  250. normalStatus.value = true
  251. }else{
  252. normalStatus.value = false
  253. }
  254. }
  255. function switchChange(event) {
  256. console.log(event.detail.value)
  257. //是
  258. if (event.detail.value) {
  259. normalStatus.value = true
  260. } else {
  261. //否
  262. normalStatus.value = false
  263. }
  264. }
  265. function addDayworkItem(callback) {
  266. // 判断选择下工段和下车间
  267. if (curDaywork.value.workshopId == null || curDaywork.value.deptId == null || deptList.value.find(v => v.value ===
  268. curDaywork.value.deptId) == null) {
  269. uni.showToast({
  270. icon: 'none',
  271. title: '请选择周转车间和下序工段'
  272. })
  273. return
  274. }
  275. const params = lotData.value.map(v => ({
  276. ...v,
  277. daywork: {
  278. ...v.daywork,
  279. processId: v.process.id,
  280. processStepNumber: v.process.processStepNumber,
  281. technologicalProcessDetailId: v.process.technologicalProcessDetailId
  282. },
  283. quickInfo: {
  284. deptId: curDaywork.value.deptId,
  285. workshopId: curDaywork.value.workshopId,
  286. deptName: deptList.value.find(v => v.value === curDaywork.value.deptId).text,
  287. isSortPackaging :normalStatus.value?"1":"0"
  288. }
  289. }))
  290. console.log(params)
  291. reportDaywork(params).then(res => {
  292. callback()
  293. })
  294. // callback()
  295. }
  296. //继续扫码
  297. function handleContinueScan() {
  298. // 保存报工信息
  299. // 调用前一个页面的扫码方法
  300. // 关闭dialog
  301. // console.log(props)
  302. addDayworkItem(() => {
  303. props.getList()
  304. baseDialog.value.close()
  305. emit("scan")
  306. })
  307. }
  308. function close() {
  309. baseDialog.value.close()
  310. }
  311. defineExpose({
  312. open
  313. })
  314. </script>
  315. <style lang="scss">
  316. .dialog-body {
  317. // height: 60%;
  318. // margin: auto auto;
  319. overflow: auto;
  320. }
  321. .item-info {
  322. margin: 8rpx;
  323. .label {
  324. font-size: 28rpx;
  325. width: 220rpx;
  326. color: #808080;
  327. &.right {
  328. flex: 1;
  329. color: #000000;
  330. }
  331. }
  332. }
  333. .middle {
  334. display: flex;
  335. flex-direction: row;
  336. align-items: center;
  337. justify-content: center
  338. }
  339. .segment {
  340. width: 280rpx;
  341. background-color: rgba(213, 213, 213, 1);
  342. border: 1rpx solid rgba(213, 213, 213, 1);
  343. }
  344. .middle {
  345. display: flex;
  346. flex-direction: row;
  347. align-items: center;
  348. justify-content: center
  349. }
  350. .segment {
  351. width: 80rpx;
  352. background-color: rgba(213, 213, 213, 1);
  353. border: 1rpx solid rgba(213, 213, 213, 1);
  354. }
  355. .add-btn-container {
  356. margin-top: 32rpx;
  357. .leftBtn {
  358. flex: 1;
  359. background-color: rgb(164, 173, 179);
  360. color: #FFFFFF;
  361. }
  362. .rightBtn {
  363. flex: 1;
  364. margin-left: 24rpx;
  365. background-color: rgb(91, 214, 165);
  366. color: #FFFFFF;
  367. }
  368. }
  369. </style>