WarehouseInfo.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="warehouse-info">
  3. <view class="filter-buttons">
  4. <button class="filter-btn" type="primary" @click="handleSelectAll">
  5. {{ isAllSelected ? "取消全选" : "全选" }}
  6. </button>
  7. <!-- <button class="filter-btn" type="primary" @click="confirmSelection">
  8. 确认选择
  9. </button> -->
  10. </view>
  11. <view class="info-list">
  12. <view
  13. v-for="(item, index) in warehouseList"
  14. :key="index"
  15. class="info-card"
  16. @click="handleWarehouseItem(item)"
  17. >
  18. <view class="info-content">
  19. <view class="info-row">
  20. <view class="warehouse-name-container">
  21. <view class="warehouse-icon">
  22. <image src="/static/images/warehouse.png" mode="aspectFit" />
  23. </view>
  24. <text class="label warehouse-name">仓房名称:</text>
  25. <text class="value warehouse-name">{{ item.cfmc }}</text>
  26. </view>
  27. <!-- :disabled="item.hyState !== 3" -->
  28. <checkbox
  29. v-if="item.hyState === 3"
  30. class="check-circle"
  31. :checked="item.checked"
  32. @click.stop="handleCheck(item)"
  33. style="transform: scale(0.8)"
  34. />
  35. <view
  36. v-if="item.hyState === 1 || item.hyState === 2"
  37. :style="{
  38. color: item.hyState === 1 ? '#1976d2' : '#f44336',
  39. }"
  40. >
  41. {{ item.hyState === 1 ? "检验通过" : "检验不通过" }}
  42. </view>
  43. </view>
  44. <view class="info-row">
  45. <view class="info-row-item">
  46. <text class="label">仓房类型:</text>
  47. <text class="value">{{ filterLX(item.cflx) || "-" }}</text>
  48. </view>
  49. <view class="info-row-item">
  50. <text class="label status-label">仓房状态:</text>
  51. <text class="value">{{ filterZT(item.cazt) || "-" }}</text>
  52. </view>
  53. </view>
  54. <view class="info-row">
  55. <view class="info-row-item">
  56. <text class="label">设计仓容:</text>
  57. <text class="value">{{ item.sjcr }}吨</text>
  58. </view>
  59. <view class="info-row-item">
  60. <text class="label status-label">是否空仓:</text>
  61. <text class="value">{{ item.sfkc === 1 ? "是" : "否" }}</text>
  62. </view>
  63. </view>
  64. <view class="info-row">
  65. <view class="info-row-item">
  66. <text class="label">租仓参考价:</text>
  67. <text class="value">{{ item.zcckj || "-" }}元/天</text>
  68. </view>
  69. <view class="info-row-item">
  70. <text class="label status-label">委托保管参考价:</text>
  71. <text class="value">{{ item.wtbgckj || "-" }}元/吨/月</text>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view v-if="warehouseList.length === 0" class="empty-container">
  77. <image src="" mode="aspectFit" class="empty-image"></image>
  78. <text class="empty-text">暂无数据</text>
  79. </view>
  80. <view style="height: 200rpx"></view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import { getCaxxByKqId, getTasks } from "@/api/task";
  86. import { getDictOptions, DICT_TYPE } from "@/utils/dict.js";
  87. export default {
  88. name: "WarehouseInfo",
  89. props: {
  90. taskInfo: {
  91. type: Object, // 根据实际数据类型调整
  92. default: () => ({}), // 默认值
  93. },
  94. },
  95. data() {
  96. return {
  97. warehouseList: [],
  98. cflxList: [],
  99. ztlxList: [],
  100. isAllSelected: false,
  101. selectedWarehouses: [],
  102. };
  103. },
  104. async mounted() {
  105. // console.log("接收到的任务信息:", this.taskInfo);
  106. this.cflxList = await getDictOptions(DICT_TYPE.SYSTEM_CFLX);
  107. this.ztlxList = await getDictOptions(DICT_TYPE.SYSTEM_CAZT);
  108. this.getWarehouseList();
  109. },
  110. methods: {
  111. filterLX(value) {
  112. return this.cflxList.find((item) => item.value == value)?.label;
  113. },
  114. filterZT(value) {
  115. return this.ztlxList.find((item) => item.value == value)?.label;
  116. },
  117. handleSelectAll() {
  118. this.isAllSelected = !this.isAllSelected;
  119. this.warehouseList = this.warehouseList.map(
  120. (item) => {
  121. if (item.hyState === 3) {
  122. return {
  123. ...item,
  124. checked: this.isAllSelected,
  125. };
  126. } else {
  127. return {
  128. ...item,
  129. // hyState: 3,
  130. };
  131. }
  132. }
  133. // {
  134. // ...item,
  135. // checked: this.isAllSelected,
  136. // }
  137. );
  138. },
  139. handleCheck(item) {
  140. item.checked = !item.checked;
  141. this.isAllSelected = this.warehouseList.every((item) => item.checked);
  142. },
  143. async confirmSelection(params) {
  144. this.selectedWarehouses = this.warehouseList.filter(
  145. (item) => item.checked && item.hyState === 3
  146. );
  147. if (this.selectedWarehouses.length === 0) {
  148. uni.showToast({
  149. title: "请至少选择一个仓房",
  150. icon: "none",
  151. });
  152. return;
  153. }
  154. // this.$emit("selected-warehouses", this.selectedWarehouses);
  155. // console.log(params, this.selectedWarehouses, "params");
  156. // 加载
  157. uni.showLoading({
  158. title: "处理中...",
  159. });
  160. let caIds = this.selectedWarehouses.map((item) => item.caId);
  161. const res = await getTasks({
  162. ...params,
  163. // hyState: 3,
  164. caIds,
  165. });
  166. if (res.code === 0) {
  167. uni.showToast({
  168. title: res.msg,
  169. icon: "success",
  170. });
  171. // 刷新仓房数据
  172. this.getWarehouseList();
  173. // 跳转到任务列表页面
  174. // uni.reLaunch({
  175. // url: "/pages/taskList-verification/taskListLayout?tab=1",
  176. // });
  177. } else {
  178. uni.showToast({
  179. title: "核验失败",
  180. icon: "none",
  181. });
  182. }
  183. uni.hideLoading();
  184. },
  185. handleWarehouseItem(item) {
  186. console.log("点击仓房:", item);
  187. },
  188. getWarehouseList() {
  189. getCaxxByKqId({
  190. kqId: this.taskInfo.kqId,
  191. listType: 2,
  192. }).then((res) => {
  193. if (res.code === 0) {
  194. this.warehouseList = res.data.map((item) => ({
  195. ...item,
  196. checked: false,
  197. }));
  198. } else {
  199. uni.showToast({
  200. title: res.msg || "获取任务列表失败",
  201. icon: "none",
  202. });
  203. }
  204. });
  205. },
  206. handleVerify(isPassed) {
  207. // 处理验证结果
  208. console.log("仓房信息验证结果:", isPassed);
  209. },
  210. },
  211. };
  212. </script>
  213. <style lang="scss" scoped>
  214. .warehouse-info {
  215. padding: 20rpx;
  216. height: 100%;
  217. overflow: auto;
  218. .filter-buttons {
  219. position: fixed;
  220. top: 0;
  221. left: 0;
  222. right: 0;
  223. padding: 20rpx;
  224. z-index: 99;
  225. box-sizing: border-box;
  226. .filter-btn {
  227. flex: 1;
  228. height: 80rpx;
  229. line-height: 80rpx;
  230. background-color: #1976d2;
  231. color: #fff;
  232. }
  233. }
  234. .info-list {
  235. height: 100%;
  236. padding-top: 100rpx;
  237. box-sizing: border-box;
  238. .info-card {
  239. background-color: #fff;
  240. border-radius: 10rpx;
  241. padding: 20rpx;
  242. margin-bottom: 20rpx;
  243. display: flex;
  244. // 阴影
  245. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);
  246. .warehouse-icon {
  247. width: 50rpx;
  248. height: 50rpx;
  249. margin-right: 20rpx;
  250. image {
  251. width: 100%;
  252. height: 100%;
  253. }
  254. }
  255. .warehouse-name {
  256. font-size: 32rpx !important;
  257. color: #000 !important;
  258. }
  259. .storage-image {
  260. width: 100rpx;
  261. height: 100rpx;
  262. }
  263. .info-content {
  264. display: flex;
  265. flex-direction: column;
  266. .info-row {
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. margin-bottom: 10rpx;
  271. flex-wrap: wrap;
  272. font-size: 30rpx;
  273. .warehouse-name-container {
  274. display: flex;
  275. align-items: center;
  276. }
  277. .label {
  278. color: #666;
  279. font-size: 30rpx;
  280. margin-right: 10rpx;
  281. }
  282. .value {
  283. color: #333;
  284. font-size: 30rpx;
  285. margin-right: 30rpx;
  286. }
  287. .status-label {
  288. margin-left: auto;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. .empty-container {
  296. display: flex;
  297. flex-direction: column;
  298. align-items: center;
  299. justify-content: center;
  300. // padding: 100rpx 0;
  301. .empty-image {
  302. width: 200rpx;
  303. height: 200rpx;
  304. margin-bottom: 20rpx;
  305. }
  306. .empty-text {
  307. color: #999;
  308. font-size: 28rpx;
  309. }
  310. }
  311. .check-circle {
  312. width: 40rpx;
  313. height: 40rpx;
  314. border-radius: 50%;
  315. border: 2rpx solid #ddd;
  316. margin-left: auto;
  317. &.checked {
  318. background-color: #1976d2;
  319. border-color: #1976d2;
  320. }
  321. }
  322. </style>