From 59765cab961847dfd101e69ae6d8d1d501a5284c Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期二, 04 六月 2024 11:10:28 +0800
Subject: [PATCH] 1、ice配置文件上传
---
Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue | 400 +++++++++++++++++---------------------------------------
1 files changed, 124 insertions(+), 276 deletions(-)
diff --git a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
index 3104d06..4cadbbc 100644
--- a/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
+++ b/Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -1,74 +1,35 @@
<template>
<div :id="'UI-dynamic-'+areasName+componentVO.oid" class="UI-dynamic">
- <avue-form v-model="form" :option="option">
- <template v-for="item in slotData" :slot="item.prop + 'Label'">
- <span>
- <span>{{ item.label }} </span>
- <el-tooltip
- v-if="item.keyAttr"
- class="item"
- content="璇ュ睘鎬т负鍏抽敭灞炴��"
- effect="dark"
- placement="top-start"
- >
- <i class="el-icon-star-on" style="font-size: 17px !important; color: red;vertical-align: baseline;"></i>
- </el-tooltip>
- </span>
- </template>
- <template slot="menuForm">
- <dynamic-button :butttonList="componentVO.buttons" type="form" @buttonClick="buttonClick"></dynamic-button>
- </template>
-
- <template v-for="item in slotData" :slot="item.prop + ''">
- <vciWebRefer v-if="item.type == 'refer'"
- :key="item.prop"
- :ref="'referFormRef'+item.prop"
- :data-key="item.prop"
- :disabled="item.disabled || false"
- :display="item.display || true"
- :referConfig="item.referConfig || {}"
- :reloadFormKey="(item.referConfig.useFormKey && item.referConfig.formValues && item.referConfig.formValues[item.referConfig.useFormKey]) || ''"
- :text="item.referConfig.showProp"
- :value="item.prop || item.value"
- referType="master"
- @setReferValue="setReferValue">
-
- </vciWebRefer>
- <quill-editor ref="customQuillEditor" v-model="content" :options="editorOption" class="editor">
- </quill-editor>
- </template>
- </avue-form>
+ <dynamic-button v-if="componentVO && componentVO.buttons" :key="areasName+'buttons-'+componentVO.oid"
+ :componentVO="componentVO" :butttonList="componentVO.buttons" :dataStore="[form]" :sourceData="sourceData"
+ @afterMethod="handleRefresh" 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="canEdit"
+ :formData="form"
+ :initValue="paramVOS.initvalue"
+ :uploadattachment="paramVOS.uploadattachment || false"
+ @getFormData="getFormData">
+ </basic-form>
</div>
</template>
<script>
-import vciWebRefer from '@/components/refer/vciWebRefer'
-import VciWebRefer from "@/components/refer/vciWebRefer";
-import {verifyNull, verifySlash} from "@/util/validate";
+import {dataForm} from "@/api/base/ui";
-const toolbarOptions = [
- ['bold', 'italic', 'underline', 'strike'], // toggled buttons
- ['blockquote', 'code-block'],
-
- [{'header': 1}, {'header': 2}], // custom button values
- [{'list': 'ordered'}, {'list': 'bullet'}],
- [{'script': 'sub'}, {'script': 'super'}], // superscript/subscript
- [{'indent': '-1'}, {'indent': '+1'}], // outdent/indent
- [{'direction': 'rtl'}], // text direction
-
- [{'size': ['small', false, 'large', 'huge']}], // custom dropdown
- [{'header': [1, 2, 3, 4, 5, 6, false]}],
-
- [{'color': []}, {'background': []}], // dropdown with defaults from theme
- [{'font': []}],
- [{'align': []}],
- ['link', 'image', 'video'],
- ['clean'] // remove formatting button
-];
export default {
name: "dynamic-form",
- components: {VciWebRefer},
props: {
+ //ui涓婁笅鏂囩殑涓氬姟绫诲瀷锛堟垨閾炬帴绫诲瀷锛�
+ uiBtmType: {
+ type: String
+ },
+ //ui涓婁笅鏂�
+ uiContext:{
+ type: String
+ },
componentVO: {
type: Object,
default: {}
@@ -76,6 +37,15 @@
inDialog: {
type: Boolean,
default: false
+ },
+ canEdit:{
+ //鍐呭鏄惁鍙紪杈�
+ type:Boolean,
+ default:false
+ },
+ actionType:{
+ //鎸夐挳鎿嶄綔绫诲瀷
+ default:""
},
areasName: {
type: String,
@@ -85,6 +55,10 @@
//鎵�灞炲尯鍩熺殑涓婁竴鍖哄煙閫変腑鏁版嵁
type: Object,
default: {}
+ },
+ //涓婁竴鍖哄煙涓氬姟绫诲瀷
+ sourceBtmType:{
+ type: String
},
dataStore: {
//寮圭獥鏃舵寜閽墍灞炲尯鍩熼�変腑鏁版嵁
@@ -104,239 +78,113 @@
data() {
return {
form: {},
- content: '',
- editorOption: {
- placeholder: '浣犳兂璇翠粈涔堬紵',
- modules: {
- imageResize: {
- displayStyles: {
- backgroundColor: 'black',
- border: 'none',
- color: 'white'
- },
- modules: ['Resize', 'DisplaySize', 'Toolbar']
- },
- toolbar: {
- container: toolbarOptions, // 宸ュ叿鏍�
- handlers: {
- 'image': function (value) {
- if (value) {
- document.querySelector('#quillEditorQiniu .avatar-uploader input').click()
- } else {
- this.quill.format('image', false);
- }
- },
- 'video': function (value) {
- if (value) {
- document.querySelector('#quillEditorQiniu .avatar-uploader input').click()
- } else {
- this.quill.format('video', false);
- }
- },
- }
- }
- }
- }
+ params:{},
+ sourceDataMapParams:{},
+ currentDefineVO:this.componentVO.formDefineVO,
}
},
mounted() {
},
- computed: {
- option() {
- return {
- submitBtn: false,
- emptyBtn: false,
- height: 300,
- column: this.getColumnData()
- }
- },
- slotData() {
- return this.getColumnData()
- }
- },
watch: {
- slotData: {
- handler(newV) {
- this.getDictList(newV)
- },
- immediate: true,
- },
- form: {
- handler(val) {
- if (val) {
- if (Array.isArray(val)) { // 妫�鏌� val 鏄惁涓烘暟缁�
- for (let code of val) {
- if (
- code.type == "refer" &&
- code.referConfig &&
- code.referConfig.useFormKey
- ) {
- code.referConfig.formValues = val;
- // code.referConfigTemp.options = code.referConfig;
- }
- }
- } else if (typeof val === 'object') { // 妫�鏌� val 鏄惁涓哄璞�
- // 杩唬瀵硅薄鐨勯�昏緫
- }
- this.$emit("input", val);
+ form:{
+ handler(newval) {
+ if(newval) {
+
}
},
deep: true,
- immediate: true,
+ immediate: true
},
sourceData: {
handler(newval) {
//婧愭暟鎹湁鍙樺寲鏃跺彉鏇村綋鍓嶅尯鍩熸暟鎹�
- console.log(this.areasName);
- console.log(newval);
- }
+ this.sourceDataMapParams=this.sourceDataMap();
+ this.getParams();
+ this.handleRefresh();
+ },
+ deep: true,
+ immediate: true
}
},
+ created() {
+ this.getParams();
+ },
methods: {
- //杞寲鏁版嵁
- formColumn(formList) {
- return formList.map(item => {
- const typeValue = item.type === 'text' ? 'input' : item.type === 'combox' ? 'select' : item.type;
+ sourceDataMap: function () {
+ const sourceDataMap = {};
+ if (Object.keys(this.sourceData).length > 0) {
+ if (this.sourceData.oid) {
+ if (this.sourceData.oid.indexOf('@vcitreesep@') > -1) {
+ this.sourceData.oid = this.sourceData.oid.split('@vcitreesep@')[1];
+ }
+ sourceDataMap.sourceBtmName = this.sourceBtmType;
+ ;
+ sourceDataMap.sourceOid = this.sourceData.oid;
+ }
+ for (let i in this.sourceData) {
+ const item = this.sourceData[i]
+ if (item && item.constructor === Object) continue;
+ if (i == 'type' || i == 'context' || i == 'content') continue;
+ sourceDataMap['sourceData["' + i + '"]'] = item
+ }
+ }
- const focusFunc = item.type === 'refer' ? (i) => {
+ if (Object.keys(this.paramVOS).length > 0) {
+ for (let j in this.paramVOS) {
+ if (this.paramVOS[j] && this.paramVOS[j].constructor === Object) continue;
+ if (j == 'type' || j == 'context' || j == 'content' || j == "getdataurl" || j == "getdatamethod" || j == "url" || j == "method" || j == "uploadfileurl" || j == "title") continue;
+ sourceDataMap['sourceData["' + j + '"]'] = this.paramVOS[j]
+ }
+ }
+ return sourceDataMap;
+ },
+ getParams: function () {
+ const formParams = {
+ btmname: this.currentDefineVO.btmType,
+ btmType: this.currentDefineVO.btmType,
+ formDefineId: this.currentDefineVO.id,
+ oid: this.currentDefineVO.oid
+ };
+ if (this.dataStore[0] && this.dataStore[0].oid) {
+ formParams.oid = this.dataStore[0].oid;
+ }
+ const sourceDataMapList = this.sourceDataMapParams;
- } : undefined;
-
-
- return {
- label: item.text,
- prop: item.field,
- type: typeValue,
- labelWidth: item.text.length >= 6 ? 115 : 90,
- value: item.defaultValue,
- dicData: item.type === 'combox' ? item.dicData : item.dicUrl,
- readonly: item.readOnly,
- disabled: item.disabled,
- display: !item.hidden,
- labelSuffix: item.suffix,
- suffixIcon: item.prefix,
- placeholder: item.placeholder,
- clearable: item.clearable,
- tip: item.tooltips,
- keyAttr: item.keyAttr,
- focus: focusFunc,
- referConfig: item.referConfig,
- rules: [{
- required: item.required,
- message: `璇疯緭鍏�${item.text}!`,
- trigger: "blur"
- }]
- };
+ this.params = Object.assign({}, formParams, sourceDataMapList);
+ },
+ onLoad: function () {
+ if (this.paramVOS.initvalue) {
+ this.form = this.paramVOS.initvalue;
+ }
+ if (Object.keys(this.sourceData).length > 0 && this.isShow && this.actionType != "add") {
+ this.loading = true;
+ dataForm(this.params, this.paramVOS.getdataurl, this.paramVOS.getdatamethod).then(res => {
+ this.form = res.data.obj.data;
+ this.loading = false;
+ }).catch(error => {
+ this.loading = false;
+ });
+ }
+ },
+ handleRefresh() {
+ this.form = {}
+ this.onLoad();
+ },
+ getFormData(form) {
+ this.form = form;
+ this.$emit("setDataStore", {
+ area: this.areasName,
+ type: this.componentVO.uiComponentType,
+ btmType: this.currentDefineVO.btmType,
+ dataStore: [this.form]
});
- },
-
- //鏁版嵁鍒ょ┖
- getColumnData() {
- if (this.componentVO && this.componentVO.formDefineVO && this.componentVO.formDefineVO.items && this.componentVO.formDefineVO.items.length > 0) {
- return this.formColumn(this.componentVO.formDefineVO.items)
- } else {
- return null;
- }
- },
-
- buttonClick(item) {
- console.log(item.id)
- },
- async getDictList(val) {
- for (let code of val) {
- if (!verifyNull(code.dictData) && code.type == "select") {
- if (
- verifySlash(code.dictCode) &&
- Object.prototype.hasOwnProperty.call(code, "dictCode")
- ) {
- const res = await getlistByCode(code.dictCode);
- if (res.success) {
- const dic = res.data;
- code.dictData = dic.map((d) => {
- return {
- label: d.name,
- key: d.code,
- value: d.id,
- };
- });
- }
- } else {
- this.getDicts(code.dictCode)
- .then((res) => {
- if (res.success) {
- const dic = res.obj.datas;
- code.dictData = dic.map((d) => {
- return {
- label: d.name,
- key: d.code,
- value: d.code,
- };
- });
- }
- })
- .catch(() => {
- this.$message.error(` 鏁版嵁瀛楀吀${code.dictCode}閿欒`);
- });
- }
- }
- if (code.type == "refer") {
- if (code.referConfig && code.referConfig.useFormKey) {
- if (verifyNull(code.referConfig.formValuesKey)) {
- code.referConfig.formValuesKey = "form";
- }
- code.referConfig.formValues = this[code.referConfig.formValuesKey];
- }
- code.referConfigTemp = {
- title: code.label,
- showProp:
- code.showProp || code.referConfig.showProp || code.prop + "Name",
- prop: code.prop,
- propMap: code.propMap || {},
- placeholder: code.placeholder
- ? code.placeholder
- : ` 璇烽�夋嫨` + code.label,
- options: code.referConfig,
- };
- }
- }
- this.formTemplateData = val;
- },
- setReferValue(data) {
- if (data && data.prop) {
- this.form[data.prop] = data.value || "";
- this.form[data.showProp] = data.text || "";
- if (data.propMap) {
- //璇存槑闇�瑕佹槧灏�
- for (let key in data.propMap) {
- let mapFields = data.propMap[key].split(",");
- let value = [];
- data.rawData.forEach((_item) => {
- var temp;
- if (!_item.extendData) {
- _item.extendData = {};
- }
- if (mapFields.length == 1) {
- var mapField = mapFields[0];
- temp = _item[mapField] || _item["extendData"][mapField];
- } else {
- //鏈夊涓�
- var mutiTemp = [];
- mapFields.forEach((_itemField) => {
- mutiTemp.push(
- _item[_itemField] || _item["extendData"][_itemField]
- );
- });
- temp = mutiTemp.join(" ");
- }
- if (temp != null && temp != "") {
- value.push(temp);
- }
- });
- this.form[key] = value.join(",");
- }
- }
- }
- },
+ this.$emit("setData", {
+ area: this.areasName,
+ type: this.componentVO.uiComponentType,
+ currentDefineVO: this.currentDefineVO,
+ data: this.form
+ });
+ }
}
}
</script>
--
Gitblit v1.9.3