| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <div class="farm-table">
- <div class="new-wrap">
- <div class="new-title">
- <div class="title-1"><div class="table-name">类型</div></div>
- <div class="title-2"><div class="table-name">名称</div></div>
- <div class="title-3"><div class="table-name">品牌</div></div>
- <div class="title-4"><div class="table-name">单价</div></div>
- <div class="title-5"><div class="table-name">用量</div></div>
- <div class="title-6"><div class="table-name">总价</div></div>
- </div>
- <div
- class="new-table-wrap"
- >
- <div
- class="new-prescription"
- v-for="(subP, subI) in prescriptionData.pesticideFertilizerList"
- :key="subI"
- >
- <div class="new-table">
- <div class="line-l">
- <div class="line-1 title-1">{{ subP.typeName }}</div>
- <div class="line-2">{{ subP.name || subP.defaultName || subP.pesticideFertilizerName }}</div>
- <div class="title-3">{{ subP.brand }}</div>
- <div class="title-4">{{ subP.price }}</div>
- <div class="title-5">{{ subP.dosage }}</div>
- <div class="title-6">{{ getTotal(subP) }}元</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <slot name="bottomContent"></slot>
- </div>
- </template>
- <script setup>
- const props = defineProps({
- prescriptionData: {
- default: () => ({}),
- },
- // 面积(亩数),用于计算总价:单价 * 用量 * 面积
- area: {
- type: [Number, String],
- default: null,
- },
- });
- // 计算单个药肥的总价:单价 * 用量 * 面积
- const getTotal = (item) => {
- const price = Number(item?.price ?? 0);
- const dosage = Number(item?.dosage ?? 0);
- const area = props.area != null ? Number(props.area) : Number(item?.area ?? 0);
- // 如果有现成的 total 字段且无法计算,则退回使用 total
- if (!price || !dosage || !area) {
- return item?.total ?? "--";
- }
- return (price * dosage * area).toFixed(2);
- };
- </script>
- <style lang="scss" scoped>
- .box-wrap {
- background: #fff;
- padding: 10px;
- border-radius: 8px;
- }
- .card-title {
- font-size: 16px;
- font-weight: bold;
- color: #000;
- display: flex;
- align-items: center;
- .type-tag {
- margin-left: 5px;
- font-size: 12px;
- color: #000000;
- padding: 0 10px;
- background: rgba(119, 119, 119, 0.1);
- border-radius: 20px;
- font-weight: normal;
- height: 26px;
- line-height: 26px;
- }
- }
- .farm-table {
- .table-item {
- padding: 10px 0 12px 0;
- }
- .form-item {
- display: flex;
- align-items: center;
- font-size: 14px;
- color: #767676;
- height: 24px;
- .item-name {
- width: 80px;
- color: rgba(0, 0, 0, 0.2);
- }
- }
- }
- .new-wrap {
- border-radius: 5px;
- text-align: center;
- border: 1px solid rgba(225, 225, 225, 0.5);
- .new-title {
- background: rgba(241, 241, 241, 0.4);
- border-radius: 5px 5px 0 0;
- border-bottom: 1px solid rgba(225, 225, 225, 0.5);
- display: flex;
- color: #767676;
- // justify-content: space-around;
- padding: 5px 6px;
- font-size: 12px;
- .table-name {
- width: 24px;
- font-size: 12px;
- margin: 0 auto;
- }
- }
- .title-1 {
- width: 40px;
- }
- .title-2 {
- flex: 1;
- }
- .title-3 {
- width: 52px;
- }
- .title-4 {
- width: 56px;
- }
- .title-5 {
- width: 52px;
- }
- .title-6 {
- width: 52px;
- }
- .new-table-wrap {
- padding: 5px;
- .new-prescription {
- .new-table {
- display: flex;
- align-items: center;
- background: #fff;
- border-radius: 5px;
- color: rgba(0, 0, 0, 0.6);
- font-size: 11px;
- min-height: 45px;
- .line-l {
- display: flex;
- align-items: center;
- flex: 1;
- .line-2 {
- flex: 1;
- padding: 0 2px;
- }
- }
- .line-r {
- &.has-border {
- border-left: 1px solid rgba(225, 225, 225, 0.8);
- }
- .line-3 {
- display: flex;
- align-items: center;
- }
- .sub-line {
- padding: 10px 0;
- }
- .line-4 {
- display: flex;
- align-items: center;
- border-top: 1px solid rgba(225, 225, 225, 0.8);
- }
- .execute-line {
- border-right: 1px solid rgba(225, 225, 225, 0.8);
- }
- }
- }
- .note-text {
- margin: 8px 0 4px 0;
- color: rgba(0, 0, 0, 0.4);
- background: #fff;
- padding: 6px 8px;
- border-radius: 5px;
- text-align: left;
- font-size: 11px;
- }
- }
- .new-prescription + .new-prescription {
- padding-top: 8px;
- }
- }
- .new-table-wrap + .new-table-wrap {
- border-top: 1px solid rgba(0, 0, 0, 0.08);
- }
- }
- </style>
|