orders.vue 5.8 KB

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