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> /// </summary>
public string Area { get; set; } public string Area { get; set; }
public string Name { get; set; }
[Newtonsoft.Json.JsonIgnore] [Newtonsoft.Json.JsonIgnore]
public string AreaID { get; set; } public string AreaID { get; set; }
/// <summary> /// <summary>

View File

@@ -113,7 +113,7 @@ namespace Ewide.NbzsZheliban.Service
//调查表集合 //调查表集合
var list_dcbs = list_zz_dcb.Concat(list_fzz_dcb); 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 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 + " ) ;"); 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(); }).FirstAsync();
return entity; return entity;
} }
/// <summary> /// <summary>
/// 协议详细 /// 协议详细
/// </summary> /// </summary>
@@ -206,7 +205,7 @@ namespace Ewide.NbzsZheliban.Service
/// <returns></returns> /// <returns></returns>
[HttpPost("/agreement/info")] [HttpPost("/agreement/info")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous] [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 ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true); var id = args.GetJsonGuidValue("id", isThrowExp: true);
@@ -231,9 +230,44 @@ namespace Ewide.NbzsZheliban.Service
} }
if (string.IsNullOrEmpty(XyFile)) if (string.IsNullOrEmpty(XyFile))
throw Oops.Oh("未上传附件"); throw Oops.Oh("未上传附件");
var filePath = App.Configuration["nbzs_file_path"] + XyFile; var filePath = App.Configuration["nbzs_domain"] + XyFile;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name }; 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>
/// 分布评估详细 /// 分布评估详细
/// </summary> /// </summary>

View File

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

View File

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