@zhijiancloud/bpm 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/components/api/batch-loader.js +61 -0
  2. package/components/api/index.js +108 -0
  3. package/components/css/bpmAudit.less +13 -0
  4. package/components/css/bpmMulFile.less +9 -5
  5. package/components/css/bpmSelectEntranceForm.less +62 -0
  6. package/components/css/bpmSelectHouseOwner.less +30 -0
  7. package/components/css/bpmSignature.less +40 -0
  8. package/components/css/bpmText.less +0 -10
  9. package/components/css/common.less +43 -0
  10. package/components/css/index.less +6 -1
  11. package/components/lib/bpmAudit/src/main.vue +35 -4
  12. package/components/lib/bpmAudit/src/part/auditor/audit-new.vue +534 -0
  13. package/components/lib/bpmAudit/src/part/auditor/audit-select.vue +127 -0
  14. package/components/lib/bpmAudit/src/part/auditor/audit-with-others.vue +634 -0
  15. package/components/lib/bpmAudit/src/part/auditor.vue +54 -0
  16. package/components/lib/bpmAudit/src/part/editor.vue +7 -5
  17. package/components/lib/bpmAudit/src/part/reader.vue +10 -9
  18. package/components/lib/bpmDateTime/src/part/editor.vue +3 -1
  19. package/components/lib/bpmField/src/main.vue +5 -150
  20. package/components/lib/bpmFieldsFilter/index.js +7 -0
  21. package/components/lib/bpmFieldsFilter/src/main.vue +324 -0
  22. package/components/lib/bpmFormField/index.js +7 -0
  23. package/components/lib/bpmFormField/src/lib/form_mixin.js +818 -0
  24. package/components/lib/bpmFormField/src/lib/mixin.js +245 -0
  25. package/components/lib/bpmFormField/src/main.vue +35 -0
  26. package/components/lib/bpmMulFile/src/main.vue +0 -1
  27. package/components/lib/bpmMulFile/src/part/editor.vue +1 -1
  28. package/components/lib/bpmMulFile/src/part/reader.vue +12 -33
  29. package/components/lib/bpmMulImage/src/main.vue +1 -2
  30. package/components/lib/bpmMulImage/src/part/editor.vue +5 -1
  31. package/components/lib/bpmMulImage/src/part/reader.vue +14 -4
  32. package/components/lib/bpmNumber/src/part/editor.vue +8 -9
  33. package/components/lib/bpmSelect/src/part/reader.vue +11 -2
  34. package/components/lib/bpmSelectCheckItem/src/part/editor.vue +3 -7
  35. package/components/lib/bpmSelectEntranceForm/index.js +7 -0
  36. package/components/lib/bpmSelectEntranceForm/src/main.vue +529 -0
  37. package/components/lib/bpmSelectFromField/src/main.vue +1 -0
  38. package/components/lib/bpmSelectFromField/src/part/editor.vue +27 -13
  39. package/components/lib/bpmSelectFromForm/src/part/editor.vue +2 -5
  40. package/components/lib/bpmSelectHouseOwner/index.js +7 -0
  41. package/components/lib/bpmSelectHouseOwner/src/main.vue +102 -0
  42. package/components/lib/bpmSelectHouseOwner/src/part/editor.vue +101 -0
  43. package/components/lib/bpmSelectHouseOwner/src/part/reader.vue +17 -0
  44. package/components/lib/bpmSelectIssue/index.js +7 -0
  45. package/components/lib/bpmSelectIssue/src/main.vue +180 -0
  46. package/components/lib/bpmSignature/index.js +7 -0
  47. package/components/lib/bpmSignature/src/main.vue +248 -0
  48. package/components/lib/bpmSubForm/src/main.vue +25 -3
  49. package/components/lib/bpmTime/src/part/editor.vue +3 -2
  50. package/components/lib/field-const.js +5 -2
  51. package/components/lib/index.ts +32 -2
  52. package/components/mixins/field_base_mixin.vue +188 -0
  53. package/components/vendor/draw.js +240 -0
  54. package/dist/bpmAudit.umd.js +1 -1
  55. package/dist/bpmDateTime.umd.js +1 -1
  56. package/dist/bpmField.umd.js +7 -1
  57. package/dist/bpmField.umd.js.LICENSE.txt +2 -0
  58. package/dist/bpmFieldsFilter.umd.js +8 -0
  59. package/dist/bpmFieldsFilter.umd.js.LICENSE.txt +1 -0
  60. package/dist/bpmFormField.umd.js +8 -0
  61. package/dist/bpmFormField.umd.js.LICENSE.txt +11 -0
  62. package/dist/bpmMulFile.umd.js +1 -1
  63. package/dist/bpmMulImage.umd.js +1 -1
  64. package/dist/bpmNumber.umd.js +1 -1
  65. package/dist/bpmSelect.umd.js +1 -1
  66. package/dist/bpmSelectCheckItem.umd.js +1 -1
  67. package/dist/bpmSelectEntranceForm.umd.js +8 -0
  68. package/dist/bpmSelectEntranceForm.umd.js.LICENSE.txt +1 -0
  69. package/dist/bpmSelectFromField.umd.js +1 -1
  70. package/dist/bpmSelectFromForm.umd.js +1 -1
  71. package/dist/bpmSelectHouseOwner.umd.js +1 -0
  72. package/dist/bpmSelectIssue.umd.js +1 -0
  73. package/dist/bpmSignature.umd.js +2 -0
  74. package/dist/bpmSignature.umd.js.LICENSE.txt +9 -0
  75. package/dist/bpmSubForm.umd.js +1 -1
  76. package/dist/bpmText.umd.js +1 -1
  77. package/dist/bpmTime.umd.js +1 -1
  78. package/dist/css/bpmAudit.css +1 -0
  79. package/dist/css/bpmMulFile.css +1 -1
  80. package/dist/css/bpmSelectEntranceForm.css +1 -0
  81. package/dist/css/bpmSelectHouseOwner.css +1 -0
  82. package/dist/css/bpmSignature.css +1 -0
  83. package/dist/css/bpmText.css +1 -1
  84. package/dist/css/common.css +1 -0
  85. package/dist/css/index.css +1 -1
  86. package/dist/demo.umd.js +1 -1
  87. package/dist/demo2.umd.js +1 -1
  88. package/dist/index.umd.js +7 -1
  89. package/dist/index.umd.js.LICENSE.txt +2 -0
  90. package/package.json +25 -18
  91. package/CHANGELOG.md +0 -27
  92. package/dist/bpmDateTime.umd.js.LICENSE.txt +0 -38
  93. package/dist/bpmNumber.umd.js.LICENSE.txt +0 -38
  94. package/dist/bpmSelect.umd.js.LICENSE.txt +0 -38
  95. package/dist/bpmSelectUser.umd.js +0 -1
  96. package/dist/bpmText.umd.js.LICENSE.txt +0 -38
  97. package/dist/bpmTime.umd.js.LICENSE.txt +0 -38
@@ -0,0 +1,102 @@
1
+ <template>
2
+ <component
3
+ class="bpm-select-house-owner"
4
+ v-model="curVal"
5
+ :is="curComponent"
6
+ :fieldConf="fieldConf"
7
+ :row="row"
8
+ :mode="mode"
9
+ :uiType="uiType"
10
+ :orgInfo="orgInfo"
11
+ :formName="formName"
12
+ :isMultiple="isMultiple"
13
+ v-bind="$attrs"
14
+ v-on="$listeners"
15
+ >
16
+ </component>
17
+ </template>
18
+ <script>
19
+ import editorComponent from "./part/editor.vue";
20
+ import readerComponent from "./part/reader.vue";
21
+
22
+ export default {
23
+ name: "bpmSelectHouseOwner",
24
+ components: {
25
+ editorComponent,
26
+ readerComponent
27
+ },
28
+ props: {
29
+ value: {
30
+ type: [String, Array],
31
+
32
+ },
33
+ fieldConf: {
34
+ type: Object,
35
+ default() {
36
+ return {};
37
+ },
38
+ },
39
+ row: {
40
+ type: Object,
41
+ default() {
42
+ return {};
43
+ },
44
+ },
45
+ mode: {
46
+ type: String,
47
+ default() {
48
+ return "view";
49
+ },
50
+ },
51
+ uiType: {
52
+ type: String,
53
+ default() {
54
+ return "default";
55
+ },
56
+ },
57
+ orgInfo: {
58
+ type: Object,
59
+ },
60
+ formName:{
61
+ type: String
62
+ },
63
+ isMultiple: {
64
+ type: Boolean,
65
+ default() {
66
+ return false;
67
+ },
68
+ }
69
+ },
70
+ data () {
71
+ return {
72
+ curVal: ""
73
+ }
74
+ },
75
+ computed: {
76
+ curComponent() {
77
+ if (this.mode == "view") {
78
+ return readerComponent;
79
+ } else {
80
+ return editorComponent;
81
+ }
82
+ },
83
+ },
84
+ watch: {
85
+ curVal(val){
86
+ this.$emit("input", val)
87
+ this.$emit("change", val)
88
+ },
89
+ value(){
90
+ this.curVal = this.value
91
+ },
92
+
93
+ },
94
+ mounted () {
95
+ this.curVal = this.value
96
+ }
97
+ };
98
+ </script>
99
+
100
+ <style>
101
+ @import "../../../css/bpmSelectFromId.less";
102
+ </style>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div class="house-owner">
3
+ <el-autocomplete
4
+ class="bpm-autocomplete"
5
+ v-model="curVal.name"
6
+ :fetch-suggestions="querySearch"
7
+ :placeholder="placeholder"
8
+ @select="handleSelect"
9
+ >
10
+ <template slot-scope="{ item }">
11
+ <div class="name">{{ item.value }}</div>
12
+ <span class="addr">{{ item.phone }}</span>
13
+ </template>
14
+ </el-autocomplete>
15
+ <el-input
16
+ style="margin-top: 10px; user-select: text"
17
+ class="bpm-default-input owner-phone"
18
+ v-model="curVal.phone"
19
+ :placeholder="$z('请输入业主电话', 'b2.common.select_owner_number')"
20
+ >
21
+ </el-input>
22
+ </div>
23
+ </template>
24
+ <script>
25
+ import Vue from "vue";
26
+ import _ from "lodash";
27
+ import { Autocomplete } from "element-ui";
28
+ Vue.use(Autocomplete);
29
+ export default {
30
+ props: ["value", "fieldConf", "row", "formName", "orgInfo", "isMultiple", "selectList"],
31
+ data() {
32
+ return {
33
+ placeholder: zj.z("请选择或输入业主名称", "b2.common.select_owner"),
34
+ curValue: {
35
+ id: "",
36
+ name: "",
37
+ phone: "",
38
+ },
39
+ restaurants: [],
40
+ firstListVal: ""
41
+ };
42
+ },
43
+ watch: {
44
+ ["value"]: {
45
+ handler(val) {
46
+ this.curValue = val ? val : {
47
+ id: null,
48
+ name: "",
49
+ phone: ""
50
+ };
51
+ },
52
+ deep: true,
53
+ },
54
+ curValue(val){
55
+ this.$emit("input", val)
56
+ },
57
+ ["selectList"](val) {
58
+ let isEVCFirstElem =
59
+ _.get(this.fieldConf, "default.value.type") == "EVCFirstElem";
60
+ if (
61
+ isEVCFirstElem &&
62
+ (!this.curValue || (this.curValue && !this.curValue.name))
63
+ )
64
+ this.curValue = _.get(val, "0", null);
65
+ this.firstListVal = _.get(val, "0", null);
66
+ },
67
+ },
68
+
69
+ methods: {
70
+ querySearch(queryString, cb) {
71
+ var restaurants = [];
72
+ _.each(this.selectList, (item) => {
73
+ restaurants.push({
74
+ value: item.name,
75
+ phone: item.phone,
76
+ id: item.id,
77
+ });
78
+ });
79
+ var results = queryString
80
+ ? restaurants.filter(this.createFilter(queryString))
81
+ : restaurants;
82
+ // 调用 callback 返回建议列表的数据
83
+ cb(results);
84
+ },
85
+ createFilter(queryString) {
86
+ return (restaurant) => {
87
+ return (
88
+ restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
89
+ 0
90
+ );
91
+ };
92
+ },
93
+ handleSelect(item) {
94
+ let select = _.cloneDeep(item);
95
+ select.name = select.value;
96
+ delete select.value;
97
+ this.curValue = select;
98
+ },
99
+ },
100
+ };
101
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div>
3
+ <span v-if="!value" :title="value" class="qs-content">{{
4
+ "--"
5
+ }}</span>
6
+ <div v-else class="qs-content">
7
+ <div>{{ value.name }}</div>
8
+ <div style="margin-top: 15px">{{ value.phone }}</div>
9
+ </div>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ props: ["type", "value", "fieldConf", "row"],
16
+ };
17
+ </script>
@@ -0,0 +1,7 @@
1
+ import BpmSelectIssue from './src/main.vue'
2
+
3
+ BpmSelectIssue.install = function(Vue) {
4
+ Vue.component(BpmSelectIssue.name , BpmSelectIssue);
5
+ }
6
+
7
+ export default BpmSelectIssue
@@ -0,0 +1,180 @@
1
+ <template>
2
+ <div class="bpm-select-issue q-field-no-input">
3
+ <div
4
+ @click="toOpen()"
5
+ style="display: flex; max-width: 360px; cursor: pointer;"
6
+ >
7
+ <div class="select-user-label" style="flex: 1;">
8
+ {{ (value.length || mode === 'view') ?
9
+ $z("已选问题", "b2.common.selected_question") + ' ' + value.length :
10
+ $z("选择问题", "b2.common.choice_question") }}
11
+ </div>
12
+ <i aria-hidden="true" class="fa fa-angle-right icon-right"></i>
13
+ </div>
14
+
15
+ <el-dialog
16
+ :title="searchTitle"
17
+ :visible.sync="opened"
18
+ width="90%"
19
+ :fullscreen="true"
20
+ custom-class="bpm-select-issue"
21
+ @close="toClose">
22
+ <issue-list
23
+ ref="issue_list"
24
+ :category_cls="category_cls"
25
+ :mode="issueMode"
26
+ :selectItems="selectedVals"
27
+ @select="selectIssueList"
28
+ ></issue-list>
29
+
30
+ <div v-if="mode === 'edit'" slot="footer" class="modal-footer">
31
+ <el-button @click="toClose">{{ $z('取消', 'c.cancel') }}</el-button>
32
+ <el-button type="primary" @click="onSubmit">{{ $z('确定', 'c.confirm') }}</el-button>
33
+ </div>
34
+ </el-dialog>
35
+ </div>
36
+ </template>
37
+ <script>
38
+ export default {
39
+ name: "BpmSelectIssue",
40
+ props: {
41
+ value: {
42
+ type: Array,
43
+ default () {
44
+ return []
45
+ }
46
+ },
47
+ type: {
48
+ type: String,
49
+ default: 'MulSelectIssue'
50
+ },
51
+ fieldConf: {
52
+ type: Object,
53
+ default() {
54
+ return {};
55
+ },
56
+ },
57
+ mode: {
58
+ type: String,
59
+ default: 'view' // view, edit
60
+ },
61
+ uiType: {
62
+ type: String,
63
+ default: 'default' // default,table,form,search
64
+ },
65
+ },
66
+ data() {
67
+ return {
68
+ // 结合 houseqm3/list 和原组件,有3个值:view, add, selected
69
+ issueMode: 'view',
70
+ searchTitle: zj.z("已选问题", "b2.common.selected_question"),
71
+
72
+ module_loaded: false,
73
+
74
+ loading: false,
75
+ opened: false,
76
+ selectedVals: [],
77
+
78
+ category_cls: 0,
79
+ };
80
+ },
81
+ watch: {
82
+ value (val) {
83
+ this.selectedVals = _.clone(val);
84
+ },
85
+ mode (val) {
86
+ if (val === 'view') {
87
+ this.issueMode = 'view'
88
+ this.searchTitle = zj.z("已选问题", "b2.common.selected_question")
89
+ } else {
90
+ this.issueMode = 'add'
91
+ this.searchTitle = zj.z("选择问题", "b2.common.choice_question")
92
+ }
93
+ }
94
+ },
95
+ computed: {
96
+ maxCount() {
97
+ return _.hasIn(this.fieldConf, "check.max_count")
98
+ ? _.get(this.fieldConf, "check.max_count")
99
+ : 100;
100
+ },
101
+ },
102
+ mounted() {
103
+ //动态跨模块加载页面组件
104
+ setTimeout(async () => {
105
+ if (this.fieldConf.issue_src == "building_qm") {
106
+ await zj.ui.loadPageComponent("IssueList", "buildingqm3", "list");
107
+ this.category_cls = 23;
108
+ console.log("动态加载安全检查模块组件");
109
+ } else {
110
+ await zj.ui.loadPageComponent("IssueList", "houseqm3", "list");
111
+ this.category_cls = 28;
112
+ console.log("动态加载分户验收模块组件");
113
+ }
114
+ this.module_loaded = true;
115
+ }, 4);
116
+ // TODO title 哪里来
117
+ // if (this.title) this.searchTitle = this.title;
118
+ },
119
+ methods: {
120
+ selectIssueList(data) {
121
+ this.selectedVals = _.clone(data);
122
+ },
123
+
124
+ toClose() {
125
+ this.opened = false;
126
+ this.selectedVals = [];
127
+ },
128
+ toOpen() {
129
+ if (!this.module_loaded) return;
130
+
131
+ this.opened = true;
132
+
133
+ this.$nextTick(() => {
134
+ setTimeout(() => {
135
+ this.setDefaultSelected();
136
+ }, 4);
137
+ });
138
+ },
139
+
140
+ setDefaultSelected() {
141
+ this.selectedVals = this.value ? _.cloneDeep(this.value) : []
142
+ if (this.$refs.issue_list) {
143
+ this.$refs.issue_list.selectedIds = _.clone(this.selectedVals);
144
+ this.$refs.issue_list.loadIssueList();
145
+ }
146
+ },
147
+ onSubmit() {
148
+ this.$emit('input', this.selectedVals)
149
+ this.$emit('change', this.selectedVals)
150
+
151
+ this.toClose();
152
+ },
153
+ },
154
+ }
155
+ </script>
156
+
157
+ <style lang="less">
158
+ .bpm-select-issue {
159
+ .icon-right {
160
+ color: #c1c1c1;
161
+ }
162
+
163
+ .select-user-label {
164
+ overflow-x: auto;
165
+ white-space: normal;
166
+ // color: #a4a4a4;
167
+ }
168
+ .select-user-label::-webkit-scrollbar {
169
+ display: none;
170
+ }
171
+
172
+ &.el-dialog {
173
+ .el-dialog__body {
174
+ height: calc(100vh - 54px - 70px);
175
+ box-sizing: border-box;
176
+ overflow: auto;
177
+ }
178
+ }
179
+ }
180
+ </style>
@@ -0,0 +1,7 @@
1
+ import BpmSignature from './src/main.vue'
2
+
3
+ BpmSignature.install = function(Vue) {
4
+ Vue.component(BpmSignature.name , BpmSignature);
5
+ }
6
+
7
+ export default BpmSignature
@@ -0,0 +1,248 @@
1
+ <template>
2
+ <div class="bpm-signature" style="position: relative;">
3
+ <template v-if="mode === 'edit'">
4
+ <div class="canvas-box" style="position: absolute;border-color: #fff;" v-if="openLastSign && lastSign">
5
+ <bpm-mul-image class="signature-reader" type="Signature" :value="curSign"></bpm-mul-image>
6
+ </div>
7
+ <div class="canvas-box">
8
+ <canvas ref="canvasElem"></canvas>
9
+ </div>
10
+ <div class="action-wrap">
11
+ <el-checkbox
12
+ v-if="openLastSign"
13
+ v-model="useNextUser"
14
+ :label="$z('保留签名以备下次调用', 'b2.common.sign_for_next_use')"
15
+ style="margin-right: 10px;"></el-checkbox>
16
+ <el-button size="default" @click="clearSignature">{{ $z('重置签名', 'b2.common.reset_sign') }}</el-button>
17
+ </div>
18
+ </template>
19
+ <bpm-mul-image v-else class="signature-reader" type="Signature" :value="curSign"></bpm-mul-image>
20
+ </div>
21
+ </template>
22
+ <script>
23
+ import BpmMulImage from '../../bpmMulImage/index.js';
24
+ import Draw from '../../../vendor/draw.js'
25
+
26
+ export default {
27
+ name: "BpmSignature",
28
+ components: {
29
+ BpmMulImage
30
+ },
31
+ props: {
32
+ value: {
33
+ type: String,
34
+ },
35
+ type: {
36
+ type: String,
37
+ default: 'Signature'
38
+ },
39
+ fieldConf: {
40
+ type: Object,
41
+ default() {
42
+ return {};
43
+ },
44
+ },
45
+ mode: {
46
+ type: String,
47
+ default: 'edit' // view, edit
48
+ },
49
+ uiType: {
50
+ type: String,
51
+ default: 'default' // default,table,form,search
52
+ },
53
+ container: {
54
+ type: [Object,null],
55
+ default () {
56
+ return null
57
+ }
58
+ },
59
+ },
60
+ data() {
61
+ return {
62
+ curSign: '',
63
+ hasDraw: false,
64
+ openLastSign: true, // 是否开启【保留签名以备下次调用】功能
65
+ lastSign: "",
66
+ useNextUser: false, // 保留签名以备下次调用
67
+ canvas: null,
68
+ timer:null
69
+ }
70
+ },
71
+ watch: {
72
+ value (val) {
73
+ if (val) {
74
+ this.curSign = val
75
+ }
76
+ },
77
+ curSign (val) {
78
+ this.$emit('input', val)
79
+ this.$emit('change', val, {
80
+ open: this.openLastSign,
81
+ for_next_use: this.useNextUser,
82
+ signature: this.curSign
83
+ })
84
+ }
85
+ },
86
+ created() {
87
+ },
88
+ mounted() {
89
+
90
+ if (this.mode === 'edit') {
91
+ this.$nextTick(()=>{
92
+ this.initCanvas();
93
+ })
94
+ }
95
+
96
+ // TODO 是否保存签名下次使用, 需接上 container/form 后调试
97
+ // 此处 topContainer 指的是 container/form
98
+ let topContainer = this.container
99
+ if (topContainer) {
100
+ console.log('Singnature topContainer: ', topContainer)
101
+ topContainer.$on("afterFormSubmit", (errors) => {
102
+ console.log('Singnature topContainer afterFormSubmit')
103
+ if (!errors && this.openLastSign && this.curSign) {
104
+ this.$bpm.postEleSign(this.curSign, this.useNextUser)
105
+ }
106
+ })
107
+ topContainer.$on("dataLoaded", (container) => {
108
+ console.log('Singnature topContainer dataLoaded')
109
+ this.onDataLoaded(container)
110
+ this.curSign = null
111
+ this.useNextUser = false
112
+ this.handleInit()
113
+ setTimeout(() => {
114
+ this.initCanvas();
115
+ }, 100)
116
+ })
117
+ }
118
+ },
119
+ methods: {
120
+ handleInit() {
121
+ let userSign = this.$bpm.userSign
122
+ this.openLastSign = userSign.open
123
+ if (userSign.for_next_use) this.lastSign = userSign.signature
124
+ if (this.openLastSign && this.lastSign) this.curSign = userSign.signature
125
+ if (userSign.for_next_use && this.openLastSign) this.useNextUser = true
126
+
127
+ console.log('userSign: ', userSign)
128
+ },
129
+ initCanvas() {
130
+ this.hasDraw = false;
131
+ if(this.canvas){
132
+ this.canvas.removeEventListener('touchstart', function() {})
133
+ this.canvas.removeEventListener('mousedown', function() {})
134
+ this.canvas.removeEventListener('touchend', function() {})
135
+ this.canvas.removeEventListener('mouseup', function() {})
136
+ }
137
+
138
+ console.log("初始化initCanvas")
139
+
140
+ this.canvas = this.$refs.canvasElem
141
+ this.draw = new Draw(
142
+ this.canvas,
143
+ -this.degree,
144
+ {},
145
+ {
146
+ // width: canvasBox.width(),
147
+ // height: canvasBox.height()
148
+ }
149
+ );
150
+ this.canvas.addEventListener("touchstart", () => {
151
+ if(this.timer){
152
+ clearTimeout(this.timer)
153
+ this.timer = null
154
+ }
155
+ this.hasDraw = true;
156
+ });
157
+ this.canvas.addEventListener("mousedown", () => {
158
+ if(this.timer){
159
+ clearTimeout(this.timer)
160
+ this.timer = null
161
+ }
162
+ this.hasDraw = true;
163
+ });
164
+ this.canvas.addEventListener("touchend", () => {
165
+ if(this.timer){
166
+ return
167
+ }
168
+ this.timer = setTimeout( ()=> {this.transToImg()},1000);
169
+ });
170
+ this.canvas.addEventListener("mouseup", () => {
171
+ if(this.timer){
172
+ return
173
+ }
174
+ console.log('mouseup')
175
+ this.timer = setTimeout( ()=> {this.transToImg()},1000);
176
+ });
177
+ },
178
+ // topContainer(container/form) dataLoaded
179
+ onDataLoaded(container) {
180
+ this.hasDraw = false;
181
+ this.draw && this.draw.clear();
182
+ },
183
+ clearSignature() {
184
+ this.hasDraw = false;
185
+ this.draw && this.draw.clear();
186
+ this.curSign = null
187
+ this.lastSign = ""
188
+ },
189
+ transToImg() {
190
+ console.log('Canvas transToImg called')
191
+ if (this.draw) {
192
+ let signatureImg = this.draw.getPNGImage()
193
+ console.log('Signature canvas img: ', signatureImg)
194
+ this.uploadImage({
195
+ basestr: signatureImg,
196
+ type: "png",
197
+ name: "签名图片.png",
198
+ model: "userfile"
199
+ }, (md5) => {
200
+ this.curSign = md5
201
+ this.timer = null
202
+ console.log('Signature img md5: ', md5)
203
+ })
204
+ }
205
+ },
206
+ uploadImage({
207
+ basestr, type, name, model
208
+ }, resolve) {
209
+ let text = window.atob(basestr.split(",")[1]);
210
+ let buffer = new ArrayBuffer(text.length);
211
+ let ubuffer = new Uint8Array(buffer);
212
+
213
+ for (let i = 0; i < text.length; i++) {
214
+ ubuffer[i] = text.charCodeAt(i);
215
+ }
216
+
217
+ let Builder = window.WebKitBlobBuilder || window.MozBlobBuilder;
218
+
219
+ let blob;
220
+ if (Builder) {
221
+ let builder = new Builder();
222
+ builder.append(buffer);
223
+ blob = builder.getBlob(type);
224
+ } else {
225
+ blob = new window.Blob([buffer], { type: type });
226
+ }
227
+
228
+ let formdata = new FormData();
229
+ formdata.append(model, blob, name);
230
+ zj.net.w
231
+ .noapi({
232
+ method: "POST",
233
+ url: "/platform/v1/papi/app_file/upload/",
234
+ data: formdata,
235
+ processData: false,
236
+ contentType: false
237
+ })
238
+ .then(res => {
239
+
240
+ if (resolve) resolve(res.file_md5)
241
+ });
242
+ }
243
+ }
244
+ }
245
+ </script>
246
+
247
+ <style lang="less">
248
+ </style>