Commit 692cc9d7 by chenwq

feat(签名管理): 新增签名预设功能

- 添加 vue-signature-pad 依赖用于签名功能
- 创建签名管理页面及弹窗组件
- 实现签名保存、撤销、清除功能
- 添加签名预设的增删查接口
- 限制最多添加5个签名预设
1 parent f1176dea
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-amap": "^0.5.10", "vue-amap": "^0.5.10",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vue-signature-pad": "^2.0.5",
"vuex": "^3.1.2" "vuex": "^3.1.2"
}, },
"devDependencies": { "devDependencies": {
......
import { http } from '@/main'
// 分页查询签名预设
const getList = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = 'dj.api.smartcarlife.purchaseOrder.preset.sign.page'
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
// 新增签名
const addSign = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = 'dj.api.smartcarlife.purchaseOrder.preset.sign.add'
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
// 删除签名
const deleteSign = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = 'dj.api.smartcarlife.purchaseOrder.preset.sign.delete'
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
export default { getList, addSign, deleteSign }
\ No newline at end of file \ No newline at end of file
...@@ -16,6 +16,8 @@ import utils from './utils/index' ...@@ -16,6 +16,8 @@ import utils from './utils/index'
// import 'glsx-components/dist/glsx-components.css' // import 'glsx-components/dist/glsx-components.css'
import { start } from '@/setup' import { start } from '@/setup'
import VueAMap from 'vue-amap' import VueAMap from 'vue-amap'
import VueSignaturePad from 'vue-signature-pad'
Vue.use(VueSignaturePad)
Vue.use(VueAMap) Vue.use(VueAMap)
// 初始化vue-amap // 初始化vue-amap
VueAMap.initAMapApiLoader({ VueAMap.initAMapApiLoader({
......
<template>
<GLDialog v-if="dialogShow" bigTitle="签名预设" mode="big" :visible.sync="dialogShow" :close-on-click-modal="false" @onCancel="handleDetailClose">
<div class="table-wrap">
<div class="sign-box">
<div class="red-txt">*空白区域内写下名字</div>
<div class="background-text">签字区</div>
<div class="signature-container">
<VueSignaturePad width="100%" height="100%" ref="signaturePad" :options="options" />
</div>
</div>
</div>
<template slot="footer">
<span class="dialog-footer">
<el-button plain size="small" class="btn-three" @click="clear">重写</el-button>
<el-button plain size="small" class="btn-three" @click="undo">撤销</el-button>
<el-button type="primary" size="small" @click="save">确定</el-button>
</span>
</template>
</GLDialog>
</template>
<script>
import * as dayjs from 'dayjs'
export default {
name: 'SignDialog',
props: {
visible: {
type: Boolean,
default: false
},
info: {
type: Object,
default: () => { }
}
},
computed: {
dialogShow: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
data() {
return {
options: {
penColor: '#000',
minWidth: 1,
maxWidth: 2,
dotSize: 1,
velocityFilterWeight: 0.7,
backgroundColor: 'rgba(255, 255, 255, 0.0)'
},
btnLoading: false,
dayjs: dayjs,
detailInfo: {}
}
},
created() { },
methods: {
undo() {
this.$refs.signaturePad.undoSignature()
},
clear() {
this.$refs.signaturePad.clearSignature()
},
save() {
// if (!this.$refs.signaturePad) {
// this.$message.warning('签名组件未加载')
// return
// }
const { isEmpty, data } = this.$refs.signaturePad.saveSignature()
if (this.btnLoading) {
return
}
if (isEmpty) {
this.$message({
message: '请先完成签名',
type: 'warning',
customClass: 'message-Z-zinde'
})
return
}
console.log(data, '保存图片----')
const base64 = 'png@' + data.split('base64,')[1]
this.loading = true
this.$apis.sysBase.uploadImg({ file: base64, fileType: 'image' }).then(res => {
console.log(res, 'res----')
this.deliverySign(res)
}).catch(() => {
this.loading = false
})
},
deliverySign(url) {
const params = {
id: this.info.orderDeliveryId,
signFileUrl: url
}
this.btnLoading = true
console.log(params, 'params----')
this.$apis.sign.addSign(params)
.then(res => {
if (res.code == 0) {
this.$message({
message: '签名预设成功',
type: 'success',
customClass: 'message-Z-zinde'
})
this.$emit('handleConfirm')
} else {
this.$message({
type: 'error',
message: res.message,
customClass: 'message-Z-zinde'
})
}
})
.finally(() => {
this.btnLoading = false
})
},
handleDetailClose() {
this.$emit('handleClose')
}
}
}
</script>
<style lang="scss" scoped>
.detail-info {
display: flex;
align-items: center;
justify-content: space-between;
color: #666666ff;
font-size: 14px;
margin-bottom: 16px;
span {
color: #333333ff;
}
.add-btn {
font-size: 14px;
color: #5850ff;
cursor: pointer;
}
}
.table-wrap {
// border: 1px solid #e5e5e5;
// padding: 16px;
// box-sizing: border-box;
margin: 30px 0;
::v-deep .el-form-item__error {
padding-top: 2px;
z-index: 9999999;
position: static;
}
.sign-box {
position: relative;
width: 640px;
height: 226px;
border-radius: 4px;
opacity: 1;
border: 1px solid #e5e5e5;
background: #fafafa;
margin: 24px auto 19px;
.signature-container {
position: relative;
width: 640px;
height: 226px;
}
.background-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
text-align: center;
color: #ededed;
font-size: 88px;
pointer-events: none;
}
::v-deep .vue-signature-pad {
position: relative;
z-index: 2;
}
.red-txt {
position: absolute;
top: 8px;
left: 262.5px;
text-align: center;
color: #eb4e4e;
font-size: 12px;
}
.btns {
position: absolute;
bottom: 8px;
right: 12px;
display: flex;
flex-direction: row-reverse;
.el-button--mini {
margin-left: 0px !important;
}
}
}
}
.look-card-wrap {
max-height: 600px;
overflow-y: scroll;
overflow-x: hidden;
::v-deep.el-table th.el-table__cell > .cell {
padding: 0 16px;
text-align: center;
}
::v-deep.el-table__body td.el-table__cell {
text-align: center;
}
}
</style>
<template>
<div class="shop">
<div class="container" style="height: calc(100vh - 160px)">
<!-- <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm> -->
<div class="table-header">
<h2>签名预设列表</h2>
<div>
<GLButton size="small" @click="handleAddSign" fn="新增签名预设" plain>新增签名预设</GLButton>
</div>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="pointRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :hasPage="false" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
<div slot="signFileUrl" slot-scope="scope" v-if="scope.scope.signFileUrl">
<el-image class="img-36" :src="scope.scope.signFileUrl" :preview-src-list="[scope.scope.signFileUrl]"></el-image>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
<sign-dialog v-if="signVisible" :visible.sync="signVisible" :info="signInfo" @handleClose="signVisibleChange" @handleConfirm="handleSignConfirm"></sign-dialog>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import SignDialog from './components/SignDialog.vue'
export default {
data() {
return {
size: 'small',
url: url,
signVisible: false,
signInfo: {},
userInfo: {},
searchForm: {
settlementStatus: ''
},
tableSearchForm: {},
tableButtonList: [
{
type: 'GLButton',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
listeners: {
click: row => this.handleDelete(row)
}
}
],
// 表格
getListApi: this.$apis.sign.getList,
tableParams: {
listName: 'list',
tableOption: {
width: '150px'
},
tableColumns: [
{
label: '签名图片',
prop: 'signFileUrl',
addHtml: 'signFileUrl',
minWidth: 120
},
{
label: '签名时间',
prop: 'createdDate',
formatter: cellValue => {
return cellValue.createdDate ? dayjs(cellValue.createdDate).format('YYYY/MM/DD HH:mm:ss') : '--'
}
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
// isApplyVisible: false,
// isInviteVisible: false,
// inviteInfo: {},
// 基本数据
baseData: {
// merchantList: []
}
}
},
components: {
SignDialog
},
mounted() {
},
methods: {
getServiceCenterList() {
const params = {
partnerMerchantId: this.userInfo.merchantId
}
this.$apis.customer.getServiceCenterList(params).then(res => {
this.baseData.merchantList = res
this.$utils.getOptionsList(this, 'showFormData')
})
},
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
handleSearch() {
this.$refs.pointRef.refreshTable()
},
handleEnlargeImg(url) {
if (url) {
this.previewImgUrl = url
this.imgVisible = !this.imgVisible
}
},
handleReset() {
this.searchForm = {
settlementStatus: ''
}
this.handleSearch()
},
signVisibleChange() {
this.signVisible = !this.signVisible
},
handleAddSign() {
console.log(this.$refs.pointRef.data.length)
if (this.$refs.pointRef.data.length == 5) {
this.$confirm('签名预设最多添加5个,请知悉。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
showCancelButton: false,
type: 'warning'
}).then(() => {
}).catch(() => { })
return true
}
this.signInfo = {}
this.signVisibleChange()
},
handleSignConfirm() {
this.signVisibleChange()
this.$refs.pointRef.refreshTable()
},
handleDelete(row) {
this.$confirm('确定删除此签名预设吗?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$apis.sign.deleteSign({ id: row.id }).then(res => {
if (res.code == 0) {
this.$message({
message: '删除成功',
type: 'success',
customClass: 'message-Z-zinde'
})
this.$refs.pointRef.refreshTable()
}
})
}).catch(() => { })
}
// handleApply() {
// this.isApplyVisible = !this.isApplyVisible
// },
// handleInviteClose() {
// this.isInviteVisible = !this.isInviteVisible
// },
// handleInvite(row) {
// this.inviteInfo = row
// this.handleInviteClose()
// },
// handleEditCustomer(editType, row) {
// var params = {
// editType: editType,
// $title: encodeURI(editType == 'add' ? '新增客户' : '编辑客户')
// }
// editType != 'add' && (params.merchantInfo = row)
// this.$router.push({
// path: '/customerManage/editCustomer',
// query: params
// })
// },
}
}
</script>
<style scoped>
.img-36 {
width: 101px;
height: 36px;
}
.import-btn {
position: relative;
width: 116px;
height: 32px;
text-align: center;
background: #5850ff;
border-radius: 4px;
color: #ffffff;
font-size: 14px;
margin-right: 8px;
}
.import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!