warehouse.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="page">
  3. <view class="navbar">
  4. <view
  5. v-for="(item, index) in navList"
  6. :key="index"
  7. class="nav-item"
  8. :class="{ current: tabCurrentIndex === index }"
  9. @click="tabClick(index)"
  10. >
  11. {{ item.text }}
  12. </view>
  13. </view>
  14. <swiper
  15. :current="tabCurrentIndex"
  16. class="swiper-box"
  17. duration="300"
  18. @change="changeTab"
  19. >
  20. <swiper-item class="tab-content">
  21. <scroll-view class="list-scroll-content" scroll-y>
  22. <view class="warehouse-list">
  23. <view
  24. v-for="(warehouseItem, index) in warehousesList"
  25. :key="index"
  26. class="warehouse-item"
  27. @click="goPage(warehouseItem)"
  28. >
  29. <view class="warehouse-header">
  30. <view class="info-container">
  31. <view class="warehouse-name">
  32. <image
  33. src="../../static/icons/warehouse-ico.png"
  34. mode="widthFix"
  35. ></image>
  36. <text>仓房名称:{{ warehouseItem.cfmc }}</text>
  37. </view>
  38. </view>
  39. <view class="select-button" v-if="sourcePage != 'self'">
  40. <checkbox
  41. :checked="warehouseItem.checked"
  42. @click.stop="handleCheck(index)"
  43. />
  44. </view>
  45. </view>
  46. <view class="warehouse-details">
  47. <view class="detail-row">
  48. <text
  49. >仓库类型:{{
  50. getDictLabelSync(
  51. DICT_TYPE.SYSTEM_CFLX,
  52. warehouseItem.cflx
  53. )
  54. }}</text
  55. >
  56. <text
  57. >仓库状态:{{
  58. getDictLabelSync(
  59. DICT_TYPE.SYSTEM_CAZT,
  60. warehouseItem.cazt
  61. )
  62. }}</text
  63. >
  64. </view>
  65. <view class="detail-row">
  66. <text>设计仓容:{{ warehouseItem.sjcr }}</text>
  67. <text
  68. >是否空仓:{{
  69. warehouseItem.sfkc === 0 ? "否" : "是"
  70. }}</text
  71. >
  72. </view>
  73. <view class="detail-row">
  74. <text
  75. >租仓参考价:{{ warehouseItem.zcckj || "-" }}
  76. 元/月
  77. </text>
  78. <text
  79. >委托保管参考价:{{
  80. warehouseItem.wtbgckj || "-"
  81. }}元/吨/月</text
  82. >
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </scroll-view>
  88. <view class="button-container" v-if="sourcePage != 'self'">
  89. <view class="button-pad">
  90. <button class="confirm" @click="confirmSelection">确认选择</button>
  91. </view>
  92. </view>
  93. </swiper-item>
  94. <swiper-item class="tab-content">
  95. <scroll-view class="info-scroll-content" scroll-y>
  96. <view class="warehouse-info">
  97. <warehouse-info :kqInfo="kqInfo"></warehouse-info>
  98. </view>
  99. </scroll-view>
  100. </swiper-item>
  101. </swiper>
  102. </view>
  103. </template>
  104. <script setup>
  105. import { ref, reactive, onMounted } from "vue";
  106. import { onLoad } from "@dcloudio/uni-app";
  107. import { getDictOptions, DICT_TYPE, getDictLabelSync } from "@/utils/dict.js";
  108. import {
  109. getCaxxByKqIdForClr,
  110. getKqxxByKqId,
  111. getStoreroom,
  112. } from "@/api/grainDepositor";
  113. import warehouseInfo from "./components/warehouseInfo/warehouseInfo.vue";
  114. const sourcePage = ref("all");
  115. const navList = [
  116. {
  117. state: 0,
  118. text: "仓房基本信息",
  119. loadingType: "more",
  120. orderList: [],
  121. },
  122. {
  123. state: 1,
  124. text: "库区基本信息",
  125. loadingType: "more",
  126. orderList: [],
  127. },
  128. ];
  129. const tabCurrentIndex = ref(0);
  130. const tabClick = (index) => {
  131. tabCurrentIndex.value = index;
  132. };
  133. const detailkqId = ref(null);
  134. const warehousesList = ref([]);
  135. const kqInfo = ref({
  136. resid: "",
  137. });
  138. onLoad(async (options) => {
  139. if (options && options.kqId) {
  140. sourcePage.value = options.source;
  141. detailkqId.value = options.kqId;
  142. let postData = {
  143. listType: 3,
  144. kqId: detailkqId.value,
  145. };
  146. if (sourcePage.value === "self") {
  147. postData.listType = 4;
  148. }
  149. const getData = await getCaxxByKqIdForClr(postData);
  150. warehousesList.value = getData.data;
  151. const getKqxx = await getKqxxByKqId({ kqId: detailkqId.value });
  152. kqInfo.value = getKqxx.data;
  153. } else {
  154. console.warn("没有接收到 id 参数");
  155. }
  156. });
  157. const handleCheck = (index) => {
  158. warehousesList.value[index].checked = !warehousesList.value[index].checked;
  159. };
  160. const changeTab = () => {};
  161. const confirmSelection = async () => {
  162. const selIds = warehousesList.value
  163. .filter((item) => item.checked) // 筛选出checked为true的项
  164. .map((item) => item.caId); // 提取每个项的caId
  165. if (selIds.length > 0) {
  166. try {
  167. const getData = await getStoreroom({ caIds: selIds });
  168. uni.navigateTo({
  169. url: `/pages/grainDepositor/grainDepositorLayout?tabIndex=1`,
  170. });
  171. } catch (error) {
  172. console.error("请求失败:", error);
  173. }
  174. } else {
  175. uni.navigateTo({
  176. url: `/pages/grainDepositor/grainDepositorLayout?tabIndex=1`,
  177. });
  178. console.warn("未选择任何仓库");
  179. }
  180. };
  181. const goPage = async (warehouseItem) => {
  182. if (sourcePage.value === "self") {
  183. uni.navigateTo({
  184. url: `/pages/infoDetails/infoDetailsLayout?caId=${warehouseItem.caId}`,
  185. });
  186. }
  187. };
  188. // 组件挂载时预加载需要的字典
  189. onMounted(async () => {
  190. await getDictOptions(DICT_TYPE.SYSTEM_CAZT);
  191. await getDictOptions(DICT_TYPE.SYSTEM_CFLX);
  192. });
  193. </script>
  194. <style lang="scss" scoped>
  195. .page {
  196. position: relative; // 确保伪元素相对于 .page 定位
  197. }
  198. .page::before {
  199. content: "";
  200. position: absolute;
  201. top: 0;
  202. left: 0;
  203. width: 100%;
  204. height: 200rpx; // 设置渐变的高度
  205. background: linear-gradient(180deg, #cfddfc, #eff2f5);
  206. z-index: -1; // 确保它在内容之下
  207. }
  208. .warehouse-list {
  209. padding: 40rpx 20rpx 20rpx;
  210. .warehouse-item {
  211. background: linear-gradient(180deg, #ffffff, #f5f8ff);
  212. border-radius: 10px;
  213. padding: 20px 15px 10px;
  214. margin-bottom: 25rpx;
  215. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  216. .warehouse-header {
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: flex-start; // 对齐到顶部
  220. padding-bottom: 30rpx;
  221. border-bottom: 1px solid #e7e8ea;
  222. font-size: 35rpx;
  223. color: #00122f;
  224. .info-container {
  225. flex-grow: 1;
  226. .warehouse-name,
  227. .warehouse-address {
  228. display: flex;
  229. align-items: center;
  230. margin-bottom: 5px;
  231. &:last-child {
  232. margin-bottom: 0;
  233. }
  234. image {
  235. width: 20px;
  236. height: 20px;
  237. margin-right: 10px;
  238. }
  239. }
  240. }
  241. .select-button {
  242. display: flex;
  243. align-items: flex-start;
  244. margin-left: 10px;
  245. }
  246. }
  247. .warehouse-details {
  248. padding-top: 30rpx;
  249. font-size: 30rpx;
  250. color: #747476;
  251. .detail-row {
  252. display: flex;
  253. margin-bottom: 10px;
  254. text {
  255. flex: 1;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. .button-container {
  262. position: fixed;
  263. bottom: 0;
  264. background-color: #ffffff;
  265. width: 100vw;
  266. padding: 40rpx 0;
  267. .button-pad {
  268. padding: 0 40rpx;
  269. display: flex;
  270. justify-content: space-between;
  271. }
  272. .confirm {
  273. width: 88%;
  274. height: 70rpx;
  275. line-height: 70rpx;
  276. border-radius: 10rpx;
  277. background-color: #1e5fdf;
  278. color: #fff;
  279. font-size: 28rpx;
  280. text-align: center;
  281. }
  282. }
  283. .warehouse-info {
  284. padding-top: 20rpx;
  285. }
  286. .navbar {
  287. display: flex;
  288. height: 40px;
  289. padding: 0 5px;
  290. position: relative;
  291. z-index: 10;
  292. .nav-item {
  293. flex: 1;
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. height: 100%;
  298. font-size: 35rpx;
  299. position: relative;
  300. color: #334b68;
  301. &.current {
  302. color: #0f2239;
  303. &:after {
  304. content: "";
  305. position: absolute;
  306. left: 50%;
  307. bottom: 0;
  308. transform: translateX(-50%);
  309. width: 60%;
  310. height: 0;
  311. border-bottom: 4px solid #789fec;
  312. }
  313. }
  314. }
  315. }
  316. .swiper-box {
  317. height: calc(100vh - 80rpx);
  318. }
  319. .list-scroll-content {
  320. height: calc(100vh - 200rpx);
  321. }
  322. .info-scroll-content {
  323. height: calc(100vh - 120rpx);
  324. }
  325. </style>