dialog-lotReporting.vue 11 KB

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