分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-23 663995bb11e71fa2960cc388d9e0bad6b9257439
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<template>
  <div class="example-tb">
    <el-alert
      title="table从后台api加载数据源"
      type="warning"
      show-icon
      :closable="false"
    >
      <p>
        1、只需要配置好列信息即可从后台加载(自动求和见代码中的备注说明或table组件api)。
      </p>
      <p>
        2、如果需要筛选条件,在loadTableBefore方法中按demo格式提交查询参数即可
      </p>
      <p>
        3、具体使用见:框架文档->组件api->voltable。<a
          href="http://v2.volcore.xyz/document/api"
          target="_blank"
          >点击查看文档
        </a>
      </p>
    </el-alert>
    <div class="tb">
      <div class="search-info">
        <vol-form
          :label-width="80"
          ref="myform"
          class="my-form"
          :formFields="searchFields"
          :formRules="formOptions"
        >
        </vol-form>
        <div class="btns">
          <el-button type="danger" size="small" @click="getSelectRows"
            >获取选中行</el-button
          >
          <el-button type="primary" size="small" @click="search"
            ><i class="el-icon-search"></i>搜索</el-button
          >
        </div>
      </div>
      <vol-table
        ref="table"
        :columns="columns"
        :pagination-hide="false"
        :max-height="400"
        :url="url"
        :index="true"
        @loadBefore="loadTableBefore"
        @loadAfter="loadTableAfter"
      ></vol-table>
    </div>
  </div>
</template>
<script>
import VolTable from "@/components/basic/VolTable.vue";
import VolForm from "@/components/basic/VolForm.vue";
export default {
  components: { VolTable, VolForm },
  created() {},
  data() {
    return {
      //查询条件字段
      searchFields: {
        TranNo: "",
        CreateDate: [],
        OrderType: null,
      },
      formOptions: [
        //表单配置见表单组件文档
        [
          {
            title: "运单号",
            field: "TranNo",
            placeholder: "模糊查询",
          },
          {
            title: "订单类型",
            field: "OrderType",
            dataKey: "ordertype",
            placeholder: "订单类型",
            data: [],
            type: "select",
          },
          {
            title: "创建时间",
            range: true,
            colSize: 6,
            field: "CreateDate",
            type: "date",
            onChange:(val)=>{
           
            }
          },
        ],
      ],
      viewModel: false, //点击单元格时弹出框
      url: "api/SellOrder/getPageData", //后从加载数据的url
      columns: [
        { field: "Order_Id", title: "Id", width: 90, hidden: true },
        {
          field: "TranNo",
          title: "运单号",
          type: "string",
          width: 130,
          sort: true,
        },
        {
          field: "OrderType",
          title: "订单类型",
          type: "int",
          bind: { key: "ordertype", data: [] },
          width: 90,
          sort: true,
        },
        {
          field: "Qty",
          title: "销售数量",
          type: "int",
          width: 90,
          sort: true,
          summary: true, //前端只设置summary: true 即可求后,后台见SellOrderService.cs中查询方法说明
        },
        {
          field: "AuditStatus",
          title: "审核状态",
          type: "int",
          bind: { key: "audit", data: [] },
          width: 90,
          sort: true,
        },
        {
          field: "AuditDate",
          title: "审核时间",
          type: "datetime",
          width: 120,
          sort: true,
          sort: true,
        },
        {
          field: "Remark",
          title: "备注",
          type: "string",
          width: 100,
          sort: true,
        },
        {
          field: "Creator",
          title: "创建人",
          type: "string",
          width: 100,
          sort: true,
        },
        {
          field: "CreateDate",
          title: "创建时间",
          type: "datetime",
          width: 90,
          sort: true,
        },
      ],
    };
  },
  methods: {
    //点击查询时生成查询条件
    loadTableBefore(param, callBack) {
      console.log("加载数据前" + param);
      //生成查询条件
      param.wheres = [
        //设置为like模糊查询
        {
          name: "TranNo",
          value: this.searchFields.TranNo,
          displayType: "like",
        },
        {
          name: "OrderType",
          value: this.searchFields.OrderType,
        },
        {
          name: "CreateDate",
          value: this.searchFields.CreateDate[0],
          displayType: "thanorequal", //>=
        },
        {
          name: "CreateDate",
          value: this.searchFields.CreateDate[1],
          displayType: "lessorequal", //<=
        },
      ];
      callBack(true); //此处必须进行回调,返回处理结果,如果是false,则不会执行后台查询
    },
    loadTableAfter(data, callBack) {
      //此处是从后台加数据后,你可以在渲染表格前,预先处理返回的数据
      console.log("加载数据后" + data);
      callBack(true); //同上
    },
    search() {
      this.$refs.table.load();
    },
    del() {
      let rows = this.$refs.table.getSelected();
      if (rows.length == 0) {
        return this.$message.error("请先选中行");
      }
      this.$refs.table.delRow();
      //此处可以接着写删除后台的代码
    },
    getSelectRows() {
      let rows = this.$refs.table.getSelected();
      if (rows.length == 0) {
        return this.$message.error("请先选中行1");
      }
      let text = "当前选中的行数据:" + JSON.stringify(rows);
      this.$Message.info(text);
    },
  },
};
</script>
<style lang="less" scoped>
.example-tb {
  padding: 15px;
}
.tb {
  margin-top: 15px;
}
.v-header {
  background: white;
  padding: 10px;
}
.search-info {
  display: flex;
  .my-form {
    width: 840px !important;
    margin-bottom: -15px;
  }
  .btns {
    margin-left: 15px;
    position: relative;
    margin-top: 2px;
  }
}
</style>