fertilizerPrice.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="fertilizer-price">
  3. <search v-model="searchVal" placeholder="搜索专家" />
  4. <div class="record-filter">
  5. <div
  6. class="filter-item"
  7. v-for="(item, index) in filterType"
  8. :key="index"
  9. @click="handlePlanClick(index)"
  10. :class="{ active: activePlanIndex === index }"
  11. >
  12. {{ item }}
  13. </div>
  14. </div>
  15. <div class="fertilizer-list">
  16. <div class="fertilizer-card" @click.stop="handleEdit(item)" v-for="(item, index) in priceList" :key="index">
  17. <div class="card-header">
  18. <div class="title">{{ item.name }}</div>
  19. <div class="action-btn">
  20. <el-icon @click.stop="handleEdit(item)" color="#2199F8" size="18"><Edit /></el-icon>
  21. <!-- <el-icon @click.stop="openDelete" color="#E04C4C" size="18"><Delete /></el-icon> -->
  22. </div>
  23. </div>
  24. <div class="info">
  25. <div class="row">
  26. <span class="label">药物品牌</span>
  27. <span class="value">{{ item.brand }}</span>
  28. </div>
  29. <div class="row">
  30. <span class="label">药费类型</span>
  31. <span class="value">{{ item.typeName }}</span>
  32. </div>
  33. <div class="row">
  34. <span class="label">施用方式</span>
  35. <span class="value">{{ item.useMode }}</span>
  36. </div>
  37. <transition name="collapse">
  38. <div class="extra-info" v-show="isExpanded(index)">
  39. <div class="row">
  40. <span class="label">计量单位</span>
  41. <span class="value">{{ item.unit }}</span>
  42. </div>
  43. <div class="row">
  44. <span class="label">单位兑水量</span>
  45. <span class="value">{{ item.unitUsage }}</span>
  46. </div>
  47. <div class="row">
  48. <span class="label">适用品类</span>
  49. <span class="value tag-group">
  50. <span class="tag-item">{{ item.unitWaterAmount }}</span>
  51. </span>
  52. </div>
  53. </div>
  54. </transition>
  55. </div>
  56. <div class="expand" @click.stop="toggleExpand(index)">
  57. <span>{{ isExpanded(index) ? '收起' : '展开更多' }}</span>
  58. <el-icon :class="{ rotate: isExpanded(index) }"><ArrowDown /></el-icon>
  59. </div>
  60. <div class="stats">
  61. <div class="col">
  62. <div class="num">{{ item.price }}<span class="unit"> 元/{{ item.unit }}</span></div>
  63. <div class="desc">成本</div>
  64. </div>
  65. <div class="col">
  66. <div class="num">{{ item.cost }}<span class="unit"> 元/{{ item.unit }}</span></div>
  67. <div class="desc">报价</div>
  68. </div>
  69. <div class="col">
  70. <div class="num">{{ item.stock }}<span class="unit"> {{ item.unit }}</span></div>
  71. <div class="desc">库存</div>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="page-action">
  76. <div class="btn-primary" @click="handleAdd">新增药肥报价</div>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script setup>
  82. import { ref } from "vue";
  83. import { Search } from 'vant';
  84. import { useRouter } from "vue-router";
  85. import { ElMessageBox } from 'element-plus'
  86. const router = useRouter();
  87. const searchVal = ref("");
  88. const filterType = ref(["全部", "农药", "调节", "肥料"]);
  89. const activePlanIndex = ref(0);
  90. // 记录已展开卡片索引的集合
  91. const expandedSet = ref(new Set());
  92. const priceList = ref([
  93. { name: "46%尿素", brand: "东巨", typeName: "农药类/杀虫剂/胃毒性", useMode: "根部施", unit: "克", unitUsage: "5-7.5公斤", unitWaterAmount: "水稻", price: "0.02", cost: '0.007', stock: "43015" },
  94. { name: "硫酸铵", brand: "东巨", typeName: "农药类/杀虫剂/胃毒性", useMode: "根部施", unit: "克", unitUsage: "5-7.5公斤", unitWaterAmount: "水稻", price: "0.01", cost: '0.005', stock: "33426" },
  95. { name: "磷酸钙", brand: "兴发", typeName: "农药类/杀虫剂/胃毒性", useMode: "根部施", unit: "千克", unitUsage: "10-15公斤", unitWaterAmount: "水稻", price: "1.6", cost: '1.2', stock: "6745" },
  96. { name: "0.2%磷酸二氢钾溶液", brand: "亚泰", typeName: "农药类/杀虫剂/胃毒性", useMode: "叶面施", unit: "克", unitUsage: "50-100克", unitWaterAmount: "水稻", price: "0.04", cost: '0.01', stock: "17236" },
  97. { name: "0.15%-0.25%矮壮素", brand: "瑞普生", price: "0.03", cost: '0.01', stock: "2542", unit: "毫升", unitUsage: "按使用说明", typeName: "农药类/杀虫剂/胃毒性", useMode: "叶面施", unitWaterAmount: "水稻" },
  98. { name: "20%氯虫苯甲酰胺悬浮剂", brand: "立占", price: "0.08", cost: '0.02', stock: "3125", unit: "克", unitUsage: "10-15毫升", typeName: "农药类/杀虫剂/胃毒性", useMode: "叶面施", unitWaterAmount: "水稻" },
  99. ]);
  100. const handlePlanClick = (index) => {
  101. activePlanIndex.value = index;
  102. };
  103. const isExpanded = (index) => expandedSet.value.has(index);
  104. const toggleExpand = (index) => {
  105. const next = new Set(expandedSet.value);
  106. if (next.has(index)) {
  107. next.delete(index);
  108. } else {
  109. next.add(index);
  110. }
  111. expandedSet.value = next;
  112. };
  113. const handleEdit = (item) => {
  114. router.push({
  115. path: "/edit_price",
  116. query: { id: item.id }
  117. });
  118. };
  119. const openDelete = () => {
  120. ElMessageBox.confirm(
  121. '确认要删除该报价吗?',
  122. '提示',
  123. {
  124. confirmButtonText: '确认',
  125. cancelButtonText: '取消',
  126. type: 'warning',
  127. }
  128. )
  129. .then(() => {
  130. })
  131. .catch(() => {
  132. })
  133. }
  134. const handleAdd = () => {
  135. router.push({
  136. path: "/edit_price",
  137. query: { isAdd: true }
  138. });
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .fertilizer-price {
  143. ::v-deep {
  144. .van-search {
  145. background: #F5F7FB;
  146. .van-search__content {
  147. background: #FFFFFF;
  148. border-radius: 16px;
  149. }
  150. }
  151. }
  152. .record-filter {
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. padding: 5px 0;
  157. .filter-item {
  158. color: rgba(0, 0, 0, 0.5);
  159. padding: 0 16px;
  160. height: 32px;
  161. line-height: 32px;
  162. border-radius: 20px;
  163. color: #8B8B8B;
  164. &.active {
  165. color: #fff;
  166. background: #2199F8;
  167. }
  168. }
  169. .filter-item + .filter-item {
  170. margin-left: 8px;
  171. }
  172. }
  173. .fertilizer-list {
  174. padding: 8px 12px 80px;
  175. .fertilizer-card {
  176. margin-bottom: 10px;
  177. background: #FFFFFF;
  178. border-radius: 8px;
  179. // box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  180. padding: 12px 10px;
  181. .card-header {
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. .title {
  186. font-size: 16px;
  187. font-weight: 600;
  188. color: #000;
  189. }
  190. .action-btn {
  191. display: flex;
  192. gap: 10px;
  193. }
  194. }
  195. .info {
  196. padding-top: 4px;
  197. border-top: 1px solid #F5F5F5;
  198. margin-top: 8px;
  199. font-size: 14px;
  200. .row {
  201. display: flex;
  202. padding: 4px 0;
  203. .label {
  204. width: 80px;
  205. color: rgba(0, 0, 0, 0.2);
  206. flex-shrink: 0;
  207. }
  208. .value {
  209. color: #767676;
  210. }
  211. }
  212. .extra-info {
  213. overflow: hidden;
  214. }
  215. }
  216. .tag-group {
  217. display: flex;
  218. align-items: center;
  219. gap: 4px;
  220. .tag-item {
  221. font-size: 12px;
  222. color: #2199F8;
  223. background: #E8F3FF;
  224. border-radius: 2px;
  225. padding: 0 8px;
  226. height: 20px;
  227. line-height: 20px;
  228. }
  229. }
  230. .expand {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. color: rgba(0, 0, 0, 0.2);
  235. font-size: 12px;
  236. margin: 6px 0 12px;
  237. span { margin-right: 4px; }
  238. cursor: pointer;
  239. .el-icon { transition: transform .3s ease; }
  240. .el-icon.rotate { transform: rotate(180deg); }
  241. }
  242. .stats {
  243. display: flex;
  244. align-items: stretch;
  245. justify-content: space-between;
  246. background: rgba(33, 153, 248, 0.1);
  247. border: 1px solid rgba(33, 153, 248, 0.2);
  248. border-radius: 10px;
  249. padding: 10px 8px;
  250. font-size: 14px;
  251. .col {
  252. flex: 1;
  253. text-align: center;
  254. .num {
  255. color: #2199F8;
  256. font-weight: 600;
  257. font-size: 16px;
  258. .unit { font-size: 12px; font-weight: 400; color: rgba(0, 0, 0, 0.5); }
  259. }
  260. .desc { color: #000; margin-top: 4px; }
  261. }
  262. .col + .col { border-left: 1px solid rgba(33, 153, 248, 0.4); }
  263. }
  264. }
  265. .page-action {
  266. position: fixed;
  267. left: 0; right: 0; bottom: 0;
  268. padding: 10px 16px;
  269. background: #fff;
  270. box-shadow: 2px 2px 4.5px rgba(0, 0, 0, 0.4);
  271. .btn-primary {
  272. margin: 0 auto;
  273. height: 40px;
  274. line-height: 40px;
  275. border-radius: 20px;
  276. width: fit-content;
  277. padding: 0 20px;
  278. color: #fff;
  279. font-size: 14px;
  280. background: linear-gradient(#76C3FF, #2199F8);
  281. }
  282. }
  283. }
  284. }
  285. /* 折叠动画:使用 max-height + 透明度 以获得平滑过渡 */
  286. .collapse-enter-active,
  287. .collapse-leave-active { transition: max-height .3s cubic-bezier(0.4, 0, 0.2, 1), opacity .3s cubic-bezier(0.4, 0, 0.2, 1); }
  288. .collapse-enter-from,
  289. .collapse-leave-to { max-height: 0; opacity: 0; }
  290. .collapse-enter-to,
  291. .collapse-leave-from { max-height: 90px; opacity: 1; }
  292. </style>