| | |
| | | import AddEditDialog from "@/components/actions/AddEditDialog" |
| | | |
| | | export const doAction = (options,callback) => { |
| | | options.paramVOS = paramLow(options.paramVOS) |
| | | const paramVOS = Object.assign({ |
| | | url: '/api/uiDataController/addSave', |
| | | method: 'post', |
| | |
| | | * action通用入口 |
| | | */ |
| | | export const doAction = (button,options,callback) => { |
| | | options.paramVOS = paramLow(options.paramVOS) |
| | | options.paramVOS['title']=replaceFreeMarker(options.paramVOS.title,options.dataStore,options.sourceData); |
| | | let isShow = true; |
| | | if (options.paramVOS['initvalue'] && typeof(options.paramVOS.initvalue)=='string') { |
| | | let values = options.paramVOS['initvalue'].split(';'); |
| | | let initValues = {} |
| | | values.forEach((item,i) => { |
| | | if(isShow){ |
| | | item = item.replace(':', '='); |
| | | if (item.indexOf('${') > -1) { |
| | | if (item.split('=')[1].indexOf('.') > -1) { |
| | | if (options.sourceData.length < 1 || !options.sourceData.oid) { |
| | | isShow = false; |
| | | Vue.prototype.$message.error("请先选择一条来源数据") |
| | | return false; |
| | | } |
| | | let name = item.split('=')[1].split('.')[1].replace('${', '').replace('}', ''); |
| | | initValues[item.split('=')[0]] = options.sourceData[name] |
| | | } else { |
| | | if (options.dataStore.length < 1) { |
| | | isShow = false; |
| | | Vue.prototype.$message.error("请先选择一条数据"); |
| | | return false; |
| | | } |
| | | let name = item.split('=')[1].replace('${', '').replace('}', ''); |
| | | initValues[item.split('=')[0]] = options.dataStore[0][name]; |
| | | |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | if(isShow){ |
| | | options.paramVOS['initvalue'] = initValues |
| | | } |
| | | } |
| | | if(!isShow){ |
| | | return; |
| | | } |
| | | |
| | | if(button.url && button.url!='null'){ |
| | | //有配置action路径,使用路径对应的js |
| | |
| | | * @param preEventName 前置事件名称,默认beforeevent |
| | | */ |
| | | export const callPreEvent = (options,fnTarget,callback,preEventName) => { |
| | | let beforeEvent = options.paramVOS[preEventName || 'beforeevent']; |
| | | let beforeEvent = options.paramVOS[preEventName || 'prepvent']; |
| | | if(beforeEvent) { |
| | | let buttonParse = parseEventByUrl(beforeEvent,options,true); |
| | | if(validatenull(buttonParse.jsPath)){ |
| | |
| | | * @param isBefore 是否为前置事件,否则为后置 |
| | | * @returns {{jsPath: js的路径, options: 按钮的配置信息, methodName: (string)方法的名字}} |
| | | */ |
| | | export const parseEventByUrl = (url,options,isBefore) => { |
| | | export const parseEventByUrl = (url,options,isBefore,defalutmethodName) => { |
| | | //根据配置格式化事件 |
| | | let jsPath = url; |
| | | let methodName = isBefore?"doBefore":"doAfter"; |
| | | let methodName = defalutmethodName || (isBefore?"doBefore":"doAfter"); |
| | | let params = {}; |
| | | if (url.indexOf("?")) { |
| | | let temp = url.substring(0, url.indexOf("?")); |
| | |
| | | jsPath = url; |
| | | } |
| | | } |
| | | if(!options){ |
| | | options={ |
| | | paramVOS:{} |
| | | } |
| | | }else if(!options.paramVOS){ |
| | | options.paramVOS={} |
| | | } |
| | | |
| | | for (var key in params) { |
| | | options.paramVOS[key.toLowerCase()] = params[key]; |
| | | } |
| | | return { |
| | | jsPath:jsPath, |
| | | methodName:methodName, |
| | | options:options |
| | | options:options, |
| | | params:params |
| | | }; |
| | | }; |
| | |
| | | import AddEditDialog from "@/components/actions/AddEditDialog"; |
| | | |
| | | export const doAction = (options) => { |
| | | options.paramVOS = paramLow(options.paramVOS) |
| | | const paramVOS = Object.assign({ |
| | | getdataurl: '/api/uiDataController/dataFormQuery', |
| | | getdatamethod: 'post', |
| | |
| | | //查询表单项 |
| | | export const getFormDefineById = (btmType,formId) => { |
| | | return request({ |
| | | url: '/api/uiDataController/getFormDefineById', |
| | | url: '/api/webUIController/getFormDefineById', |
| | | method: 'get', |
| | | params: { |
| | | btmType, |
| | |
| | | <template> |
| | | <!--动态模板--> |
| | | <avue-form ref="formRef" :option="option" v-model="form"> |
| | | <avue-form ref="form" :option="option" v-model="form"> |
| | | <template v-for="item in allColumn" :slot="item.prop+ ''"> |
| | | <vciWebRefer |
| | | v-if="item.type === 'refer'" |
| | |
| | | } |
| | | } |
| | | } |
| | | this.$emit("input", val); |
| | | this.$emit("getFormData", val); |
| | | }, |
| | | deep: true, |
| | | immediate: true |
| | |
| | | ? 24 |
| | | : this.span, |
| | | value: item.defaultValue, |
| | | dicData: type === 'select' ? item.dicData : item.dicUrl, |
| | | display: !item.hidden, |
| | | labelSuffix: item.suffix, |
| | | suffixIcon: item.prefix, |
| | | tip: item.tooltips, |
| | | dictCode: item.comboxKey, |
| | | rules: this.isEdit?[{ |
| | | valueFormat: item.dateFormate || "yyyy-MM-dd HH:mm:ss", |
| | | format: item.dateFormate, |
| | | rules: this.isEdit?(type=="select" || type=="refer" || type=="date" || type=="datetime"?[{ |
| | | required: item.required, |
| | | message: `请选择${item.text}!`, |
| | | trigger: "change" |
| | | },{ |
| | | required: item.required, |
| | | message: `请选择${item.text}!`, |
| | | trigger: "submit" |
| | | }]:[{ |
| | | required: item.required, |
| | | message: `请输入${item.text}!`, |
| | | trigger: "blur" |
| | | }]:[] |
| | | }]):[] |
| | | }; |
| | | if(!this.isEdit){ |
| | | col.placeholder=col.label; |
| | |
| | | console.log('col',col) |
| | | } |
| | | if (col.type === "select") { |
| | | // console.log('col',col) |
| | | if(!validatenull(col.dictCode)) { |
| | | if(col.data && col.data.length>0){ |
| | | col.dicData = col.data.map((d) => { |
| | | return { |
| | | label: d.value, |
| | | key: d.key, |
| | | value: d.key, |
| | | attributes:d.attributes |
| | | }; |
| | | }); |
| | | }else if(!validatenull(col.dictCode)) { |
| | | getDicts(col.dictCode).then((res) => { |
| | | if (res.data.success){ |
| | | if(res.data.data && res.data.obj == null){ |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | // 表单校验 |
| | | validate(done) { |
| | | return new Promise((resolve) => { |
| | | this.$refs.form.validate((valid,fields) => { |
| | | done(valid,fields); |
| | | if (valid) { |
| | | resolve(true); |
| | | this.ValidataValue = true; |
| | | } else { |
| | | resolve(false); |
| | | return false; |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | resetFields(){ |
| | | this.$refs.form.resetFields() |
| | | }, |
| | | clearValidate(props){ |
| | | this.$refs.form.clearValidate(props) |
| | | } |
| | | }, |
| | | }; |
| | |
| | | :style="fullscreen?'':'height:'+height" |
| | | :isEdit="true" |
| | | :formItems="formItems" |
| | | :formData="form"> |
| | | :formData="form" |
| | | @getFormData="getFormData"> |
| | | </basic-form> |
| | | <ui-view ref="uiViewRef" v-else-if="paramVOS.context" |
| | | :key="'AddEditDialog-'+type" |
| | |
| | | :sourceData="sourceData" |
| | | :dataStore="dataStore" |
| | | :paramVOS="paramVOS" |
| | | @getFormData="getFormData" |
| | | ></ui-view> |
| | | <div v-if="showSave" class="dialog-footer avue-dialog__footer"> |
| | | <el-button type="primary" plain size="small" @click="saveHandler">保 存</el-button> |
| | | <el-button type="primary" plain size="small" @click="formSave" v-if="paramVOS.form">保 存</el-button> |
| | | <el-button type="primary" plain size="small" @click="contextSave" v-else>保 存</el-button> |
| | | <el-button size="small" @click="dialogClose">取 消</el-button> |
| | | <el-button size="small" @click="resetValue" v-if="paramVOS.form">重 置</el-button> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | import uiView from "@/views/base/UIContentViewerInDialog" |
| | | import {parseEventByUrl} from "@/actions/base/BaseAction" |
| | | import {getFormDefineById,dataForm} from "@/api/base/ui"; |
| | | import {addSave,editSave} from "@/api/base/actions" |
| | | import {validatenull} from "@/util/validate" |
| | |
| | | showSave:this.paramVOS.customBtn || true, |
| | | span:12, |
| | | formItems:[], |
| | | form:{} |
| | | form:{}, |
| | | btmDefaultKeys : ['oid', 'id', 'name', 'description', 'revisionoid', 'nameoid', 'btmname', 'lastr', 'firstr', 'lastv', 'firstv', 'creator', 'createtime', 'lastModifier', 'lastmodifytime', 'revisionrule', 'revisionseq', 'revisionvalue', 'versionrule', 'versionseq', 'versionvalue', 'lcstatus', 'ts', 'owner', 'checkinby', 'checkintime', 'checkoutby', 'checkouttime', 'copyfromversion', 'secretgrade'], |
| | | linkDefaultKeys :['oid','creator','createtime','lastmodifier','lastmodifytime','f_oid','foid','f_revisionoid','frevisionoid','f_nameoid','fnameoid','f_btmname','fbtmname','t_oid','toid','t_revisionoid','trevisionoid','t_nameoid','tnameoid','t_btmname','tbtmname','ts'] |
| | | |
| | | } |
| | | }, |
| | | computed:{ |
| | |
| | | |
| | | } |
| | | }, |
| | | saveHandler() { |
| | | if(this.paramVOS.form){ |
| | | this.$refs.formRef.validate((valid, done) => { |
| | | if (valid) { |
| | | this.saveValue(this.form) |
| | | } else { |
| | | |
| | | } |
| | | }); |
| | | }else{ |
| | | //this.$refs.uiViewRef. |
| | | debugger; |
| | | if(this.saveCallback){ |
| | | this.saveCallback({}); |
| | | } |
| | | contextSave(){ |
| | | debugger; |
| | | if(this.saveCallback){ |
| | | this.saveCallback({}); |
| | | } |
| | | |
| | | }, |
| | | saveValue(savedata){ |
| | | if(this.type=="add"){ |
| | | addSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | formSave() { |
| | | let that=this; |
| | | this.$refs.formRef.validate((valid, done) => { |
| | | if (valid) { |
| | | if (this.paramVOS.savebeforeevent) { |
| | | var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent,null,null,'doAction'); |
| | | import("../"+urlobj.jsPath+".js").then(module => { |
| | | module[urlobj.methodName]({ |
| | | paramVOS: this.paramVOS, |
| | | dataStore: this.dataStore, |
| | | sourceData:this.sourceData |
| | | },that.formSaveHandle); |
| | | }) |
| | | } else { |
| | | that.formSaveHandle(); |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | formSaveHandle(){ |
| | | let that=this; |
| | | let formValues = this.getValues(); |
| | | if(formValues.otherValue.releaseFileOids){ |
| | | formValues.otherValue.releaseFileOids=formValues.otherValue.releaseFileOids.split(','); |
| | | } |
| | | if (!formValues.defaultValues.btmname) { |
| | | formValues.defaultValues.btmname = this.paramVOS.type; |
| | | } |
| | | let datas = { |
| | | formDefineId: this.paramVOS.form, |
| | | preEvent: this.paramVOS.preevent, |
| | | afterEvent: this.paramVOS.afterevent, |
| | | beforeServerEvent: this.paramVOS.beforeserverevent, |
| | | afterServerEvent: this.paramVOS.afterserverevent, |
| | | releaseFileOids: formValues.otherValue.releaseFileOids||[], |
| | | data: formValues.otherValue |
| | | } |
| | | Object.assign(datas, formValues.defaultValues); |
| | | if(that.type=="add"){ |
| | | addSave(datas,that.paramVOS.url,that.paramVOS.method).then(() => { |
| | | that.$message({ |
| | | type: "success", |
| | | message: "保存成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(savedata); |
| | | if(that.saveCallback){ |
| | | that.saveCallback(that.form); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"保存失败") |
| | | that.dialogClose(); |
| | | }); |
| | | }else{ |
| | | editSave(savedata,this.paramVOS.url,this.paramVOS.method).then(() => { |
| | | this.$message({ |
| | | editSave(that.form,that.paramVOS.url,that.paramVOS.method).then(() => { |
| | | that.$message({ |
| | | type: "success", |
| | | message: "修改成功!" |
| | | }); |
| | | if(this.saveCallback){ |
| | | this.saveCallback(savedata); |
| | | if(that.saveCallback){ |
| | | that.saveCallback(that.form); |
| | | } |
| | | this.dialogClose(); |
| | | }).error((e) => { |
| | | this.$message.error(e||"修改失败") |
| | | that.dialogClose(); |
| | | }); |
| | | } |
| | | }, |
| | | getValues(){ |
| | | let defaultValues = {}, otherValue = {}; |
| | | for (var key in this.form) { |
| | | if (this.btmDefaultKeys.indexOf(key.toLowerCase()) > -1) { |
| | | defaultValues[key] = this.form[key]; |
| | | } else { |
| | | otherValue[key] = this.form[key]; |
| | | } |
| | | } |
| | | return { |
| | | defaultValues:defaultValues, |
| | | otherValue:otherValue |
| | | } |
| | | }, |
| | | resetValue() { |
| | | if (this.paramVOS.form) { |
| | | this.$refs.formRef.resetFields(); |
| | | } |
| | | }, |
| | | getFormData(form) { |
| | | this.form = form; |
| | | } |
| | | } |
| | | } |
| | |
| | | this.$refs.dynamicForm.form = row; |
| | | }, |
| | | buttonClick(buttonitem) { |
| | | const paramVOS=buttonitem.paramVOS; |
| | | const paramVOS = buttonitem.paramVOS; |
| | | const DefineVO = this.componentVO.treeDefineVO || this.componentVO.tableDefineVO || this.componentVO.treeTableDefineVO || this.componentVO.formDefineVO; |
| | | if (!paramVOS['title']) { |
| | | paramVOS['title'] = buttonitem.name + (DefineVO.title || this.componentVO.description || ''); |
| | |
| | | if (!paramVOS['type']) { |
| | | paramVOS['type'] = DefineVO.btmType; |
| | | } |
| | | paramVOS['initvalue']=paramVOS['initvalue'] || paramVOS['initValue']; |
| | | let isShow = true; |
| | | if (paramVOS['initvalue'] && typeof(paramVOS.initvalue)=='string') { |
| | | let values = paramVOS['initvalue'].split(';'); |
| | | let initValues = {} |
| | | values.forEach((item,i) => { |
| | | if(isShow){ |
| | | item = item.replace(':', '='); |
| | | if (item.indexOf('${') > -1) { |
| | | if (item.split('=')[1].indexOf('.') > -1) { |
| | | if (this.sourceData.length < 1 || !this.sourceData.oid) { |
| | | isShow = false; |
| | | this.$message.error("请先选择一条来源数据") |
| | | return false; |
| | | } |
| | | let name = item.split('=')[1].split('.')[1].replace('${', '').replace('}', ''); |
| | | initValues[item.split('=')[0]] = this.sourceData[name] |
| | | } else { |
| | | if (this.dataStore.length < 1) { |
| | | isShow = false; |
| | | this.$message.error("请先选择一条数据"); |
| | | return false; |
| | | } |
| | | let name = item.split('=')[1].replace('${', '').replace('}', ''); |
| | | initValues[item.split('=')[0]] = this.dataStore[0][name]; |
| | | |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | if(isShow){ |
| | | paramVOS['initvalue'] = initValues |
| | | if (paramVOS['BSContent'] || paramVOS['BSContext']) { |
| | | paramVOS['context'] = paramVOS['BSContext'] || paramVOS['BSContent'] |
| | | paramVOS['content'] = paramVOS['BSContext'] || paramVOS['BSContent']; |
| | | } |
| | | |
| | | const that = this; |
| | | //paramVOS.customBtn //弹窗默认有保存按钮,customBtn为true时内容展示自定义按钮 |
| | | paramVOS.form = "editknowledgefolderall" |
| | | doAction(buttonitem, { |
| | | paramVOS: paramVOS, |
| | | dataStore: this.dataStore || [], |
| | | sourceData: this.sourceData || {} |
| | | }, function () { |
| | | if (that.$parent.handleRefresh) { |
| | | that.$parent.handleRefresh() |
| | | } |
| | | } |
| | | if(paramVOS['BSContent'] || paramVOS['BSContext']){ |
| | | paramVOS['context']=paramVOS['BSContext'] || paramVOS['BSContent'] |
| | | paramVOS['content']=paramVOS['BSContext'] || paramVOS['BSContent']; |
| | | } |
| | | |
| | | const that=this; |
| | | if(isShow) { |
| | | //paramVOS.customBtn //弹窗默认有保存按钮,customBtn为true时内容展示自定义按钮 |
| | | //paramVOS.form="editknowledgefolderall" |
| | | doAction(buttonitem, { |
| | | paramVOS: paramVOS, |
| | | dataStore: this.dataStore || [], |
| | | sourceData: this.sourceData || {} |
| | | },function (){ |
| | | if (that.$parent.handleRefresh) { |
| | | that.$parent.handleRefresh() |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | } |
| | |
| | | :formItems="this.componentVO.formDefineVO && this.componentVO.formDefineVO.items" |
| | | :disabled="!inDialog" |
| | | :isEdit="canEdit" |
| | | :formData="form"> |
| | | :formData="form" |
| | | @getFormData="getFormData"> |
| | | </basic-form> |
| | | </div> |
| | | </template> |
| | |
| | | handleRefresh() { |
| | | this.form={} |
| | | this.onLoad(); |
| | | }, |
| | | getFormData(form) { |
| | | this.form = form; |
| | | } |
| | | } |
| | | } |