协议签订 更改

master
lion 6 months ago
parent d7d89aa14f
commit 9960f8ea6e

@ -75,22 +75,6 @@
预览协议
</view>
</view>
<!-- 协议预览区块 -->
<view class="agreementPreviewSection" v-if="agreementImage">
<view class="sectionTitle">协议预览</view>
<view class="agreementImageContainer">
<image
:src="agreementImage"
class="agreementImage"
mode="aspectFit"
@click="viewAgreementFullscreen">
</image>
</view>
<view class="agreementActions">
<text class="btnRegenerate" @click="regenerateAgreement"></text>
</view>
</view>
</view>
<view class="bottom">
@ -119,7 +103,7 @@
</view>
<view class="popupFooter" v-if="agreementHtml">
<view class="btnGenerate"
@click="generateAgreementImage"
@click="handleDirectSubmit"
:class="{ disabled: isGenerating }"
:disabled="isGenerating">
{{ generateButtonText }}
@ -154,7 +138,7 @@
<view class="btnRow btnRowReset" @click="resetPopupSignature"></view>
<view class="btnRow btnRowSave" @click="savePopupSignature"></view>
</view>
</view>
</view>
</view>
</view>
</uni-popup>
@ -162,7 +146,6 @@
</template>
<script>
import html2canvas from 'html2canvas';
var util = require("../../../../utils/util.js");
export default {
data() {
@ -181,19 +164,16 @@
customerSignImage: "", //
companySignImage: '', //
//
agreementImage: "", //
agreementId: "", // ID
canPreview: false, //
agreementHtml: "", // HTML
file_id: "", // ID
pendingAgreementHtml: "", // HTML
//
penColor: '#000',
penSize: 3,
openSmooth: true,
boundingBox: true,
//
isGenerating: false, //
generateButtonText: '生成协议', //
//
isGenerating: false, //
generateButtonText: '直接提交', //
//
currentSignatureType: '',
signaturePopupTitle: '',
@ -206,12 +186,8 @@
that.id = option.id;
util.getOrderInfo(option.id, function(r) {
that.order = r.data;
//
that.initCompanySign();
//
that.checkCanPreview();
//
that.checkAgreementConsistency();
//
that.initCompanySign();
}, function(r) {
});
@ -262,12 +238,6 @@
return false;
}
//
if (!that.file_id) {
util.alert("请先生成协议文件");
return false;
}
uni.showModal({
title: '提示',
content: "确认签订协议?",
@ -282,6 +252,42 @@
});
},
//
handleDirectSubmit: function() {
var that = this;
//
if (that.isGenerating) {
util.alert('正在提交协议,请稍候...');
return;
}
//
that.isGenerating = true;
that.generateButtonText = '提交中...';
// HTML
const fullHtml = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>协议</title>
</head>
<body style="font-family: 'SimSun', 'Microsoft YaHei', 'WenQuanYi Zen Hei', sans-serif;">
${that.agreementHtml}
</body>
</html>`;
// HTML
that.pendingAgreementHtml = fullHtml;
//
that.closeAgreementPopup();
//
that.submitAgreement();
},
//
openSignature: function(type){
this.currentSignatureType = type;
@ -596,12 +602,33 @@
var that = this;
//
if (!that.paramedicSignId || !that.customerSignId || !that.companySignId || !that.file_id) {
util.alert("请完成所有签名并生成协议文件");
if (!that.paramedicSignId || !that.customerSignId || !that.companySignId) {
util.alert("请完成所有签名");
return;
}
console.log(that.paramedicSignId,that.customerSignId,that.companySignId,that.file_id)
return
// HTML
if (!that.pendingAgreementHtml && !that.agreementHtml) {
util.alert("请先预览协议");
return;
}
// HTML
const html = that.pendingAgreementHtml || `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>协议</title>
</head>
<body style="font-family: 'SimSun', 'Microsoft YaHei', 'WenQuanYi Zen Hei', sans-serif;">
${that.agreementHtml}
</body>
</html>`;
//
that.isGenerating = false;
that.generateButtonText = '直接提交';
util.request({
api: 'manager/create-order-agreements',
method: 'POST',
@ -613,7 +640,7 @@
customer_sign_id: that.customerSignId,
//
company_sign_id: that.companySignId || 'STATIC_COMPANY_SIGN',
file_id: that.file_id
html: html
},
utilSuccess: function(r) {
util.alert("协议签订成功");
@ -649,80 +676,12 @@
//
that.$refs.agreementPopup.open();
},
//
regenerateAgreement: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确定要重新生成协议吗?",
confirmText: "确定",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
//
that.agreementImage = "";
that.file_id = "";
that.agreementId = "";
//
that.previewAgreement();
}
}
});
},
//
viewAgreementFullscreen: function() {
var that = this;
if (that.agreementImage) {
uni.previewImage({
current: that.agreementImage,
urls: [that.agreementImage],
zIndex: 9999
});
}
},
//
checkCanPreview: function() {
var that = this;
if (that.order.file_id) {
that.canPreview = true;
that.agreementImage = util.HOST + that.order.file_path;
that.agreementId = that.order.file_id;
} else {
that.canPreview = false;
that.agreementImage = "";
that.agreementId = "";
}
},
//
closeAgreementPopup: function() {
this.$refs.agreementPopup.close();
},
// ()
generateAgreement: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确定要重新生成协议吗?",
confirmText: "确定",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
that.submitAgreement(); //
util.alert('协议已重新生成,请刷新页面查看');
that.closeAgreementPopup(); //
}
}
});
},
//
processAgreementContent: function() {
var that = this;
@ -776,208 +735,6 @@
that.agreementHtml = content;
},
//
generateAgreementImage: function() {
var that = this;
//
if (that.isGenerating) {
util.alert('正在生成协议,请稍候...');
return;
}
//
that.isGenerating = true;
that.generateButtonText = '生成中...';
//
setTimeout(() => {
that.startGenerateAgreement();
}, 500);
},
//
startGenerateAgreement: function() {
var that = this;
console.log('开始生成协议图片协议HTML内容:', that.agreementHtml);
console.log('协议HTML内容长度:', that.agreementHtml ? that.agreementHtml.length : 0);
// 使
that.generateAgreementByAPI();
},
// 使
generateAgreementByAPI: function() {
var that = this;
// HTML
const fullHtml = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>协议</title>
</head>
<body style="font-family: 'SimSun', 'Microsoft YaHei', 'WenQuanYi Zen Hei', sans-serif;">
${that.agreementHtml}
</body>
</html>`;
console.log('准备发送到接口的HTML内容:', fullHtml);
var user = uni.getStorageSync('userInfo');
//
uni.request({
url: util.HOST + 'manager/html-to-image',
method: 'POST',
header: {
'Content-Type': 'application/json',
},
data: {
html: fullHtml,
'token': user.access_token,
},
success: function(res) {
console.log('接口返回结果:', res);
if (res && res.statusCode === 200) {
//
const imageData = res.data;
that.agreementImage = util.HOST + imageData.public_path;
that.agreementId = imageData.id;
that.file_id = imageData.id;
console.log('协议生成成功:', imageData);
//
that.isGenerating = false;
that.generateButtonText = '生成协议';
//
that.closeAgreementPopup();
util.alert('协议生成成功');
} else {
console.log('接口返回错误:', res.data);
that.handleAgreementGenerationError(res.data ? res.data.message : '协议生成失败');
}
},
fail: function(error) {
console.log('接口调用失败:', error);
that.handleAgreementGenerationError('网络请求失败');
}
});
},
//
handleAgreementGenerationError: function(errorMessage) {
var that = this;
//
that.isGenerating = false;
that.generateButtonText = '生成协议';
util.alert(errorMessage || '协议生成失败,请稍后重试');
},
//
uploadAgreementImage: function(file) {
var that = this;
var user = uni.getStorageSync('userInfo');
if (!user || !user.access_token) {
util.alert('用户未登录或token无效');
return;
}
// File
const reader = new FileReader();
reader.onload = function(e) {
const tempPath = e.target.result;
uni.uploadFile({
url: util.HOST + 'manager/upload-image',
filePath: tempPath,
name: 'file',
formData: {
'token': user.access_token,
'folder': 'public'
},
success(res) {
if (res.statusCode == "200") {
try {
var mod = JSON.parse(res.data);
console.log('协议图片上传成功:', mod);
// ID
that.agreementImage = util.HOST + mod.public_path;
that.file_id = mod.id;
//
that.closeAgreementPopup();
util.alert('协议生成成功');
} catch (error) {
console.log('解析上传响应失败:', error);
util.alert('协议生成失败:响应格式错误');
//
that.isGenerating = false;
that.generateButtonText = '生成协议';
}
} else {
util.alert('协议生成失败:' + res.statusCode);
//
that.isGenerating = false;
that.generateButtonText = '生成协议';
}
},
fail(res) {
console.log('协议图片上传失败:', res);
util.alert('协议生成失败:网络错误');
//
that.isGenerating = false;
that.generateButtonText = '生成协议';
}
});
};
reader.readAsDataURL(file);
},
//
submitAgreement: function() {
var that = this;
//
if (!that.paramedicSignId || !that.customerSignId || !that.companySignId || !that.file_id) {
util.alert("请完成所有签名并生成协议文件");
return;
}
util.request({
api: 'manager/create-order-agreements',
method: 'POST',
data: {
order_id: that.id,
paramedic_id: that.order.paramedic_id,
paramedic_sign_id: that.paramedicSignId,
customer_id: that.order.customer_id,
customer_sign_id: that.customerSignId,
//
company_sign_id: that.companySignId || 'STATIC_COMPANY_SIGN',
file_id: that.file_id
},
utilSuccess: function(r) {
util.alert("协议签订成功");
uni.navigateTo({
url: "/pages/order/order"
});
},
utilFail: function(r) {
util.alert(r);
}
});
},
//
previewAgreement: function() {
@ -1002,151 +759,6 @@
that.$refs.agreementPopup.open();
},
//
regenerateAgreement: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确定要重新生成协议吗?",
confirmText: "确定",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
//
that.agreementImage = "";
that.file_id = "";
that.agreementId = "";
//
that.previewAgreement();
}
}
});
},
//
viewAgreementFullscreen: function() {
var that = this;
if (that.agreementImage) {
uni.previewImage({
current: that.agreementImage,
urls: [that.agreementImage],
zIndex: 9999
});
}
},
//
checkCanPreview: function() {
var that = this;
if (that.order.file_id) {
that.canPreview = true;
that.agreementImage = util.HOST + that.order.file_path;
that.agreementId = that.order.file_id;
} else {
that.canPreview = false;
that.agreementImage = "";
that.agreementId = "";
}
},
//
closeAgreementPopup: function() {
this.$refs.agreementPopup.close();
},
// ()
generateAgreement: function() {
var that = this;
uni.showModal({
title: '提示',
content: "确定要重新生成协议吗?",
confirmText: "确定",
confirmColor: "#000",
cancelColor: "#eee",
success(res) {
if (res.confirm) {
that.submitAgreement(); //
util.alert('协议已重新生成,请刷新页面查看');
that.closeAgreementPopup(); //
}
}
});
},
//
processAgreementContent: function() {
var that = this;
let content = that.order.project.content;
//
const getSignatureImgStyle = function(imagePath) {
if (!imagePath) return '';
// 使
return 'vertical-align: middle; display: inline-block; width: 50px; height: 20px; margin: 0 5px;';
};
//
const placeholders = {
'paramedic_sign': that.paramedicSignImage ? `<img src="${that.paramedicSignImage}" alt="护工签名" style="${getSignatureImgStyle(that.paramedicSignImage)}">` : '',
'customer_sign': that.customerSignImage ? `<img src="${that.customerSignImage}" alt="客户签名" style="${getSignatureImgStyle(that.customerSignImage)}">` : '',
'company_sign': `<img class="company-stamp" src="${that.companySignImage}" alt="公司签名" style="display: inline-block;width: 80px;height: 80px;position: relative;left: -150px;margin: 0 5px;vertical-align: middle;">`,
'manage_sign': `<img class="company-stamp" src="${that.companySignImage}" alt="公司签名" style="display: inline-block; width: 80px;height: 80px;position: relative;left: -150px;margin: 0 5px;vertical-align: middle;">`,
'paramedic_sign2': that.paramedicSignImage ? `<img src="${that.paramedicSignImage}" alt="护工签名" style="${getSignatureImgStyle(that.paramedicSignImage)} margin-right: 54px;">` : '',
'customer_sign2': that.customerSignImage ? `<img src="${that.customerSignImage}" alt="客户签名" style="${getSignatureImgStyle(that.customerSignImage)} margin-right: 54px;">` : '',
'manage_sign2': `<img class="company-stamp" src="${that.companySignImage}" alt="公司签名" style="display: inline-block; width: 80px;height: 80px;position: relative;left: -150px;vertical-align: middle; margin: 0 5px; margin-right: 54px;">`,
'paramedic_sign_id': that.paramedicSignId || '',
'customer_sign_id': that.customerSignId || '',
'company_sign_id': that.companySignId || 'STATIC_COMPANY_SIGN',
'days': that.order.days || '',
'price': that.order.price || '',
'total': that.order.total || '',
'range_mobile': (that.order.project && that.order.project.range_mobile) || '',
'complaint_mobile': (that.order.project && that.order.project.complaint_mobile) || '',
'today_date': (() => {
const today = new Date();
return today.getFullYear() + '年' + (today.getMonth() + 1) + '月' + today.getDate() + '日';
})()
};
// HTML
Object.keys(placeholders).forEach(key => {
// {key} {<span>key</span>}
const regex = new RegExp(`\\{([^}]*${key}[^}]*)\\}`, 'g');
const matches = content.match(regex);
if (matches && matches.length > 0) {
content = content.replace(regex, placeholders[key]);
}
});
// text-wrap-mode: nowrap
content = content.replace(/text-wrap-mode:\s*nowrap;?/gi, '');
content = content.replace(/text-wrap-mode:\s*nowrap/gi, '');
that.agreementHtml = content;
},
//
generateAgreementImage: function() {
var that = this;
//
if (that.isGenerating) {
util.alert('正在生成协议,请稍候...');
return;
}
//
that.isGenerating = true;
that.generateButtonText = '生成中...';
//
setTimeout(() => {
that.startGenerateAgreement();
}, 500);
}
}
}
</script>
@ -1660,4 +1272,3 @@
}
}
</style>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,2 +1,2 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>护工管理</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/h5/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/h5/static/js/chunk-vendors.2916c8b2.js></script><script src=/h5/static/js/index.402d305a.js></script></body></html>
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/h5/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/h5/static/js/chunk-vendors.2916c8b2.js></script><script src=/h5/static/js/index.31cd4916.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save