tijiao
This commit is contained in:
commit
2c2750bb2f
|
|
@ -0,0 +1,8 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
export function faceLogin(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/facelogin/',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -103,6 +103,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
activeName: "",
|
||||||
loading: false,
|
loading: false,
|
||||||
passwordType: "password",
|
passwordType: "password",
|
||||||
redirect: undefined,
|
redirect: undefined,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-card>
|
<el-card>
|
||||||
|
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span style="font-size: 16px;
|
<span style="font-size: 16px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
">子工序列表</span>
|
">子工序列表</span>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
||||||
>新增子工序</el-button
|
>新增子工序</el-button>
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="listLoading"
|
v-loading="listLoading"
|
||||||
:data="stepList"
|
:data="stepList"
|
||||||
|
|
@ -43,24 +39,20 @@
|
||||||
width="220px"
|
width="220px"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
||||||
|
|
||||||
<el-link
|
<el-link
|
||||||
v-if="checkPermission(['step_update'])"
|
v-if="checkPermission(['step_update'])"
|
||||||
@click="handleEdit(scope)"
|
@click="handleEditStep(scope)"
|
||||||
>编辑</el-link
|
>编辑</el-link
|
||||||
>
|
>
|
||||||
<el-link
|
<el-link
|
||||||
v-if="checkPermission(['step_delete'])"
|
v-if="checkPermission(['step_delete'])"
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleDelete(scope)"
|
@click="handleDeleteStep(scope)"
|
||||||
>删除</el-link
|
>删除</el-link
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:visible.sync="dialogVisibles"
|
:visible.sync="dialogVisibles"
|
||||||
:title="dialogTypes === 'edit' ? '编辑工序' : '新增工序'"
|
:title="dialogTypes === 'edit' ? '编辑工序' : '新增工序'"
|
||||||
|
|
@ -107,8 +99,6 @@
|
||||||
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
|
|
@ -119,10 +109,9 @@
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
">过程记录表</span>
|
">过程记录表</span>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
<el-button type="primary" icon="el-icon-plus" @click="handleCreateStep"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
<el-table
|
<el-table
|
||||||
|
|
||||||
:data="recordformList.results"
|
:data="recordformList.results"
|
||||||
border
|
border
|
||||||
fit
|
fit
|
||||||
|
|
@ -132,34 +121,26 @@
|
||||||
v-el-height-adaptive-table="{bottomOffset: 50}"
|
v-el-height-adaptive-table="{bottomOffset: 50}"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
>
|
>
|
||||||
|
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column label="表名称">
|
<el-table-column label="表名称">
|
||||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||||
|
|
||||||
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
align="center"
|
align="center"
|
||||||
label="操作"
|
label="操作"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
||||||
<el-link
|
<el-link
|
||||||
v-if="checkPermission(['material_update'])"
|
v-if="checkPermission(['material_update'])"
|
||||||
@click="handleEdit(scope)"
|
@click="handleEdit(scope)"
|
||||||
>编辑</el-link
|
>编辑</el-link>
|
||||||
>
|
|
||||||
<el-link
|
<el-link
|
||||||
v-if="checkPermission(['material_delete'])"
|
v-if="checkPermission(['material_delete'])"
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleDelete(scope)"
|
@click="handleDelete(scope)"
|
||||||
>删除</el-link
|
>删除</el-link>
|
||||||
>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
|
|
@ -195,7 +176,6 @@
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="18" >
|
<el-col :span="18" >
|
||||||
<el-card >
|
<el-card >
|
||||||
|
|
@ -230,16 +210,12 @@
|
||||||
<el-table-column label="字段标识">
|
<el-table-column label="字段标识">
|
||||||
<template slot-scope="scope">{{ scope.row.field_key }}</template>
|
<template slot-scope="scope">{{ scope.row.field_key }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="布尔类型显示名">
|
|
||||||
<template slot-scope="scope">{{ scope.row.boolean_field_display }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="选项显示名">
|
<el-table-column label="选项显示名">
|
||||||
<template slot-scope="scope">{{ scope.row.field_choice }}</template>
|
<template slot-scope="scope">{{ scope.row.field_choice }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="创建时间">
|
|
||||||
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
align="center"
|
align="center"
|
||||||
label="操作"
|
label="操作"
|
||||||
|
|
@ -262,17 +238,8 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-dialog
|
<el-dialog :visible.sync="dialogVisible1" :title="dialogType1 === 'edit' ? '编辑表格字段' : '新增表格字段'">
|
||||||
:visible.sync="dialogVisible1"
|
<el-form ref="Form" :model="field" label-width="80px" label-position="right">
|
||||||
:title="dialogType1 === 'edit' ? '编辑表格字段' : '新增表格字段'"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
ref="Form"
|
|
||||||
:model="field"
|
|
||||||
label-width="80px"
|
|
||||||
label-position="right"
|
|
||||||
>
|
|
||||||
|
|
||||||
<el-form-item label="字段类型" prop="field_type">
|
<el-form-item label="字段类型" prop="field_type">
|
||||||
<el-select style="width: 100%" v-model="field.field_type" placeholder="请选择">
|
<el-select style="width: 100%" v-model="field.field_type" placeholder="请选择">
|
||||||
<el-option
|
<el-option
|
||||||
|
|
@ -284,36 +251,28 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="字段标识" prop="field_key">
|
<el-form-item label="字段标识" prop="field_key">
|
||||||
<el-input v-model="field.field_key" placeholder="字段标识" />
|
<el-input v-model="field.field_key" placeholder="字段标识" onkeyup="value=value.replace(/[^A-Za-z_\/]/ig,'')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="字段名称" prop="field_name">
|
<el-form-item label="字段名称" prop="field_name">
|
||||||
<el-input v-model="field.field_name" placeholder="字段名称" />
|
<el-input v-model="field.field_name" placeholder="字段名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="布尔类型显示名" prop="boolean_field_display">
|
<el-form-item label="选项" v-show="field.field_type=='radio'||field.field_type=='checkbox'||field.field_type=='select'||field.field_type=='selects'">
|
||||||
<vue-json-editor
|
<el-button @click.prevent="addDomain" style="border: none;">
|
||||||
v-model="field.boolean_field_display"
|
<i class="el-icon-circle-plus-outline"></i>
|
||||||
:showBtns="false"
|
<span style="font-size:14px;">添加</span>
|
||||||
:mode="'code'"
|
</el-button>
|
||||||
lang="zh"
|
<el-row v-for="(domain, $index) in field_choice" :key=domain+$index style="margin-bottom: 10px">
|
||||||
|
<el-col :span="20">
|
||||||
/>
|
<el-input v-model="field_choice[$index]" auto-complete="off"></el-input>
|
||||||
</el-form-item>
|
</el-col>
|
||||||
<el-form-item label="选项" prop="field_choice">
|
<el-col :span="3" style="text-align: center" v-if="$index!==0">
|
||||||
|
<i class="el-icon-remove-outline" @click.prevent="removeDomain($index,'1')" style="color: red;font-size: 16px;"></i>
|
||||||
<vue-json-editor
|
</el-col>
|
||||||
v-model="field.field_choice"
|
</el-row>
|
||||||
:showBtns="false"
|
|
||||||
:mode="'code'"
|
|
||||||
lang="zh"
|
|
||||||
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input v-model="field.sort" placeholder="排序" />
|
<el-input-number v-model="field.sort" :min="1" placeholder="排序"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right">
|
||||||
<el-button type="danger" @click="dialogVisible1 = false">取消</el-button>
|
<el-button type="danger" @click="dialogVisible1 = false">取消</el-button>
|
||||||
|
|
@ -321,12 +280,10 @@
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -336,7 +293,6 @@ import { getEquipmentAll } from "@/api/equipment";
|
||||||
import { upUrl, upHeaders } from "@/api/file";
|
import { upUrl, upHeaders } from "@/api/file";
|
||||||
import { getStep,getrecordformList,createrecordform,updaterecordform,deleterecordform,getrffieldList,createrffield,updaterffield,
|
import { getStep,getrecordformList,createrecordform,updaterecordform,deleterecordform,getrffieldList,createrffield,updaterffield,
|
||||||
deleterffield} from "@/api/mtm";
|
deleterffield} from "@/api/mtm";
|
||||||
|
|
||||||
import vueJsonEditor from 'vue-json-editor'
|
import vueJsonEditor from 'vue-json-editor'
|
||||||
import { genTree } from "@/utils";
|
import { genTree } from "@/utils";
|
||||||
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||||
|
|
@ -363,16 +319,20 @@ export default {
|
||||||
listLoading: true,
|
listLoading: true,
|
||||||
dialogVisibles: false,
|
dialogVisibles: false,
|
||||||
dialogTypes: "new",
|
dialogTypes: "new",
|
||||||
|
field: {
|
||||||
|
field_type:'',
|
||||||
|
field_key:'',
|
||||||
|
field_name:'',
|
||||||
|
sort:'',
|
||||||
|
field_choice:[""],
|
||||||
|
},
|
||||||
|
field_choice:[''],
|
||||||
options:[],
|
options:[],
|
||||||
|
|
||||||
rule1: {
|
rule1: {
|
||||||
name: [{ required: true, message: "请输入", trigger: "blur" }],
|
name: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||||
number: [{ required: true, message: "请输入", trigger: "blur" }],
|
number: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
recordform: defaultrecordform,
|
recordform: defaultrecordform,
|
||||||
field: defaultfield,
|
|
||||||
dialogType: "new",
|
dialogType: "new",
|
||||||
dialogVisible:false,
|
dialogVisible:false,
|
||||||
dialogType1: "new",
|
dialogType1: "new",
|
||||||
|
|
@ -392,38 +352,29 @@ export default {
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
},
|
},
|
||||||
options_: {
|
options_: {
|
||||||
'string':'字符串',
|
'string':'文本',
|
||||||
'int':'整型',
|
'number':'数字',
|
||||||
'float': '浮点',
|
|
||||||
'boolean':'布尔',
|
|
||||||
'date': '日期',
|
'date': '日期',
|
||||||
'datetime': '日期时间',
|
'datetime': '日期时间',
|
||||||
'radio': '单选',
|
'radio': '单选',
|
||||||
'checkbox': '多选',
|
'checkbox': '多选',
|
||||||
'select': '单选下拉',
|
|
||||||
'selects': '多选下拉',
|
|
||||||
'textarea': '文本域'
|
|
||||||
},
|
},
|
||||||
fieldtypeoptions: [{
|
fieldtypeoptions: [{
|
||||||
value: 'string',
|
value: 'string',
|
||||||
label: '字符串'
|
label: '文本'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'int',
|
value: 'number',
|
||||||
label: '整型'
|
label: '数字'
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'float',
|
|
||||||
label: '浮点'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'boolean',
|
|
||||||
label: '布尔'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'date',
|
value: 'date',
|
||||||
label: '日期'
|
label: '日期'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: 'time',
|
||||||
|
label: '时间'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: 'datetime',
|
value: 'datetime',
|
||||||
label: '日期时间'
|
label: '日期时间'
|
||||||
|
|
@ -435,19 +386,8 @@ export default {
|
||||||
{
|
{
|
||||||
value: 'checkbox',
|
value: 'checkbox',
|
||||||
label: '多选'
|
label: '多选'
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
value: 'select',
|
|
||||||
label: '单选下拉'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'selects',
|
|
||||||
label: '多选下拉'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'textarea',
|
|
||||||
label: '文本域'
|
|
||||||
}],
|
|
||||||
typeoptions: [{
|
typeoptions: [{
|
||||||
value: 1,
|
value: 1,
|
||||||
label: '生产记录'
|
label: '生产记录'
|
||||||
|
|
@ -463,6 +403,14 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//添加
|
||||||
|
addDomain() {
|
||||||
|
this.field_choice.push('')
|
||||||
|
},
|
||||||
|
//删除
|
||||||
|
removeDomain(index){
|
||||||
|
this.field_choice.splice(index, 1)
|
||||||
|
},
|
||||||
checkPermission,
|
checkPermission,
|
||||||
//子工序列表
|
//子工序列表
|
||||||
getList() {
|
getList() {
|
||||||
|
|
@ -510,7 +458,7 @@ export default {
|
||||||
}
|
}
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
handleCreate() {
|
handleCreateStep() {
|
||||||
this.step = Object.assign({}, defaultstep);
|
this.step = Object.assign({}, defaultstep);
|
||||||
this.dialogTypes = "new";
|
this.dialogTypes = "new";
|
||||||
this.dialogVisibles = true;
|
this.dialogVisibles = true;
|
||||||
|
|
@ -524,7 +472,7 @@ export default {
|
||||||
this.recordformLists();
|
this.recordformLists();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEdit(scope) {
|
handleEditStep(scope) {
|
||||||
this.step = Object.assign({}, scope.row); // copy obj
|
this.step = Object.assign({}, scope.row); // copy obj
|
||||||
this.dialogTypes = "edit";
|
this.dialogTypes = "edit";
|
||||||
this.dialogVisibles = true;
|
this.dialogVisibles = true;
|
||||||
|
|
@ -533,7 +481,7 @@ export default {
|
||||||
this.$refs["Form"].clearValidate();
|
this.$refs["Form"].clearValidate();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleDelete(scope) {
|
handleDeleteStep(scope) {
|
||||||
this.$confirm("确认删除?", "警告", {
|
this.$confirm("确认删除?", "警告", {
|
||||||
confirmButtonText: "确认",
|
confirmButtonText: "确认",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
|
|
@ -577,8 +525,6 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
handleCurrentChange(row){
|
handleCurrentChange(row){
|
||||||
this.formID=row.id;
|
this.formID=row.id;
|
||||||
this.fieldLists();
|
this.fieldLists();
|
||||||
|
|
@ -631,6 +577,7 @@ export default {
|
||||||
},
|
},
|
||||||
handlefieldEdit(scope) {
|
handlefieldEdit(scope) {
|
||||||
this.field = Object.assign({}, scope.row); // copy obj
|
this.field = Object.assign({}, scope.row); // copy obj
|
||||||
|
this.field_choice = this.field.field_choice;
|
||||||
this.dialogType1 = "edit";
|
this.dialogType1 = "edit";
|
||||||
this.dialogVisible1 = true;
|
this.dialogVisible1 = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
@ -702,8 +649,8 @@ export default {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const isEdit = this.dialogType1 === "edit";
|
const isEdit = this.dialogType1 === "edit";
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
this.field.form=this.formID
|
this.field.form=this.formID;
|
||||||
|
this.field.field_choice = this.field_choice;
|
||||||
updaterffield(this.field.id, this.field).then((res) => {
|
updaterffield(this.field.id, this.field).then((res) => {
|
||||||
if (res.code >= 200) {
|
if (res.code >= 200) {
|
||||||
this.fieldLists()
|
this.fieldLists()
|
||||||
|
|
@ -712,8 +659,8 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.field.form=this.formID
|
this.field.form=this.formID;
|
||||||
|
this.field.field_choice = this.field_choice;
|
||||||
createrffield(this.field).then((res) => {
|
createrffield(this.field).then((res) => {
|
||||||
if (res.code >= 200) {
|
if (res.code >= 200) {
|
||||||
this.fieldLists()
|
this.fieldLists()
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {faceLogin} from "@/api/testModel";
|
||||||
// import "tracking/build/data/face-min.js";
|
// import "tracking/build/data/face-min.js";
|
||||||
// import "tracking/build/data/mouth-min.js";
|
// import "tracking/build/data/mouth-min.js";
|
||||||
// import "tracking/build/data/tracking-min.js";
|
// import "tracking/build/data/tracking-min.js";
|
||||||
|
|
@ -64,10 +65,19 @@
|
||||||
let canvas = document.getElementById("myCanvas");
|
let canvas = document.getElementById("myCanvas");
|
||||||
let context = canvas.getContext('2d');
|
let context = canvas.getContext('2d');
|
||||||
var video = document.getElementById("myVideo");
|
var video = document.getElementById("myVideo");
|
||||||
context.drawImage(video,0,0,this.videoWidth,this.videoHeight);
|
context.drawImage(video,0,0,90,68);
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
image = canvas.toDataURL('image/png');
|
image = canvas.toDataURL('image/png');
|
||||||
document.getElementById('res').innerHTML = '<img style="border: 1px solid #666666;" src="'+image+'">';
|
document.getElementById('res').innerHTML = '<img style="border: 1px solid #666666;" src="'+image+'">';
|
||||||
|
console.log(image);
|
||||||
|
debugger;
|
||||||
|
let imgData = {base64:image};
|
||||||
|
faceLogin(imgData).then((res) => {
|
||||||
|
if (res.code >= 200) {
|
||||||
|
debugger;
|
||||||
|
this.$message.success("成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 关闭摄像头
|
// 关闭摄像头
|
||||||
closeCamera () {
|
closeCamera () {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<button @click="back()">回退</button>
|
<button @click="back()">回退</button>
|
||||||
<button @click="saveTu()">保存</button>
|
<button @click="saveTu()">保存</button>
|
||||||
<hr>
|
<hr>
|
||||||
<!--<img src="./../../assets/404_images/404.png">-->
|
<img id="canvasImg" src="./../../assets/404_images/404.png" style="display: none">
|
||||||
<div style="position: relative;">
|
<div style="position: relative;">
|
||||||
<canvas id="canvas" width="700" height="500" >
|
<canvas id="canvas" width="700" height="500" >
|
||||||
您的浏览器不支持绘图,请升级或更换浏览器!
|
您的浏览器不支持绘图,请升级或更换浏览器!
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
let preDrawAry = [];
|
let preDrawAry = [];
|
||||||
|
let img = new Image();
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -38,19 +39,45 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
|
let _this=this;
|
||||||
|
preDrawAry = [];
|
||||||
|
let canvas = document.getElementById('canvas');
|
||||||
this.canvas = document.getElementById('canvas');
|
this.canvas = document.getElementById('canvas');
|
||||||
this.ctx = this.canvas.getContext('2d');
|
this.ctx = canvas.getContext('2d');
|
||||||
this.myCanvas_rect = this.canvas.getBoundingClientRect();
|
this.myCanvas_rect = this.canvas.getBoundingClientRect();
|
||||||
this.Txt = document.getElementById('txt');
|
this.Txt = document.getElementById('txt');
|
||||||
this.word = document.getElementById('word');
|
this.word = document.getElementById('word');
|
||||||
this.widths = this.myCanvas_rect.width;
|
this.widths = this.myCanvas_rect.width;
|
||||||
this.heights = this.myCanvas_rect.height;
|
this.heights = this.myCanvas_rect.height;
|
||||||
|
setTimeout(function(){
|
||||||
|
_this.draw();
|
||||||
|
},1000)
|
||||||
|
/*
|
||||||
|
this.ctx .clearRect(0, 0, 700, 500);
|
||||||
let imgs = new Image();
|
let imgs = new Image();
|
||||||
imgs.src ="./../../assets/404_images/404.png";
|
imgs.src ="./../../assets/404_images/404.png";
|
||||||
this.ctx.drawImage(imgs,0,0,this.widths,this.heights);
|
setTimeout(function(){
|
||||||
preDrawAry = [];
|
this.draw();
|
||||||
|
this.ctx.drawImage(imgs,0,0,700,500);
|
||||||
|
},1000)*/
|
||||||
|
/* imgs.onload=function(){
|
||||||
|
this.ctx.drawImage(imgs,0,0,700,500);
|
||||||
|
this.ctx.closePath();
|
||||||
|
|
||||||
|
let pattern=this.ctx.createPattern(imgs,"no-repeat")//不加;号
|
||||||
|
this.ctx.fillStyle=pattern;
|
||||||
|
this.ctx.fillRect(0,0,700,500);
|
||||||
|
}*/
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
draw(){
|
||||||
|
debugger;
|
||||||
|
let canvasImg = document.getElementById("canvasImg");
|
||||||
|
canvasImg.style.width = '700px';
|
||||||
|
canvasImg.style.height = '500px';
|
||||||
|
this.ctx.drawImage(canvasImg,0,0,700,500);
|
||||||
|
},
|
||||||
// 叉号
|
// 叉号
|
||||||
error1(){
|
error1(){
|
||||||
let canvas1 = document.getElementById('canvas');
|
let canvas1 = document.getElementById('canvas');
|
||||||
|
|
@ -58,7 +85,7 @@
|
||||||
this.Txt.style.display="none";
|
this.Txt.style.display="none";
|
||||||
this.word.style.display="none";
|
this.word.style.display="none";
|
||||||
ctx1.closePath();
|
ctx1.closePath();
|
||||||
this.canvas.onmousedown=function () {
|
canvas1.onmousedown=function () {
|
||||||
this.imgData= ctx1.getImageData(0,0,canvas1.width,canvas1.height);
|
this.imgData= ctx1.getImageData(0,0,canvas1.width,canvas1.height);
|
||||||
preDrawAry.push(this.imgData);
|
preDrawAry.push(this.imgData);
|
||||||
ctx1.beginPath();
|
ctx1.beginPath();
|
||||||
|
|
@ -67,7 +94,7 @@
|
||||||
ctx1.lineJoin="round";
|
ctx1.lineJoin="round";
|
||||||
};
|
};
|
||||||
//鼠标按下的位置
|
//鼠标按下的位置
|
||||||
this.canvas.onmouseup=function (ev) {
|
canvas1.onmouseup=function (ev) {
|
||||||
let oldX = ev.offsetX;
|
let oldX = ev.offsetX;
|
||||||
let oldY = ev.offsetY;
|
let oldY = ev.offsetY;
|
||||||
ctx1.moveTo(oldX,oldY);
|
ctx1.moveTo(oldX,oldY);
|
||||||
|
|
@ -139,9 +166,6 @@
|
||||||
preDrawAry.push(img);
|
preDrawAry.push(img);
|
||||||
ctx3.moveTo(oldX,oldY);
|
ctx3.moveTo(oldX,oldY);
|
||||||
ctx3.fillStyle="#e42343";
|
ctx3.fillStyle="#e42343";
|
||||||
// ctx3.fillText(v,oldX,oldY+10);
|
|
||||||
// this.canvasTextAutoLine(v,canvas3,oldX,oldY,20);
|
|
||||||
|
|
||||||
let lineWidth = 0;
|
let lineWidth = 0;
|
||||||
let canvasWidth = canvas3.width;
|
let canvasWidth = canvas3.width;
|
||||||
let lastSubStrIndex= 0;
|
let lastSubStrIndex= 0;
|
||||||
|
|
@ -198,7 +222,6 @@
|
||||||
this.word.style.display="none";
|
this.word.style.display="none";
|
||||||
this.Txt.style.display="none";
|
this.Txt.style.display="none";
|
||||||
if(preDrawAry.length>0) {
|
if(preDrawAry.length>0) {
|
||||||
// console.log(this.preDrawAry)
|
|
||||||
var popData = preDrawAry.pop();
|
var popData = preDrawAry.pop();
|
||||||
this.ctx.putImageData(popData, 0, 0);
|
this.ctx.putImageData(popData, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -211,9 +234,40 @@
|
||||||
|
|
||||||
//保存
|
//保存
|
||||||
saveTu(){
|
saveTu(){
|
||||||
|
let canvas = document.getElementById('canvas');
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
image = this.canvas.toDataURL('image/png');
|
image = canvas.toDataURL('image/png');
|
||||||
document.getElementById('res').innerHTML = '<img style="border: 1px solid #666666;" src="'+image+'">';
|
document.getElementById('res').innerHTML = '<img style="border: 1px solid #666666;" src="'+image+'">';
|
||||||
|
console.log(image);
|
||||||
|
debugger;
|
||||||
|
/*img.setAttribute('crossOrigin', 'Anonymous') ;// 解决某些图片跨域(有些图片仍不可使用)
|
||||||
|
img.src = 'url';
|
||||||
|
img.onload = (imgs) => {
|
||||||
|
let base64 = this.setBase64(imgs);
|
||||||
|
var arr = base64.split(',');
|
||||||
|
var mime = arr[0].match(/:(.*?);/)[1] ;// 获取图片的类型 (image/jpg)
|
||||||
|
var bstr = atob(arr[1]); // 将base64转码
|
||||||
|
var n = bstr.length ;// 获得转码长度
|
||||||
|
var u8arr = new Uint8Array(n); // 获得length个为0的数组
|
||||||
|
while (n--) {
|
||||||
|
u8arr[n] = bstr.charCodeAt(n) // 获得unicode码
|
||||||
|
}
|
||||||
|
this.file = new File([u8arr], 'faceImg', { type: mime }); // 生成文件
|
||||||
|
console.log(this.file);
|
||||||
|
this.url = base64
|
||||||
|
}*/
|
||||||
|
},
|
||||||
|
setBase64(img) {
|
||||||
|
let ctx = document.createElement('canvas');
|
||||||
|
const c = ctx.getContext('2d');
|
||||||
|
ctx.width = img.path[0].width;
|
||||||
|
ctx.height = img.path[0].height;
|
||||||
|
c.drawImage(img.path[0], 0, 0, img.path[0].width, img.path[0].height);
|
||||||
|
let ext = img.src
|
||||||
|
.substring(img.src.lastIndexOf('.') + 1)
|
||||||
|
.toLowerCase(); // 获取图片后缀
|
||||||
|
let url = ctx.toDataURL(`image/${ext}`);
|
||||||
|
return url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue