AllFormula.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <LjDrawer
  3. v-if="visible"
  4. ref="LjDrawerRef"
  5. :class="`${prefixCls}`"
  6. :id="prefixCls"
  7. direction="btt"
  8. size="70%"
  9. destroy-on-close
  10. append-to-body
  11. :show-close="false"
  12. @close="autoClose"
  13. >
  14. <template #header>
  15. <div class="flx-justify-between">
  16. <div class="">
  17. 详细报价
  18. <el-segmented v-model="dannumValue" :options="dannumOptions" class="ml-32" size="default" />
  19. </div>
  20. <div class="flx-shrink">
  21. <el-button type="danger" :icon="Close" text circle @click="cancelClick"></el-button>
  22. </div>
  23. </div>
  24. </template>
  25. <template #default>
  26. <template v-if="iforigin">
  27. <el-tabs v-model="activeName">
  28. <el-tab-pane label="新公式" name="first">
  29. <FormulaGroup :data="isNormalFormulas" :fields="isFieldsReplace" />
  30. </el-tab-pane>
  31. <el-tab-pane label="旧公式" name="second">
  32. <FormulaGroup :data="isNormalFormulasOri" :fields="isFieldsReplaceOri" />
  33. </el-tab-pane>
  34. </el-tabs>
  35. </template>
  36. <template v-else>
  37. <FormulaGroup :data="isNormalFormulas" :fields="isFieldsReplace" />
  38. </template>
  39. </template>
  40. </LjDrawer>
  41. </template>
  42. <script setup lang="ts" name="mattressQuoteDetail_AllFormula">
  43. import { ref, computed, watch, nextTick } from "vue";
  44. import LjDrawer from "@/components/LjDrawer/index.vue";
  45. import { useI18n } from "vue-i18n";
  46. import { useDesign } from "@/hooks/useDesign";
  47. import { useGlobalStore } from "@/stores/modules/global";
  48. import { Close, Search } from "@element-plus/icons-vue";
  49. import { ElSegmented } from "element-plus";
  50. import FormulaGroup from "./FormulaGroup.vue";
  51. import LjHeader from "@/components/LjHeader/index.vue";
  52. import { cloneDeep } from "lodash-es";
  53. interface WidgetProps {
  54. iforigin: boolean;
  55. }
  56. const props = withDefaults(defineProps<WidgetProps>(), {
  57. iforigin: false
  58. });
  59. const { t } = useI18n();
  60. const { prefixCls } = useDesign("bednet-formal-detail");
  61. const globalStore = useGlobalStore();
  62. const visible = ref(false);
  63. const LjDrawerRef = ref();
  64. const formulaList = ref<any>([]);
  65. const fieldsReplace = ref<any>([]);
  66. const formulaListOri = ref<any>([]);
  67. const differ = ref<any>([]);
  68. // const mainData = ref<any>({});
  69. const formulaMxList = ref<any>([]);
  70. const dannumValue = ref("标准");
  71. const dannumOptions = ["散单", "小单", "标准", "大单"];
  72. const isNormalFormulas = computed(() => {
  73. let _formula = formulaList.value.filter((item: any) => item.type == 0);
  74. let _formula1 = formulaList.value.filter((item: any) => item.type == 1);
  75. // _formula = _formula.map((item: any) => {
  76. // let _val = fieldsReplace.value.find((_item: any) => _item.label == item.label);
  77. // if (!_val) {
  78. // let tgItem = formulaList.value.find(_item => _item.value.indexOf(item.label) > -1);
  79. // if (tgItem) {
  80. // item.parentId = tgItem.label;
  81. // } else {
  82. // item.parentId = null;
  83. // }
  84. // } else {
  85. // item.parentId = null;
  86. // }
  87. // return item;
  88. // });
  89. // return buildTreeArr(_formula);
  90. _formula = formulaList.value.map((item: any) => {
  91. let matchArr = formulaList.value.filter((_item: any) => _item.type != 0 && item.value.indexOf(_item.label) > -1);
  92. if (matchArr.length > 0) {
  93. item.children = matchArr;
  94. }
  95. return item;
  96. });
  97. console.log("_formula :>> ", _formula);
  98. console.log(
  99. "_formula 0:>> ",
  100. _formula.filter((item: any) => item.type == 0)
  101. );
  102. // console.log("isNormalFormulas: >>> ", buildTreeArr(_formula));
  103. // return buildTreeArr(_formula);
  104. // let replaceFormula = cloneDeep(_formula.filter((item: any) => item.ifnotreplace == true));
  105. // _formula = cloneDeep(_formula.filter((item: any) => !item.ifnotreplace));
  106. // replaceFormula.map((item: any) => {
  107. // let index = _formula.findIndex((_item: any) => _item.value.indexOf(item.label) > -1);
  108. // if (index > -1) {
  109. // if (!Object.keys(_formula[index]).includes("children")) {
  110. // _formula[index].children = [];
  111. // }
  112. // item.ifnotreplace = null;
  113. // _formula[index].children.push(item);
  114. // }
  115. // });
  116. console.log("_formula :>> ", _formula);
  117. // console.log("isNormalFormulas: >>> ", buildTreeArr(_formula));
  118. // return buildTreeArr(_formula);
  119. return _formula.filter((item: any) => item.type == 0);
  120. });
  121. const isNormalFormulasOri = computed(() => {
  122. return formulaListOri.value.filter((item: any) => item.type == 0);
  123. });
  124. const getDannumType = computed(() => {
  125. let _type = 1;
  126. switch (dannumValue.value) {
  127. case "标准":
  128. _type = 2;
  129. break;
  130. case "散单":
  131. _type = 1;
  132. break;
  133. case "大单":
  134. _type = 3;
  135. break;
  136. case "小单":
  137. _type = 4;
  138. break;
  139. }
  140. return _type;
  141. });
  142. const isFieldsReplace = computed(() => {
  143. let tg = differ.value.find((item: any) => item.type == getDannumType.value);
  144. return tg.replace;
  145. });
  146. const isFieldsReplaceOri = computed(() => {
  147. let tg = differ.value.find((item: any) => item.type == getDannumType.value);
  148. return tg.replace_origin;
  149. });
  150. const isMxFormulas = computed(() => {
  151. return formulaList.value.filter((item: any) => item.type == 2);
  152. });
  153. // const isWeigthFormulas = computed(() => {
  154. // return formulaList.value.filter((item: any) => item.type == 3);
  155. // });
  156. const buildTreeArr = (items, parentId = null) => {
  157. return items
  158. .filter(item => item.parentId === parentId)
  159. .map(item => ({
  160. ...item,
  161. children: buildTreeArr(items, item.label)
  162. }));
  163. };
  164. const activeName = ref("first");
  165. const autoClose = () => {
  166. setTimeout(() => {
  167. visible.value = false;
  168. }, 200);
  169. };
  170. const cancelClick = () => {
  171. // searchField.value = "";
  172. LjDrawerRef.value.hide();
  173. // selectColumn.value = [];
  174. // ifAllSelect.value = false;
  175. };
  176. /**
  177. * @description 显示组件
  178. */
  179. const open = (data: any) => {
  180. switch (data.dannum_type) {
  181. case 2:
  182. dannumValue.value = "标准";
  183. break;
  184. case 1:
  185. dannumValue.value = "散单";
  186. break;
  187. case 3:
  188. dannumValue.value = "大单";
  189. break;
  190. case 4:
  191. dannumValue.value = "小单";
  192. break;
  193. }
  194. visible.value = true;
  195. formulaList.value = data.formula;
  196. fieldsReplace.value = data.replace;
  197. formulaListOri.value = data.formula_ori;
  198. differ.value = data.differ;
  199. // mainData.value = data;
  200. // formulaMxList.value;
  201. nextTick(() => {
  202. // list.value = cloneDeep(params);
  203. // oriList.value = cloneDeep(params);
  204. // let arr: string[] = [];
  205. // params.map((item: any) => {
  206. // if (item.basicinfo && item.basicinfo.hasOwnProperty("group")) {
  207. // item.basicinfo.group && !arr.includes(item.basicinfo.group) && arr.push(item.basicinfo.group);
  208. // }
  209. // });
  210. // groupList.value = arr;
  211. // selectGroup.value = group;
  212. LjDrawerRef.value.show();
  213. // console.log("open columnsDrag.value :>> ", columnsDrag.value);
  214. // nextTick(() => {
  215. // initDragSelect();
  216. // });
  217. });
  218. };
  219. defineExpose({
  220. open
  221. });
  222. </script>
  223. <style lang="scss" scoped>
  224. $prefix-cls: "#{$namespace}-bednet-formal-detail";
  225. .#{$prefix-cls} {
  226. .summary-wrapper {
  227. &__label-item {
  228. position: relative;
  229. margin-right: $space-a3;
  230. &::after {
  231. content: "=";
  232. position: absolute;
  233. bottom: 0;
  234. right: -$space-b3;
  235. font-size: 24px;
  236. color: $color-text-disable;
  237. }
  238. }
  239. }
  240. }
  241. </style>