index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. :table-events="{
  12. select: selectRow,
  13. 'select-all': selectRow,
  14. }"
  15. :action-list="[
  16. {
  17. text: '一键申购',
  18. action: () => oneKeySubscribe(),
  19. },
  20. ]"
  21. @get-list="getList"
  22. @clickReset="clickReset"
  23. :cellClassName="cellClassName">
  24. </byTable>
  25. </el-card>
  26. </div>
  27. </template>
  28. <script setup>
  29. import byTable from "/src/components/byTable/index";
  30. import subscribeStore from "/src/store/modules/subscribe";
  31. const { proxy } = getCurrentInstance();
  32. const sourceList = ref({
  33. data: [],
  34. pagination: {
  35. total: 0,
  36. pageNum: 1,
  37. pageSize: 10,
  38. bomSpecCode: "",
  39. bomSpecName: "",
  40. },
  41. });
  42. const loading = ref(false);
  43. const searchConfig = computed(() => {
  44. return [
  45. {
  46. type: "input",
  47. prop: "bomSpecCode",
  48. label: "品号",
  49. },
  50. {
  51. type: "input",
  52. prop: "bomSpecName",
  53. label: "品名",
  54. },
  55. ];
  56. });
  57. const config = computed(() => {
  58. return [
  59. {
  60. type: "selection",
  61. attrs: {
  62. checkAtt: "isCheck",
  63. },
  64. },
  65. {
  66. attrs: {
  67. label: "品号",
  68. prop: "bomSpecCode",
  69. width: 160,
  70. },
  71. },
  72. {
  73. attrs: {
  74. label: "品名",
  75. prop: "bomSpecName",
  76. "min-width": 220,
  77. },
  78. },
  79. {
  80. attrs: {
  81. label: "当前库存",
  82. prop: "inventoryQuantity",
  83. align: "center",
  84. width: 100,
  85. },
  86. },
  87. {
  88. attrs: {
  89. label: "40天安全库存",
  90. prop: "safetyInventoryQuantity",
  91. align: "center",
  92. width: 110,
  93. },
  94. },
  95. {
  96. attrs: {
  97. label: "近七天消耗量",
  98. prop: "outStorageQuantitySevenDays",
  99. align: "center",
  100. width: 110,
  101. },
  102. },
  103. {
  104. attrs: {
  105. label: "近15天消耗量",
  106. prop: "outStorageQuantityFifteenDays",
  107. align: "center",
  108. width: 110,
  109. },
  110. },
  111. {
  112. attrs: {
  113. label: "近30天消耗量",
  114. prop: "outStorageQuantityThirtyDays",
  115. align: "center",
  116. width: 110,
  117. },
  118. },
  119. {
  120. attrs: {
  121. label: "近60天消耗量",
  122. prop: "outStorageQuantitySixtyDays",
  123. align: "center",
  124. width: 110,
  125. },
  126. },
  127. {
  128. attrs: {
  129. label: "周环比销量",
  130. prop: "outStorageWeekOnWeekRatio",
  131. align: "center",
  132. width: 100,
  133. },
  134. render(val) {
  135. return val * 100 + "%";
  136. },
  137. },
  138. {
  139. attrs: {
  140. label: "预计消耗天数",
  141. prop: "predictOutStorageDays",
  142. align: "center",
  143. width: 110,
  144. },
  145. },
  146. {
  147. attrs: {
  148. label: "在途总数",
  149. prop: "inTransitSum",
  150. align: "center",
  151. width: 100,
  152. },
  153. },
  154. {
  155. attrs: {
  156. label: "下一批到货天数",
  157. prop: "nextDeliveryDays",
  158. align: "center",
  159. width: 130,
  160. },
  161. },
  162. {
  163. attrs: {
  164. label: "操作",
  165. width: 100,
  166. align: "center",
  167. fixed: "right",
  168. },
  169. renderHTML(row) {
  170. return [
  171. {
  172. attrs: {
  173. label: "发起申购",
  174. type: "primary",
  175. text: true,
  176. },
  177. el: "button",
  178. click() {
  179. clickSubscribe(row);
  180. },
  181. },
  182. ];
  183. },
  184. },
  185. ];
  186. });
  187. const getList = async (req, status) => {
  188. if (status) {
  189. sourceList.value.pagination = {
  190. pageNum: sourceList.value.pagination.pageNum,
  191. pageSize: sourceList.value.pagination.pageSize,
  192. };
  193. } else {
  194. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  195. }
  196. loading.value = true;
  197. proxy.post("/purchaseBomBoard/page", sourceList.value.pagination).then((res) => {
  198. if (res.rows && res.rows.length > 0) {
  199. sourceList.value.data = res.rows.map((item) => {
  200. return {
  201. ...item,
  202. isCheck: true,
  203. };
  204. });
  205. } else {
  206. sourceList.value.data = [];
  207. }
  208. sourceList.value.pagination.total = res.total;
  209. setTimeout(() => {
  210. loading.value = false;
  211. }, 200);
  212. });
  213. };
  214. getList();
  215. const clickReset = () => {
  216. getList("", true);
  217. };
  218. const selectData = ref([]);
  219. const selectRow = (data) => {
  220. selectData.value = data;
  221. };
  222. const cellClassName = ({ columnIndex, row }) => {
  223. if (columnIndex === 3 && row.inventoryQuantity < row.safetyInventoryQuantity) {
  224. return "colorDim";
  225. }
  226. if (columnIndex === 10 && row.predictOutStorageDays < 40) {
  227. return "colorDim";
  228. }
  229. };
  230. const clickSubscribe = (row) => {
  231. subscribeStore().setSubscribe([row]);
  232. proxy.$router.replace({
  233. path: "/platform_manage/process/processApproval",
  234. query: {
  235. flowKey: "apply_buy",
  236. flowName: "申购流程",
  237. random: proxy.random(),
  238. subscribeStatus: true,
  239. },
  240. });
  241. };
  242. const oneKeySubscribe = () => {
  243. if (selectData.value && selectData.value.length > 0) {
  244. subscribeStore().setSubscribe(selectData.value);
  245. proxy.$router.replace({
  246. path: "/platform_manage/process/processApproval",
  247. query: {
  248. flowKey: "apply_buy",
  249. flowName: "申购流程",
  250. random: proxy.random(),
  251. subscribeStatus: true,
  252. },
  253. });
  254. } else {
  255. return ElMessage("请选择需要申购的数据");
  256. }
  257. };
  258. </script>
  259. <style lang="scss" scoped>
  260. ::v-deep(.colorDim) {
  261. color: red;
  262. }
  263. </style>