cloudroam
2024-11-22 0390f5ab4b062a9146cd7d92bdd91954a052e13d
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<template>
  <el-dialog append-to-body
             :visible.sync="open"
             class="equ-add-form-dialog"
             :close-on-click-modal="true"
  >
    <div class="equ-form equ-form-add">
      <div class="equ-form-container">
 
        <div class="flex m-t-2rem">
          <div class="label require">区域编号:</div>
          <el-input v-model="areacode"></el-input>
        </div>
        <div class="flex m-t-2rem">
          <div class="label require">区域名称:</div>
          <el-input v-model="areaName"></el-input>
        </div>
        <div class="flex m-t-2rem">
          <div class="label require">布局数量:</div>
          <el-input v-model="areaConfigNum"></el-input>
        </div>
        <div class="flex m-t-2rem">
          <div class="label require">首页背景:</div>
          <el-upload
              class="upload-demo"
              action="http://localhost:44311/home/UploadFile"
              :before-upload="beforeUpload"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              :on-success="handleSuccess"
              :on-error="handleError"
              multiple
              :limit="1"
              :on-exceed="handleExceed"
              :file-list="fileList">
            <el-button size="small" type="primary" class="button-container">点击上传</el-button>
          </el-upload>
        </div>
        <div class="flex m-t-2rem">
          <div class="label require">区域背景:</div>
          <el-upload
              class="upload-demo"
              action="http://localhost:44311/home/UploadFile"
              :before-upload="beforeUpload"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              :on-success="handleSuccess2"
              :on-error="handleError"
              multiple
              :limit="1"
              :on-exceed="handleExceed"
              :file-list="fileList2">
            <el-button size="small" type="primary" class="button-container">点击上传</el-button>
          </el-upload>
        </div>
        <div class="m-t-2rem flex">
          <div style="text-align: center;" class="flex">
            <div class="equ-form-add-button-confirm" @click="submit">确认</div>
            <div class="equ-form-add-button-cancel" @click="open = false">取消</div>
          </div>
 
        </div>
      </div>
    </div>
  </el-dialog>
</template>
 
<script>
import {addAreaItemInfo} from "@/api/addareaitem";
 
export default {
  props: {
    menuPositionx:'',
    menuPositiony:'',
  },
  data() {
    return {
      open: false,
      fileList: [],
      fileList2: [],
      uploadUrl: '',
      areaBackGroudURL: '',
      areacode: '',
      areaConfigNum: '',
      areaName: '',
      num: 1,
      editItemId: '',
      filename1: '',
      filename2: '',
    };
  },
  mounted() {
  },
  methods: {
      async submit() {
 
        if (!this.uploadUrl || !this.areaBackGroudURL || !this.areacode || !this.areaConfigNum || !this.areacode) {
          this.$message.warning("数据未填写完整");
          return;
        }
        await this.$modal.confirm("确定新增区域吗?");
        var dto = {
          xVal: this.menuPositionx,
          yVal: this.menuPositiony,
          uRL: this.uploadUrl,
          areaBackGroudURL: this.areaBackGroudURL,
          areaConfigNum : this.areaConfigNum,
          areacode: this.areacode,
          tVal: this.areaName,
          moduleName : this.filename1,
          areaBackGroudName : this.filename2,
        };
        const re = await addAreaItemInfo(dto);
        if (re.isSuccess) {
          this.$emit('update-area-list'); // 触发自定义事件
          this.$message.success("创建成功");
          this.open = false;
        }
      },
    openConfig() {
      this.open = !this.open;
    },
    editConfig(editItem) {
      this.open = !this.open;
      console.log("editItem",editItem)
      this.editItemId = editItem.id;
      this.areacode = editItem.areacode;
      this.areaName = editItem.t;
      this.areaConfigNum = editItem.areaConfigNum;
      var fileInfo1 = {
        name : editItem.moduleName,
      }
      var fileInfo2 = {
        name : editItem.areaBackGroudName,
      }
      this.fileList[0] = fileInfo1;
      this.fileList2[0].name = fileInfo2;
 
      console.log( " this.fileList",this.fileList)
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
      //删除文件
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}?`);
    },
    handleChange(value) {
      console.log(value);
    },
    async beforeUpload(file) {
      return true;
    },
    handleSuccess(response, file, fileList) {
      // 在这里处理文件上传成功的逻辑,例如保存响应数据到组件的状态中。
      this.$message.success('文件上传成功');
      console.log('文件上传成功', response);
      this.uploadUrl = response.result;
      this.filename1 = file.name;
      console.log('文件上传成功地址', this.uploadUrl);
    },
    handleError(err, file, fileList) {
      // 在这里处理文件上传失败的逻辑,例如显示错误消息。
      this.$message.error('文件上传失败');
      console.error('文件上传失败', err);
    },
    handleSuccess2(response, file, fileList) {
      // 在这里处理文件上传成功的逻辑,例如保存响应数据到组件的状态中。
      this.$message.success('文件上传成功');
      console.log('文件上传成功', response);
      this.areaBackGroudURL = response.result;
      this.filename2 = file.name;
      console.log('文件上传成功地址', this.uploadUrl);
    },
  },
  watch: {},
};
</script>
<style lang="scss">
.equ-add-form-dialog .el-dialog {
  background: none !important;
  box-shadow: none !important;
}
</style>
 
<style lang="scss" scoped>
.equ-form-add-button {
  width: 4.1rem;
  height: 4.1rem;
  background-size: 100% 100%;
  background-image: url("../assets/area/equ-form-add-button.svg");
  cursor: pointer;
}
 
.equ-form-add {
  display: flex;
  margin: 0 auto;
  width: fit-content;
  margin-bottom: 80px;
  margin-top: 60px;
}
 
.equ-form-container {
  //靠右
  margin-left: 1rem;
  width: 37.6rem;
  background: #ffffff;
  box-shadow: 0rem 0.2rem 3.4rem 0rem #bccbdd;
  border-radius: 1rem;
  padding: 2.2rem;
  padding-bottom: 1.5rem;
 
  .label {
    width: 12rem;
    font-size: 1.6rem;
    font-family: SourceHanSansCN-Bold, SourceHanSansCN;
    font-weight: bold;
    color: #333333;
    line-height: 2em;
    margin-right: 1rem;
    text-align: left;
  }
 
  .require::before {
    content: "*";
    color: red;
  }
 
  .value.input {
    width: 25rem;
    max-width: 25rem;
    height: 3.2rem;
    border-radius: 0.2rem;
    border: 0.1rem solid #6c99be !important;
    padding-left: 0.8rem;
  }
 
  .value.input::placeholder,
  .value.select::placeholder {
    font-family: SourceHanSansCN-Regular, SourceHanSansCN;
    font-weight: 400;
    color: #6c99be;
  }
 
  .value.select {
    width: 26.1rem;
 
    height: 3.2rem;
    border-radius: 0.2rem;
    border: 0.1rem solid #6c99be;
    padding-left: 0.5rem;
    color: #6c99be;
  }
 
  .equ-form-add-button-confirm {
    width: 10.5rem;
    height: 3.6rem;
    background: #278afa;
    border-radius: 0.4rem;
 
    font-size: 1.6rem;
    font-family: SourceHanSansCN-Regular, SourceHanSansCN;
    font-weight: 400;
    color: #ffffff;
    line-height: 3.2rem;
    margin-left: auto;
    margin-right: 0;
    cursor: pointer;
  }
 
  .equ-form-add-button-cancel {
    width: 10.5rem;
    height: 3.6rem;
    border: 1px solid #278afa;
    border-radius: 0.4rem;
 
    font-size: 1.6rem;
    font-family: SourceHanSansCN-Regular, SourceHanSansCN;
    font-weight: 400;
    color: #333;
    line-height: 3.2rem;
    margin-left: 16.7rem;
    margin-right: 0;
    cursor: pointer;
  }
 
  .button-container {
    width: 18rem;
    height: 40px;
  }
}
</style>