steps.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="body">
  3. <div class="steps" v-for="(item, index) in opsArray" :key="index" @click="boxClick(item, index)">
  4. <div :class="item.opComplete
  5. ? 'stepBox stepBoxDisabled'
  6. : item.exists == true
  7. ? selectStepIndex == index
  8. ? 'stepBox stepBoxHover'
  9. : 'stepBox'
  10. : 'stepBox stepExistsHover'
  11. ">
  12. <div style="display: flex; align-items: center">
  13. <div :class="selectStepIndex == index
  14. ? 'stepIndex stepIndexHover'
  15. : 'stepIndex'
  16. ">
  17. <span :class="selectStepIndex == index
  18. ? 'indexText hoverTextColor'
  19. : 'indexText'
  20. ">{{ index + 1 }}</span>
  21. </div>
  22. <div class="midTextBox">
  23. <div :class="selectStepIndex == index ? 'stepName stepNameHover' : 'stepName'
  24. ">
  25. {{ item.operationName }}
  26. </div>
  27. <div :class="selectStepIndex == index
  28. ? 'stepStation stepStationHover'
  29. : 'stepStation'
  30. ">
  31. {{ item.operationCode }}
  32. </div>
  33. </div>
  34. </div>
  35. <div :class="selectStepIndex == index ? 'timeBox timeBoxHover' : 'timeBox'">
  36. {{ item.completeNum }}
  37. </div>
  38. </div>
  39. <div v-if="item.exists != true" class="existsText">
  40. 注:该工位在计划上未分配此工序任务!
  41. </div>
  42. <div class="line" v-if="index != opsArray.length - 1"></div>
  43. </div>
  44. <el-empty v-if="!opsArray" description="暂无数据" />
  45. <!-- 弹窗 -->
  46. <el-dialog v-model="centerDialogVisible" width="500" align-center style="border-radius: 16px">
  47. <template #header>
  48. <div class="titleText" style="text-align: center">通知</div>
  49. </template>
  50. <span class="titleText">已选择好工序,点击确认立即开工</span>
  51. <template #footer>
  52. <div class="dialog-footer">
  53. <el-button @click="centerDialogVisible = false">取消</el-button>
  54. <el-button type="primary" @click="getScanData"> 确定 </el-button>
  55. </div>
  56. </template>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script lang="ts" setup>
  61. import { useProcessStore } from "@/store";
  62. import { emitter, EventsNames } from "@/utils/common";
  63. import { getScan } from "@/api/process";
  64. const store = useProcessStore();
  65. const props = defineProps<{
  66. opsArray?: object;
  67. }>();
  68. //步骤显示index
  69. const router = useRouter();
  70. const selectStepIndex = ref(null);
  71. const scanStatus = inject("scanStatus");
  72. const centerDialogVisible = ref(false);
  73. const emitFnc = () => {
  74. emitter.emit(EventsNames.PROCESS_STEPOBJ, {
  75. index: selectStepIndex.value,
  76. lastStatus:
  77. selectStepIndex.value == null || selectStepIndex.value == 0
  78. ? false
  79. : true,
  80. });
  81. };
  82. emitter.on(EventsNames.PROCESS_STEPINDEX, (val: any) => {
  83. selectStepIndex.value = val;
  84. });
  85. // const setStepIndex = () => {
  86. // for (let i = 0; i < props.opsArray.length; i++) {
  87. // if (props.opsArray[i].opComplete == false) {
  88. // selectStepIndex.value = i;
  89. // return;
  90. // }
  91. // }
  92. // };
  93. const boxClick = (item, index) => {
  94. if (item.opComplete == true || item.exists != true) return;
  95. store.odersData.operationId = item.operationId;
  96. store.processInfo.operationCode = item.operationCode;
  97. store.processInfo.operationName = item.operationName;
  98. selectStepIndex.value = index;
  99. emitFnc();
  100. centerDialogVisible.value = true;
  101. };
  102. const getScanData = async () => {
  103. try {
  104. const { code, data, msg } = await getScan({
  105. operationId: Number(store.odersData.operationId),
  106. qrCode: store.odersData.qrCode,
  107. workOrderCode: store.odersData.workOrderCode,
  108. //stationId暂时随便传一个
  109. stationId: 1,
  110. });
  111. if (code == "200") {
  112. store.scanInfo = data;
  113. router.push({ path: "/pro-steps" });
  114. }
  115. } catch {
  116. } finally {
  117. centerDialogVisible.value = false;
  118. }
  119. };
  120. watch(
  121. () => props.opsArray,
  122. () => {
  123. if (props.opsArray.length > 0) {
  124. selectStepIndex.value = null;
  125. // setStepIndex();
  126. if (selectStepIndex.value !== null) {
  127. boxClick(props.opsArray[selectStepIndex.value], selectStepIndex.value);
  128. } else {
  129. emitFnc();
  130. }
  131. } else {
  132. selectStepIndex.value = null;
  133. }
  134. }
  135. );
  136. watch(
  137. () => scanStatus.value,
  138. () => {
  139. selectStepIndex.value = null;
  140. }
  141. );
  142. onBeforeUnmount(() => {
  143. emitter.off(EventsNames.PROCESS_STEPOBJ);
  144. });
  145. </script>
  146. <style lang="scss" scoped>
  147. .body {
  148. width: 100%;
  149. }
  150. .existsText {
  151. margin-left: 40px;
  152. font-size: $f16;
  153. font-weight: 500;
  154. color: #303030;
  155. }
  156. .stepBox {
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. height: 88px;
  161. border-radius: 44px;
  162. background-color: white;
  163. box-shadow: 0px 1px 1px 1px #00000025;
  164. }
  165. .stepBoxHover {
  166. box-shadow: 0px 0px 0px 0px;
  167. background-color: $select-hover;
  168. }
  169. .stepExistsHover {
  170. background-color: grey;
  171. cursor: not-allowed;
  172. }
  173. .stepBoxDisabled {
  174. background-color: green;
  175. cursor: not-allowed;
  176. }
  177. .stepIndexHover {
  178. border-color: white !important;
  179. span {
  180. color: white;
  181. }
  182. }
  183. .stepNameHover {
  184. color: white !important;
  185. }
  186. .stepStationHover {
  187. color: white !important;
  188. }
  189. .timeBoxHover {
  190. color: white !important;
  191. }
  192. .hoverTextColor {
  193. color: white !important;
  194. }
  195. .stepIndex {
  196. width: 88px;
  197. height: 88px;
  198. border: 2px solid #303030;
  199. border-radius: 44px;
  200. @include flex;
  201. .indexText {
  202. font-size: $f24;
  203. color: #303030;
  204. }
  205. }
  206. .midTextBox {
  207. margin-left: 10px;
  208. .stepName {
  209. font-size: $f24;
  210. color: $font-default-black;
  211. }
  212. .stepStation {
  213. font-size: $f20;
  214. color: $font-default-60;
  215. line-height: 20px;
  216. }
  217. }
  218. .timeBox {
  219. margin-right: 20px;
  220. @include flex;
  221. font-size: $f24;
  222. }
  223. .line {
  224. border-right: 1px solid #303030;
  225. height: 15px;
  226. width: 1px;
  227. margin-left: 44px;
  228. }
  229. </style>