index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. sortField: "turnoverRate",
  41. sortBy: 2,
  42. },
  43. });
  44. const sortField = ref([
  45. {
  46. dictKey: "turnoverRate",
  47. dictValue: "周转率",
  48. },
  49. {
  50. dictKey: "predictOutStorageDays",
  51. dictValue: "预计消耗天数",
  52. },
  53. {
  54. dictKey: "nextDeliveryDays",
  55. dictValue: "下一批到货天数",
  56. },
  57. ]);
  58. const sortBy = ref([
  59. {
  60. dictKey: 1,
  61. dictValue: "升序",
  62. },
  63. {
  64. dictKey: 2,
  65. dictValue: "降序",
  66. },
  67. ]);
  68. const loading = ref(false);
  69. const searchConfig = computed(() => {
  70. return [
  71. {
  72. type: "input",
  73. prop: "bomSpecCode",
  74. label: "品号",
  75. },
  76. {
  77. type: "input",
  78. prop: "bomSpecName",
  79. label: "品名",
  80. },
  81. {
  82. type: "select",
  83. prop: "sortField",
  84. label: "排序字段",
  85. data: sortField.value,
  86. },
  87. {
  88. type: "select",
  89. prop: "sortBy",
  90. label: "排序方式",
  91. data: sortBy.value,
  92. },
  93. ];
  94. });
  95. const config = computed(() => {
  96. return [
  97. {
  98. type: "selection",
  99. attrs: {
  100. checkAtt: "isCheck",
  101. },
  102. },
  103. {
  104. attrs: {
  105. label: "品号",
  106. prop: "bomSpecCode",
  107. width: 160,
  108. },
  109. },
  110. {
  111. attrs: {
  112. label: "品名",
  113. prop: "bomSpecName",
  114. "min-width": 220,
  115. },
  116. },
  117. {
  118. attrs: {
  119. label: "当前库存",
  120. prop: "inventoryQuantity",
  121. align: "center",
  122. width: 100,
  123. },
  124. },
  125. {
  126. attrs: {
  127. label: "40天安全库存",
  128. prop: "safetyInventoryQuantity",
  129. align: "center",
  130. width: 110,
  131. },
  132. },
  133. {
  134. attrs: {
  135. label: "近七天消耗量",
  136. prop: "outStorageQuantitySevenDays",
  137. align: "center",
  138. width: 110,
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: "近15天消耗量",
  144. prop: "outStorageQuantityFifteenDays",
  145. align: "center",
  146. width: 110,
  147. },
  148. },
  149. {
  150. attrs: {
  151. label: "近30天消耗量",
  152. prop: "outStorageQuantityThirtyDays",
  153. align: "center",
  154. width: 110,
  155. },
  156. },
  157. {
  158. attrs: {
  159. label: "近60天消耗量",
  160. prop: "outStorageQuantitySixtyDays",
  161. align: "center",
  162. width: 110,
  163. },
  164. },
  165. {
  166. attrs: {
  167. label: "周环比销量",
  168. prop: "outStorageWeekOnWeekRatio",
  169. align: "center",
  170. width: 100,
  171. },
  172. render(val) {
  173. return val * 100 + "%";
  174. },
  175. },
  176. {
  177. attrs: {
  178. label: "预计消耗天数",
  179. prop: "predictOutStorageDays",
  180. align: "center",
  181. width: 110,
  182. },
  183. },
  184. {
  185. attrs: {
  186. label: "在途总数",
  187. prop: "inTransitSum",
  188. align: "center",
  189. width: 100,
  190. },
  191. },
  192. {
  193. attrs: {
  194. label: "下一批到货天数",
  195. prop: "nextDeliveryDays",
  196. align: "center",
  197. width: 130,
  198. },
  199. },
  200. {
  201. attrs: {
  202. label: "周转率",
  203. prop: "turnoverRate",
  204. width: 100,
  205. },
  206. },
  207. {
  208. attrs: {
  209. label: "操作",
  210. width: 100,
  211. align: "center",
  212. fixed: "right",
  213. },
  214. renderHTML(row) {
  215. return [
  216. {
  217. attrs: {
  218. label: "发起申购",
  219. type: "primary",
  220. text: true,
  221. },
  222. el: "button",
  223. click() {
  224. clickSubscribe(row);
  225. },
  226. },
  227. ];
  228. },
  229. },
  230. ];
  231. });
  232. const getList = async (req, status) => {
  233. if (status) {
  234. sourceList.value.pagination = {
  235. pageNum: sourceList.value.pagination.pageNum,
  236. pageSize: sourceList.value.pagination.pageSize,
  237. sortField: "turnoverRate",
  238. sortBy: 2,
  239. };
  240. } else {
  241. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  242. }
  243. loading.value = true;
  244. proxy.post("/purchaseBomBoard/page", sourceList.value.pagination).then((res) => {
  245. if (res.rows && res.rows.length > 0) {
  246. sourceList.value.data = res.rows.map((item) => {
  247. return {
  248. ...item,
  249. isCheck: true,
  250. };
  251. });
  252. } else {
  253. sourceList.value.data = [];
  254. }
  255. sourceList.value.pagination.total = res.total;
  256. setTimeout(() => {
  257. loading.value = false;
  258. }, 200);
  259. });
  260. };
  261. getList();
  262. const clickReset = () => {
  263. getList("", true);
  264. };
  265. const selectData = ref([]);
  266. const selectRow = (data) => {
  267. selectData.value = data;
  268. };
  269. const cellClassName = ({ columnIndex, row }) => {
  270. if (columnIndex === 3 && row.inventoryQuantity < row.safetyInventoryQuantity) {
  271. return "colorDim";
  272. }
  273. if (columnIndex === 10 && row.predictOutStorageDays < 40) {
  274. return "colorDim";
  275. }
  276. };
  277. const clickSubscribe = (row) => {
  278. subscribeStore().setSubscribe([row]);
  279. proxy.$router.replace({
  280. path: "/platform_manage/process/processApproval",
  281. query: {
  282. flowKey: "apply_buy",
  283. flowName: "申购流程",
  284. random: proxy.random(),
  285. subscribeStatus: true,
  286. },
  287. });
  288. };
  289. const oneKeySubscribe = () => {
  290. if (selectData.value && selectData.value.length > 0) {
  291. subscribeStore().setSubscribe(selectData.value);
  292. proxy.$router.replace({
  293. path: "/platform_manage/process/processApproval",
  294. query: {
  295. flowKey: "apply_buy",
  296. flowName: "申购流程",
  297. random: proxy.random(),
  298. subscribeStatus: true,
  299. },
  300. });
  301. } else {
  302. return ElMessage("请选择需要申购的数据");
  303. }
  304. };
  305. </script>
  306. <style lang="scss" scoped>
  307. ::v-deep(.colorDim) {
  308. color: red;
  309. }
  310. </style>