新版交易所前段管理后台
1
admin
2026-01-20 b8fc0ec44bc61966a60a7d0f6a0d93f7b68928a5
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
<template>
  <el-dialog
    :title="'修改时间'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    :append-to-body="true"
    width="700px"
    @close="handClose"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="120px"
    >
      <el-form-item label="创建时间" prop="create_time">
        <el-date-picker
          v-model="dataForm.create_time"
          type="datetime"
          placeholder="选择创建时间"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="处理时间" prop="handle_time">
        <el-date-picker
          v-model="dataForm.handle_time"
          type="datetime"
          placeholder="选择处理时间"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="关闭时间" prop="close_time">
        <el-date-picker
          v-model="dataForm.close_time"
          type="datetime"
          placeholder="选择关闭时间"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="支付时间" prop="pay_time">
        <el-date-picker
          v-model="dataForm.pay_time"
          type="datetime"
          placeholder="选择支付时间"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import { Debounce } from "@/utils/debounce";
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        order_no: "",
        create_time: "",
        handle_time: "",
        close_time: "",
        pay_time: "",
      },
      dataRule: {},
    };
  },
  methods: {
    // 格式化时间为 yyyy-MM-dd HH:mm:ss 格式
    formatDateTimeForPicker(dateTime) {
      if (!dateTime) return "";
      
      let date;
      // 如果是字符串格式(可能包含T)
      if (typeof dateTime === "string") {
        // 替换T为空格,移除毫秒和时区
        const cleaned = dateTime.replace("T", " ").replace(/\.\d{3}Z?$/, "").replace(/Z$/, "");
        // 如果已经是 yyyy-MM-dd HH:mm:ss 格式,直接返回
        if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(cleaned)) {
          return cleaned;
        }
        date = new Date(dateTime);
      } else if (dateTime instanceof Date) {
        date = dateTime;
      } else {
        return "";
      }
      
      // 检查日期是否有效
      if (isNaN(date.getTime())) {
        return "";
      }
      
      // 格式化为 yyyy-MM-dd HH:mm:ss
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, "0");
      const day = String(date.getDate()).padStart(2, "0");
      const hours = String(date.getHours()).padStart(2, "0");
      const minutes = String(date.getMinutes()).padStart(2, "0");
      const seconds = String(date.getSeconds()).padStart(2, "0");
      
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    init(row) {
      this.dataForm = {
        order_no: row.order_no || "",
        create_time: this.formatDateTimeForPicker(row.create_time),
        handle_time: this.formatDateTimeForPicker(row.handle_time),
        close_time: this.formatDateTimeForPicker(row.close_time),
        pay_time: this.formatDateTimeForPicker(row.pay_time),
      };
      this.visible = true;
    },
    handClose() {
      // 关闭时重置表单
      this.$nextTick(() => {
        if (this.$refs["dataForm"]) {
          this.$refs["dataForm"].clearValidate();
        }
      });
    },
    // 表单提交
    dataFormSubmit: Debounce(function () {
      this.$refs["dataForm"].validate((valid) => {
        if (!valid) {
          return;
        }
        
        // 格式化时间字段,确保不包含"T"
        const formatTime = (time) => {
          if (!time) return "";
          return time.toString().replace("T", " ").replace(/\.\d{3}Z?$/, "");
        };
        
        this.$http({
          url: this.$http.adornUrl(`/c2cOrder/updateDate`),
          method: "post",
          data: this.$http.adornData({
            orderNo: this.dataForm.order_no,
            createDate: formatTime(this.dataForm.create_time),
            handleTime: formatTime(this.dataForm.handle_time),
            closeDate: formatTime(this.dataForm.close_time),
            payDate: formatTime(this.dataForm.pay_time),
          }),
        }).then(({ data }) => {
          if (data.code == 0) {
            this.$message({
              message: "修改时间成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.visible = false;
                this.$emit("refreshDataList", this.page);
              },
            });
          } else {
            this.$message({
              message: data.msg || "修改时间失败",
              type: "error",
              duration: 1500,
            });
          }
        });
      });
    }),
  },
};
</script>
 
<style lang="scss" scoped>
::v-deep .el-dialog__body {
  padding: 20px 20px;
}
 
::v-deep .avue-crud__menu {
  height: auto;
  min-height: 0px;
}
</style>