master
xy 2 years ago
parent 789d8f482d
commit c7c0f49393

@ -16,6 +16,7 @@
"dependencies": {
"@smallwei/avue": "^2.9.15",
"@tinymce/tinymce-vue": "^3.0.1",
"af-table-column": "^1.0.3",
"avue-plugin-map": "^1.0.1",
"axios": "0.18.1",
"core-js": "3.6.5",

@ -794,7 +794,7 @@ export default {
return $scopedSlots[item.prop](item, index);
}
return (
<el-table-column
<af-table-column
// TODO: keysort
//key={`xy-table-col-${item.prop}`}
key={String(Math.random()) + index}
@ -804,7 +804,7 @@ export default {
column-key={String(Math.random())}
label={item.label}
prop={item.prop}
width={item.width || "auto"}
width={item.width}
min-width={item.minWidth}
fixed={item.fixed ?? false}
render-header={item.renderHeader}
@ -819,7 +819,6 @@ export default {
header-align={item.headerAlign ?? "center"}
class-name={`xy-table__row-fade ${item.className} body-cell-${index}`}
label-class-name={`xy-table__title-fade ${item.labelClassName} header-cell-${index}`}
selectable={item.selectable}
reserve-selection={item.reserveSelection}
filters={item.filters}
@ -845,7 +844,7 @@ export default {
{item.multiHd
? item.multiHd.map((item1, index1) => {
return (
<el-table-column
<af-table-column
//key={`xy-table-col-multi-${item1.prop}`}
key={String(Math.random()) + index1}
prop={`${item.pProp ? item.pProp + "." : ""}${
@ -889,11 +888,11 @@ export default {
}
: ""
}
></el-table-column>
></af-table-column>
);
})
: ""}
</el-table-column>
</af-table-column>
);
})}
{$scopedSlots.btns ? $scopedSlots.btns() : this.isCreateAuthBtns()}

@ -6,13 +6,16 @@ export const templatePropsMap = new Map([
}],
["richtext",'my-tinymce'],
['select', {
value: '选项1'
value: '选项1',
readonly: true
}],
['radio',{
value: '选项1'
value: '选项1',
readonly: true
}],
["checkbox", {
multiple: true,
readonly: true,
value: ['选项1']
}],
["date", {

@ -79,6 +79,8 @@ import tinymce from '@/components/XyTinymce'
Vue.component('my-tinymce',tinymce)
import myMap from "@/components/XyMap"
Vue.component('my-map',myMap)
import afTableColumn from 'af-table-column'
Vue.component('af-table-column',afTableColumn)
Vue.prototype.$integrateData = (target,value) => {
for(let i in target){

@ -54,7 +54,10 @@ export default {
props: {
label: i.name,
prop: i.field,
required: i.validation instanceof Array ? !!i.validation.find(i => i === 'required') : false,
required:
i.validation instanceof Array
? !!i.validation.find((i) => i === "required")
: false,
},
},
[
@ -63,7 +66,7 @@ export default {
{
ref: `elEdit_${i.field}`,
style: {
width: '100%'
width: "100%",
},
props: {
...addPropsMap.get(i.edit_input),
@ -83,6 +86,55 @@ export default {
}
},
},
scopedSlots:
i.edit_input === "file" || i.edit_input === "files"
? {
file: (scope) => {
let { file } = scope;
console.log(111, file);
return [
h("div", {}, [
h("i", {
class: {
"el-icon-circle-check":
file.status === "success",
"el-icon-loading":
file.status === "uploading",
},
style: {
"color": file.status === "success" ? "green" : ""
}
}),
h(
"a",
{
attrs: {
href: file.url,
download: file.name,
},
class: {
"uploaded-a":
file.status === "success",
}
},
file.name
)
]),
h("i", {
class: "el-icon-close",
on: {
["click"]: () =>
this.fileRemoveHandler(
file,
i.field
),
},
}),
];
},
}
: "",
},
this.optionsRender(h, i)
),
@ -140,12 +192,14 @@ export default {
dialogVisible: false,
form: {},
rules: {},
file: {
}
file: {},
};
},
methods: {
fileRemoveHandler(file, field) {
this.file[field] = this.file[field].filter((item) => item !== file);
this.file = Object.assign({}, this.file);
},
//on
getEventType(info) {
if (info.type === "checkbox") {
@ -159,11 +213,13 @@ export default {
if (info.edit_input === "checkbox" || info.edit_input === "radio") {
return info._paramters && info._paramters instanceof Array
? info._paramters.map((i) =>
h(
"el-option",
{ props: { label: i.name || i.no || i.value || i.id , value : i.id } }
h("el-option", {
props: {
label: i.name || i.no || i.value || i.id,
value: i.id,
},
})
)
)
: [];
}
if (info.edit_input === "file" || info.edit_input === "files") {
@ -230,6 +286,14 @@ export default {
props.onRemove = (file, fileList) => {
this.file[info.field] = fileList;
};
props.onError = (err,file,fileList) => {
this.file[info.field] = fileList;
this.$message({
type: "warning",
message: err
})
}
}
return props;
},
@ -270,6 +334,18 @@ export default {
const res = await show({ id: this.id, table_name: this.tableName });
this.$integrateData(this.form, res);
this.form = Object.assign({}, this.form);
this.formInfo.forEach((i) => {
if (i && i.edit_input === "file") {
this.file[i.field] = [
{
name: res[i.link_with_name]?.original_name,
url: res[i.link_with_name]?.url,
response: res[i.link_with_name],
},
];
}
});
},
submit() {
@ -294,8 +370,8 @@ export default {
(i) => i?.response?.id
);
}
if(info.edit_input === "file") {
this.form[info.field] = this.file[info.field][0]?.response?.id
if (info.edit_input === "file") {
this.form[info.field] = this.file[info.field][0]?.response?.id;
}
});
console.log(this.form);
@ -322,7 +398,11 @@ export default {
newVal.forEach((i) => {
if (i.field) {
this.form[i.field] = "";
if (i.validation instanceof Array && i.validation.length > 0 && !!i.validation.find(i => i === 'required')) {
if (
i.validation instanceof Array &&
i.validation.length > 0 &&
!!i.validation.find((i) => i === "required")
) {
this.rules[i.field] = [
{ required: true, message: `请填写${i.name}` },
];
@ -330,7 +410,7 @@ export default {
if (i.edit_input === "files") {
this.form[i.field] = [];
}
if(i.edit_input === "files" || i.edit_input === "file") {
if (i.edit_input === "files" || i.edit_input === "file") {
this.file[i.field] = [];
}
if (i.edit_input === "checkbox") {
@ -359,4 +439,15 @@ export default {
};
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
.uploaded-a {
color: red;
text-decoration: none;
transition: all 0.2s;
}
.uploaded-a:hover {
color: red;
text-decoration: underline;
}
</style>

@ -43,7 +43,7 @@
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
import { getToken } from "@/utils/auth";
import { imports } from "@/api/system/baseForm"
import { imports } from "@/api/system/baseForm";
export default {
props: {
formInfo: {

@ -283,6 +283,7 @@ export default {
this.selectForm = ''
this.table = res.data.map(i => {
let linkOb = {}
if(i.parameter_id) {
linkOb.customFn = row => {
return (
@ -293,9 +294,15 @@ export default {
if(i.link_table_name) {
if(i.link_relation === 'hasOne') {
linkOb.customFn = row => {
return (
<span>{ row[i.link_with_name]?.name || row[i.link_with_name]?.no || row[i.link_with_name]?.value }</span>
)
if(i.edit_input === 'file') {
return (
<a download={row[i.link_with_name]?.original_name} href={ row[i.link_with_name]?.url }>{ row[i.link_with_name]?.original_name }</a>
)
}else{
return (
<span>{ row[i.link_with_name]?.name || row[i.link_with_name]?.no || row[i.link_with_name]?.value }</span>
)
}
}
}
if(i.link_relation === 'hasMany') {
@ -311,8 +318,15 @@ export default {
return Object.assign({
prop: i.field,
label: i.name,
width: i.width,
fixed: i.is_fixed
},linkOb)
})
this.table.unshift({
type: 'index',
width: 60,
label: '序号'
})
}
},
computed: {
@ -360,4 +374,15 @@ export default {
padding: 0 10px;
}
}
a {
color: red;
text-decoration: none;
transition: all 0.2s;
}
a:hover {
color: red;
text-decoration: underline;
}
</style>

@ -15,7 +15,7 @@
></el-input>
</el-form-item>
<el-form-item required prop="field" label="字段标识">
<el-input v-model="selectedForm.field" disabled></el-input>
<el-input v-model="selectedForm.field"></el-input>
</el-form-item>
<el-form-item label="关联方式">
<el-select
@ -126,6 +126,30 @@
:inactive-value="0"
></el-switch>
</el-form-item>
<el-form-item label="是否固定" prop="is_fix">
<el-select
v-model="selectedForm.is_fix"
clearable
:popper-append-to-body="false"
placeholder="请选择固定方式"
style="width: 100%"
>
<el-option
v-for="item in [{ value: 'left',label: '左' }, { value: 'right',label: '右' }]"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item prop="width" label="列宽">
<el-input-number
clearable
:controls="false"
v-model="selectedForm.width"
placeholder="不输入为自动计算"
style="width: 100%"
></el-input-number>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveField"></el-button>
<el-button
@ -283,4 +307,8 @@ export default {
};
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left;
}
</style>

@ -205,6 +205,8 @@ export default {
list_show: 1,
link_table_name: "",
link_relation: "",
is_fix: "",
width: ""
};
this.$store.commit("form/SPLICE_FORM_LIST", {

@ -69,13 +69,13 @@ export default {
{
prop:'table_name',
label:'表名',
width:180,
//width:180,
sortable:'custom',
},
{
prop:'name',
label:'名称',
width:200,
// width:200,
sortable:'custom',
},
]

Loading…
Cancel
Save