index.vue 8.4 KB

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