orders.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div>
  3. <div class="commonTitle">
  4. {{ activeName == "ok" ? "已完成工单" : "待完成工单" }}[{{ ordersSum }}]
  5. </div>
  6. <el-tabs
  7. v-model="activeName"
  8. class="demo-tabs"
  9. type="card"
  10. @tab-click="handleClick"
  11. >
  12. <el-tab-pane label="未完成" name="false" />
  13. <el-tab-pane label="已完成" name="ok" />
  14. </el-tabs>
  15. <el-scrollbar
  16. class="barHeight"
  17. ref="wrapRef"
  18. @scroll="handleScroll"
  19. v-loading="map.get('getProcessOrders')"
  20. >
  21. <!-- <el-scrollbar class="barHeight" ref="wrapRef" @scroll="handleScroll"> -->
  22. <Order
  23. v-for="(item, index) in ordersDataArray"
  24. :key="index"
  25. @click="setSlectIndex(index)"
  26. :hoverStatus="index == selectIndex ? true : false"
  27. :item="item"
  28. />
  29. <Empty v-if="ordersDataArray.length < 1" />
  30. <div
  31. class="describeText notice"
  32. v-if="ordersQuery.pageNo == ordersQuery.totalPages"
  33. >
  34. 已经到底啦~
  35. </div>
  36. </el-scrollbar>
  37. <Empty v-if="ordersDataArray.length < 1" />
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import Order from "@/views/process/components/order.vue";
  42. import { useProcessStore } from "@/store";
  43. import { useDictionaryStore } from "@/store";
  44. import { getOrders } from "@/api/process";
  45. import { emitter, EventsNames } from "@/utils/common";
  46. import { useCommonStoreHook } from "@/store";
  47. const dictS = useDictionaryStore();
  48. const store = useProcessStore();
  49. const selectSeqIndex = inject("selectSeqIndex");
  50. const selectedOderStatus = inject("selectedOderStatus");
  51. const ordersSum = ref(0);
  52. const commonS = useCommonStoreHook();
  53. const map = commonS.loadingMap;
  54. const emit = defineEmits(["getindex"]);
  55. const ordersDataArray = inject("ordersDataArray");
  56. const selectSeqArray = inject("selectSeqArray");
  57. //获取未完成订单的参数
  58. const ordersQuery = ref({
  59. pageNo: 1,
  60. pageSize: 5,
  61. queryComplete: 0,
  62. totalPages: 1,
  63. });
  64. const wrapRef = ref(null);
  65. //获取未完成订单Data
  66. const getOrdersData = async () => {
  67. const { code, data } = await getOrders(ordersQuery.value);
  68. if (code == "200") {
  69. ordersDataArray.value.push(...data.records);
  70. ordersSum.value = data.totalCount;
  71. ordersQuery.value.totalPages = data.totalPages;
  72. }
  73. };
  74. //重新刷新当前页码数据
  75. const resetOrdersDataArray = async () => {
  76. ordersDataArray.value = [];
  77. ordersQuery.value = {
  78. pageNo: 1,
  79. pageSize: 5,
  80. queryComplete: 0,
  81. totalPages: 1,
  82. };
  83. store.odersData.productLineId = "";
  84. store.odersData.workOrderCode = "";
  85. store.processInfo.materialName = "";
  86. store.processInfo.materialModel = "";
  87. store.odersData.operationId = "";
  88. store.processInfo.operationCode = "";
  89. store.processInfo.operationName = "";
  90. store.useSeqNo = "";
  91. selectSeqArray.value = [];
  92. selectSeqIndex.value = null;
  93. getOrdersData();
  94. };
  95. const activeName = ref("false");
  96. //这里是存放控制当前选择工序的index
  97. const selectIndex = ref(null);
  98. const setSlectIndex = (index: number) => {
  99. if (index == null) {
  100. selectIndex.value = null;
  101. selectedOderStatus.value = false;
  102. return;
  103. }
  104. selectIndex.value = index;
  105. store.odersData.productLineId =
  106. ordersDataArray.value[selectIndex.value].productLineId;
  107. store.odersData.workOrderCode =
  108. ordersDataArray.value[selectIndex.value].workOrderCode;
  109. store.processInfo.materialName =
  110. ordersDataArray.value[selectIndex.value].materialName;
  111. store.processInfo.materialModel =
  112. ordersDataArray.value[selectIndex.value].materialModel;
  113. store.odersData.operationId = "";
  114. store.processInfo.operationCode = "";
  115. store.processInfo.operationName = "";
  116. store.useSeqNo = "";
  117. selectSeqIndex.value = null;
  118. emit("getindex", selectIndex.value);
  119. };
  120. const handleClick = (tab: TabsPaneContext, event: Event) => {
  121. setSlectIndex(null);
  122. store.odersData.productLineId = "";
  123. store.odersData.workOrderCode = "";
  124. store.processInfo.materialName = "";
  125. store.processInfo.materialModel = "";
  126. };
  127. //滚动事件
  128. const handleScroll = (obj: obj) => {
  129. //当发生滚动触底时
  130. if (
  131. wrapRef.value.wrapRef.scrollHeight ==
  132. Math.ceil(obj.scrollTop) + wrapRef.value.wrapRef.clientHeight
  133. ) {
  134. if (ordersQuery.value.pageNo < ordersQuery.value.totalPages) {
  135. ordersQuery.value.pageNo = ordersQuery.value.pageNo + 1;
  136. getOrdersData();
  137. }
  138. }
  139. };
  140. watch(
  141. () => activeName.value,
  142. (val) => {
  143. if (val == "ok") {
  144. ordersQuery.value.queryComplete = 1;
  145. ordersQuery.value.pageNo = 1;
  146. } else {
  147. ordersQuery.value.queryComplete = 0;
  148. ordersQuery.value.pageNo = 1;
  149. }
  150. ordersDataArray.value = [];
  151. getOrdersData();
  152. }
  153. );
  154. onMounted(() => {
  155. getOrdersData();
  156. emitter.on(EventsNames.PROCESS_REDER, () => {
  157. resetOrdersDataArray();
  158. setSlectIndex(null);
  159. });
  160. });
  161. </script>
  162. <style lang="scss" scoped>
  163. .barHeight {
  164. height: calc(100vh - 265px);
  165. .notice {
  166. text-align: center;
  167. }
  168. }
  169. :deep(.el-tabs--card > .el-tabs__header .el-tabs__nav) {
  170. background: rgba(0, 0, 0, 0.1);
  171. border-radius: 16px 16px 16px 16px;
  172. overflow: hidden;
  173. border: 0;
  174. }
  175. :deep(.el-tabs--card > .el-tabs__header) {
  176. height: 80px;
  177. border: 0;
  178. overflow: hidden;
  179. border-radius: 16px 16px 16px 16px;
  180. }
  181. :deep(.el-tabs--card > .el-tabs__header .el-tabs__item) {
  182. width: calc(12.5vw - 15px);
  183. height: 80px;
  184. border-radius: 0;
  185. font-weight: 500;
  186. font-size: 24px;
  187. overflow: hidden;
  188. background: transparent;
  189. border-color: transparent;
  190. }
  191. :deep(.el-tabs--card > .el-tabs__header .el-tabs__item.is-active) {
  192. background: white;
  193. border-radius: 16px 16px 16px 16px;
  194. border-color: transparent;
  195. overflow: hidden;
  196. }
  197. .scrollbar-demo-item {
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. height: 50px;
  202. margin: 10px;
  203. text-align: center;
  204. border-radius: 4px;
  205. background: var(--el-color-primary-light-9);
  206. color: var(--el-color-primary);
  207. }
  208. </style>