index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <!--
  3. 成品库存管理主页面
  4. @Author: Antigravity
  5. -->
  6. <div class="app-container goods-stock-container">
  7. <!-- 头部高格调数据看板区 -->
  8. <el-row :gutter="20" class="mb20 summary-row">
  9. <el-col :span="6">
  10. <div class="summary-card total-stock">
  11. <div class="card-icon"><el-icon><Box /></el-icon></div>
  12. <div class="card-info">
  13. <span class="label">当前总库存支数</span>
  14. <h2 class="value">{{ summaryData.totalQty.toLocaleString() }} <small>支</small></h2>
  15. </div>
  16. </div>
  17. </el-col>
  18. <el-col :span="6">
  19. <div class="summary-card total-weight">
  20. <div class="card-icon"><el-icon><ScaleToOriginal /></el-icon></div>
  21. <div class="card-info">
  22. <span class="label">库存总重量</span>
  23. <h2 class="value">{{ summaryData.totalWt.toFixed(2) }} <small>kg</small></h2>
  24. </div>
  25. </div>
  26. </el-col>
  27. <el-col :span="6">
  28. <div class="summary-card aging-stock">
  29. <div class="card-icon"><el-icon><Timer /></el-icon></div>
  30. <div class="card-info">
  31. <span class="label">超 30 天超龄库存</span>
  32. <h2 class="value warning-text">{{ summaryData.agingCount }} <small>款</small></h2>
  33. </div>
  34. </div>
  35. </el-col>
  36. <el-col :span="6">
  37. <div class="summary-card warehouse-stock">
  38. <div class="card-icon"><el-icon><HomeFilled /></el-icon></div>
  39. <div class="card-info">
  40. <span class="label">关联单据数</span>
  41. <h2 class="value info-text">{{ summaryData.docCount }} <small>个</small></h2>
  42. </div>
  43. </div>
  44. </el-col>
  45. </el-row>
  46. <!-- 过滤搜索控制栏 -->
  47. <el-card class="search-card mb20 shadow-sm" border="false">
  48. <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="80px">
  49. <el-form-item label="型材型号" prop="modelNum">
  50. <el-input
  51. v-model="queryParams.modelNum"
  52. placeholder="请输入型材型号"
  53. clearable
  54. style="width: 200px"
  55. @keyup.enter="handleQuery"
  56. />
  57. </el-form-item>
  58. <el-form-item label="表面名称" prop="colorName">
  59. <el-input
  60. v-model="queryParams.colorName"
  61. placeholder="请输入表面名称"
  62. clearable
  63. style="width: 200px"
  64. @keyup.enter="handleQuery"
  65. />
  66. </el-form-item>
  67. <el-form-item label="客户名称" prop="clientName">
  68. <el-input
  69. v-model="queryParams.clientName"
  70. placeholder="请输入客户名称"
  71. clearable
  72. style="width: 200px"
  73. @keyup.enter="handleQuery"
  74. />
  75. </el-form-item>
  76. <el-form-item label="单据编号" prop="docCode">
  77. <el-input
  78. v-model="queryParams.docCode"
  79. placeholder="请输入单据编号"
  80. clearable
  81. style="width: 200px"
  82. @keyup.enter="handleQuery"
  83. />
  84. </el-form-item>
  85. <el-form-item class="btn-group">
  86. <el-button type="primary" icon="Search" class="glow-btn" @click="handleQuery">搜索</el-button>
  87. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  88. </el-form-item>
  89. </el-form>
  90. </el-card>
  91. <!-- 数据呈现主表格 -->
  92. <el-card class="table-card shadow-sm" border="false">
  93. <el-table
  94. v-loading="loading"
  95. :data="stockList"
  96. stripe
  97. row-key="itemNo"
  98. border
  99. highlight-current-row
  100. class="premium-table"
  101. >
  102. <el-table-column type="index" label="序号" align="center" width="55" fixed />
  103. <el-table-column label="单据编号" align="center" prop="docCode" width="130" show-overflow-tooltip fixed />
  104. <el-table-column label="型材型号" align="left" prop="modelNum" width="130" show-overflow-tooltip fixed>
  105. <template #default="scope">
  106. <span class="bold-text">{{ scope.row.modelNum }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="型材名称" align="left" prop="modelName" width="150" show-overflow-tooltip />
  110. <el-table-column label="客户型号" align="left" prop="clientModel" width="130" show-overflow-tooltip />
  111. <el-table-column label="表面名称" align="center" prop="colorName" width="130" show-overflow-tooltip>
  112. <template #default="scope">
  113. <el-tag effect="plain" type="success" size="small">{{ scope.row.colorName }}</el-tag>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="材质" align="center" prop="alloyName" width="90" />
  117. <el-table-column label="壁厚(mm)" align="right" prop="thick" width="95">
  118. <template #default="scope">
  119. <span>{{ scope.row.thick ? Number(scope.row.thick).toFixed(2) : '-' }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="膜厚" align="right" prop="film" width="85">
  123. <template #default="scope">
  124. <span>{{ scope.row.film ? Number(scope.row.film).toFixed(2) : '-' }}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="长度(mm)" align="right" prop="flength" width="95">
  128. <template #default="scope">
  129. <span class="highlight-value">{{ scope.row.flength ? Math.round(scope.row.flength) : '-' }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="现存支数" align="right" prop="qty" width="100">
  133. <template #default="scope">
  134. <span class="qty-text">{{ scope.row.qty ? scope.row.qty : 0 }}</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="实际重量(kg)" align="right" prop="wt" width="115">
  138. <template #default="scope">
  139. <span class="wt-text">{{ scope.row.wt ? Number(scope.row.wt).toFixed(2) : '0.00' }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="存放框名" align="center" prop="frameName" width="120" show-overflow-tooltip />
  143. <el-table-column label="仓库名称" align="center" prop="storeName" width="120" show-overflow-tooltip />
  144. <el-table-column label="库龄" align="center" prop="stockDays" width="95">
  145. <template #default="scope">
  146. <el-tooltip :content="'生产完成日期: ' + parseTime(scope.row.finishDate)" placement="top">
  147. <el-tag :type="getAgingTagType(scope.row.stockDays)" effect="dark" size="small">
  148. {{ scope.row.stockDays }} 天
  149. </el-tag>
  150. </el-tooltip>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="客户名称" align="left" prop="clientName" width="150" show-overflow-tooltip />
  154. <el-table-column label="完成日期" align="center" prop="finishDate" width="160">
  155. <template #default="scope">
  156. <span>{{ parseTime(scope.row.finishDate, '{y}-{m}-{d} {h}:{i}') }}</span>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <pagination
  161. v-show="total > 0"
  162. :total="total"
  163. v-model:page="queryParams.pageNum"
  164. v-model:limit="queryParams.pageSize"
  165. @pagination="getList"
  166. />
  167. </el-card>
  168. </div>
  169. </template>
  170. <script setup name="GoodsStock">
  171. /**
  172. * 成品库存组件逻辑
  173. * @Author: Antigravity
  174. */
  175. import { ref, onMounted, reactive } from 'vue';
  176. import { listGoodsStockPage } from '@/api/erp/goodsStock';
  177. import { parseTime } from '@/utils/ruoyi';
  178. const queryFormRef = ref();
  179. const loading = ref(false);
  180. const total = ref(0);
  181. const stockList = ref([]);
  182. // 汇总栏数据定义
  183. const summaryData = reactive({
  184. totalQty: 0,
  185. totalWt: 0,
  186. agingCount: 0,
  187. docCount: 0
  188. });
  189. // 查询参数配置
  190. const queryParams = ref({
  191. pageNum: 1,
  192. pageSize: 10,
  193. modelNum: undefined,
  194. colorName: undefined,
  195. clientName: undefined,
  196. docCode: undefined
  197. });
  198. /** 查询库存列表 */
  199. function getList() {
  200. loading.value = true;
  201. listGoodsStockPage(queryParams.value).then(response => {
  202. stockList.value = response.rows;
  203. total.value = response.total;
  204. loading.value = false;
  205. calculateSummary(response.rows);
  206. }).catch(() => {
  207. loading.value = false;
  208. });
  209. }
  210. /** 动态统计当前页/当前汇总概览 */
  211. function calculateSummary(rows) {
  212. if (!rows || rows.length === 0) {
  213. summaryData.totalQty = 0;
  214. summaryData.totalWt = 0;
  215. summaryData.agingCount = 0;
  216. summaryData.docCount = 0;
  217. return;
  218. }
  219. let qty = 0;
  220. let wt = 0;
  221. let aging = 0;
  222. const docs = new Set();
  223. rows.forEach(r => {
  224. qty += Number(r.qty || 0);
  225. wt += Number(r.wt || 0);
  226. if (Number(r.stockDays || 0) > 30) {
  227. aging++;
  228. }
  229. if (r.docCode) {
  230. docs.add(r.docCode);
  231. }
  232. });
  233. summaryData.totalQty = qty;
  234. summaryData.totalWt = wt;
  235. summaryData.agingCount = aging;
  236. summaryData.docCount = docs.size;
  237. }
  238. /** 库龄颜色渲染 */
  239. function getAgingTagType(days) {
  240. const d = Number(days || 0);
  241. if (d <= 7) return 'success'; // 新鲜库存
  242. if (d <= 30) return 'info'; // 正常库存
  243. if (d <= 90) return 'warning'; // 超龄中等库存
  244. return 'danger'; // 呆滞库存
  245. }
  246. /** 搜索按钮操作 */
  247. function handleQuery() {
  248. queryParams.value.pageNum = 1;
  249. getList();
  250. }
  251. /** 重置查询 */
  252. function resetQuery() {
  253. queryFormRef.value?.resetFields();
  254. handleQuery();
  255. }
  256. onMounted(() => {
  257. getList();
  258. });
  259. </script>
  260. <style scoped lang="scss">
  261. .goods-stock-container {
  262. padding: 20px;
  263. background-color: #f6f8fb;
  264. min-height: calc(100vh - 84px);
  265. // 1. 数据统计卡片区美化
  266. .summary-row {
  267. margin-bottom: 20px;
  268. .summary-card {
  269. display: flex;
  270. align-items: center;
  271. padding: 20px;
  272. background: #ffffff;
  273. border-radius: 12px;
  274. box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.03);
  275. transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  276. border-left: 5px solid #409eff;
  277. &:hover {
  278. transform: translateY(-4px);
  279. box-shadow: 0 8px 30px 0 rgba(64, 158, 255, 0.12);
  280. }
  281. &.total-stock {
  282. border-left-color: #409eff;
  283. .card-icon { background: rgba(64, 158, 255, 0.1); color: #409eff; }
  284. }
  285. &.total-weight {
  286. border-left-color: #67c23a;
  287. .card-icon { background: rgba(103, 194, 58, 0.1); color: #67c23a; }
  288. }
  289. &.aging-stock {
  290. border-left-color: #f56c6c;
  291. .card-icon { background: rgba(245, 108, 108, 0.1); color: #f56c6c; }
  292. }
  293. &.warehouse-stock {
  294. border-left-color: #e6a23c;
  295. .card-icon { background: rgba(230, 162, 60, 0.1); color: #e6a23c; }
  296. }
  297. .card-icon {
  298. width: 54px;
  299. height: 54px;
  300. border-radius: 10px;
  301. display: flex;
  302. align-items: center;
  303. justify-content: center;
  304. font-size: 26px;
  305. margin-right: 15px;
  306. }
  307. .card-info {
  308. .label {
  309. font-size: 13px;
  310. color: #909399;
  311. display: block;
  312. margin-bottom: 5px;
  313. }
  314. .value {
  315. margin: 0;
  316. font-size: 22px;
  317. font-weight: 700;
  318. color: #303133;
  319. small {
  320. font-size: 12px;
  321. font-weight: normal;
  322. color: #909399;
  323. margin-left: 2px;
  324. }
  325. }
  326. .warning-text { color: #f56c6c; }
  327. .info-text { color: #e6a23c; }
  328. }
  329. }
  330. }
  331. // 2. 搜索控制栏美化
  332. .search-card {
  333. background: #ffffff;
  334. border-radius: 12px;
  335. border: none;
  336. :deep(.el-form-item) {
  337. margin-bottom: 0;
  338. margin-right: 18px;
  339. }
  340. .btn-group {
  341. margin-left: 10px;
  342. }
  343. .glow-btn {
  344. box-shadow: 0 4px 14px 0 rgba(64, 158, 255, 0.4);
  345. transition: all 0.3s;
  346. &:hover {
  347. transform: translateY(-1px);
  348. box-shadow: 0 6px 20px 0 rgba(64, 158, 255, 0.5);
  349. }
  350. }
  351. }
  352. // 3. 数据表格区美化
  353. .table-card {
  354. border-radius: 12px;
  355. border: none;
  356. background: #ffffff;
  357. .premium-table {
  358. font-size: 13px;
  359. :deep(.el-table__header-wrapper) th {
  360. background-color: #f8f9fc !important;
  361. color: #606266;
  362. font-weight: bold;
  363. height: 48px;
  364. }
  365. :deep(.el-table__row) {
  366. height: 44px;
  367. }
  368. .bold-text {
  369. font-weight: 600;
  370. color: #2c3e50;
  371. }
  372. .highlight-value {
  373. color: #2c3e50;
  374. font-weight: bold;
  375. }
  376. .qty-text {
  377. font-weight: bold;
  378. color: #2980b9;
  379. }
  380. .wt-text {
  381. font-weight: bold;
  382. color: #27ae60;
  383. }
  384. }
  385. }
  386. .mb20 { margin-bottom: 20px; }
  387. }
  388. </style>