zydx-plus 1.30.176 → 1.31.177

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.30.176",
3
+ "version": "1.31.177",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -40,7 +40,8 @@
40
40
  "@tiptap/extension-link": "^2.0.3",
41
41
  "@vue-office/docx": "^1.1.3",
42
42
  "@vue-office/excel": "^1.1.3",
43
- "fabric": "^5.3.0"
43
+ "fabric": "^5.3.0",
44
+ "js-export-word": "^1.0.5"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "vue": "^3.2.13"
@@ -101,7 +101,7 @@ export default {
101
101
  return `transform: translate(${this.x}px, ${this.y}px);width:${this.footRightOffset}px;height:${this.footDownOffset}px;`;
102
102
  },
103
103
  },
104
- emits: ['dragStatus','close'],
104
+ emits: ['dragStatus','close','enlarge'],
105
105
  methods: {
106
106
  disconnect() {
107
107
  this.$emit('dragStatus')
@@ -149,6 +149,7 @@ export default {
149
149
  this.isMove = false;
150
150
  },
151
151
  enlarge() {
152
+ let state = false
152
153
  let clientWidth = document.documentElement.clientWidth;
153
154
  let clientHeight = document.documentElement.clientHeight;
154
155
  if(clientWidth === this.footRightOffset && clientHeight === this.footDownOffset) {
@@ -156,12 +157,15 @@ export default {
156
157
  this.y = clientHeight / 2 - this.height / 2;
157
158
  this.footDownOffset = this.height;
158
159
  this.footRightOffset = this.width;
160
+ state = false
159
161
  }else {
160
162
  this.x = 0;
161
163
  this.y = 0;
162
164
  this.footDownOffset = clientHeight;
163
165
  this.footRightOffset = clientWidth;
166
+ state = true
164
167
  }
168
+ this.$emit('enlarge', state)
165
169
  },
166
170
  close() {
167
171
  this.isMove = false
@@ -116,7 +116,7 @@ function numSort(editor) {
116
116
  let num = 1
117
117
  const data = editor.getJSON().content
118
118
  data.forEach((item, index) => {
119
- const id = item.attrs.signId
119
+ const id = item.attrs === undefined? null :item.attrs.signId
120
120
  if(id) {
121
121
  let arr = item.attrs.signId.split('-')[1]
122
122
  num = Number(arr) + 1 > num ? Number(arr) + 1 : num
@@ -88,6 +88,8 @@
88
88
  }
89
89
  .subject-title{
90
90
  flex: 1;
91
+ text-indent: 2em;
92
+ position: relative;
91
93
  }
92
94
  .subject-title label{
93
95
  display: flex;
@@ -138,5 +140,13 @@
138
140
  input[name='check'] {
139
141
  width: 15px;
140
142
  height: 15px;
141
- margin: 5px 5px 0 0;
143
+ position: absolute;
144
+ top: 5px;
145
+ left: 0;
146
+ }
147
+ .subject-but{
148
+ position: absolute;
149
+ bottom: 2px;
150
+ right: 0;
151
+ z-index: 1;
142
152
  }
@@ -1,17 +1,24 @@
1
1
  <template>
2
2
  <div :class="{paper: borderShow}">
3
3
  <div class="parer-cont" ref="parer">
4
- <div class="paper-choice" :class="{'array-ch': !styleText(item.testKey)}" v-for="(item,index) in data">
4
+ <div class="paper-choice" :class="{'array-ch': !styleText(item.testKey)}" v-for="(item,index) in value">
5
5
  <div class="subject">
6
6
  <div class="subject-title">
7
7
  <label>
8
8
  <input v-if="multipleShow" type="checkbox" :checked="item.checked" @change="checkboxChange($event,index)" name="check" />
9
9
  <span>{{ item.order }}.<em v-html="item.title"></em></span>
10
10
  </label>
11
- </div>
12
- <div class="subject-but" v-if="butShow">
13
- <button class="but" @click="modify(item)">修改</button>
14
- <button class="but" @click="del(item)">删除</button>
11
+ <div class="subject-but">
12
+ <button class="but" v-if="butShow" @click="modify(item)">修改</button>
13
+ <button class="but" v-if="butShow" @click="del(item)">删除</button>
14
+ <button class="but" v-if="replace" @click="replaceTap(item,index)">替换题目</button>
15
+ <button class="but" v-if="choice"
16
+ @click="choiceTap(item,index)"
17
+ :disabled="!item.choice"
18
+ :style="{border: !item.choice?'1px solid #ccc': '1px solid #000'}">
19
+ {{ choiceState? '选择题目' : item.choice?'撤销选择': '选择题目' }}
20
+ </button>
21
+ </div>
15
22
  </div>
16
23
  </div>
17
24
  <div class="choice" v-if="item.testKey">
@@ -33,8 +40,9 @@ export default {
33
40
  name: "zydx-seek",
34
41
  data() {
35
42
  return {
36
- value: this.data,
37
- multipleShow: this.multiple
43
+ value: [],
44
+ multipleShow: this.multiple,
45
+ choiceState: true
38
46
  }
39
47
  },
40
48
  props: {
@@ -57,14 +65,26 @@ export default {
57
65
  borderShow: {
58
66
  type: Boolean,
59
67
  default: true
68
+ },
69
+ replace: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ choice: {
74
+ type: Boolean,
75
+ default: false
60
76
  }
61
77
  },
62
78
  watch: {
63
79
  data: {
64
80
  handler: function (val, oldVal) {
65
81
  this.value = val
82
+ this.value.map((item,index) => {
83
+ item.choice = true
84
+ return item
85
+ })
66
86
  },
67
- deep: true
87
+ immediate: true,
68
88
  },
69
89
  multiple: {
70
90
  handler: function (val, oldVal) {
@@ -73,7 +93,7 @@ export default {
73
93
  deep: true
74
94
  }
75
95
  },
76
- emits: ['change','modify','del','changeAll'],
96
+ emits: ['change','modify','del','changeAll','replaceData','choiceData'],
77
97
  methods: {
78
98
  checkboxChange(e,index) {
79
99
  this.value[index].checked = e.target.checked
@@ -102,6 +122,24 @@ export default {
102
122
  }
103
123
  return false
104
124
  },
125
+ replaceTap(v,i) {
126
+ this.$emit('replaceData', {
127
+ data: v,
128
+ index: i
129
+ })
130
+ },
131
+ choiceTap(v,i) {
132
+ this.value.map((item,index) => {
133
+ item.choice = !this.choiceState;
134
+ return item
135
+ })
136
+ this.value[i].choice = true
137
+ this.choiceState = !this.choiceState
138
+ this.$emit('choiceData', {
139
+ data: v,
140
+ index: i
141
+ })
142
+ }
105
143
  }
106
144
  }
107
145
  </script>
@@ -0,0 +1,6 @@
1
+ import main from './src/word';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -0,0 +1,24 @@
1
+ .page-cont{
2
+ width: 794px;
3
+ margin: 0 auto;
4
+ position: relative;
5
+ }
6
+ .page-cont-html{
7
+ width: 100%;
8
+ height: 1123px;
9
+ padding: 100px;
10
+ background-color: #fff;
11
+ box-sizing: border-box;
12
+ position: relative;
13
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
14
+ margin: 20px 0;
15
+ }
16
+ .page-cont-num{
17
+ position: absolute;
18
+ bottom: 25px;
19
+ left: 50%;
20
+ z-index: 1;
21
+ font-size: 14px;
22
+ transform: translateX(-50%);
23
+ color: #999;
24
+ }
@@ -0,0 +1,91 @@
1
+ <template>
2
+ <div class="word-cont">
3
+ <div class="word-slot" :style="page?style:{}" id="test">
4
+ <slot></slot>
5
+ </div>
6
+ <div class="word-page" v-if="page">
7
+ <div class="page-cont" v-for="(item,index) in htmlArr">
8
+ <div class="page-cont-html" v-html="item"></div>
9
+ <div class="page-cont-num">{{ index + 1 }}/{{ htmlArr.length }}</div>
10
+ </div>
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import exportWord from 'js-export-word'
17
+
18
+ export default {
19
+ name: "zydx-paper",
20
+ data() {
21
+ return {
22
+ htmlArr: []
23
+ }
24
+ },
25
+ props: {
26
+ page: {
27
+ type: Boolean,
28
+ default: false
29
+ },
30
+ fileName: {
31
+ type: String,
32
+ default: '试卷'
33
+ }
34
+ },
35
+ computed: {
36
+ style() {
37
+ return {
38
+ position: 'fixed',
39
+ top: '-9999px',
40
+ left: 0,
41
+ zIndex: -1,
42
+ opacity: 0
43
+ }
44
+ }
45
+ },
46
+ mounted() {
47
+ this.$nextTick(() => {
48
+ this.init()
49
+ })
50
+ },
51
+ methods: {
52
+ init() {
53
+ const slot = this.$slots.default()[0]
54
+ let max = 1123
55
+ let pHeight = 0
56
+ let html = ''
57
+ for (let i = 0; i < slot.children.length; i++) {
58
+ const data = document.getElementsByClassName(slot.children[i].props.class)
59
+ let text = data[0].offsetHeight
60
+ if((pHeight + text) > max) {
61
+ this.htmlArr.push(html)
62
+ pHeight = 0
63
+ html = ''
64
+ }
65
+ pHeight += text
66
+ html += data[0].outerHTML
67
+ if(i === slot.children.length - 1) {
68
+ this.htmlArr.push(html)
69
+ pHeight = 0
70
+ html = ''
71
+ break
72
+ }
73
+ }
74
+ },
75
+ exportToWord() {
76
+ const wrap = document.getElementById('test')
77
+ const config = {
78
+ addStyle: true, // 是否导出样式,默认为true,此操作会将所有样式转换成行内样式导出
79
+ fileName: this.fileName, // 导出文件名
80
+ // toImg:['.need-to-img','.bg-danger'], // 页面哪些部分需要转化成图片,例如echart图表之类
81
+ success() {
82
+ console.log('导出成功')
83
+ } // 完成之后回调,一般页面篇幅比较大,时间比较长
84
+ }
85
+ exportWord(wrap, config)
86
+ }
87
+ }
88
+ }
89
+ </script>
90
+
91
+ <style scoped src="./word.css"></style>
package/src/index.js CHANGED
@@ -30,6 +30,7 @@ import word from './components/word/index';
30
30
  import sketchpad from './components/sketchpad/index';
31
31
  import pictureViewer from './components/pictureViewer/index';
32
32
  import lessonTemplate from './components/lesson_template/index';
33
+ import paper from './components/word2/index';
33
34
 
34
35
  const components = [
35
36
  Calendar,
@@ -61,7 +62,8 @@ const components = [
61
62
  word,
62
63
  sketchpad,
63
64
  pictureViewer,
64
- lessonTemplate
65
+ lessonTemplate,
66
+ paper
65
67
  ];
66
68
 
67
69
  function install(app) {
@@ -73,7 +75,7 @@ function install(app) {
73
75
  }
74
76
 
75
77
  export default {
76
- version: '1.30.176',
78
+ version: '1.31.177',
77
79
  install,
78
80
  Calendar,
79
81
  Message,
@@ -106,6 +108,7 @@ export default {
106
108
  word,
107
109
  sketchpad,
108
110
  pictureViewer,
109
- lessonTemplate
111
+ lessonTemplate,
112
+ paper
110
113
  };
111
114