205 lines
5.2 KiB
Vue
205 lines
5.2 KiB
Vue
<template>
|
|
<view class="">
|
|
<el-card>
|
|
<div slot="header" class="clearfix">
|
|
<span>印章管理</span>
|
|
</div>
|
|
<!-- 自定义按钮区域开始 -->
|
|
<view>
|
|
<el-row>
|
|
<el-button type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
|
</el-row>
|
|
</view>
|
|
<!-- 自定义按钮区域结束 -->
|
|
<vk-data-table
|
|
ref="table1"
|
|
:action="table1.action"
|
|
:columns="table1.columns"
|
|
:right-btns="['delete']"
|
|
@update="updateBtn"
|
|
@delete="deleteBtn"
|
|
></vk-data-table>
|
|
|
|
<!-- 添加或编辑的弹窗开始 -->
|
|
<el-dialog :visible.sync="form1.props.show">
|
|
<vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"
|
|
:rules="form1.props.rules" :form-type="form1.props.formType" :loading.sync="form1.props.loading"
|
|
:auto-close="true" label-width="140px" @success="form1.props.show = false;refresh();" @cancel="closeForm"
|
|
:before-action="form1.props.beforeAction"></vk-data-form>
|
|
</el-dialog>
|
|
|
|
|
|
|
|
<!-- 添加或编辑的弹窗结束 -->
|
|
|
|
</el-card>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
let that;
|
|
const originalForms = {sort: 0, enable: true}
|
|
// import { VueCropper } from 'vue-cropper'
|
|
export default {
|
|
components: {
|
|
// VueCropper
|
|
},
|
|
data() {
|
|
return {
|
|
// 表格相关开始 -----------------------------------------------------------
|
|
table1: {
|
|
// 表格数据请求地址
|
|
action: "client/seal/kh/getList",
|
|
// 表格字段显示规则
|
|
columns: [
|
|
{
|
|
key: "imageUrl",
|
|
title: "印章",
|
|
type: "image",
|
|
width: 280,
|
|
},
|
|
{
|
|
key: "remark",
|
|
title: "备注",
|
|
type: "text",
|
|
},
|
|
{
|
|
key: "_add_time_str",
|
|
title: "添加时间",
|
|
type: "time",
|
|
width: 160
|
|
},
|
|
|
|
],
|
|
// 多选框选中的值
|
|
multipleSelection: [],
|
|
// 当前高亮的记录
|
|
selectItem: ""
|
|
|
|
},
|
|
// 表格相关结束 -----------------------------------------------------------
|
|
// 表单相关开始 -----------------------------------------------------------
|
|
form1: {
|
|
// 表单请求数据,此处可以设置默认值
|
|
data: {
|
|
enable: true
|
|
},
|
|
// 表单属性
|
|
props: {
|
|
// 表单请求地址
|
|
action: "",
|
|
// 表单字段显示规则
|
|
columns: [
|
|
{
|
|
key:"imageUrl", title:"印章图片", type:"image",
|
|
limit: 1,
|
|
tips: '图片格式:PNG,需设置为透明底;图片尺寸:企业章 166x166 像素,个人章 134x60 像素,印章紧密贴紧四周,尽量避免留白;',
|
|
watch: (data) => {
|
|
const { value, formData, column, index, option, $set } = data
|
|
if(!value) {
|
|
this.form1.data.imageBase64 = ""
|
|
}else {
|
|
vk.showLoading('正在上传')
|
|
vk.myfn.urlTobase64(value).then(res => {
|
|
this.form1.data.imageBase64 = res
|
|
vk.hideLoading();
|
|
})
|
|
}
|
|
|
|
}
|
|
},
|
|
|
|
{
|
|
key:"remark", title:"备注", type:"text"
|
|
},
|
|
{ key: "enable", title: "启用", type: "switch", activeValue: true, inactiveValue: false, width: 100 },
|
|
|
|
],
|
|
// 表单验证规则
|
|
rules: {
|
|
imageUrl: [
|
|
{ required:true, message:'印章不能为空', trigger:'blur' },
|
|
{ required:true, message:'印章不能为空', trigger:'blur' },
|
|
],
|
|
label:[
|
|
{ required:true, message:'属性名称不能为空', trigger:'blur' },
|
|
],
|
|
values:[
|
|
{ required:true, message:'可选值不能为空', trigger:'blur' },
|
|
],
|
|
|
|
},
|
|
// add 代表添加 update 代表修改
|
|
formType: "",
|
|
// 是否显示表单的弹窗
|
|
show: false,
|
|
beforeAction:(formData)=>{
|
|
// 可在此处修改 formData 后返回 formData,若在此处return false,则表单不触发提交请求。
|
|
|
|
return formData;
|
|
},
|
|
}
|
|
},
|
|
// 其他弹窗表单
|
|
// 表单相关结束 -----------------------------------------------------------
|
|
|
|
}
|
|
},
|
|
created() {
|
|
that = this
|
|
},
|
|
methods: {
|
|
addBtn() {
|
|
that.resetForm();
|
|
that.form1.props.action = 'client/seal/kh/add';
|
|
that.form1.props.formType = 'add';
|
|
that.form1.props.title = '添加';
|
|
that.form1.props.show = true;
|
|
},
|
|
// 显示修改页面
|
|
updateBtn({
|
|
item
|
|
}) {
|
|
that.form1.props.action = 'client/seal/kh/update';
|
|
that.form1.props.formType = 'update';
|
|
that.form1.props.title = '编辑';
|
|
that.form1.props.show = true;
|
|
that.form1.data = item;
|
|
},
|
|
closeForm() {
|
|
this.form1.props.show = false
|
|
this.form1.data = {
|
|
sort: 0,
|
|
enable: true
|
|
}
|
|
},
|
|
// 删除按钮
|
|
deleteBtn({
|
|
item,
|
|
deleteFn
|
|
}) {
|
|
deleteFn({
|
|
action: "client/seal/kh/delete",
|
|
data: {
|
|
_id: item._id
|
|
},
|
|
});
|
|
},
|
|
// 表单重置
|
|
resetForm() {
|
|
vk.pubfn.resetForm(originalForms, that);
|
|
},
|
|
// 搜索
|
|
search() {
|
|
that.$refs.table1.search();
|
|
},
|
|
// 刷新
|
|
refresh() {
|
|
that.$refs.table1.refresh();
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style> |