分支自 SuZhouGuanHong/TaiYuanTaiZhong

PCS
dengjunjie
2023-12-13 113d1d4262d8f9e78a9d92123713c41669ad6c87
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
<template>
  <div style="margin-top: 15px; padding: 0 16px">
    <el-tabs type="border-card" style="min-height: 320px; box-shadow: none">
      <el-tab-pane>
        <template #label>
          <span><i class="el-icon-date"></i> 订单明细</span>
        </template>
        <vol-table
          ref="tableList"
          :loadKey="true"
          :columns="columns"
          :pagination-hide="false"
          :height="230"
          :defaultLoadPage="false"
          @loadBefore="loadBefore"
          :endEditAfter="endEditAfter"
          url="/api/SellOrder/getDetailPage"
          :row-index="true"
          :columnIndex="true"
          :index="true"
          :click-edit="true"
        ></vol-table>
      </el-tab-pane>
      <el-tab-pane :lazy="true" label="消息中心">消息中心</el-tab-pane>
      <el-tab-pane :lazy="true" label="角色管理">角色管理</el-tab-pane>
      <el-tab-pane :lazy="true" label="定时任务补偿">定时任务补偿</el-tab-pane>
    </el-tabs>
  </div>
</template>
 
<script>
import VolTable from "@/components/basic/VolTable.vue";
export default {
  components: {
    VolTable,
  },
  methods: {
    loadBefore(params, callback) {
      //设置查询 条件
 
      var _row;
      //获取主表选中的行
      this.$emit("parentCall", ($vue) => {
        var rows = $vue.getSelectRows();
        if (rows.length) {
          _row = rows[0];
        }
      });
      if (!_row) {
        //取消选中,清空明细
        return (this.$refs.tableList.rowData.length = 0);
        //  return this.$Message.error("请选中主表行数据");
      }
 
      //设置查询条件,用主表id加载明细表数据(如果是自己定义的接口,这里条件自己处理)
      params.value = _row.Order_Id;
      //设置排序字段(如果是自己定义的接口,排序字段不一定填写)
      if (!params.sort) {
        params.sort = "CreateDate";
      }
      return callback(true);
    },
    endEditAfter(row) {
      //结束编辑时,可以直接调用后台的代码进行保存
      console.log(row);
      return true;
    },
    save(row) {
      //保存
      this.$Message.info("保存");
    },
    del(row) {
      this.$confirm(
        "确认要删除此行数据【" + row.ProductName + "】??",
        "确认信息",
        {
          distinguishCancelAndClose: true,
          confirmButtonText: "确认删除",
          cancelButtonText: "取消",
            center: true
        }
      )
        .then(() => {
          this.$message({
            type: "info",
            message: "提交删除请求",
          });
        })
    },
    getRender() {
      //生成表格编辑配置
      return (h, { row, column, index }) => {
        return h(
          "div",
          {
            style: {
              cursor: "pointer",
              color: " #409eff",
              "font-size": "13px",
            },
          },
          [
            h(
              "a",
              {
                props: {},
                style: { "border-bottom": "1px solid" },
                onClick: (e) => {
                  e.stopPropagation();
                  this.del(row);
                },
              },
              "删除"
            ),
            h(
              "a",
              {
                props: {},
                style: { "margin-left": "9px", "border-bottom": "1px solid" },
                onClick: (e) => {
                  e.stopPropagation();
                  this.$refs.tableList.edit.rowIndex = index;
                },
              },
              "编辑"
            ),
            h(
              "a",
              {
                props: {},
                style: { "margin-left": "9px", "border-bottom": "1px solid" },
                onClick: (e) => {
                  e.stopPropagation();
                  //强制结束编辑
                  this.$refs.tableList.edit.rowIndex = -1;
                  this.save();
                },
              },
              "保存"
            ),
          ]
        );
      };
    },
  },
  data() {
    return {
      tableData: [],
      //从生成的代码sellorder2.vue里面把明细配置复制过来就能用
      columns: [
        {
          field: "OrderList_Id",
          title: "OrderList_Id",
          type: "string",
          width: 90,
          hidden: true,
          require: true,
        },
        {
          field: "Order_Id",
          title: "订单Id",
          type: "string",
          width: 90,
          hidden: true,
          readonly: true,
        },
        {
          field: "ProductName",
          title: "商品名称",
          type: "string",
          bind: { key: "pn", data: [] },
          width: 150,
          edit: { type: "select" },
          require: true,
        },
        {
          field: "MO",
          title: "批次",
          type: "string",
          width: 100,
          edit: { type: "" },
          require: true,
          sort: true,
        },
        {
          field: "Qty",
          title: "数量",
          type: "int",
          width: 90,
          edit: { type: "drop" },
          summary: true, //设置求和
          require: true,
        },
        {
          field: "Weight",
          title: "重量",
          type: "decimal",
          summary: true, //设置求和
          width: 90,
          edit: { type: "" },
        },
        {
          field: "Creator",
          title: "创建人",
          type: "string",
          width: 100,
        },
        {
          field: "CreateDate",
          title: "创建时间",
          type: "datetime",
          width: 140,
          sort: true,
        },
        {
          title: "操作",
          width: 110,
          align: "center",
          render: this.getRender(),
        },
      ],
    };
  },
};
</script>
<style scoped>
h3 {
  font-weight: 500;
  padding-left: 10px;
  background: white;
  margin-top: 10px;
  padding-top: 6px;
  padding-bottom: 5px;
}
</style>