| | |
| | | key="masterForm" data-key="masterForm" |
| | | v-bind="$attrs" |
| | | :type="type" |
| | | :LoadingStatus="status" |
| | | :TreeValue="TreeValue" |
| | | :eventList="eventList" |
| | | ref="FormTemplate" |
| | |
| | | @getFormData="getCodeApplyFormData" |
| | | @referConfigDataUpdate="referConfigDataUpdate" |
| | | ></FormTemplate> |
| | | <el-button |
| | | @click="submit()" |
| | | type="primary" |
| | | size="small" |
| | | style="float: right" |
| | | >保存</el-button> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | |
| | | </div> |
| | | </basic-container> |
| | | </el-col> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule} from '@/api/code/codeApply.js' |
| | | |
| | | import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule,addSaveCode} from '@/api/code/codeApply.js' |
| | | import func from '@/util/func'; |
| | | export default { |
| | | name: "codeApply", |
| | | components: { FormTemplate: () => import('@/components/FormTemplate/FormTemplate') }, |
| | | data() { |
| | | return { |
| | | defaultKeys: [ |
| | | "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", |
| | | ], |
| | | codeClassifyOid:'', |
| | | type:'add', |
| | | status:'code', |
| | | TreeValue:'', |
| | | dialogVisible:true, |
| | | setForm:{}, |
| | |
| | | activeName: "codeApply", |
| | | showCodeApply: false, |
| | | eventList:[], |
| | | showResembleQuery:false, |
| | | hasResemble:false, |
| | | form: {}, |
| | | TreeData:[], |
| | | TreeOption: { |
| | |
| | | this.getTreeData() |
| | | }, |
| | | methods:{ |
| | | async submit() { |
| | | // 进行表单校验 |
| | | const formValidate = await this.$refs.FormTemplate.validate(); |
| | | if (!formValidate) return; |
| | | let resembleQueryList = []; |
| | | if (this.showResembleQuery && this.$refs.resembleQueryRef) { |
| | | // 进行相似项查询 |
| | | resembleQueryList = await this.$refs.resembleQueryRef.resembleQuery( |
| | | this.form |
| | | ); |
| | | } |
| | | if (resembleQueryList.length > 0) { |
| | | await this.$confirm( |
| | | `该物料已有${resembleQueryList.length}条相似数据,是否继续保存?`, |
| | | "需要您确认", |
| | | { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | } |
| | | ); |
| | | } |
| | | // 排除一些字段 |
| | | const noData = [ |
| | | "jiliangdwname", |
| | | "materialtypeText", |
| | | "morengongysname", |
| | | "$caigouwl", |
| | | "$xiaoshouwl", |
| | | "$shifoupihaoguanli", |
| | | "lcstatus_text", |
| | | "hesuanfenleiname", |
| | | "$kucunwl", |
| | | "oldcode", |
| | | "lastmodifier" |
| | | ]; |
| | | let resForm = {}; |
| | | const { defaultValue, formValue } = this.getDefaultValueAndFormValues( |
| | | this.form |
| | | ); |
| | | noData.forEach((item) => { |
| | | this.$delete(formValue, item); |
| | | }); |
| | | const keys = Object.keys(formValue); |
| | | keys.forEach((item, index) => { |
| | | keys.forEach((itm, idx) => { |
| | | if ((item === ('$' + itm)) && idx !== index) { |
| | | this.$delete(formValue, keys[index]); |
| | | } |
| | | }) |
| | | }); |
| | | |
| | | resForm.data = formValue; |
| | | resForm = Object.assign({}, resForm, defaultValue); |
| | | resForm.secDTOList = this.secVOList.map((item) => { |
| | | return { |
| | | secOid: item.oid, |
| | | secValue: this.codeApplyForm[item.oid], |
| | | }; |
| | | }); |
| | | resForm.codeClassifyOid = this.codeClassifyOid; |
| | | resForm.codeRuleOid = this.codeRuleOid; |
| | | resForm.templateOid = this.templateOid; |
| | | // this.$emit("submit", resForm); |
| | | if(func.notEmpty(resForm.ts)) { |
| | | resForm.ts = func.formattedDateTime(resForm.ts); |
| | | // resForm.ts = resForm.ts.toISOString().replace("Z", ""); |
| | | } |
| | | addSaveCode(resForm).then(res => { |
| | | this.$nextTick(() => { |
| | | this.addvisible = false; |
| | | this.$message.success("保存成功"); |
| | | this.onLoad() |
| | | }) |
| | | }) |
| | | // console.log(resForm) |
| | | }, |
| | | getDefaultValueAndFormValues(form) { |
| | | let defaultValue = {}; |
| | | let formValue = {}; |
| | | for (const key in form) { |
| | | if (Object.hasOwnProperty.call(form, key)) { |
| | | const element = form[key]; |
| | | if (this.defaultKeys.includes(key)) { |
| | | defaultValue[key] = element; |
| | | } else { |
| | | formValue[key] = element; |
| | | } |
| | | } |
| | | } |
| | | return { |
| | | defaultValue, |
| | | formValue, |
| | | }; |
| | | }, |
| | | getFormData(form) { |
| | | this.form = form; |
| | | }, |
| | |
| | | }); |
| | | }, |
| | | nodeClick(row){ |
| | | // console.log(row) |
| | | console.log(row) |
| | | this.TreeValue=row.text.split(" ")[0].trim(); |
| | | this.codeClassifyOid = row.oid; |
| | | getUsedTemplateByClassifyOid({ 'codeClassifyOid': this.codeClassifyOid,templateOid:' 97e979919a1f1dca67290e85fee22688' }).then((res) => { |
| | | console.log('===res',res) |
| | | if (res.data.code === 200) { |
| | | if (res.status === 200) { |
| | | this.hasResemble = |
| | | res.data.resembleTableVO && |
| | | res.data.resembleTableVO.cols && |
| | | res.data.resembleTableVO.cols.length > 0; |
| | | this.resembleTableColumn = res.data.resembleTableVO.cols || []; |
| | | if (this.hasResemble) { |
| | | this.activeName = "resembleQuery"; |
| | | this.showResembleQuery = true; |
| | | } else { |
| | | this.showResembleQuery = false; |
| | | } |
| | | this.$nextTick(() => { |
| | | this.eventList=res.data.data.attributes |
| | | this.$refs.FormTemplate.templateRender( |
| | | res.data.formDefineVO.items |
| | | ); |
| | | this.eventList=res.data.templateVO.attributes |
| | | // this.$refs.FormTemplate.$emit('eventList', res.data.templateVO.attributes); |
| | | if (Object.keys(this.setForm).length > 0) { |
| | | this.$refs.FormTemplate.form = this.setForm; |