Compare commits

...

2 Commits

Author SHA1 Message Date
路 范
79b324b0bc Merge branch 'master' of http://118.178.224.202:3000/ewide/zsxt_nbzs_h5 2021-09-18 10:54:55 +08:00
路 范
2eb2a7c60f update 研究pdf预览功能 2021-09-18 10:49:15 +08:00
19 changed files with 131 additions and 46 deletions

View File

@@ -57,6 +57,7 @@ namespace Ewide.NbzsZheliban.Entity.Extends
/// 区域
/// </summary>
public string Area { get; set; }
public string Name { get; set; }
[Newtonsoft.Json.JsonIgnore]
public string AreaID { get; set; }
/// <summary>

View File

@@ -113,7 +113,7 @@ namespace Ewide.NbzsZheliban.Service
//调查表集合
var list_dcbs = list_zz_dcb.Concat(list_fzz_dcb);
//项目列表
var list_projects = await db.Ado.SqlQueryAsync<H5IndexPrjModel>("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'号') zsjdh,dbo.get_current_state(a.ID) CurrentState from Projects a where ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') ");
var list_projects = await db.Ado.SqlQueryAsync<H5IndexPrjModel>("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'号') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME from Projects a where ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') ");
//分户评估
var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'";
var list_fhpgs = await db.Ado.SqlQueryAsync<Fhpgs>("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ) ;");
@@ -198,7 +198,6 @@ namespace Ewide.NbzsZheliban.Service
}).FirstAsync();
return entity;
}
/// <summary>
/// 协议详细
/// </summary>
@@ -206,7 +205,7 @@ namespace Ewide.NbzsZheliban.Service
/// <returns></returns>
[HttpPost("/agreement/info")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult AgreementInfo([FromBody] JObject args)
public async Task<dynamic> AgreementInfo([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true);
@@ -231,9 +230,44 @@ namespace Ewide.NbzsZheliban.Service
}
if (string.IsNullOrEmpty(XyFile))
throw Oops.Oh("未上传附件");
var filePath = App.Configuration["nbzs_file_path"] + XyFile;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
var filePath = App.Configuration["nbzs_domain"] + XyFile;
return filePath;
}
///// <summary>
///// 协议详细
///// </summary>
///// <param name="args"></param>
///// <returns></returns>
//[HttpPost("/agreement/info")]
//[Microsoft.AspNetCore.Authorization.AllowAnonymous]
//public IActionResult AgreementInfo([FromBody] JObject args)
//{
// var ticket = args.GetJsonValue("ticket", isThrowExp: true);
// var id = args.GetJsonGuidValue("id", isThrowExp: true);
// JObject userInfoObj = GetInfoByTicket(ticket);
// var XyFile = "";
// //住宅
// var entity_zz = db.Queryable<Entity.ResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
// if (entity_zz != null)
// {
// XyFile = entity_zz.XyFile;
// }
// //非住宅
// else
// {
// var entity_fzz = db.Queryable<Entity.NonResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
// if (entity_fzz != null)
// {
// XyFile = entity_fzz.XyFile;
// }
// else
// throw Oops.Oh("ID错误");
// }
// if (string.IsNullOrEmpty(XyFile))
// throw Oops.Oh("未上传附件");
// var filePath = App.Configuration["nbzs_file_path"] + XyFile;
// return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
//}
/// <summary>
/// 分布评估详细
/// </summary>

View File

@@ -362,7 +362,7 @@ export default {
pageJump(id) {
this.$router.push({
name: "policyInfo",
params: { ticket: this.ticket, id: id }
params: { ticket: this.ticket, id: id },
});
},
setZwUserAplus(Userid, userName) {
@@ -388,13 +388,15 @@ export default {
ZWJSBridge.onReady(() => {
console.log("初始化完成后执行bridge方法");
ZWJSBridge.getUserType()
.then(result1 => {
console.log(result1);
.then((result1) => {
console.log("getUserType():" + JSON.stringify(result1));
console.log("result1.userType:" + result1.userType);
//经纬度
ZWJSBridge.getLocation()
.then(result2 => {
console.log(result2);
debugger;
.then((result2) => {
console.log("getLocation():" + JSON.stringify(result2));
console.log("result2.longitude:" + result2.longitude);
console.log("result2.latitude:" + result2.latitude);
aplus_queue.push({
action: "aplus.sendPV",
arguments: [

View File

@@ -8,6 +8,9 @@
<el-button type="primary">保存到相册</el-button>
</a>
</div>
<el-button type="primary" @click="this.savePdf()">测试2</el-button>
<el-button type="primary" @click="this.handlePrint()">测试3</el-button>
<el-button type="primary" @click="testdownload4()">测试4</el-button>
</div>
</template>
@@ -16,19 +19,29 @@
import pdf from "vue-pdf";
import $ from "jquery";
import html2canvas from "html2canvas";
import axios from "axios";
// import axios from "axios";
import request from "@/common/util";
import { mgop } from "@aligov/jssdk-mgop";
export default {
components: {
pdf
pdf,
},
data() {
return {
url: ""
url: "",
};
},
created() {
this.onInit();
console.log("pdf");
},
mounted() {
// 截图
html2canvas(this.$refs.PDF).then((canvas) => {
canvas.id = "mycanvas";
const base64 = canvas.toDataURL("image/png");
jquery("a").prop("href", base64);
});
},
methods: {
onInit() {
@@ -38,11 +51,11 @@ export default {
method: "post",
data: {
ticket: window.sessionStorage.getItem("ticket"),
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C"
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
},
headers: { "Content-Type": "application/json; charset=UTF-8" },
responseType: "arraybuffer" //一定要设置响应类型否则页面会是空白pdf
}).then(result => {
responseType: "arraybuffer", //一定要设置响应类型否则页面会是空白pdf
}).then((result) => {
const binaryData = [];
binaryData.push(result.data);
//获取blob链接
@@ -54,32 +67,38 @@ export default {
// this.handlePrint(pdfUrl);
// }
});
// axios({
// method: "post",
// url: "http://10.19.94.9:7099/api/agreement/info",
// responseType: "blob",
// data: {
// ticket: "8a1188557bda7894017bed584f803119-ticket",
// id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
// },
// }).then((res) => {
// debugger;
// console.log(res);
// if (!res) {
// return;
// }
// let blob = new Blob([res.data], {
// type: "application/octet-stream",
// });
// let url = window.URL.createObjectURL(blob);
// let link = document.createElement("a");
// link.style.display = "none";
// link.href = url;
// document.body.appendChild(link);
// link.click();
// });
mgop({
api: "mgop.kykj.houseexpropriat.getagreementinfo",
host: "https://mapi.zjzwfw.gov.cn/",
dataType: "JSON",
type: "POST",
data: {
ticket: "8a1189377bdad67c017bf66039d76376-ticket",
id: "C655515B-FD91-48F2-BD79-EAABAFB7077C",
},
appKey: "es4b8zmz+2001833218+dehllx",
onSuccess: (result) => {
console.log("pdf.vue页面请求pdf文件:", result);
if (result.data && result.data.success == true) {
console.log("result.data.data:", result.data.data);
this.url = result.data.data;
// const binaryData = [];
// binaryData.push(result.data);
// //获取blob链接
// this.url = window.URL.createObjectURL(
// new Blob(binaryData, { type: "application/pdf" })
// );
// if (pdfUrl) {
// this.handlePrint(pdfUrl);
// }
}
},
onFail: (err) => {
console.log("用户无数据,不展示");
},
});
},
handlePrint(pdf) {
handlePrint() {
if (document.getElementById("print-iframe")) {
document.body.removeChild(document.getElementById("print-iframe"));
}
@@ -88,7 +107,7 @@ export default {
if (!iframe) {
iframe = document.createElement("IFRAME");
let doc = null;
iframe.setAttribute("src", pdf);
iframe.setAttribute("src", this.url);
iframe.setAttribute("id", "print-iframe");
document.body.appendChild(iframe);
doc = iframe.contentWindow.document;
@@ -100,8 +119,37 @@ export default {
onLoadData() {
// console.log(this.$route.params);
// this.url = this.$route.params.url;
}
}
},
savePdf() {
ZWJSBridge.onReady(() => {
console.log("初始化完成后执行bridge方法-savePdf");
ZWJSBridge.saveImage({
url: this.url,
})
.then((result) => {
console.log("saveImage()成功:" + JSON.stringify(result));
})
.catch((error) => {
console.log("saveImage()失败:" + JSON.stringify(result));
console.log(error);
});
});
},
testdownload4() {
ZWJSBridge.onReady(() => {
console.log("初始化完成后执行bridge方法-testdownload4");
ZWJSBridge.openLink({
url: this.url,
})
.then((result) => {
console.log("testdownload4():" + result);
})
.catch((error) => {
console.log(error);
});
});
},
},
};
</script>
<style lang="less" scoped>