From c4d9e7a20dac267c5496ad3586c5053be279a17a Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 26 四月 2024 20:09:59 +0800
Subject: [PATCH] 添加action,表单组件
---
Source/ProjectWeb/src/actions/base/AddAction.js | 6
Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue | 11 +-
Source/ProjectWeb/src/actions/base/BaseAction.js | 14 +-
Source/ProjectWeb/src/views/base/UIContentArea.vue | 13 ++
Source/ProjectWeb/src/App.vue | 13 ++
Source/ProjectWeb/src/components/PLT-basic-component/formUpload.vue | 13 ++
Source/ProjectWeb/src/components/actions/AddEditDialog.vue | 115 +++++++++++++---------
Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue | 8 +
Source/ProjectWeb/src/components/PLT-basic-component/richText.vue | 12 ++
Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue | 4
Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue | 35 +++++-
Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue | 1
12 files changed, 164 insertions(+), 81 deletions(-)
diff --git a/Source/ProjectWeb/src/App.vue b/Source/ProjectWeb/src/App.vue
index e909b77..7e3593f 100644
--- a/Source/ProjectWeb/src/App.vue
+++ b/Source/ProjectWeb/src/App.vue
@@ -28,7 +28,18 @@
.el-card__body {
padding: 15px;
}
-
+.el-dialog{
+ margin: 50px auto;
+}
+.avue-dialog .el-dialog{
+ top:50%;
+ max-height: calc(100% - 100px);
+ -webkit-transform: translate(-50%, 0);
+ transform: translate(-50%, -50%);
+}
+.avue-dialog .el-dialog__body{
+ padding: 20px;
+}
.avue--detail .el-col{
margin-bottom: 0;
}
diff --git a/Source/ProjectWeb/src/actions/base/AddAction.js b/Source/ProjectWeb/src/actions/base/AddAction.js
index e233a7e..5ac9b70 100644
--- a/Source/ProjectWeb/src/actions/base/AddAction.js
+++ b/Source/ProjectWeb/src/actions/base/AddAction.js
@@ -6,7 +6,7 @@
import Vue from "vue";
import AddEditDialog from "@/components/actions/AddEditDialog"
-export const doAction = (options) => {
+export const doAction = (options,callback) => {
options.paramVOS = paramLow(options.paramVOS)
const paramVOS = Object.assign({
url: '/api/uiDataController/addSave',
@@ -19,7 +19,7 @@
callPreEvent(options, doBefore, function (options) {
doAdd(options, function () {
- callPostEvent(options, doAfter, options.callback);
+ callPostEvent(options, doAfter, callback);
});
});
};
@@ -50,7 +50,7 @@
instance = null;
};
if (callback) {
- instance.saveCallback = callback(options);
+ instance.saveCallback = callback;
}
let vm = instance.$mount();
document.body.appendChild(vm.$el);
diff --git a/Source/ProjectWeb/src/actions/base/BaseAction.js b/Source/ProjectWeb/src/actions/base/BaseAction.js
index 93c5db0..c4cec61 100644
--- a/Source/ProjectWeb/src/actions/base/BaseAction.js
+++ b/Source/ProjectWeb/src/actions/base/BaseAction.js
@@ -8,13 +8,13 @@
/**
* action閫氱敤鍏ュ彛
*/
-export const doAction = (button,options) => {
+export const doAction = (button,options,callback) => {
options.paramVOS['title']=replaceFreeMarker(options.paramVOS.title,options.dataStore,options.sourceData);
if(button.url && button.url!='null'){
//鏈夐厤缃產ction璺緞锛屼娇鐢ㄨ矾寰勫搴旂殑js
import("../"+button.url+".js").then(module => {
- module.doAction(options);
+ module.doAction(options,callback);
})
}else {
//閫氱敤action
@@ -23,15 +23,15 @@
view: () => {},
//鍒涘缓
add: () => {import("@/actions/base/AddAction").then(module => {
- module.doAction(options);
+ module.doAction(options,callback);
})},
//淇敼
edit: () => {import("@/actions/base/EditAction").then(module => {
- module.doAction(options);
+ module.doAction(options,callback);
})},
//鍒犻櫎
delete: () => {import("@/actions/base/DeleteAction").then(module => {
- module.doAction(options);
+ module.doAction(options,callback);
})},
};
if(validatenull(options.paramVOS.context)) {
@@ -124,7 +124,7 @@
fnTarget(buttonParse,callback);
}else{
try {
- import("../"+buttonParse.jsPath).then(module => {
+ import("../"+buttonParse.jsPath+".js").then(module => {
module[buttonParse.methodName](options,callback);
})
} catch (error) {
@@ -152,7 +152,7 @@
fnTarget(buttonParse,callback);
}else{
try {
- import("../"+buttonParse.jsPath).then(module => {
+ import("../"+buttonParse.jsPath+".js").then(module => {
module[buttonParse.methodName](options,callback);
})
} catch (error) {
diff --git a/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue b/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
index cf56bf7..fd07194 100644
--- a/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
+++ b/Source/ProjectWeb/src/components/PLT-basic-component/basicForm.vue
@@ -3,7 +3,7 @@
<avue-form ref="formRef" :option="option" v-model="form">
<template v-for="item in allColumn" :slot="item.prop+ ''">
<vciWebRefer
- v-if="item.propType === 'refer' || item.type === 'refer'"
+ v-if="item.type === 'refer'"
:key="item.prop"
referType="master"
:data-key="item.prop"
@@ -16,9 +16,18 @@
@setReferValue="setReferValue"
></vciWebRefer>
<!-- 瀵屾枃鏈帶浠� -->
- <rich-text v-if="item.type === 'richText'" :value="form[subitemName]" @input="form[subitemName] = $event"></rich-text>
+ <rich-text v-else-if="item.type === 'richText'"
+ :key="item.prop"
+ :data-key="item.prop"
+ :disabled="item.disabled || false"
+ :display="item.display || true"
+ :value="form[subitemName]" @input="form[subitemName] = $event"></rich-text>
<!-- 琛ㄥ崟涓婁紶鏂囦欢缁勪欢 -->
- <form-upload v-if="item.type === 'upload'"></form-upload>
+ <form-upload v-else-if="item.type === 'upload'"
+ :key="item.prop"
+ :data-key="item.prop"
+ :disabled="item.disabled || false"
+ :display="item.display || true"></form-upload>
</template>
</avue-form>
</template>
@@ -57,6 +66,11 @@
type:Boolean,
default:false
},
+ isEdit:{
+ //琛ㄥ崟鏄惁鍙紪杈�
+ type:Boolean,
+ default:true
+ }
},
data() {
return {
@@ -107,7 +121,7 @@
handler(val) {
for (let code of this.option.column) {
if (
- (code.propType == "refer" || code.type == 'refer' )&&
+ code.type == 'refer' &&
code.referConfig &&
code.referConfig.useFormKey
) {
@@ -118,7 +132,7 @@
for (let code of this.option.group) {
for (let col of code.column) {
if (
- (col.propType == "refer" || col.type == 'refer')&&
+ col.type == 'refer'&&
col.referConfig &&
col.referConfig.useFormKey
) {
@@ -158,7 +172,7 @@
this.option.group = group;
},
initItem(item){
- const type=this.columnType[item.type] || item.type
+ const type=this.columnType[item.type] || item.type;
const col= {
...item,
label: item.text,
@@ -179,11 +193,14 @@
suffixIcon: item.prefix,
tip: item.tooltips,
dictCode: item.comboxKey,
- rules: [{
+ rules: this.isEdit?[{
required: item.required,
message: `璇疯緭鍏�${item.text}!`,
trigger: "blur"
- }]
+ }]:[]
+ };
+ if(!this.isEdit){
+ col.placeholder=col.label;
}
if(col.type === 'richText'){
this.subitemName = col.field;
@@ -211,7 +228,7 @@
});
}
}
- if (col.propType === "refer"|| col.type==='refer') {
+ if (col.type==='refer') {
if (col.referConfig && col.referConfig.useFormKey) {
if (validatenull(col.referConfig.formValuesKey)) {
col.referConfig.formValuesKey = "form";
diff --git a/Source/ProjectWeb/src/components/PLT-basic-component/formUpload.vue b/Source/ProjectWeb/src/components/PLT-basic-component/formUpload.vue
index 8783f13..1728191 100644
--- a/Source/ProjectWeb/src/components/PLT-basic-component/formUpload.vue
+++ b/Source/ProjectWeb/src/components/PLT-basic-component/formUpload.vue
@@ -2,10 +2,11 @@
<!--
directory 寮�鍚洰褰�
-->
- <el-upload
+ <el-upload v-if="display"
ref="uploadRef"
:before-upload="handleBeforeUpload"
:directory="true"
+ :disabled="disabled"
:headers="uploadHeaders"
:on-change="handleFileChange"
:on-error="onError"
@@ -34,6 +35,16 @@
// fileAccpet:String,
// defalut:'.img,.xls,.png,.xlsx'
// },
+ props: {
+ disabled:{
+ type:Boolean,
+ default:false
+ },
+ display:{
+ type:Boolean,
+ default:true
+ }
+ },
data() {
return {
pageLoading: null,
diff --git a/Source/ProjectWeb/src/components/PLT-basic-component/richText.vue b/Source/ProjectWeb/src/components/PLT-basic-component/richText.vue
index 36cddd7..025248d 100644
--- a/Source/ProjectWeb/src/components/PLT-basic-component/richText.vue
+++ b/Source/ProjectWeb/src/components/PLT-basic-component/richText.vue
@@ -1,5 +1,5 @@
<template>
- <div id='quillEditorQiniu'>
+ <div id='quillEditorQiniu' v-if="display">
<!-- 鍩轰簬elementUi鐨勪笂浼犵粍浠� el-upload begin-->
<el-upload
:accept="'image'"
@@ -12,7 +12,7 @@
class="avatar-uploader">
</el-upload>
<!-- 鍩轰簬elementUi鐨勪笂浼犵粍浠� el-upload end-->
- <quill-editor ref="customQuillEditor" v-model="value" :options="editorOption" class="editor">
+ <quill-editor ref="customQuillEditor" v-model="value" :disabled="disabled" :options="editorOption" class="editor">
</quill-editor>
</div>
<!-- <template #footer>-->
@@ -48,6 +48,14 @@
},
value: {
type: String
+ },
+ disabled:{
+ type:Boolean,
+ default:false
+ },
+ display:{
+ type:Boolean,
+ default:true
}
},
data() {
diff --git a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
index 54343ca..a051c80 100644
--- a/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
+++ b/Source/ProjectWeb/src/components/actions/AddEditDialog.vue
@@ -1,31 +1,33 @@
<template>
<el-dialog v-dialogDrag
- :title="paramVOS.title"
+ :title="title"
:visible.sync="visible"
:width="width"
- :fullscreen="paramVOS.content || paramVOS.context"
+ :fullscreen="fullscreen"
:append-to-body="true"
- class="avue-dialog avue-dialog--top"
+ top="0"
+ class="avue-dialog"
:destroy-on-close="true"
@close="dialogClose">
<basic-form ref="formRef" v-if="paramVOS.form"
+ :key="'dialog-'+paramVOS.form"
:span="span"
:formItems="formItems"
:formData="form">
</basic-form>
- <ui-view ref="uiViewRef" v-else-if="paramVOS.content || paramVOS.context"
+ <ui-view ref="uiViewRef" v-else-if="paramVOS.context"
+ :key="'AddEditDialog-'+type"
:btmType="paramVOS.type"
:context="paramVOS.context"
:inDialog="true"
- :key="'AddEditDialog-'+type"
:sourceData="sourceData"
:dataStore="dataStore"
:paramVOS="paramVOS"
></ui-view>
- <div slot="footer" class="dialog-footer avue-dialog__footer">
+ <div class="dialog-footer avue-dialog__footer">
<el-button type="primary" plain size="small" @click="saveHandler">淇� 瀛�</el-button>
<el-button size="small" @click="dialogClose">鍙� 娑�</el-button>
- <el-button size="small" @click="resetValue">閲� 缃�</el-button>
+ <el-button size="small" @click="resetValue" v-if="paramVOS.form">閲� 缃�</el-button>
</div>
</el-dialog>
</template>
@@ -52,10 +54,6 @@
paramVOS: {
type: Object,
default: {}
- },
- width: {
- type: String,
- default:'60%'
}
},
data(){
@@ -70,6 +68,20 @@
computed:{
title(){
return this.paramVOS.title || (this.type=='add'?'娣诲姞':'淇敼')
+ },
+ width(){
+ return this.paramVOS.width || "60%"
+ },
+ height(){
+ return this.paramVOS.height || "500px"
+ },
+ fullscreen(){
+ if(this.paramVOS.width || this.paramVOS.height){
+ return false;
+ }else if(this.paramVOS.form){
+ return false;
+ }
+ return false;
}
},
created() {
@@ -117,49 +129,60 @@
}
},
saveHandler() {
- this.$refs.formRef.validate((valid, done) => {
- if (valid) {
- if(this.type=="add"){
- addSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => {
- this.$message({
- type: "success",
- message: "淇濆瓨鎴愬姛!"
- });
- if(this.saveCallback){
- this.saveCallback();
- }
- this.dialogClose();
- }).error((e) => {
- this.$message.error(e||"淇濆瓨澶辫触")
- });
- }else{
- editSave(this.form,this.paramVOS.url,this.paramVOS.method).then(() => {
- this.$message({
- type: "success",
- message: "淇敼鎴愬姛!"
- });
- if(this.saveCallback){
- this.saveCallback();
- }
- this.dialogClose();
- }).error((e) => {
- this.$message.error(e||"淇敼澶辫触")
- });
- }
- } else {
+ if(this.paramVOS.form){
+ this.$refs.formRef.validate((valid, done) => {
+ if (valid) {
+ this.saveValue(this.form)
+ } else {
+ }
+ });
+ }else{
+ //this.$refs.uiViewRef.
+ if(this.saveCallback){
+ this.saveCallback({});
}
- });
+ }
+
+ },
+ saveValue(savedata){
+ if(this.type=="add"){
+ addSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => {
+ this.$message({
+ type: "success",
+ message: "淇濆瓨鎴愬姛!"
+ });
+ if(this.saveCallback){
+ this.saveCallback(savedata);
+ }
+ this.dialogClose();
+ }).error((e) => {
+ this.$message.error(e||"淇濆瓨澶辫触")
+ });
+ }else{
+ editSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => {
+ this.$message({
+ type: "success",
+ message: "淇敼鎴愬姛!"
+ });
+ if(this.saveCallback){
+ this.saveCallback(savedata);
+ }
+ this.dialogClose();
+ }).error((e) => {
+ this.$message.error(e||"淇敼澶辫触")
+ });
+ }
},
resetValue() {
- this.$refs.formRef.resetFields();
+ if (this.paramVOS.form) {
+ this.$refs.formRef.resetFields();
+ }
}
}
}
</script>
<style scoped>
-.avue-dialog__footer{
- margin-bottom: 20px;
-}
+
</style>
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
index c190cd4..00548e2 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
@@ -176,15 +176,14 @@
}
const that=this;
- if(isShow){
+ if(isShow) {
doAction(buttonitem, {
paramVOS: paramVOS,
dataStore: this.dataStore || [],
- sourceData: this.sourceData || {},
- callback: function () {
- if (that.$parent.handleRefresh) {
- that.$parent.handleRefresh()
- }
+ sourceData: this.sourceData || {}
+ },function (){
+ if (that.$parent.handleRefresh) {
+ that.$parent.handleRefresh()
}
});
}
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
index 3e51d12..0ae6114 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -1,8 +1,12 @@
<template>
<div :id="'UI-dynamic-'+areasName+componentVO.oid" class="UI-dynamic">
- <dynamic-button v-if="componentVO && componentVO.buttons" :componentVO="componentVO" :butttonList="componentVO.buttons" :dataStore="[form]" :sourceData="sourceData" type="form"></dynamic-button>
- <basic-form :span="this.componentVO.formDefineVO.columnOneRow?(24/this.componentVO.formDefineVO.columnOneRow) : 12"
+ <dynamic-button v-if="componentVO && componentVO.buttons" :key="areasName+'buttons-'+componentVO.oid"
+ :componentVO="componentVO" :butttonList="componentVO.buttons" :dataStore="[form]" :sourceData="sourceData" type="form"></dynamic-button>
+ <basic-form :key="areasName+'basicForm-'+componentVO.oid"
+ :span="this.componentVO.formDefineVO.columnOneRow?(24/this.componentVO.formDefineVO.columnOneRow) : 12"
:formItems="this.componentVO.formDefineVO && this.componentVO.formDefineVO.items"
+ :disabled="!inDialog"
+ :isEdit="inDialog"
:formData="form">
</basic-form>
</div>
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
index 43bde97..92ee092 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-table.vue
@@ -16,7 +16,9 @@
@selection-change="selectChange">
<!--top鍖哄煙鎸夐挳-->
<template slot="menuLeft" slot-scope="scope">
- <dynamic-button :componentVO="componentVO" :butttonList="componentVO.buttons" :dataStore="selectList" LocationType="top" :sourceData="sourceData"
+ <dynamic-button :componentVO="componentVO"
+ :key="areasName+'buttons-'+componentVO.oid"
+ :butttonList="componentVO.buttons" :dataStore="selectList" LocationType="top" :sourceData="sourceData"
type="table"></dynamic-button>
</template>
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
index 5eb4afb..a51cb18 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-tree.vue
@@ -1,6 +1,7 @@
<template>
<div class="UI-dynamic" :id="'UI-dynamic-'+areasName+componentVO.oid">
<dynamic-button v-if="componentVO.buttons && componentVO.buttons.length>0" :componentVO="componentVO"
+ :key="areasName+'buttons-'+componentVO.oid"
:butttonList="componentVO.buttons" :dataStore="checkDatas"
:sourceData="sourceData" type="tree" style="margin-bottom: 5px;"></dynamic-button>
<el-input
diff --git a/Source/ProjectWeb/src/views/base/UIContentArea.vue b/Source/ProjectWeb/src/views/base/UIContentArea.vue
index d6c7056..3978afc 100644
--- a/Source/ProjectWeb/src/views/base/UIContentArea.vue
+++ b/Source/ProjectWeb/src/views/base/UIContentArea.vue
@@ -84,12 +84,19 @@
description="璇ュ尯鍩熸病鏈夐厤缃樉绀虹殑鍐呭">
</el-alert>
<el-alert
- v-else-if="Object.keys(newSourceData).length> 0"
+ v-else-if="Object.keys(newSourceData).length== 0"
class="alert"
:closable="false"
title=""
- type="error"
- show-icon
+ type="info"
+ description="娌℃湁鍙樉绀虹殑鍐呭锛岃閫夋嫨鏉ユ簮鏁版嵁銆�">
+ </el-alert>
+ <el-alert
+ v-else-if="newAreasData.length== 0"
+ class="alert"
+ :closable="false"
+ title=""
+ type="info"
description="涓嶆弧瓒虫樉绀鸿〃杈惧紡鏉′欢锛屾病鏈夊彲鏄剧ず鐨勫唴瀹广��">
</el-alert>
</div>
--
Gitblit v1.9.3