index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[
  12. selectStatus
  13. ? {}
  14. : {
  15. text: '导出Excel',
  16. action: () => deriveExcel(),
  17. },
  18. ]"
  19. @get-list="getList"
  20. >
  21. <template #btn="{ item }">
  22. <div style="width: 100%; text-align: center">
  23. <el-button
  24. type="primary"
  25. @click="checkTheFlow(item)"
  26. v-if="!selectStatus"
  27. text
  28. >查看流水</el-button
  29. >
  30. <el-button type="primary" @click="clickSelect(item)" v-else text
  31. >选择</el-button
  32. >
  33. </div>
  34. </template>
  35. </byTable>
  36. </div>
  37. </div>
  38. </template>
  39. <script setup>
  40. import { computed, ref } from "vue";
  41. import byTable from "@/components/byTable/index";
  42. import useUserStore from "@/store/modules/user";
  43. const { proxy } = getCurrentInstance();
  44. const props = defineProps({
  45. selectStatus: Boolean,
  46. warehouseId: String,
  47. });
  48. const warehouseList = ref([]);
  49. const sourceList = ref({
  50. data: [],
  51. pagination: {
  52. total: 0,
  53. pageNum: 1,
  54. pageSize: 10,
  55. keyword: "",
  56. id: "",
  57. },
  58. });
  59. const productUnit = ref([]);
  60. const definition = ref([
  61. {
  62. label: "产品",
  63. value: "1",
  64. },
  65. {
  66. label: "物料",
  67. value: "2",
  68. },
  69. ]);
  70. const loading = ref(false);
  71. const selectConfig = computed(() => {
  72. if (props.warehouseId) {
  73. return [];
  74. }
  75. return [
  76. {
  77. label: "仓库名称",
  78. prop: "id",
  79. data: warehouseList.value,
  80. },
  81. ];
  82. });
  83. const config = computed(() => {
  84. return [
  85. {
  86. attrs: {
  87. label: "仓库名称",
  88. prop: "warehouseId",
  89. width: 220,
  90. },
  91. render(type) {
  92. return proxy.dictValueLabel(type, warehouseList.value);
  93. },
  94. },
  95. {
  96. attrs: {
  97. label: "物品类型",
  98. prop: "productDefinition",
  99. width: 140,
  100. },
  101. render(type) {
  102. return proxy.dictValueLabel(type, definition.value);
  103. },
  104. },
  105. {
  106. attrs: {
  107. label: "所属分类",
  108. prop: "productClassifyName",
  109. width: 140,
  110. },
  111. },
  112. {
  113. attrs: {
  114. label: "物品编码",
  115. prop: "productCode",
  116. width: 160,
  117. },
  118. },
  119. {
  120. attrs: {
  121. label: "物品名称",
  122. prop: "productName",
  123. "min-width": 180,
  124. },
  125. },
  126. {
  127. attrs: {
  128. label: "规格型号",
  129. prop: "productSpec",
  130. width: 160,
  131. },
  132. },
  133. {
  134. attrs: {
  135. label: "单位",
  136. prop: "productUnit",
  137. width: 120,
  138. },
  139. render(unit) {
  140. return proxy.dictDataEcho(unit, productUnit.value);
  141. },
  142. },
  143. {
  144. attrs: {
  145. label: "库存数量",
  146. prop: "quantity",
  147. width: 140,
  148. },
  149. },
  150. {
  151. attrs: {
  152. label: "操作",
  153. slot: "btn",
  154. width: 120,
  155. fixed: "right",
  156. align: "center",
  157. },
  158. },
  159. ];
  160. });
  161. const getDict = () => {
  162. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  163. if (res.rows && res.rows.length > 0) {
  164. warehouseList.value = res.rows.map((item) => {
  165. return {
  166. label: item.name,
  167. value: item.id,
  168. };
  169. });
  170. }
  171. });
  172. proxy.getDict(["unit"]).then((res) => {
  173. productUnit.value = res["unit"];
  174. });
  175. // proxy
  176. // .post("/dictTenantData/page", {
  177. // pageNum: 1,
  178. // pageSize: 999,
  179. // dictCode: "product_type",
  180. // tenantId: useUserStore().user.tenantId,
  181. // })
  182. // .then((res) => {
  183. // if (res.rows && res.rows.length > 0) {
  184. // productType.value = res.rows.map((item) => {
  185. // return {
  186. // label: item.dictValue,
  187. // value: item.dictKey,
  188. // };
  189. // });
  190. // }
  191. // });
  192. };
  193. const getList = async (req) => {
  194. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  195. loading.value = true;
  196. if (props.warehouseId) {
  197. sourceList.value.pagination.id = props.warehouseId;
  198. }
  199. proxy.post("/stock/page", sourceList.value.pagination).then((res) => {
  200. sourceList.value.data = res.rows;
  201. sourceList.value.pagination.total = res.total;
  202. setTimeout(() => {
  203. loading.value = false;
  204. }, 200);
  205. });
  206. };
  207. getDict();
  208. getList();
  209. const checkTheFlow = (item) => {
  210. proxy.$router.replace({
  211. path: "/purchaseSales/outAndInWarehouse/record",
  212. query: {
  213. productId: item.productId,
  214. },
  215. });
  216. };
  217. const deriveExcel = () => {
  218. console.log("deriveExcel");
  219. };
  220. const clickSelect = (item) => {
  221. proxy.$emit("select", item);
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. .tenant {
  226. padding: 20px;
  227. }
  228. ::v-deep(.el-input-number .el-input__inner) {
  229. text-align: left;
  230. }
  231. </style>