|
@@ -53,15 +53,15 @@
|
|
|
|
|
|
<div style="margin-bottom: 20px;color: #00ffff80;font-family: PingFangSC-Regular;font-weight: 400;font-size: 14px;">支持.docx、.xlsx格式</div>
|
|
|
|
|
|
- <el-button style="width: 100px;margin-top: 10px;margin-right: 10px;border: 1px solid #00FFFF;border-radius: 2px;">提交</el-button>
|
|
|
- <el-button style="width: 100px;margin-top: 10px;background: rgba(15, 86, 86, 0.54);color: #00ffff;border: 1px solid #00FFFF;border-radius: 2px;">取消</el-button>
|
|
|
+ <el-button @click="changeIssueStatus" style="width: 100px;margin-top: 10px;margin-right: 10px;border: 1px solid #00FFFF;border-radius: 2px;">提交</el-button>
|
|
|
+ <el-button @click="close" style="width: 100px;margin-top: 10px;background: rgba(15, 86, 86, 0.54);color: #00ffff;border: 1px solid #00FFFF;border-radius: 2px;">取消</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { getFoodsList } from "@/api/screen/service";
|
|
|
+ import { changeIssueStatus, getFoodsList } from '@/api/screen/service'
|
|
|
import pinyin from "../data/pinyin.js";
|
|
|
|
|
|
export default {
|
|
@@ -83,17 +83,60 @@
|
|
|
this.$refs.fileInput.click();
|
|
|
},
|
|
|
|
|
|
+ changeIssueStatus() {
|
|
|
+ if (this.file == null){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 添加二次校验
|
|
|
+ if (!this.fileName.endsWith('.docx') && !this.fileName.endsWith('.xlsx')) {
|
|
|
+ this.$message.error('文件格式不符合要求');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const issueData = {
|
|
|
+ createDate:this.value,
|
|
|
+ title:this.title,
|
|
|
+ description:this.description,
|
|
|
+ id:this.getProList.id,
|
|
|
+ status: 1,
|
|
|
+ };
|
|
|
+
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append("file", this.file);
|
|
|
+ formData.append("issue", new Blob([JSON.stringify(issueData)], { type: "application/json" }));
|
|
|
+
|
|
|
+ changeIssueStatus(formData).then((res) => {
|
|
|
+ if (Number(res.code) === 200) {
|
|
|
+ this.close();
|
|
|
+ }
|
|
|
+ }).catch((err) => {
|
|
|
+ console.error("提交失败:", err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
handleFileChange(event) {
|
|
|
const file = event.target.files[0];
|
|
|
- if (file) {
|
|
|
- this.fileFlag = true
|
|
|
- const reader = new FileReader();
|
|
|
- reader.onload = (e) => {
|
|
|
- this.dialogImageUrl = e.target.result; // base64 编码的图片 URL
|
|
|
- };
|
|
|
- reader.readAsDataURL(file); // 读取文件并转换为 base64 格式
|
|
|
- console.log(this.dialogImageUrl)
|
|
|
+ if (!file) return;
|
|
|
+
|
|
|
+ // 添加文件类型白名单
|
|
|
+ const allowedExtensions = ['.docx', '.xlsx'];
|
|
|
+ const fileName = file.name.toLowerCase();
|
|
|
+
|
|
|
+ // 校验文件后缀
|
|
|
+ const isValidFile = allowedExtensions.some(ext => fileName.endsWith(ext));
|
|
|
+
|
|
|
+ if (!isValidFile) {
|
|
|
+ this.$message.error('仅支持上传.docx和.xlsx格式文件');
|
|
|
+ this.handleRemove(); // 清空错误文件
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ // 更新文件状态
|
|
|
+ this.fileName = file.name;
|
|
|
+ this.file = file;
|
|
|
+ this.fileFlag = true;
|
|
|
+
|
|
|
+ // 移除图片预览相关代码
|
|
|
+ this.dialogImageUrl = URL.createObjectURL(file) // 删除这行
|
|
|
},
|
|
|
handleRemove() {
|
|
|
this.fileFlag = false
|