部门上传文件加分类和后缀名

master
王家东 3 weeks ago
parent 02ff92b78b
commit c258cc7d81
  1. 18
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depfile/controller/DepfileController.java
  2. 10
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depfile/entity/Depfile.java
  3. 10
      jeecgboot-vue3/src/views/depfile/Depfile.data.ts
  4. 10
      jeecgboot-vue3/src/views/depfile/components/DepfileForm.vue

@ -1,5 +1,7 @@
package org.jeecg.modules.demo.depfile.controller; package org.jeecg.modules.demo.depfile.controller;
import java.io.File;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -97,6 +99,10 @@ public class DepfileController extends JeecgController<Depfile, IDepfileService>
depfile.setUserid(user.getId()); depfile.setUserid(user.getId());
String depiid = depadminlxService.getdepid(user.getId()); String depiid = depadminlxService.getdepid(user.getId());
depfile.setDepid(depiid); depfile.setDepid(depiid);
String extension = getFileExtensionFromUrl(depfile.getUpfile());
System.out.println(depfile.getUpfile());
System.out.println(depfile.getUpfile());
depfile.setFilehz(extension);
depfileService.save(depfile); depfileService.save(depfile);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
@ -111,6 +117,10 @@ public class DepfileController extends JeecgController<Depfile, IDepfileService>
@ApiOperation(value="单位技术研究资质情况-编辑", notes="单位技术研究资质情况-编辑") @ApiOperation(value="单位技术研究资质情况-编辑", notes="单位技术研究资质情况-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody Depfile depfile) { public Result<String> edit(@RequestBody Depfile depfile) {
String extension = getFileExtensionFromUrl(depfile.getUpfile());
depfile.setFilehz(extension);
System.out.println(depfile.getUpfile());
System.out.println(depfile.getUpfile());
depfileService.updateById(depfile); depfileService.updateById(depfile);
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
} }
@ -181,6 +191,14 @@ public class DepfileController extends JeecgController<Depfile, IDepfileService>
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Depfile.class); return super.importExcel(request, response, Depfile.class);
} }
public static String getFileExtensionFromUrl(String fileUrl) {
File file = new File(fileUrl);
String fileName = file.getName();
String extension = fileName.substring(fileName.lastIndexOf(".") + 1);
return extension;
}
} }

@ -85,4 +85,14 @@ public class Depfile implements Serializable {
@Excel(name = "用户id", width = 15) @Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private java.lang.String userid; private java.lang.String userid;
/**文件后缀*/
@Excel(name = "文件后缀", width = 15)
@ApiModelProperty(value = "文件后缀")
private java.lang.String filehz;
/**文件类型*/
@Excel(name = "文件类型", width = 15, dicCode = "filetext")
@Dict(dicCode = "filetext")
@ApiModelProperty(value = "文件类型")
private java.lang.String filelx;
} }

@ -30,6 +30,16 @@ export const columns: BasicColumn[] = [
align: "center", align: "center",
dataIndex: 'upfile', dataIndex: 'upfile',
}, },
{
title: '文件后缀',
align: "center",
dataIndex: 'filehz'
},
{
title: '文件类型',
align: "center",
dataIndex: 'filelx_dictText'
},
]; ];
// //

@ -29,6 +29,12 @@
<j-upload v-model:value="formData.upfile" ></j-upload> <j-upload v-model:value="formData.upfile" ></j-upload>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24">
<a-form-item label="文件类型" v-bind="validateInfos.filelx" id="DepfileForm-filelx" name="filelx">
<j-dict-select-tag v-model:value="formData.filelx" dictCode="filetext" placeholder="请选择文件类型" allow-clear />
</a-form-item>
</a-col>
</a-row> </a-row>
</a-form> </a-form>
</template> </template>
@ -37,6 +43,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue'; import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
@ -61,6 +68,9 @@
depnumber: '', depnumber: '',
rdtime: '', rdtime: '',
upfile: '', upfile: '',
userid: '',
filehz: '',
filelx: '',
}); });
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });

Loading…
Cancel
Save