byt-ui 0.0.5

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.
@@ -0,0 +1,195 @@
1
+ <!--
2
+ * @Description:
3
+ * @Author: 王国火
4
+ * @Date: 2022-07-13 08:46:34
5
+ * @LastEditTime: 2022-09-15 10:08:10
6
+ * @LastEditors: 王国火
7
+ -->
8
+ <!-- -->
9
+ <template>
10
+ <el-form ref="form" :model="form" :inline="inline" label-width="80px">
11
+ <el-form-item :label="item.label" :key="index" v-for="(item,index) in searchList">
12
+ <template v-if="item.type=='input' || !item.type">
13
+ <el-input v-model="form[item.key]" clearable :placeholder="`请输入${item.label}`"></el-input>
14
+ </template>
15
+
16
+ <template v-if="item.type=='cascader'">
17
+ <el-cascader
18
+ :options="item.options||[]"
19
+ filterable
20
+ clearable
21
+ :props="item.props||{}"
22
+ v-model="form[item.key]"
23
+ :show-all-levels="false"
24
+ ></el-cascader>
25
+ </template>
26
+
27
+ <template v-if="item.type=='select'">
28
+ <el-select clearable v-model="form[item.key]" :multiple="item.multiple" placeholder="请选择">
29
+ <el-option
30
+ v-for="(opt,i) in item.options"
31
+ :key="i"
32
+ :label="opt.label"
33
+ :value="opt.value"
34
+ >
35
+ </el-option>
36
+ </el-select>
37
+ </template>
38
+
39
+ <template v-if="item.type=='datepicker'">
40
+ <el-date-picker
41
+ v-model="form[item.key]"
42
+ :type="item.fields||'date'"
43
+ placeholder="选择日期"
44
+ :value-format="formateDate(item.fields)"
45
+ >
46
+ </el-date-picker>
47
+ <!-- fields可选值:date、month、year -->
48
+ </template>
49
+
50
+ <template v-if="item.type=='daterange'">
51
+ <el-date-picker
52
+ v-model="form[item.key]"
53
+ type="daterange"
54
+ range-separator="至"
55
+ start-placeholder="开始日期"
56
+ end-placeholder="结束日期"
57
+ value-format="yyyy-MM-dd"
58
+ :picker-options="pickerOptions"
59
+ >
60
+ </el-date-picker>
61
+ <!-- fields可选值:date、month、year -->
62
+ </template>
63
+ </el-form-item>
64
+
65
+ <el-form-item>
66
+ <el-button icon="el-icon-search" type="primary" @click="onSearch">查询</el-button>
67
+ <el-button icon="el-icon-refresh-right" @click="onReset">重置</el-button>
68
+ </el-form-item>
69
+ </el-form>
70
+ </template>
71
+
72
+ <script>
73
+ import moment from 'moment'
74
+ /**
75
+ * 通用表格组件
76
+ * @displayName FormView
77
+ */
78
+ export default {
79
+ name: 'FormView',
80
+ props: {
81
+ inline: {
82
+ type: Boolean,
83
+ defualt: false
84
+ },
85
+ searchList: {
86
+ type: Array,
87
+ default() {
88
+ return []
89
+ }
90
+ },
91
+ value: {
92
+ type: Object,
93
+ default() {
94
+ return {}
95
+ }
96
+ }
97
+ },
98
+ data () {
99
+ return {
100
+ form: {},
101
+ options: [],
102
+ pickerOptions: {
103
+ shortcuts: [{
104
+ text: '最近一周',
105
+ onClick(picker) {
106
+ const end = moment().subtract(7, 'day').toDate();
107
+ const start = new Date();
108
+ picker.$emit('pick', [start, end]);
109
+ }
110
+ }, {
111
+ text: '最近一个月',
112
+ onClick(picker) {
113
+ const end = moment().subtract(1, 'month').toDate();
114
+ const start = new Date();
115
+ picker.$emit('pick', [start, end]);
116
+ }
117
+ }, {
118
+ text: '最近三个月',
119
+ onClick(picker) {
120
+ const end = moment().subtract(3, 'month').toDate();
121
+ const start = new Date();
122
+ picker.$emit('pick', [start, end]);
123
+ }
124
+ }]
125
+ }
126
+ };
127
+ },
128
+ components: {},
129
+ computed: {},
130
+ mounted() {},
131
+ methods: {
132
+ formateDate(type) {
133
+ // date、week 、month、year
134
+ switch (type) {
135
+ case 'date':
136
+ return 'yyyy-MM-dd'
137
+ case 'month':
138
+ return 'yyyy-MM'
139
+ case 'year':
140
+ return 'yyyy'
141
+ case 'datetime':
142
+ return 'yyyy-MM-dd HH:mm:ss';
143
+ default:
144
+ return 'yyyy-MM-dd'
145
+ }
146
+ },
147
+ onSearch() {
148
+ /** 点击搜索
149
+ * @event search
150
+ * @type {Event}
151
+ */
152
+ this.$emit('search')
153
+ },
154
+ onReset() {
155
+ this.form = {};
156
+ /** 点击重置
157
+ * @event reset
158
+ * @type {Event}
159
+ */
160
+ this.$emit('reset')
161
+ },
162
+ validate() {
163
+ return new Promise((resolve) => {
164
+ this.$refs.form.validate(v => {
165
+ if (v)resolve(v)
166
+ })
167
+ })
168
+ }
169
+ },
170
+ watch: {
171
+ value: {
172
+ handler(val) {
173
+ if (JSON.stringify(val) != JSON.stringify(this.form)) {
174
+ this.form = Object.assign({}, this.form, val);
175
+ }
176
+ },
177
+ immediate: true,
178
+ deep: true
179
+ },
180
+ form: {
181
+ handler(val) {
182
+ /** 表单数据双向绑定
183
+ * @event input
184
+ * @type {Input}
185
+ */
186
+ this.$emit('input', val)
187
+ },
188
+ deep: true
189
+ }
190
+ }
191
+ }
192
+
193
+ </script>
194
+ <style lang='scss' scoped>
195
+ </style>
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Description:
3
+ * @Author: 王国火
4
+ * @Date: 2022-09-19 14:31:00
5
+ * @LastEditTime: 2022-09-19 14:32:39
6
+ * @LastEditors: 王国火
7
+ */
8
+ import BaseView from "./components/basic-view/index"
9
+ import FormView from "./components/form-view/index"
10
+
11
+ const components=[
12
+ BaseView,
13
+ FormView
14
+ ]
15
+
16
+ export default components
@@ -0,0 +1,38 @@
1
+ /*
2
+ * @Description:
3
+ * @Author: 王国火
4
+ * @Date: 2022-09-15 17:02:55
5
+ * @LastEditTime: 2022-09-19 14:33:33
6
+ * @LastEditors: 王国火
7
+ */
8
+ import Vue from 'vue'
9
+ //通用组件
10
+ import components from "./components.js"
11
+ //公用方法
12
+ import utils from "./common/index"
13
+
14
+ // 第三方依赖
15
+ import 'xe-utils'
16
+ import VXETable from 'vxe-table'
17
+ import 'vxe-table/lib/style.css'
18
+ import ElementUI from 'element-ui'
19
+ import 'element-ui/lib/theme-chalk/index.css'
20
+ Vue.use(VXETable)
21
+ Vue.use(ElementUI, {
22
+ size: 'small',
23
+ menuType: 'text'
24
+ })
25
+
26
+
27
+ // install组件api
28
+ const install = function (Vue) {
29
+ components.map(component => {
30
+ Vue.component(component.name, component);
31
+ })
32
+ Vue.prototype.$byt=utils;
33
+ }
34
+
35
+ export default{
36
+ install,
37
+ ...components
38
+ }