董国庆
2025-03-27 b92ee4b804a085c681117731ecc64c2bd28c20cd
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
<template>
  <el-dialog
    :title="title"
    :visible.sync="visible"
    width="600px"
    @open="open"
    :close-on-click-modal="false"
    append-to-body
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="批次号" prop="batchNumber">
        <el-input
          :disabled="batchNumber"
          v-model="form.batchNumber"
          placeholder="请输入"
          clearable
        ></el-input>
      </el-form-item>
      <div>
        <el-form-item label="导入资金表" prop="assetFile" v-if="type != 2">
          <el-upload
            class="upload-container"
            action="#"
            drag
            :auto-upload="false"
            accept=".xlsx,.xls"
            :on-change="handlehouseholdFileChangePrice"
            :limit="1"
          >
            <div class="upload-area">
              <i class="el-icon-folder"></i>
              <div class="upload-text">点击或将文件文件拖拽到这里上传</div>
              <div class="upload-tip">支持格式:.xlsx、.xls...</div>
            </div>
            <div slot="tip" class="el-upload__tip">已上传:</div>
          </el-upload>
        </el-form-item>
 
        <el-form-item label="导入购房表" prop="householdFile" v-if="type != 1">
          <el-upload
            class="upload-container"
            action="#"
            drag
            :auto-upload="false"
            accept=".xlsx,.xls"
            :on-change="handlehouseholdFileChange"
            :limit="1"
          >
            <div class="upload-area">
              <i class="el-icon-folder"></i>
              <div class="upload-text">点击或将文件文件拖拽到这里上传</div>
              <div class="upload-tip">支持格式:.xlsx、.xls...</div>
            </div>
            <div slot="tip" class="el-upload__tip">已上传:</div>
          </el-upload>
        </el-form-item>
      </div>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
      <el-button type="primary" @click="handleSubmit" :loading="loading"
        >确 认</el-button
      >
    </div>
  </el-dialog>
</template>
 
<script>
export default {
  name: "ExportMoneyApplay",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    type: {
      type: Number,
      default: 3,
    },
    title: {
      type: String,
      default: "导入自主购房安置资金申请",
    },
    batchNumber: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      loading: false,
      uploadUrl: "/api/upload", // 上传地址
      form: {
        batchNumber: "",
        assetFile: "",
        householdFile: "",
      },
      rules: {
        batchNumber: [
          { required: true, message: "请输入批次号", trigger: "blur" },
        ],
        assetFile: [
          { required: true, message: "请上传资金表", trigger: "change" },
        ],
        householdFile: [
          { required: true, message: "请上传购房表", trigger: "change" },
        ],
      },
    };
  },
  methods: {
    open() {
      console.log("333333333333333333", this.batchNumber);
      this.form.batchNumber = JSON.parse(JSON.stringify(this.batchNumber));
    },
    handlehouseholdFileChange(file, fileList) {
      this.form.householdFile = file.raw;
      this.$refs.form.validateField("householdFile");
    },
    handlehouseholdFileChangePrice(file, fileList) {
      this.form.assetFile = file.raw;
      this.$refs.form.validateField("assetFile");
    },
    // 移除文件
    handleRemoveFile(file, type) {
      if (type === "money") {
        this.form.assetFile = "";
        this.$refs.form.validateField("assetFile");
      } else {
        this.form.householdFile = "";
        this.$refs.form.validateField("householdFile");
      }
    },
    // 取消
    handleCancel() {
      this.$emit("update:visible", false);
      this.resetForm();
    },
    // 提交
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true;
          if (this.type == 2) {
            delete this.form.assetFile;
          }
          this.$emit("importPrice", this.form);
          setTimeout(() => {
            this.loading = false;
            this.resetForm();
          }, 1000);
        }
      });
    },
    // 重置表单
    resetForm() {
      this.form = {
        batchNumber: "",
        assetFile: "",
        householdFile: "",
      };
      this.$refs.form && this.$refs.form.resetFields();
    },
  },
};
</script>
 
<style lang="scss" scoped>
::v-deep .el-upload-dragger {
  width: 100%;
  height: unset !important;
}
 
.upload-container {
  .upload-area {
    width: 100%;
    height: 120px;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #666;
 
    &:hover {
      border-color: #409eff;
    }
 
    .el-icon-folder {
      font-size: 28px;
      color: #8c939d;
      margin-bottom: 10px;
    }
 
    .upload-text {
      font-size: 14px;
      margin-bottom: 5px;
    }
 
    .upload-tip {
      font-size: 12px;
      color: #999;
    }
  }
 
  .file-item {
    display: flex;
    align-items: center;
    margin-top: 8px;
 
    .el-icon-document {
      margin-right: 5px;
      color: #909399;
    }
 
    .file-name {
      flex: 1;
      color: #606266;
    }
 
    .el-icon-close {
      cursor: pointer;
      color: #909399;
 
      &:hover {
        color: #f56c6c;
      }
    }
  }
}
 
.dialog-footer {
  text-align: center;
}
</style>