Browse Source

[feat]通过模块

修改附件表:新增业务Id和业务key作为上传模块的识别
附件实体类新增新增业务Id和业务key
新增 通用不分文件类型的单文件上传请求后端接口
新增 通过业务id查询附件集合后端接口
国税发票实体类新增 附件集合
修改国税发票上传:新增操作附件数据
修改国税发票列表页面,所有按钮加上条件判断
修改上传国税发票页面,修改上传组件和方法
修改上传国税发票详情页面,修改上传组件和方法
dev
liuxiaoxu 3 months ago
parent
commit
c3ff210396
  1. 5
      ruoyi-admin/src/main/java/com/ruoyi/common/service/ICommonService.java
  2. 42
      ruoyi-admin/src/main/java/com/ruoyi/common/service/impl/CommonServiceImpl.java
  3. 12
      ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialTaxInvoice.java
  4. 71
      ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialTaxInvoiceServiceImpl.java
  5. 25
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysAttachFile.java
  6. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachFileMapper.java
  7. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysAttachFileService.java
  8. 9
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysAttachFileServiceImpl.java
  9. 13
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
  10. 20
      ruoyi-admin/src/main/resources/mapper/financial/FinancialTaxInvoiceMapper.xml
  11. 15
      ruoyi-admin/src/main/resources/mapper/system/SysAttachFileMapper.xml
  12. 17
      ruoyi-admin/src/main/resources/templates/financial/taxInvoice/taxInvoice.html
  13. 5
      ruoyi-admin/src/main/resources/templates/financial/taxInvoice/uploadInvoiceRMB.html
  14. 216
      ruoyi-admin/src/main/resources/templates/financial/taxInvoice/uploadInvoiceRMBDetail.html

5
ruoyi-admin/src/main/java/com/ruoyi/common/service/ICommonService.java

@ -18,4 +18,9 @@ public interface ICommonService {
AjaxResult delete(Long id);
void deleteByIds(List<String> ids);
/**
* 通用不分文件类型的单文件上传请求
*/
AjaxResult uploadSingleAllClassFile(MultipartFile file);
}

42
ruoyi-admin/src/main/java/com/ruoyi/common/service/impl/CommonServiceImpl.java

@ -115,6 +115,48 @@ public class CommonServiceImpl implements ICommonService {
}
}
/**
* 通用不分文件类型的单文件上传请求
*/
@Override
public AjaxResult uploadSingleAllClassFile(MultipartFile file) {
try
{
String loginName = ShiroUtils.getLoginName();
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
String originalFilename = file.getOriginalFilename();
String fileExt = originalFilename.substring(originalFilename.lastIndexOf(".")+1);
Long fileSize = file.getSize();
// 保存文件信息
SysAttachFile sysAttachFile = new SysAttachFile();
sysAttachFile.setName(originalFilename);
sysAttachFile.setUrl(url);
sysAttachFile.setSize(fileSize);
sysAttachFile.setExt(fileExt);
sysAttachFile.setPath(fileName);
sysAttachFile.setCreateBy(loginName);
sysAttachFile.setCreateTime(DateUtils.getNowDate());
attachFileService.insertSysAttachFile(sysAttachFile);
Long attachId = sysAttachFile.getAttachId();
//创建一个ajax结果,这个ajax继承map集合,相当于一个map集合
AjaxResult ajax = new AjaxResult();
ajax.put("url",url);
ajax.put("name", originalFilename);
ajax.put("attachId",attachId);
ajax.put("fileName", fileName);
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
@Override
public AjaxResult delete(Long id) {
SysAttachFile attachFile = attachFileService.selectSysAttachFileById(id);

12
ruoyi-admin/src/main/java/com/ruoyi/financial/domain/FinancialTaxInvoice.java

@ -5,6 +5,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.system.domain.SysAttachFile;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -186,6 +187,9 @@ public class FinancialTaxInvoice extends BaseEntity
/** 国税发票物料集合*/
private List<FinancialTaxInvoiceMaterial> invoiceMaterialList;
private List<SysAttachFile> sysAttachFiles;
public void setTaxInvoiceId(Long taxInvoiceId)
{
this.taxInvoiceId = taxInvoiceId;
@ -600,6 +604,14 @@ public class FinancialTaxInvoice extends BaseEntity
this.photoAttachId = photoAttachId;
}
public List<SysAttachFile> getSysAttachFiles() {
return sysAttachFiles;
}
public void setSysAttachFiles(List<SysAttachFile> sysAttachFiles) {
this.sysAttachFiles = sysAttachFiles;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

71
ruoyi-admin/src/main/java/com/ruoyi/financial/service/impl/FinancialTaxInvoiceServiceImpl.java

@ -17,6 +17,7 @@ import com.ruoyi.financial.mapper.FinancialTaxInvoiceHistoryMapper;
import com.ruoyi.financial.mapper.FinancialTaxInvoiceMaterialMapper;
import com.ruoyi.financial.service.IFinancialTaxInvoiceMaterialService;
import com.ruoyi.system.domain.SysAttach;
import com.ruoyi.system.domain.SysAttachFile;
import com.ruoyi.system.domain.SysCustomerVo;
import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.mapper.SysCustomerMapper;
@ -317,35 +318,50 @@ public class FinancialTaxInvoiceServiceImpl implements IFinancialTaxInvoiceServi
financialTaxInvoice.setUpdateTime(new Date());
financialTaxInvoice.setUpdateBy(loginName);
Long taxInvoiceId = financialTaxInvoice.getTaxInvoiceId();
//Long taxInvoiceId = financialTaxInvoice.getTaxInvoiceId();
String fileIdStr = financialTaxInvoice.getFileIdStr();
Long attachId = null;
if (StringUtils.isNotEmpty(fileIdStr)){
SysAttach tempAttach = new SysAttach();
tempAttach.setSourceType("taxInvoice");
tempAttach.setRelId(taxInvoiceId);
List<SysAttach> sysAttaches = attachService.selectSysAttachList(tempAttach);
if (CollectionUtils.isEmpty(sysAttaches)){
//保存新的文件附件关联
SysAttach sysAttach = new SysAttach();
sysAttach.setSourceType("taxInvoice");
sysAttach.setRelId(taxInvoiceId);
sysAttach.setCreateTime(new Date());
sysAttach.setCreateBy(loginName);
attachService.insertSysAttach(sysAttach);
attachId = sysAttach.getId();
}else {
SysAttach sysAttach = sysAttaches.get(0);
sysAttach.setUpdateBy(loginName);
sysAttach.setUpdateTime(new Date());
attachService.updateSysAttach(sysAttach);
attachId = sysAttach.getId();
}
//更新附件与文件关联
List<String> fileIdList = Arrays.asList(fileIdStr.split(","));
attachFileService.updateAttachIdByIdList(attachId,fileIdList);
//获取业务的id
Long taxInvoiceId = financialTaxInvoice.getTaxInvoiceId();
//根据文件的id拿到在数据库中的那条文件数据
SysAttachFile sysAttachFile = attachFileService.selectSysAttachFileById(Long.valueOf(fileIdStr));
sysAttachFile.setBusinessKey("financialTaxInvoice");
//把文件数据中的业务Id属性赋值
sysAttachFile.setBusinessId(taxInvoiceId);
sysAttachFile.setUpdateBy(loginName);
sysAttachFile.setUpdateTime(new Date());
//更新文件数据库中的这条信息
attachFileService.updateSysAttachFile(sysAttachFile);
}
// if (StringUtils.isNotEmpty(fileIdStr)) {
// SysAttach tempAttach = new SysAttach();
// tempAttach.setSourceType("taxInvoice");
// tempAttach.setRelId(taxInvoiceId);
// List<SysAttach> sysAttaches = attachService.selectSysAttachList(tempAttach);
// if (CollectionUtils.isEmpty(sysAttaches)){
// //保存新的文件附件关联
// SysAttach sysAttach = new SysAttach();
// sysAttach.setSourceType("taxInvoice");
// sysAttach.setRelId(taxInvoiceId);
// sysAttach.setCreateTime(new Date());
// sysAttach.setCreateBy(loginName);
// attachService.insertSysAttach(sysAttach);
// attachId = sysAttach.getId();
// }else {
// SysAttach sysAttach = sysAttaches.get(0);
// sysAttach.setUpdateBy(loginName);
// sysAttach.setUpdateTime(new Date());
// attachService.updateSysAttach(sysAttach);
// attachId = sysAttach.getId();
// }
// //更新附件与文件关联
// List<String> fileIdList = Arrays.asList(fileIdStr.split(","));
// attachFileService.updateAttachIdByIdList(attachId,fileIdList);
// }
if ("2".equals(taxInvoiceStatus)) {
//审核通过
invoiceHistory.setTaxInvoiceStatus(taxInvoiceStatus);
@ -376,7 +392,12 @@ public class FinancialTaxInvoiceServiceImpl implements IFinancialTaxInvoiceServi
*/
@Override
public FinancialTaxInvoice selectFinancialTaxInvoiceWithAttachById(Long taxInvoiceId) {
FinancialTaxInvoice financialTaxInvoice = financialTaxInvoiceMapper.selectFinancialTaxInvoiceWithAttachById(taxInvoiceId);
FinancialTaxInvoice financialTaxInvoice = financialTaxInvoiceMapper.selectFinancialTaxInvoiceById(taxInvoiceId);
Long businessId = taxInvoiceId;
List<SysAttachFile> attachFileList = attachFileService.selectSysAttachFileByBusinessId(businessId);
financialTaxInvoice.setSysAttachFiles(attachFileList);
return financialTaxInvoice;
}
}

25
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysAttachFile.java

@ -45,6 +45,14 @@ public class SysAttachFile extends BaseEntity
@Excel(name = "文件路径")
private String path;
/** 某个业务的Id */
private Long businessId;
/** 某个业务的key */
private String businessKey;
public void setId(Long id)
{
this.id = id;
@ -117,6 +125,23 @@ public class SysAttachFile extends BaseEntity
this.path = path;
}
public Long getBusinessId() {
return businessId;
}
public void setBusinessId(Long businessId) {
this.businessId = businessId;
}
public String getBusinessKey() {
return businessKey;
}
public void setBusinessKey(String businessKey) {
this.businessKey = businessKey;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

5
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachFileMapper.java

@ -64,4 +64,9 @@ public interface SysAttachFileMapper
List<SysAttachFile> selectListByAttachId(Long attachId);
int updateAttachIdByIdList(@Param("attachId")Long attachId,@Param("idList")List<String> idList);
/**
* 通过业务id查询附件集合
* */
List<SysAttachFile> selectSysAttachFileByBusinessId(Long businessId);
}

6
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysAttachFileService.java

@ -65,4 +65,10 @@ public interface ISysAttachFileService
int delFileAndAttachById(Long id);
int updateAttachIdByIdList(Long attachId,List<String> idList);
/**
* 通过业务id查询附件集合
* */
List<SysAttachFile> selectSysAttachFileByBusinessId(Long businessId);
}

9
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysAttachFileServiceImpl.java

@ -127,4 +127,13 @@ public class SysAttachFileServiceImpl implements ISysAttachFileService
public int updateAttachIdByIdList(Long attachId,List<String> idList) {
return sysAttachFileMapper.updateAttachIdByIdList(attachId,idList);
}
/**
* 通过业务id查询附件集合
* */
@Override
public List<SysAttachFile> selectSysAttachFileByBusinessId(Long businessId) {
return sysAttachFileMapper.selectSysAttachFileByBusinessId(businessId);
}
}

13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@ -106,6 +106,19 @@ public class CommonController
return ajaxResult;
}
/**
* 通用不分文件类型的单文件上传请求
*/
@PostMapping("/uploadSingleAllClassFile")
@ResponseBody
public AjaxResult uploadSingleAllClassFile(@RequestParam("file") MultipartFile file) throws Exception
{
AjaxResult ajaxResult = commonService.uploadSingleAllClassFile(file);
return ajaxResult;
}
/**
* 删除文件
*/

20
ruoyi-admin/src/main/resources/mapper/financial/FinancialTaxInvoiceMapper.xml

@ -55,8 +55,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="delFlag" column="del_flag" />
<result property="fileIdStr" column="fileId_str"/>
<result property="photoAttachId" column="photo_attach_id"/>
<!-- <collection property="sysAttachFiles" column="business_id" ofType="com.ruoyi.system.domain.SysAttachFile" resultMap="SysAttachFileResult"/>-->
</resultMap>
<!-- <resultMap type="com.ruoyi.system.domain.SysAttachFile" id="SysAttachFileResult">-->
<!-- <result property="id" column="id" />-->
<!-- <result property="delFlag" column="del_flag" />-->
<!-- <result property="createBy" column="create_by" />-->
<!-- <result property="createTime" column="create_time" />-->
<!-- <result property="updateBy" column="update_by" />-->
<!-- <result property="updateTime" column="update_time" />-->
<!-- <result property="remark" column="remark" />-->
<!-- <result property="attachId" column="attach_id" />-->
<!-- <result property="name" column="name" />-->
<!-- <result property="ext" column="ext" />-->
<!-- <result property="size" column="size" />-->
<!-- <result property="url" column="url" />-->
<!-- <result property="path" column="path" />-->
<!-- <result property="businessId" column="business_id"/>-->
<!-- <result property="businessKey" column="business_key"/>-->
<!-- </resultMap>-->
<sql id="selectFinancialTaxInvoiceVo">
select tax_invoice_id, tax_invoice_code, tax_invoice_status, use_status, sales_order_code, sales_order_number, sales_order_type, tax_invoice_type, tax_invoice_class, tax_invoice_title, business_members, apply_user, enterprise_code, enterprise_name, contact_number, enterprise_address, common_currency, invoice_company_name, invoice_company_code, deposit_bank, bank_account, tax_rate, usd_tax, material_sum, enterprise_sum, noRmbSum, rmbTaxSum, noUsdSum, usdTaxSum, invoice_email, invoice_quota_ratio, invoice_amount_rmb, invoice_amount_usd, actual_invoice_amount, actual_invoice_amount_rmb, actual_invoice_amount_usd, invoice_purpose, business_remark, invoice_remark, invoice_data, invoice_code, invoice_phone, fileId_str, create_by, create_time, update_by, update_time, remark, del_flag from financial_tax_invoice
</sql>

15
ruoyi-admin/src/main/resources/mapper/system/SysAttachFileMapper.xml

@ -18,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="size" column="size" />
<result property="url" column="url" />
<result property="path" column="path" />
<result property="businessId" column="business_id"/>
<result property="businessKey" column="business_key"/>
</resultMap>
<sql id="selectSysAttachFileVo">
select id, del_flag, create_by, create_time, update_by, update_time, remark, attach_id, name, ext, size, url,path from sys_attach_file
select id, del_flag, create_by, create_time, update_by, update_time, remark, attach_id, name, ext, size, url,path, business_id, business_key from sys_attach_file
</sql>
<select id="selectSysAttachFileList" parameterType="SysAttachFile" resultMap="SysAttachFileResult">
@ -44,6 +46,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where attach_id = #{attachId}
</select>
<select id="selectSysAttachFileByBusinessId" parameterType="Long" resultMap="SysAttachFileResult">
<include refid="selectSysAttachFileVo"/>
where business_id = #{businessId}
</select>
<insert id="insertSysAttachFile" parameterType="SysAttachFile" useGeneratedKeys="true" keyProperty="id">
insert into sys_attach_file
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -59,6 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="size != null ">size,</if>
<if test="url != null and url != ''">url,</if>
<if test="path != null and path != ''">path,</if>
<if test="businessId != null ">business_id,</if>
<if test="businessKey != null ">business_key,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
@ -73,6 +82,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="size != null ">#{size},</if>
<if test="url != null and url != ''">#{url},</if>
<if test="path != null and path != ''">#{path},</if>
<if test="businessId != null ">#{businessId},</if>
<if test="businessKey != null ">#{businessKey},</if>
</trim>
</insert>
@ -91,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="size != null ">size = #{size},</if>
<if test="url != null and url != ''">url = #{url},</if>
<if test="path != null and path != ''">path = #{path},</if>
<if test="businessId != null ">business_id = #{businessId},</if>
<if test="businessKey != null ">business_key = #{businessKey},</if>
</trim>
where id = #{id}
</update>

17
ruoyi-admin/src/main/resources/templates/financial/taxInvoice/taxInvoice.html

@ -264,20 +264,31 @@
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
if (row.taxInvoiceStatus=="0" && row.commonCurrency=="1"){
actions.push('<a class="btn btn-success btn-xs ' + auditInvoiceFlag + '" href="javascript:void(0)" onclick="auditInvoiceRmb(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>审核</a>');
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="auditInvoiceDetail(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>详情</a>');
}
if (row.taxInvoiceStatus=="0" && row.commonCurrency=="2"){
actions.push('<a class="btn btn-success btn-xs ' + auditInvoiceFlag + '" href="javascript:void(0)" onclick="auditInvoiceUsd(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>审核</a>');
}
//审核详情
if (row.taxInvoiceStatus=="1"){
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="auditInvoiceDetail(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>详情</a>');
}
// if (row.taxInvoiceStatus=="1" ){
// actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="auditInvoiceDetail(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>详情</a>');
// }
if (row.taxInvoiceStatus=="1" && row.commonCurrency=="1"){
actions.push('<a class="btn btn-success btn-xs ' + uploadInvoiceFlag + '" href="javascript:void(0)" onclick="uploadInvoiceRmb(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>上传发票</a>');
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="uploadInvoiceDetail(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>详情</a>');
}
if (row.taxInvoiceStatus=="1" && row.commonCurrency=="2"){
actions.push('<a class="btn btn-success btn-xs ' + uploadInvoiceFlag + '" href="javascript:void(0)" onclick="uploadInvoiceUsd(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>上传发票</a>');
}
//上传发票详情
if (row.taxInvoiceStatus=="2" ){
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="uploadInvoiceDetail(\'' + row.taxInvoiceId + '\')"><i class="fa fa-edit"></i>详情</a>');
}
return actions.join('');
}
}]

5
ruoyi-admin/src/main/resources/templates/financial/taxInvoice/uploadInvoiceRMB.html

@ -380,6 +380,8 @@
uploadUrl: ctx + "common/uploadSingleFile",
maxFileCount: 1,
autoReplace: true,
allowedFileExtensions: ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'html', 'htm', 'txt', 'text', 'rar', 'zip', 'gz', 'bz2', 'pdf', 'bpmn', 'bar', 'db'],
previewFileType: ['image', 'txt', 'text', 'pdf', 'bpmn', 'bar', 'db',"doc","docx"],
showUpload: false, // 不显示上传按钮
showCaption: false, // 不显示标题
showRemove: true, // 显示移除按钮
@ -399,7 +401,8 @@
}).on('fileuploaded', function (event, data, previewId, index) {
log.info("data:" + JSON.stringify(data))
var response = data.response;
// var rsp = data.response;
// document.getElementById('attachFileId').value = rsp.attachFileId;
var attachFileId = response.data.id;
if (response.code === web_status.SUCCESS) {
$('#fileIdStr').val(attachFileId);

216
ruoyi-admin/src/main/resources/templates/financial/taxInvoice/uploadInvoiceRMBDetail.html

@ -10,7 +10,7 @@
<form class="form-horizontal m" id="form-taxInvoice-uploadRmb" th:object="${taxInvoice}">
<input name="taxInvoiceId" th:field="*{taxInvoiceId}" type="hidden">
<!-- 添加隐藏的输入框 -->
<input id="fileIdStr" th:field="*{fileIdStr}" name="fileIdStr" type="text" hidden>
<input id="fileIdStr" name="fileIdStr" type="text" hidden>
<div class="form-group">
<label class="col-sm-5 control-label">发票单号:</label>
<div class="col-sm-7">
@ -251,7 +251,6 @@
</div>
<div class="file-loading col-sm-8">
<input class="file-upload" id="singleFile" name="file" type="file">
<input id="photoAttachId" readonly name = "photoAttachId" hidden th:field="*{photoAttachId}">
</div>
</div>
<!-- 用户评价 -->
@ -284,121 +283,47 @@
autoclose: true
});
//开票物料
$(function() {
var options = {
id: 'bootstrap-table-material',
url: prefix + "/getInvoiceMaterialListByCode",
queryParams: function(params) {
return {
taxInvoiceCode: $("#taxInvoiceCode").val(),
$(document).ready(function () {
var initialPreview = [];
var initialPreviewConfig = [];
var initialPreviewFileType = [];
var sysAttachFiles = taxInvoice.sysAttachFiles || []; // 确保 sysAttachFiles 是一个数组
// 遍历 sysAttachFiles 并构建 initialPreview 和 initialPreviewConfig
if (sysAttachFiles.length > 0) {
for (var i = 0; i < sysAttachFiles.length; i++) {
var sysAttachFile = sysAttachFiles[i];
if (sysAttachFile) {
var delSysAttachFile = generFilDel(sysAttachFile);
initialPreview.push(sysAttachFile.url);
initialPreviewConfig.push(delSysAttachFile);
}
},
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
pagination: false, // 设置不分页
modalName: "国税发票物料",
columns: [{
checkbox: true
},
{
title: '国税发票物料ID',
field: 'invoiceMaterialId',
visible: false
},
{
title: '物料编号',
field: 'materialCode',
},
{
title: '物料名称',
field: 'materialName',
},
{
field: 'materialType',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
title: '物料加工方式',
field: 'materialProcessMethod',
formatter: function(value, row, index) {
return $.table.selectDictLabel(materialProcessMethodDatas, value);
}
},
{
title: '物料品牌',
field: 'materialBrand',
},
{
title: '物料图片',
field: 'materialPhotourl',
},
{
title: '物料单位',
field: 'materialUnit',
},
{
title: '物料描述',
field: 'materialDescribe',
},
{
title: '物料的数量',
field: 'materialNum',
},
{
title: '物料的含税单价(RMB)',
field: 'taxRmb',
},
{
title: '物料的不含税单价(RMB)',
field: 'noTaxRmb',
},
{
title: '已出库数量',
field: 'outBoundQuantity',
},
{
title: '已验收数',
field: 'hasCheckNum',
},
{
title: '退货数',
field: 'refundsNum',
}]
};
$.table.init(options);
});
$(document).ready(function () {
// 单图上传
$(".file-upload").fileinput({
$("#singleFile").fileinput({
uploadUrl: ctx + "common/uploadSingleFile",
dropZoneTitle: '可以将文件拖放到这里,支持文件上传',
language: 'zh',
allowedFileExtensions: ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'html', 'htm', 'txt', 'text', 'rar', 'zip', 'gz', 'bz2', 'pdf', 'bpmn', 'bar', 'db'],
showPreview: true, // 是否显示预览
showCaption: false, // 是否显示标题
fileSizeGetter: true,
previewFileType: ['image', 'txt', 'text','pdf'],
validateInitialCount: true,
preferIconicPreview: true, // 这将强制缩略图按照以下文件扩展名的图标显示
maxFileCount: 1,
autoReplace: true,
showUpload: false, // 不显示上传按钮
showCaption: false, // 不显示标题
showRemove: true, // 显示移除按钮
browseClass: "btn btn-primary", // 浏览按钮样式
removeClass: "btn btn-danger", // 移除按钮样式
removeIcon: "<i class='fa fa-trash'></i>", // 移除按钮图标
browseLabel: "选择文件", // 浏览按钮文本
removeLabel: "删除", // 移除按钮文本
layoutTemplates: {
main2: "{preview}\n" +
"{remove}\n" +
"{browse}"
}
}).on('filepreupload', function (event, data, previewId, index) {
// 在文件上传前的处理
// 可以在这里设置一些上传前的逻辑
autoReplace: true, // 自动替换
initialPreview: initialPreview,
initialPreviewConfig: initialPreviewConfig,
initialPreviewFileType: initialPreviewFileType,
initialPreviewAsData: true, // 默认为数据
}).on('filebatchselected', function (event, data, previewId, index) {
// 当文件被选中时,开始上传
$(this).fileinput("upload");
}).on('fileuploaded', function (event, data, previewId, index) {
log.info("data:" + JSON.stringify(data))
log.info("data:" + JSON.stringify(data));
var response = data.response;
var attachFileId = response.data.id;
@ -417,53 +342,50 @@
$("#fileIdStr").val('');
});
// 绑定详情按钮点击事件
var photoAttachId = $('#photoAttachId').val();
if (photoAttachId) {
$.ajax({
type: "GET",
url: ctx + "system/attach/file/getListByAttachId",
data: {attachId: photoAttachId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function (result) {
if (result.code === web_status.SUCCESS) {
var fileList = result.data.map(function (item) {
// 生成文件删除配置
function generFilDel(file) {
if (file) {
var type = file.url.substr(file.url.lastIndexOf('.') + 1);
return {
caption: item.name,
url: item.url,
key: item.id,
extra: {
attachFileId: item.id,
isBind: true
}
type: getTypeByExtension(type),
size: file.size,
caption: file.name,
url: prefix + "/deletePic",
key: file.id,
downloadUrl: file.url
};
});
// 清除现有的文件信息
$(".file-upload").fileinput("clear");
// 使用获取的文件信息初始化文件上传组件
$(".file-upload").fileinput("batchAdd", fileList);
}
}
$.modal.msgSuccess("文件信息加载成功");
} else {
$.modal.alertError(result.msg);
// 根据文件扩展名获取文件类型
function getTypeByExtension(extension) {
switch (extension) {
case 'pdf':
return "pdf";
case 'text':
return "text";
case 'mp4':
return {type: "video", filetype: "video/mp4"};
case 'txt':
return "txt";
case 'db':
return "db";
default:
return "";
}
},
error: function (error) {
$.modal.msgError("获取附件失败。");
}
});
} else {
$.modal.msgError("没有文件信息可以显示。");
}
});
// var attachId = $("#photoAttachId").val();
// var fileIdList=[];

Loading…
Cancel
Save