p-pc-ui 1.2.1 → 1.2.2
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, reactive, onMounted, render, onBeforeMount, useSlots, toRaw, shallowRef } from "vue";
|
|
3
|
-
import type { FormDataItem } from "./index
|
|
3
|
+
import type { FormDataItem } from "./index";
|
|
4
4
|
import {
|
|
5
5
|
Button as AButton,
|
|
6
6
|
message,
|
|
@@ -80,15 +80,21 @@ const disposeRenderData = (renderData: FormDataItem[]) => {
|
|
|
80
80
|
const _renderData = _.cloneDeep(renderData).map((val) => ({
|
|
81
81
|
...val,
|
|
82
82
|
rules: [] as any,
|
|
83
|
-
}));
|
|
83
|
+
})) as (FormDataItem & {rules:[]})[];
|
|
84
84
|
|
|
85
85
|
for (const renderItem of _renderData) {
|
|
86
|
-
|
|
86
|
+
let { fieldType, fieldRules, label } = renderItem;
|
|
87
87
|
// 处理校验规则
|
|
88
88
|
const rules: any = [];
|
|
89
89
|
const operateType = ["select", "treeSeect", "date", "datePicker"].includes(renderItem.type) ? "选择" : "输入";
|
|
90
90
|
for (const fieldRule of fieldRules || []) {
|
|
91
91
|
const { msg, required, min, max } = fieldRule;
|
|
92
|
+
|
|
93
|
+
// 图片需要额外处理
|
|
94
|
+
|
|
95
|
+
if((renderItem.type == 'uploadOss' || renderItem.type== 'upload') && renderItem.fieldType == 'string'){
|
|
96
|
+
fieldType ='array'
|
|
97
|
+
}
|
|
92
98
|
|
|
93
99
|
if (required) {
|
|
94
100
|
rules.push({
|
|
@@ -184,7 +190,7 @@ const initFormState = (renderData: FormDataItem[], initFromData = {}) => {
|
|
|
184
190
|
break;
|
|
185
191
|
case "string":
|
|
186
192
|
// 如果是图片类型, 并且是string类型,代表用户只需要1张图片,并且已文本的形式存放
|
|
187
|
-
if (renderItem.type == "uploadOss") {
|
|
193
|
+
if (renderItem.type == "uploadOss" || renderItem.type == 'upload') {
|
|
188
194
|
initValue = [];
|
|
189
195
|
} else {
|
|
190
196
|
initValue = "";
|
|
@@ -272,9 +278,9 @@ const getFormData = async (options: { no_check?: Boolean } = {}) => {
|
|
|
272
278
|
else if (renderItem.type == "uploadOss") {
|
|
273
279
|
const fileData = toRaw(formData[key]);
|
|
274
280
|
console.log("asdasdasd", fileData);
|
|
275
|
-
const keys = fileData.map((val)
|
|
281
|
+
const keys = fileData.map((val)=>{return val?.response?.key || val.key});
|
|
276
282
|
returnFormData[key] = renderItem?.fieldType == "string" ? keys[0] : keys;
|
|
277
|
-
}
|
|
283
|
+
}
|
|
278
284
|
// 获取file对象
|
|
279
285
|
else if (renderItem.type == "upload") {
|
|
280
286
|
console.log("上传数据", formState[key]);
|
|
@@ -368,7 +374,8 @@ const uploadRequest = async (options, renderItem: FormDataItem) => {
|
|
|
368
374
|
if (renderItem.type == "uploadOss") {
|
|
369
375
|
const config: any = await renderItem.getOssToken({ file_name: file.name });
|
|
370
376
|
|
|
371
|
-
const key = await uploadOss(file, config
|
|
377
|
+
const key = await uploadOss(file, config);
|
|
378
|
+
console.log("上传结果",key)
|
|
372
379
|
|
|
373
380
|
options.onSuccess({ key }, file);
|
|
374
381
|
} else {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
interface TableBase {
|
|
3
|
-
key: string;
|
|
4
3
|
title: string;
|
|
5
4
|
width?: number;
|
|
6
5
|
sorter?: boolean;
|
|
@@ -11,6 +10,7 @@ interface TableBase {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
interface TablePic extends TableBase {
|
|
13
|
+
key: string;
|
|
14
14
|
type: 'pic';
|
|
15
15
|
showOssUrlFunc?: (ossKey: string) => string;
|
|
16
16
|
picWidth?: number;
|
|
@@ -18,21 +18,23 @@ interface TablePic extends TableBase {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
interface TableLink extends TableBase {
|
|
21
|
+
key: string;
|
|
21
22
|
type: 'link';
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface TableCommon extends TableBase {
|
|
25
|
-
|
|
26
|
+
key: string;
|
|
27
|
+
type: 'common';
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
interface TableDate extends TableBase {
|
|
31
|
+
key: string;
|
|
29
32
|
type: 'date';
|
|
30
33
|
format?: string;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
interface TableOperate extends TableBase {
|
|
34
37
|
type: 'operate',
|
|
35
|
-
key?: string,
|
|
36
38
|
operateButtons: { label: string; click: Function; visibleFunc?: Function }[];
|
|
37
39
|
|
|
38
40
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<script lang="ts" setup>
|
|
3
2
|
// import "viewerjs/dist/viewer.css";
|
|
4
3
|
import { api as viewerApi } from "v-viewer";
|
|
@@ -6,7 +5,7 @@ import PForm from "../p-form/p-form.vue";
|
|
|
6
5
|
import { h, ref, reactive, onMounted, toRaw } from "vue";
|
|
7
6
|
import * as _ from "../../utils/dataUtils";
|
|
8
7
|
import dayjs from "dayjs";
|
|
9
|
-
import {Table as ATable} from
|
|
8
|
+
import { Table as ATable, Button as AButton } from "ant-design-vue";
|
|
10
9
|
import type { FormDataItem } from "../p-form/index.d";
|
|
11
10
|
import type { TableColumn } from "./index.d";
|
|
12
11
|
const SearchFormRef = ref();
|
|
@@ -237,7 +236,7 @@ defineExpose({
|
|
|
237
236
|
:is-search-form="true"
|
|
238
237
|
:render-data="searchRenderData"
|
|
239
238
|
:init-form="initSearchFormData"
|
|
240
|
-
layout="
|
|
239
|
+
layout="inline"
|
|
241
240
|
>
|
|
242
241
|
<template v-slot:button>
|
|
243
242
|
<a-button type="primary" @click="searchClick" style="margin-left: 20px"> 搜索 </a-button>
|
|
@@ -270,11 +269,13 @@ defineExpose({
|
|
|
270
269
|
}"
|
|
271
270
|
bordered
|
|
272
271
|
@change="onchange"
|
|
273
|
-
|
|
272
|
+
>
|
|
273
|
+
<template #bodyCell="slotProps">
|
|
274
|
+
<slot name="bodyCell" v-bind="slotProps" />
|
|
275
|
+
</template>
|
|
276
|
+
</a-table>
|
|
274
277
|
</template>
|
|
275
278
|
|
|
276
|
-
|
|
277
|
-
|
|
278
279
|
<style>
|
|
279
280
|
.ant-table-striped :deep(.table-striped) td {
|
|
280
281
|
background-color: #fafafa;
|