ソースを参照

Merge branch '周转率' into 测试

lxf 1 年間 前
コミット
846bdc16ec

+ 12 - 2
src/components/byTable/index.vue

@@ -119,13 +119,16 @@
         :default-expand-all="defaultExpandAll || false"
         :cell-class-name="cellClassName"
         :span-method="spanMethod"
-        :border="borderStatus">
+        :border="borderStatus"
+        :default-sort="defaultSort">
         <el-table-column
           v-for="(item, index) in config"
           :key="index"
           v-bind="getAttrsValue(item)"
           :type="item.type || ''"
-          :selectable="(rowData, rowIndex) => isSelectable(rowData, rowIndex, item)">
+          :selectable="(rowData, rowIndex) => isSelectable(rowData, rowIndex, item)"
+          :sortable="item.sortable || false"
+          :prop="item.attrs.prop">
           <template #default="scope" v-if="!item.type">
             <slot :name="item.attrs.slot" :item="scope.row" v-if="item.attrs.slot"> 插槽占位符 </slot>
             <div v-else-if="isFunction(getValue(scope, item))">
@@ -270,6 +273,13 @@ export default defineComponent({
       type: Boolean,
       default: false,
     },
+    // 排序配置
+    defaultSort: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
   },
   setup(props) {
     const { proxy } = getCurrentInstance();

+ 17 - 1
src/views/group/data-board/turnover-rate/index.vue

@@ -5,10 +5,12 @@
         <el-row :gutter="10">
           <el-col :span="8">
             <byTable
+              ref="data30"
               :hidePagination="true"
               :source="sourceList.data30"
               :config="config"
               :loading="sourceList.loading30"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -37,10 +39,12 @@
           </el-col>
           <el-col :span="8">
             <byTable
+              ref="data60"
               :hidePagination="true"
               :source="sourceList.data60"
               :config="config"
               :loading="sourceList.loading60"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -69,10 +73,12 @@
           </el-col>
           <el-col :span="8">
             <byTable
+              ref="data90"
               :hidePagination="true"
               :source="sourceList.data90"
               :config="config"
               :loading="sourceList.loading90"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -105,10 +111,12 @@
         <el-row :gutter="10">
           <el-col :span="8">
             <byTable
+              ref="data30"
               :hidePagination="true"
               :source="sourceList.data30"
               :config="config"
               :loading="sourceList.loading30"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -137,10 +145,12 @@
           </el-col>
           <el-col :span="8">
             <byTable
+              ref="data60"
               :hidePagination="true"
               :source="sourceList.data60"
               :config="config"
               :loading="sourceList.loading60"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -169,10 +179,12 @@
           </el-col>
           <el-col :span="8">
             <byTable
+              ref="data90"
               :hidePagination="true"
               :source="sourceList.data90"
               :config="config"
               :loading="sourceList.loading90"
+              :defaultSort="{ prop: 'turnoverRate', order: 'ascending' }"
               highlight-current-row
               :action-list="[
                 {
@@ -207,6 +219,7 @@
 
 <script setup>
 import byTable from "/src/components/byTable/index";
+import { nextTick } from "vue";
 
 const { proxy } = getCurrentInstance();
 const activeName = ref("1");
@@ -239,6 +252,7 @@ const config = computed(() => {
         prop: "turnoverRate",
         width: 90,
       },
+      sortable: true,
     },
     {
       attrs: {
@@ -251,11 +265,13 @@ const config = computed(() => {
 });
 const getData = (days) => {
   sourceList.value["loading" + days] = true;
-  proxy.post("/turnoverRateBoard/getTurnoverRateStatisticsList", { bomClassify: activeName.value, days: days, sortField: 1 }).then((res) => {
+  proxy.post("/turnoverRateBoard/getTurnoverRateStatisticsList", { bomClassify: activeName.value, days: days, sortField: 1 }).then(async (res) => {
     sourceList.value["data" + days] = res;
     setTimeout(() => {
       sourceList.value["loading" + days] = false;
     }, 200);
+    await nextTick();
+    proxy.$refs["data" + days].hocElTable.sort("turnoverRate", "ascending");
   });
 };
 const getList = () => {