|
|
@ -12,10 +12,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
<view class="btn-list"> |
|
|
|
<view class="uni-color-btn" @tap="onAddImage">新建签名</view> |
|
|
|
<!-- <view class="uni-color-btn" @tap="onAddImage">新建签名</view> --> |
|
|
|
<view class="uni-color-btn" @tap="onChangeBgImage">导入合同</view> |
|
|
|
<view class="uni-color-btn" @tap="onUndo">后退</view> |
|
|
|
<view class="uni-color-btn" @tap="onClearCanvas">清空</view> |
|
|
|
<!-- <view class="uni-color-btn" @tap="onClearCanvas">清空</view> --> |
|
|
|
<view class="uni-color-btn" @tap="submit">保存</view> |
|
|
|
<!-- <view class="uni-color-btn" @tap="onExportJSON">导出模板</view> --> |
|
|
|
<!-- <view class="uni-color-btn" @tap="onAddText">添加文字</view> --> |
|
|
@ -26,6 +26,7 @@ |
|
|
|
<script> |
|
|
|
import canvasDrag from "@/components/canvas-drag/index"; |
|
|
|
import setData from "@/components/canvas-drag/setData.js"; |
|
|
|
import wxBase64src from '@/utils/wxBase64src.js' |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
canvasDrag |
|
|
@ -35,61 +36,156 @@ |
|
|
|
return { |
|
|
|
height: 750, |
|
|
|
width: 700, |
|
|
|
drawArr : [], |
|
|
|
drawArr : {}, |
|
|
|
form : { |
|
|
|
template : 'https://img.teyizhao.com/2025-01-29/891f7516-dd40-42a4-82e5-d8efc46f4ea7.pdf', |
|
|
|
employeePage : 0,//求职者(乙方)签字页码 |
|
|
|
employeePosition : '',//求职者(乙方)签字坐标 |
|
|
|
bossPage : 0,//招聘者(甲方)签字页码 |
|
|
|
bossPosition : '',//招聘者(甲方)签字坐标 |
|
|
|
title : '', |
|
|
|
}, |
|
|
|
imagesIndex : 0, |
|
|
|
imageArr : [], |
|
|
|
id : 0, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
|
|
|
|
onLoad({id}) { |
|
|
|
uni.request({ |
|
|
|
url : 'http://192.168.1.5:5173/arr', |
|
|
|
method: 'GET', |
|
|
|
success : res => { |
|
|
|
this.imageArr = res.data |
|
|
|
this.onChangeBgImage() |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
this.id = id |
|
|
|
this.getDetail() |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
console.log("mounted mounted mounted"); |
|
|
|
}, |
|
|
|
mounted() {}, |
|
|
|
methods: { |
|
|
|
// 签名位置更新时 |
|
|
|
onDrawArrChange(arr){ |
|
|
|
console.log(arr); |
|
|
|
this.drawArr = arr |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 添加签名位置 |
|
|
|
*/ |
|
|
|
onAddImage() { |
|
|
|
wx.chooseImage({ |
|
|
|
success: res => { |
|
|
|
// wx.chooseImage({ |
|
|
|
// success: res => { |
|
|
|
// this.setData({ |
|
|
|
// graph: { |
|
|
|
// w: 100, |
|
|
|
// h: 50, |
|
|
|
// type: 'image', |
|
|
|
// url: res.tempFilePaths[0] |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
uni.getImageInfo({ |
|
|
|
src: 'https://img.teyizhao.com/2025-02-03/45a56422-7294-41a0-88af-cf2a41cb9554.png', |
|
|
|
success : res => { |
|
|
|
this.setData({ |
|
|
|
graph: { |
|
|
|
id : 'a', |
|
|
|
w: 100, |
|
|
|
h: 50, |
|
|
|
type: 'image', |
|
|
|
url: res.tempFilePaths[0] |
|
|
|
url : res.path |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail(e) { |
|
|
|
console.log(e); |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
uni.getImageInfo({ |
|
|
|
src: 'https://img.teyizhao.com/2025-02-03/45a56422-7294-41a0-88af-cf2a41cb9554.png', |
|
|
|
success : res => { |
|
|
|
this.setData({ |
|
|
|
graph: { |
|
|
|
id : 'b', |
|
|
|
w: 100, |
|
|
|
h: 50, |
|
|
|
type: 'image', |
|
|
|
url : res.path |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail(e) { |
|
|
|
console.log(e); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入合同 |
|
|
|
*/ |
|
|
|
onChangeBgImage() { |
|
|
|
async onChangeBgImage() { |
|
|
|
let self = this |
|
|
|
wx.chooseImage({ |
|
|
|
success: res => { |
|
|
|
uni.getImageInfo({ |
|
|
|
src: res.tempFilePaths[0], |
|
|
|
success: image => { |
|
|
|
console.log(image); |
|
|
|
|
|
|
|
let allwh = image.height + image.width |
|
|
|
let imgw = (image.width / allwh).toFixed(2) |
|
|
|
let imgh = (image.height / allwh).toFixed(2) |
|
|
|
|
|
|
|
self.height = imgh * Math.ceil(this.width / imgw) |
|
|
|
|
|
|
|
self.$nextTick(() => { |
|
|
|
this.$refs.canvasRef.changeBgImage(image.path) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// let pdfUrl = await self.loadFDP() |
|
|
|
|
|
|
|
// console.log(pdfUrl); |
|
|
|
|
|
|
|
// this.form.template = pdfUrl |
|
|
|
|
|
|
|
// this.pdf2imagebase64() |
|
|
|
|
|
|
|
this.changeBgImage() |
|
|
|
|
|
|
|
}, |
|
|
|
async changeBgImage(){ |
|
|
|
let self = this |
|
|
|
|
|
|
|
let src = await wxBase64src.base64src(this.imageArr[this.imagesIndex]) |
|
|
|
|
|
|
|
uni.getImageInfo({ |
|
|
|
src, |
|
|
|
success: image => { |
|
|
|
console.log(image); |
|
|
|
|
|
|
|
let allwh = image.height + image.width |
|
|
|
let imgw = (image.width / allwh).toFixed(2) |
|
|
|
let imgh = (image.height / allwh).toFixed(2) |
|
|
|
|
|
|
|
self.height = imgh * Math.ceil(this.width / imgw) |
|
|
|
|
|
|
|
self.$nextTick(() => { |
|
|
|
this.$refs.canvasRef.changeBgImage(image.path) |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail(err) { |
|
|
|
console.log(err); |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
loadFDP(){ |
|
|
|
let that = this |
|
|
|
return new Promise((success, error) => { |
|
|
|
uni.chooseMessageFile({ |
|
|
|
count: 1, //一次可以上传多少个 |
|
|
|
type: 'file', |
|
|
|
extension: ['.pdf'], //文件类型 |
|
|
|
success(res) { |
|
|
|
// that.$Oss.ossUpload(res.tempFiles[0].path) |
|
|
|
success(that.$Oss.ossUpload(res.tempFiles[0].path)) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
error(err) |
|
|
|
console.log(err, 'err'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 后退 |
|
|
|
onUndo(event) { |
|
|
@ -128,9 +224,57 @@ |
|
|
|
}); |
|
|
|
this.$refs.canvasRef.clearCanvas(); |
|
|
|
}, |
|
|
|
submit() { |
|
|
|
uni.setStorageSync('drawArrJson', JSON.stringify(this.drawArr)) |
|
|
|
uni.navigateBack(-1) |
|
|
|
async submit() { |
|
|
|
|
|
|
|
let bossPosition = { |
|
|
|
// ...this.drawArr.a, |
|
|
|
x : this.$utils.rpxSystemInfoInt(this.drawArr.a.x), |
|
|
|
y : this.$utils.rpxSystemInfoInt(this.drawArr.a.y), |
|
|
|
w : this.$utils.rpxSystemInfoInt(this.drawArr.a.w), |
|
|
|
h : this.$utils.rpxSystemInfoInt(this.drawArr.a.h), |
|
|
|
} |
|
|
|
let employeePosition = { |
|
|
|
// ...this.drawArr.b, |
|
|
|
x : this.$utils.rpxSystemInfoInt(this.drawArr.b.x), |
|
|
|
y : this.$utils.rpxSystemInfoInt(this.drawArr.b.y), |
|
|
|
w : this.$utils.rpxSystemInfoInt(this.drawArr.b.w), |
|
|
|
h : this.$utils.rpxSystemInfoInt(this.drawArr.b.h), |
|
|
|
} |
|
|
|
|
|
|
|
this.form.bossPosition = JSON.stringify(bossPosition) |
|
|
|
this.form.employeePosition = JSON.stringify(employeePosition) |
|
|
|
|
|
|
|
this.$api(this.id ? 'updateContractTemplate' : |
|
|
|
'addContractTemplate', this.form).then(res => { |
|
|
|
if(res.code == 200){ |
|
|
|
uni.navigateBack(-1) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
pdf2imagebase64(){ |
|
|
|
this.$api('pdf2imagebase64', { |
|
|
|
|
|
|
|
}, res => { |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
// 修改或者保存模板 |
|
|
|
saveOrUpdate(){ |
|
|
|
|
|
|
|
}, |
|
|
|
// pdf转图片base64 |
|
|
|
async pdf2imagebase64(){ |
|
|
|
let res = await this.$api('pdf2imagebase64', { |
|
|
|
pdfPath : this.form.template |
|
|
|
}) |
|
|
|
this.imageArr = res.result |
|
|
|
console.log(this.imageArr); |
|
|
|
}, |
|
|
|
getDetail(){ |
|
|
|
if(!this.id){ |
|
|
|
this.onAddImage() |
|
|
|
return |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
@ -143,7 +287,8 @@ |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
padding: 20rpx; |
|
|
|
gap: 20rpx; |
|
|
|
gap: 60rpx; |
|
|
|
justify-content: center; |
|
|
|
.uni-color-btn { |
|
|
|
margin: 0; |
|
|
|
border-radius: 10rpx; |
|
|
|