Statistic.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div style="display: table">
  3. <el-row class="statistic-row h-full" :gutter="8" style="width: 180px" :class="{ 'is-admin': userInfo.usermode === 0 }">
  4. <el-col :span="24" v-for="(item, index) in statisticData" :key="index">
  5. <StatisticItem :data="item" v-bind="$attrs" :iforigin="props.iforigin" @click="handleClick(item)" />
  6. </el-col>
  7. </el-row>
  8. </div>
  9. </template>
  10. <script setup lang="ts" name="mattressQuoteDetail_statistic">
  11. import { ref, watch } from "vue";
  12. import StatisticItem from "./StatisticItem.vue";
  13. import { useUserStore } from "@/stores/modules/user";
  14. interface WidgetProps {
  15. data: any;
  16. differ?: any;
  17. iforigin?: any;
  18. }
  19. interface statisticDataProps {
  20. /**
  21. * @desciption: replace关键字
  22. */
  23. key: string;
  24. label: string;
  25. subtitle?: string;
  26. value: number;
  27. origin?: number;
  28. /**
  29. * @desciption: 大小单类型
  30. */
  31. type?: number;
  32. power?: () => boolean;
  33. }
  34. const props = withDefaults(defineProps<WidgetProps>(), {
  35. iforigin: false
  36. });
  37. const emit = defineEmits(["click"]);
  38. const { userInfo } = useUserStore();
  39. // const statisticData = ref<statisticDataProps[]>([
  40. // {
  41. // label: "【标准金额】",
  42. // value: 0,
  43. // origin: 0
  44. // },
  45. // {
  46. // label: "【大单金额】",
  47. // value: 0,
  48. // origin: 0
  49. // },
  50. // {
  51. // label: "【车间成本】",
  52. // value: 0,
  53. // origin: 0,
  54. // power: () => {
  55. // console.log("userInfo.usermode342 :>> ", userInfo.usermode);
  56. // return userInfo.usermode === 0;
  57. // }
  58. // },
  59. // {
  60. // label: "【不含税出厂价】",
  61. // value: 0,
  62. // origin: 0,
  63. // power: () => {
  64. // return userInfo.usermode === 0;
  65. // }
  66. // },
  67. // {
  68. // label: "【部门含税价】",
  69. // value: 0,
  70. // origin: 0,
  71. // subtitle: "财务底价",
  72. // power: () => {
  73. // return userInfo.usermode === 0;
  74. // }
  75. // },
  76. // {
  77. // label: "【税金】",
  78. // value: 0,
  79. // origin: 0,
  80. // power: () => {
  81. // return userInfo.usermode === 0;
  82. // }
  83. // },
  84. // {
  85. // label: "【部门含税价】",
  86. // value: 0,
  87. // origin: 0,
  88. // power: () => {
  89. // return userInfo.usermode === 0;
  90. // }
  91. // },
  92. // {
  93. // label: "【外币价】",
  94. // value: 0,
  95. // origin: 0,
  96. // subtitle: "报价金额",
  97. // power: () => {
  98. // return userInfo.usermode === 0;
  99. // }
  100. // }
  101. // ]);
  102. const statisticData = ref<statisticDataProps[]>([
  103. {
  104. label: "【散单金额】",
  105. value: 0,
  106. origin: 0,
  107. key: "【部门含税价】",
  108. type: 1
  109. },
  110. {
  111. label: "【小单金额】",
  112. value: 0,
  113. origin: 0,
  114. key: "【部门含税价】",
  115. type: 4
  116. },
  117. {
  118. label: "【标准金额】",
  119. value: 0,
  120. origin: 0,
  121. key: "【部门含税价】",
  122. type: 2
  123. },
  124. {
  125. label: "【大单金额】",
  126. value: 0,
  127. origin: 0,
  128. key: "【部门含税价】",
  129. type: 3
  130. }
  131. ]);
  132. watch(
  133. () => props.differ,
  134. val => {
  135. console.log("props.differ val :>> ", val);
  136. statisticData.value = statisticData.value.filter(o => {
  137. // let tg = val.find(item => item.label === o.key);
  138. let tg = val.find(item => item.type === o.type);
  139. if (tg) {
  140. let tgRl = tg.replace.find(item => item.label === o.key);
  141. o.value = tgRl ? tgRl.value : 0;
  142. console.log("tgRl, :>> ", props.iforigin, tgRl);
  143. if (props.iforigin) {
  144. let tgori = tg.replace_origin.find(item => item.label === o.key);
  145. o.origin = tgori ? tgori.value : 0;
  146. }
  147. }
  148. if (o?.power) {
  149. return o.power();
  150. } else {
  151. return true;
  152. }
  153. });
  154. // statisticData.value = statisticData.value.filter(o => o);
  155. },
  156. { immediate: true, deep: true }
  157. );
  158. const handleClick = (item: any) => {
  159. if (userInfo.usermode === 0) {
  160. emit("click", item);
  161. }
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. .statistic-row {
  166. border-radius: 8px;
  167. // background-color: $color-gray-3;
  168. padding: 8px 12px;
  169. // background-color: $color-primary-400;
  170. background-color: $color-primary-000;
  171. &.is-admin {
  172. cursor: pointer;
  173. }
  174. > .el-col:not(:nth-child(1)) {
  175. margin-top: 8px;
  176. .statistic-card {
  177. border-top: 0.5px solid var(--lj-color-text-border) !important;
  178. }
  179. }
  180. }
  181. </style>