index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="goods-page">
  3. <u-navbar
  4. height="40px"
  5. title="货物信息录入"
  6. bgColor="#fff"
  7. autoBack
  8. placeholder
  9. >
  10. <view class="u-nav-slot depot-label" slot="right">
  11. <view class="name">{{ curDepotName }}</view>
  12. </view>
  13. </u-navbar>
  14. <view class="container_main">
  15. <u-sticky :offsetTop="offsetTop" bgColor="#fff">
  16. <view class="head-box">
  17. <view class="search-box">
  18. <u-search
  19. placeholder="输入关键字进行货物的模糊查询"
  20. shape="square"
  21. :showAction="false"
  22. @search="handleSearch"
  23. @clear="handleSearch"
  24. v-model="query.number"
  25. ></u-search>
  26. <view class="scan-icon flex_box flex_row_center" @click="">
  27. <image src="@/static/image/scan-icon-2.png" mode=""></image>
  28. </view>
  29. </view>
  30. </view>
  31. </u-sticky>
  32. <view class="content-box">
  33. <view class="content-list" v-if="list.length > 0">
  34. <view class="content-list-title">
  35. <view>入库货物清单</view>
  36. <view class="content-list-title-tips">(轻触货物查看详情)</view>
  37. </view>
  38. <goodCard
  39. v-for="(item, i) in list"
  40. :key="i"
  41. :goodImg="item.imgNameArr[0] || ''"
  42. :goodName="item.materialName"
  43. :goodDesValue="item.barCode"
  44. goodDesTitle="条形码"
  45. :columns="columns"
  46. :item="item"
  47. @handleClickField="handleClickField"
  48. @clickItem="handleClickItem"
  49. >
  50. <view slot="status">
  51. <view class="dsh">待审核</view>
  52. <!-- <view class="zc">正常</view>
  53. <view class="ybh">已驳回</view> -->
  54. </view>
  55. </goodCard>
  56. </view>
  57. <u-empty
  58. mode="data"
  59. text="暂无内容"
  60. marginTop="60"
  61. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  62. v-if="list.length == 0"
  63. ></u-empty>
  64. <!-- 加载更多 -->
  65. <u-loadmore
  66. v-if="list.length > 0"
  67. :status="loadStatus"
  68. @loadmore="onLoadMore"
  69. />
  70. </view>
  71. <!-- 新增录入-->
  72. <view class="footer">
  73. <u-button class="add-btn" type="primary" plain @click="goAddGood">
  74. 新增录入
  75. </u-button>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { taskStocktakingList } from "@/common/request/apis/inventoryTask";
  82. import { mapGetters } from "vuex";
  83. import goodCard from "@/components/good-card/good-card.vue";
  84. export default {
  85. components: {
  86. goodCard,
  87. },
  88. data() {
  89. return {
  90. offsetTop: 0,
  91. query: {
  92. number: "",
  93. },
  94. currentPage: 1,
  95. pageSize: 10,
  96. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  97. columns: [
  98. { title: "规格", key: "materialStandard" },
  99. { title: "批次号", key: "patchNumber" },
  100. { title: "生产日期", key: "productionDate" },
  101. { title: "库位", key: "position" },
  102. {
  103. title: "库存",
  104. key: "inventory",
  105. formatter: (key, formData) => {
  106. const inventory = formData.inventory
  107. ? (formData.inventory * 1).toFixed(0)
  108. : "0";
  109. return `${inventory}${formData.commodityUnit || ""}`;
  110. },
  111. },
  112. { title: "录入时间", key: "lrDate" },
  113. ],
  114. list: [
  115. {
  116. id: 1,
  117. materialName:
  118. "货物名称1货物名称1货物名称1货物名称1货物名称1货物名称1",
  119. imgNameArr: [
  120. "https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png",
  121. ],
  122. barCode: "6904045405",
  123. materialStandard: "500ml",
  124. productionDate: "2024-10-01",
  125. lrDate: "2024-10-01",
  126. inventory: 10,
  127. commodityUnit: "瓶",
  128. position: "A-1-1",
  129. status: 1,
  130. patchNumber: "12345678966",
  131. },
  132. {
  133. id: 2,
  134. materialName: "货物名称2",
  135. imgNameArr: [
  136. "https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png",
  137. ],
  138. barCode: "6904045405",
  139. materialStandard: "500ml",
  140. productionDate: "2024-10-01",
  141. lrDate: "2024-10-02",
  142. inventory: 10,
  143. commodityUnit: "瓶",
  144. position: "A-1-2",
  145. status: 1,
  146. patchNumber: "12345678966",
  147. },
  148. ],
  149. };
  150. },
  151. computed: {
  152. ...mapGetters(["depotInfo"]),
  153. curDepotId() {
  154. return this.depotInfo ? this.depotInfo.id : "";
  155. },
  156. curDepotName() {
  157. return this.depotInfo ? this.depotInfo.depotName : "";
  158. },
  159. },
  160. onLoad() {
  161. let systemInfo = uni.getSystemInfoSync();
  162. let statusBarHeight = systemInfo.statusBarHeight;
  163. this.offsetTop = statusBarHeight + 40;
  164. // this.loadData();
  165. },
  166. onShow() {},
  167. onPullDownRefresh() {
  168. // 下拉刷新
  169. this.onRefresh();
  170. },
  171. onReachBottom() {
  172. // 触底加载更多
  173. this.onLoadMore();
  174. },
  175. methods: {
  176. async onRefresh() {
  177. try {
  178. await this.loadData(true);
  179. } finally {
  180. uni.stopPullDownRefresh();
  181. }
  182. },
  183. async onLoadMore() {
  184. if (this.loadStatus !== "loadmore") return;
  185. this.loadStatus = "loading";
  186. try {
  187. await this.loadData();
  188. } catch (e) {
  189. this.loadStatus = "loadmore";
  190. }
  191. },
  192. async loadData(isRefresh = false) {
  193. if (isRefresh) {
  194. this.currentPage = 1;
  195. this.list = [];
  196. }
  197. try {
  198. this.loadStatus = "loading";
  199. const currentPage = this.currentPage;
  200. const pageSize = this.pageSize;
  201. const params = {
  202. currentPage,
  203. pageSize,
  204. ...this.query,
  205. depotId: this.curDepotId,
  206. };
  207. console.log("params=====", params);
  208. const res = await taskStocktakingList(params);
  209. const { rows, total } = res.data;
  210. this.list = [...this.list, ...rows];
  211. if (currentPage * pageSize < Number(total)) {
  212. this.currentPage++;
  213. this.loadStatus = "loadmore";
  214. } else {
  215. this.loadStatus = "nomore";
  216. }
  217. } catch (error) {}
  218. },
  219. handleSearch(value) {
  220. this.loadData(true);
  221. },
  222. handleClickField(key, formData) {
  223. console.log("key", key);
  224. console.log("formData", formData);
  225. },
  226. handleClickItem(item) {
  227. console.log("item", item);
  228. },
  229. goAddGood() {
  230. uni.navigateTo({
  231. url: "/pages/goods-enter/addGood",
  232. });
  233. },
  234. },
  235. };
  236. </script>
  237. <style lang="scss" scoped>
  238. .goods-page {
  239. min-height: 100vh;
  240. background-color: #f0f6fb;
  241. .container_main {
  242. .head-box {
  243. background-color: #fff;
  244. padding-top: 20rpx;
  245. padding-bottom: 32rpx;
  246. }
  247. .search-box {
  248. background-color: rgba(191, 200, 219, 0.2);
  249. margin: 0 32rpx;
  250. display: flex;
  251. align-items: center;
  252. justify-content: space-between;
  253. border-radius: 8rpx;
  254. ::v-deep .u-search__content {
  255. background-color: transparent !important;
  256. .u-search__content__input {
  257. background-color: transparent !important;
  258. }
  259. }
  260. .scan-icon {
  261. width: 100rpx;
  262. height: 100%;
  263. image {
  264. width: 40rpx;
  265. height: 40rpx;
  266. }
  267. }
  268. }
  269. .content-box {
  270. padding: 0 24rpx;
  271. &-val {
  272. border-radius: 16rpx 16rpx 0 0;
  273. overflow: hidden;
  274. }
  275. }
  276. }
  277. }
  278. .content-list {
  279. padding: 24rpx 0;
  280. background-color: #fff;
  281. margin-top: 24rpx;
  282. border-radius: 16rpx;
  283. .content-list-title {
  284. font-family: "PingFang SC";
  285. font-size: 32rpx;
  286. font-style: normal;
  287. font-weight: bold;
  288. display: flex;
  289. align-items: center;
  290. position: relative;
  291. padding-left: 50rpx;
  292. margin-bottom: 24rpx;
  293. &::after {
  294. content: "";
  295. display: block;
  296. width: 6rpx;
  297. height: 30rpx;
  298. border-radius: 100px;
  299. background: #0256ff;
  300. position: absolute;
  301. top: 50%;
  302. left: 24rpx;
  303. transform: translateY(-50%);
  304. }
  305. .content-list-title-tips {
  306. color: #0256ff;
  307. font-size: 24rpx;
  308. font-weight: 400;
  309. }
  310. }
  311. }
  312. .dsh {
  313. background-color: rgba(255, 59, 29, 0.2);
  314. color: rgba(255, 59, 29, 1);
  315. border-radius: 8rpx;
  316. }
  317. .zc {
  318. background-color: rgba(0, 185, 123, 0.2);
  319. color: rgba(0, 185, 123, 1);
  320. border-radius: 8rpx;
  321. }
  322. .ybh {
  323. background-color: rgba(225, 51, 15, 1);
  324. color: #fff;
  325. border-radius: 8rpx;
  326. }
  327. .footer {
  328. position: fixed;
  329. bottom: 0;
  330. left: 0;
  331. right: 0;
  332. height: 144rpx;
  333. background-color: #fff;
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. .add-btn {
  338. width: 700rpx;
  339. height: 88rpx;
  340. border-radius: 16rpx;
  341. font-size: 36rpx;
  342. font-weight: bold;
  343. color: #fff;
  344. background-color: #0256ff;
  345. line-height: 88rpx;
  346. text-align: center;
  347. }
  348. }
  349. </style>