bl-common-vue3 0.2.50 → 0.2.52

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,54 @@
1
+ {
2
+ "name": "bl-common-vue3",
3
+ "version": "0.2.51",
4
+ "main": "lib/vue3common.umd.min.js",
5
+ "description": "bailing vue3 common components lib",
6
+ "private": false,
7
+ "scripts": {
8
+ "lib": "vue-cli-service build --target lib --name vue3common --dest lib index.js",
9
+ "serve": "vue-cli-service serve",
10
+ "build": "vue-cli-service build",
11
+ "lint": "vue-cli-service lint",
12
+ "publish": "npm publish --access public"
13
+ },
14
+ "dependencies": {
15
+ "@ant-design/icons-vue": "^6.0.1",
16
+ "ant-design-vue": "^2.2.8",
17
+ "axios": "^0.21.4",
18
+ "core-js": "^3.6.5",
19
+ "less": "^4.1.1",
20
+ "less-loader": "^6.0.0",
21
+ "moment": "^2.29.1",
22
+ "qrcode.vue": "^3.3.3",
23
+ "style-resources-loader": "^1.5.0",
24
+ "vue": "^3.0.4"
25
+ },
26
+ "devDependencies": {
27
+ "@vue/cli-plugin-babel": "~4.5.13",
28
+ "@vue/cli-plugin-eslint": "~4.5.13",
29
+ "@vue/cli-service": "~4.5.13",
30
+ "@vue/compiler-sfc": "^3.0.0",
31
+ "babel-eslint": "^10.1.0",
32
+ "eslint": "^6.7.2",
33
+ "eslint-plugin-vue": "^7.0.0"
34
+ },
35
+ "eslintConfig": {
36
+ "root": true,
37
+ "env": {
38
+ "node": true
39
+ },
40
+ "extends": [
41
+ "plugin:vue/vue3-essential",
42
+ "eslint:recommended"
43
+ ],
44
+ "parserOptions": {
45
+ "parser": "babel-eslint"
46
+ },
47
+ "rules": {}
48
+ },
49
+ "browserslist": [
50
+ "> 1%",
51
+ "last 2 versions",
52
+ "not dead"
53
+ ]
54
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "bl-common-vue3",
3
+ "version": "0.2.52",
4
+ "main": "lib/vue3common.umd.min.js",
5
+ "description": "bailing vue3 common components lib",
6
+ "private": false,
7
+ "scripts": {
8
+ "lib": "vue-cli-service build --target lib --name vue3common --dest lib index.js",
9
+ "serve": "vue-cli-service serve",
10
+ "build": "vue-cli-service build",
11
+ "lint": "vue-cli-service lint",
12
+ "publish": "npm publish --access public"
13
+ },
14
+ "dependencies": {
15
+ "@ant-design/icons-vue": "^6.0.1",
16
+ "ant-design-vue": "^2.2.8",
17
+ "axios": "^0.21.4",
18
+ "core-js": "^3.6.5",
19
+ "less": "^4.1.1",
20
+ "less-loader": "^6.0.0",
21
+ "moment": "^2.29.1",
22
+ "qrcode.vue": "^3.3.3",
23
+ "style-resources-loader": "^1.5.0",
24
+ "vue": "^3.0.4"
25
+ },
26
+ "devDependencies": {
27
+ "@vue/cli-plugin-babel": "~4.5.13",
28
+ "@vue/cli-plugin-eslint": "~4.5.13",
29
+ "@vue/cli-service": "~4.5.13",
30
+ "@vue/compiler-sfc": "^3.0.0",
31
+ "babel-eslint": "^10.1.0",
32
+ "eslint": "^6.7.2",
33
+ "eslint-plugin-vue": "^7.0.0"
34
+ },
35
+ "eslintConfig": {
36
+ "root": true,
37
+ "env": {
38
+ "node": true
39
+ },
40
+ "extends": [
41
+ "plugin:vue/vue3-essential",
42
+ "eslint:recommended"
43
+ ],
44
+ "parserOptions": {
45
+ "parser": "babel-eslint"
46
+ },
47
+ "rules": {}
48
+ },
49
+ "browserslist": [
50
+ "> 1%",
51
+ "last 2 versions",
52
+ "not dead"
53
+ ]
54
+ }
@@ -0,0 +1,487 @@
1
+ <template>
2
+ <div class="select-property">
3
+ <a-modal
4
+ title="选择资产"
5
+ :visible="visible"
6
+ :footer="null"
7
+ centered
8
+ @cancel="onClose"
9
+ :width="1000"
10
+ >
11
+ <!-- 筛选项 -->
12
+ <a-form layout="vertical">
13
+ <a-row :gutter="[12, 12]">
14
+ <a-col :span="6">
15
+ <a-form-item label="资产编码">
16
+ <a-input
17
+ v-model:value="searchParams.property_number"
18
+ style="width: 100%"
19
+ placeholder="请输入资产编码"
20
+ />
21
+ </a-form-item>
22
+ </a-col>
23
+ <a-col :span="6">
24
+ <a-form-item label="资产分类">
25
+ <a-tree-select
26
+ placeholder="请选择资产分类"
27
+ v-model:value="searchParams.type"
28
+ style="width: 100%"
29
+ :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
30
+ :tree-data="propertyTypeList"
31
+ :replace-fields="replaceFields"
32
+ tree-checkable
33
+ allow-clear
34
+ :maxTagCount="1"
35
+ :filterTreeNode="filterTreeNodeType"
36
+ :showCheckedStrategy="SHOW_ALL"
37
+ >
38
+ </a-tree-select>
39
+ </a-form-item>
40
+ </a-col>
41
+ <a-col :span="6">
42
+ <a-form-item label="资产名称">
43
+ <a-input
44
+ placeholder="请输入资产名称"
45
+ v-model:value="searchParams.name"
46
+ style="width: 100%"
47
+ allowClear
48
+ />
49
+ </a-form-item>
50
+ </a-col>
51
+ <a-col :span="6">
52
+ <a-form-item label="所在位置">
53
+ <a-tree-select
54
+ placeholder="请选择所在位置"
55
+ v-model:value="searchParams.position_arr"
56
+ style="width: 100%"
57
+ :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
58
+ :tree-data="positionList"
59
+ :replace-fields="replaceFieldsPosition"
60
+ tree-checkable
61
+ allow-clear
62
+ :maxTagCount="1"
63
+ :filterTreeNode="filterTreeNodePosition"
64
+ :showCheckedStrategy="SHOW_ALL"
65
+ >
66
+ </a-tree-select>
67
+ </a-form-item>
68
+ </a-col>
69
+ <a-col :span="6">
70
+ <a-form-item label="品牌">
71
+ <a-input
72
+ placeholder="请输入品牌"
73
+ v-model:value="searchParams.brand"
74
+ style="width: 100%"
75
+ allowClear
76
+ />
77
+ </a-form-item>
78
+ </a-col>
79
+ <a-col :span="6">
80
+ <a-form-item label="型号">
81
+ <a-input
82
+ placeholder="请输入型号"
83
+ v-model:value="searchParams.model_name"
84
+ style="width: 100%"
85
+ allowClear
86
+ />
87
+ </a-form-item>
88
+ </a-col>
89
+ <a-col :span="6">
90
+ <a-form-item label=" ">
91
+ <a-space>
92
+ <a-button @click="reset">重置</a-button>
93
+ <a-button type="primary" @click="getDataList(true)">
94
+ 搜索
95
+ </a-button>
96
+ </a-space>
97
+ </a-form-item>
98
+ </a-col>
99
+ </a-row>
100
+ </a-form>
101
+
102
+ <a-row style="height: 525px">
103
+ <a-col :span="24">
104
+ <!-- 表格 -->
105
+ <a-table
106
+ :columns="columns"
107
+ :dataSource="dataList"
108
+ :pagination="pagination"
109
+ @change="handleTableChange"
110
+ :loading="tableLoading"
111
+ rowKey="id"
112
+ :row-selection="rowSelection"
113
+ :scroll="{ y: 350 }"
114
+ >
115
+ <template #title>
116
+ <a-row
117
+ type="flex"
118
+ align="middle"
119
+ justify="space-between"
120
+ style="padding: 5px 20px"
121
+ >
122
+ <a-col>
123
+ <span style="font-size: 12px; color: #555555">
124
+ 共计 {{ total }} 项
125
+ </span>
126
+ <template v-if="selectedRowKeys.length > 0">
127
+ <span
128
+ style="font-size: 12px; color: #555555; margin-left: 10px"
129
+ >
130
+ 已选中 {{ selectedRowKeys.length }} 项
131
+ </span>
132
+ </template>
133
+ </a-col>
134
+ </a-row>
135
+ </template>
136
+ </a-table>
137
+ </a-col>
138
+ </a-row>
139
+
140
+ <!-- 底部操作栏 -->
141
+ <a-row style="margin-top: 24px">
142
+ <a-col
143
+ :span="24"
144
+ style="display: flex; justify-content: flex-end; align-items: center"
145
+ >
146
+ <a-button @click="onClose"> 取消 </a-button>
147
+ <a-button type="primary" @click="onSubmit" style="margin-left: 10px">
148
+ 保存
149
+ </a-button>
150
+ </a-col>
151
+ </a-row>
152
+ </a-modal>
153
+ </div>
154
+ </template>
155
+
156
+ <script>
157
+ import { computed, defineComponent, reactive, toRefs, watch } from "vue";
158
+ import {
159
+ Modal,
160
+ Button,
161
+ Row,
162
+ Col,
163
+ Table,
164
+ Space,
165
+ Form,
166
+ FormItem,
167
+ Input,
168
+ TreeSelect,
169
+ } from "ant-design-vue";
170
+
171
+ const useForm = Form.useForm;
172
+ const SHOW_ALL = TreeSelect.SHOW_ALL;
173
+
174
+ export default defineComponent({
175
+ name: "SelectProperty",
176
+ components: {
177
+ "a-modal": Modal,
178
+ "a-row": Row,
179
+ "a-col": Col,
180
+ "a-button": Button,
181
+ "a-table": Table,
182
+ "a-space": Space,
183
+ "a-form": Form,
184
+ "a-form-item": FormItem,
185
+ "a-input": Input,
186
+ "a-tree-select": TreeSelect,
187
+ },
188
+ props: {
189
+ visible: {
190
+ type: Boolean,
191
+ default: false,
192
+ },
193
+ status: {
194
+ type: Array,
195
+ default: () => {
196
+ return [];
197
+ },
198
+ },
199
+ selectedList: {
200
+ type: Array,
201
+ default: () => {
202
+ return [];
203
+ },
204
+ },
205
+ type: {
206
+ type: String,
207
+ default: "radio",
208
+ },
209
+ resetPage: {
210
+ type: Boolean,
211
+ default: false,
212
+ },
213
+ },
214
+ setup(props, context) {
215
+ const state = reactive({
216
+ dataList: [],
217
+ page: 1,
218
+ pageSize: 20,
219
+ total: 0,
220
+ tableLoading: false,
221
+ selectedRowKeys: [],
222
+ selectedRows: [],
223
+ propertyTypeList: [], //资产类别下拉列表
224
+ positionList: [], //所在位置下拉列表
225
+ dataListTotal: [], //所有资产,不会因翻页丢失
226
+ });
227
+
228
+ const searchParams = reactive({
229
+ type: undefined, //资产分类
230
+ name: "", //资产名称
231
+ property_number: "", //资产编码
232
+ brand: "", //品牌
233
+ model_name: "", //型号
234
+ position_arr: undefined, //当前位置
235
+ });
236
+ const { resetFields } = useForm(searchParams, {});
237
+
238
+ const pagination = computed(() => ({
239
+ total: state.total,
240
+ current: state.page,
241
+ pageSize: state.pageSize,
242
+ showSizeChanger: true,
243
+ }));
244
+
245
+ const handleTableChange = (pager, filters, sorter) => {
246
+ console.log("handleTableChange", filters, sorter);
247
+ state.page = pager.current;
248
+ state.pageSize = pager.pageSize;
249
+ getDataList();
250
+ };
251
+
252
+ const rowSelection = computed(() => ({
253
+ selectedRowKeys: state.selectedRowKeys,
254
+ type: props.type,
255
+ onChange: onSelectChange,
256
+ }));
257
+
258
+ const onSelectChange = (keys, rows) => {
259
+ state.selectedRowKeys = keys;
260
+
261
+ let arr = [];
262
+ keys.forEach((key) => {
263
+ state.dataListTotal.forEach((item) => {
264
+ if (item.id == key) {
265
+ arr.push(item);
266
+ }
267
+ });
268
+ });
269
+ state.selectedRows = arr;
270
+ };
271
+
272
+ const columns = computed(() => {
273
+ return [
274
+ {
275
+ title: "资产编码",
276
+ dataIndex: "property_number",
277
+ key: "property_number",
278
+ width: "15%",
279
+ align: "center",
280
+ },
281
+ {
282
+ title: "资产分类",
283
+ dataIndex: "type_name",
284
+ key: "type_name",
285
+ width: "15%",
286
+ align: "center",
287
+ },
288
+ {
289
+ title: "资产名称",
290
+ dataIndex: "name",
291
+ key: "name",
292
+ width: "15%",
293
+ align: "center",
294
+ },
295
+ {
296
+ title: "所在位置",
297
+ dataIndex: "position_name",
298
+ key: "position_name",
299
+ width: "15%",
300
+ align: "center",
301
+ },
302
+ {
303
+ title: "品牌",
304
+ dataIndex: "brand",
305
+ key: "brans",
306
+ width: "15%",
307
+ align: "center",
308
+ },
309
+ {
310
+ title: "型号",
311
+ dataIndex: "model_name",
312
+ key: "model_name",
313
+ width: "15%",
314
+ align: "center",
315
+ },
316
+ ];
317
+ });
318
+
319
+ const getDataList = (init = false) => {
320
+ state.tableLoading = true;
321
+ if (init) {
322
+ state.page = 1;
323
+ }
324
+ let params = {
325
+ page: state.page,
326
+ limit: state.pageSize,
327
+ };
328
+ if (props.status && props.status.length > 0) {
329
+ params.status = props.status;
330
+ }
331
+ console.log("searchParams.position_arr", searchParams.position_arr);
332
+ for (let key in searchParams) {
333
+ if (searchParams[key]) {
334
+ params[key] = searchParams[key];
335
+ }
336
+ }
337
+ context.emit("request", {
338
+ params: {
339
+ method: "post",
340
+ server: "/work_property",
341
+ url: "/property/list",
342
+ extra: params,
343
+ },
344
+ success: (res) => {
345
+ // 存储所有资产数据(dataList会因为翻页丢失)
346
+ let arr = [];
347
+ state.dataListTotal.forEach((item) => {
348
+ arr.push(item.id);
349
+ });
350
+ res.list.forEach((resItem) => {
351
+ if (!arr.includes(resItem.id)) {
352
+ state.dataListTotal.push(resItem);
353
+ }
354
+ });
355
+
356
+ state.dataList = res.list;
357
+ state.total = res.total;
358
+ state.tableLoading = false;
359
+ },
360
+ });
361
+ };
362
+
363
+ const reset = () => {
364
+ resetFields();
365
+ getDataList(true);
366
+ };
367
+
368
+ const getTypeList = () => {
369
+ context.emit("request", {
370
+ params: {
371
+ method: "get",
372
+ server: "/work_property",
373
+ url: "/system/category/tree",
374
+ },
375
+ success: (res) => {
376
+ const { list } = res;
377
+ if (list.length) {
378
+ state.propertyTypeList = list.map((item) => {
379
+ if (item.subcat && item.subcat.length > 0) {
380
+ item.selectable = false;
381
+ }
382
+ return item;
383
+ });
384
+ }
385
+ },
386
+ });
387
+ };
388
+
389
+ const getLocationList = () => {
390
+ context.emit("request", {
391
+ params: {
392
+ method: "get",
393
+ server: "/work_property",
394
+ url: "/system/location/tree",
395
+ },
396
+ success: (res) => {
397
+ state.positionList = res.list;
398
+ },
399
+ });
400
+ };
401
+
402
+ const init = () => {
403
+ state.dataList = [];
404
+ state.dataListTotal = [];
405
+ if (props.resetPage) {
406
+ state.page = 1;
407
+ state.pageSize = 20;
408
+ }
409
+ state.selectedRowKeys = props.selectedList.map((item) => item.id);
410
+ state.selectedRows = props.selectedList;
411
+ getDataList();
412
+ getTypeList();
413
+ getLocationList();
414
+ };
415
+
416
+ const filterTreeNodeType = (input, treeNode) => {
417
+ return treeNode.props.category_name.indexOf(input) >= 0;
418
+ };
419
+
420
+ const filterTreeNodePosition = (input, treeNode) => {
421
+ return treeNode.props.location_name.indexOf(input) >= 0;
422
+ };
423
+
424
+ const onClose = () => {
425
+ context.emit("close");
426
+ };
427
+
428
+ const onSubmit = () => {
429
+ context.emit("success", state.selectedRows);
430
+ };
431
+
432
+ watch(
433
+ () => props.visible,
434
+ (val) => {
435
+ if (val) {
436
+ init();
437
+ }
438
+ }
439
+ );
440
+ return {
441
+ columns,
442
+ pagination,
443
+ rowSelection,
444
+ replaceFields: {
445
+ children: "subcat",
446
+ title: "category_name",
447
+ key: "id",
448
+ value: "id",
449
+ },
450
+ replaceFieldsPosition: {
451
+ children: "subcat",
452
+ title: "location_name",
453
+ key: "id",
454
+ value: "id",
455
+ },
456
+ searchParams,
457
+ ...toRefs(state),
458
+ handleTableChange,
459
+ onClose,
460
+ onSubmit,
461
+ getDataList,
462
+ reset,
463
+ filterTreeNodeType,
464
+ filterTreeNodePosition,
465
+ SHOW_ALL,
466
+ };
467
+ },
468
+ });
469
+ </script>
470
+
471
+ <style lang="less" scoped>
472
+ :deep(.ant-form-item) {
473
+ margin-bottom: 0;
474
+ }
475
+
476
+ :deep(.ant-table-title) {
477
+ padding: 0;
478
+ // background-color: #f8f8f9;
479
+ // border-bottom: 1px solid #e8eaec;
480
+ margin-bottom: 5px;
481
+ margin-top: 20px;
482
+ }
483
+
484
+ :deep(.ant-modal-body) {
485
+ height: 659px;
486
+ }
487
+ </style>