steps.vue 6.7 KB

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