| | |
| | | v-if="dialogVisible" key="masterForm" |
| | | ref="FormTemplate" |
| | | v-bind="$attrs" |
| | | :selectRow="selectRow" |
| | | :TreeValue="TreeValue" |
| | | :eventList="eventList" |
| | | :rowOid="rowOid" |
| | |
| | | :selfColumnConfig="selfColumnConfig" |
| | | :selfColumnType="selfColumnType" |
| | | :type="type" |
| | | :status="status" |
| | | data-key="codeApplyForm" |
| | | secDTOListv-bind="$attrs" |
| | | @attrList="attrListForm" |
| | |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | selectRow:{ |
| | | type:Array, |
| | | default:[] |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | }, |
| | | }, |
| | | watch: { |
| | | codeApplyForm: { |
| | | handler(newval, oldval) { |
| | | // console.log('newval',newval) |
| | | } |
| | | } |
| | | |
| | | }, |
| | | methods: { |
| | | openDialog() { |
| | | //新增和修改共同调用(有改动 不需要在使用edit,方法没什么影响) |
| | | this.getFormTemplate(); |
| | | if (this.type === "add") { |
| | | if (this.type === "add" || (this.type !== "add" && this.status === "amend")) { |
| | | this.getCodeRule(); |
| | | return; |
| | | } |
| | | }, |
| | | close() { |
| | |
| | | }, |
| | | // 接口获取表单数据 |
| | | getFormTemplate() { |
| | | //新增和修改共同调用 |
| | | getFormTemplate({ |
| | | templateOid: this.templateOid, |
| | | codeClassifyOid: this.codeClassifyOid, |
| | |
| | | } else { |
| | | this.showResembleQuery = false; |
| | | } |
| | | //传递表单上方区域数据 (新增和修改) |
| | | this.$nextTick(() => { |
| | | this.$refs.FormTemplate.templateRender( |
| | | res.data.formDefineVO.items |
| | |
| | | that.secVOList = (res.data.data.secVOList || []).filter((item) => |
| | | typeList.includes(item.secType) |
| | | ); |
| | | if (that.secVOList.length > 0 && that.type === "add") { |
| | | if (that.secVOList.length > 0 && that.type === "add" ||(that.type !== "add" && that.status === "amend")) { |
| | | that.showCodeApply = true; |
| | | that.activeName = "codeApply"; |
| | | |
| | |
| | | if (this.$refs.CodeApply) { |
| | | this.$refs.CodeApply.changeChildItem(this.secVOList, this.TreeValue, this.type); |
| | | } |
| | | },, |
| | | }, |
| | | //属性码段赋值 |
| | | attrListForm(attrListForm) { |
| | | this.attrList = attrListForm; |
| | |
| | | } |
| | | }, |
| | | async submit() { |
| | | // 进行表单校验 |
| | | const formValidate = await this.$refs.FormTemplate.validate(); |
| | | if (!formValidate) return; |
| | | let codeValidate = true; |
| | | // 进行码值申请校验 |
| | | // if (this.showCodeApply) { |
| | | // codeValidate = await this.$refs.CodeApply.validate(); |
| | | // if (!codeValidate) { |
| | | // this.activeName = "codeApply"; |
| | | // return false; |
| | | // } |
| | | // } |
| | | let resembleQueryList = []; |
| | | if (this.showResembleQuery && this.$refs.resembleQueryRef) { |
| | | // 进行相似项查询 |
| | | resembleQueryList = await this.$refs.resembleQueryRef.resembleQuery( |
| | | if(this.status){ |
| | | // 进行表单校验 |
| | | 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", |
| | | "lastmodifier" |
| | | ]; |
| | | |
| | | let resForm = {}; |
| | | const {defaultValue, formValue} = this.getDefaultValueAndFormValues( |
| | | 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]); |
| | | } |
| | | }) |
| | | }); |
| | | 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.data = formValue; |
| | | resForm.data = Object.assign({}, resForm.data, defaultValue); |
| | | resForm.secDTOList = this.secVOList.map((item) => { |
| | | return { |
| | | secOid: item.oid, |
| | | secValue: this.codeApplyForm[item.oid], |
| | | }; |
| | | }); |
| | | //标准特定字段映射 |
| | | const mappings = { |
| | | codeStandardEditType: 'operationType', |
| | | reviseSeries: 'series', |
| | | oldcode: 'oldCode', |
| | | releaseDate: 'releaseTime', |
| | | isSeries: 'isEditseries' |
| | | }; |
| | | }); |
| | | resForm.codeClassifyOid = this.codeClassifyOid; |
| | | resForm.codeRuleOid = this.codeRuleOid; |
| | | resForm.templateOid = this.templateOid; |
| | | this.$emit("submit", resForm); |
| | | |
| | | for (const key in mappings) { |
| | | if (formValue[key]) { |
| | | resForm[mappings[key]] = formValue[key]; |
| | | } |
| | | } |
| | | // |
| | | resForm.codeClassifyOid = this.codeClassifyOid; |
| | | resForm.codeRuleOid = this.codeRuleOid; |
| | | resForm.templateOid = this.templateOid; |
| | | this.$emit("submit", resForm); |
| | | }else { |
| | | // 进行表单校验 |
| | | const formValidate = await this.$refs.FormTemplate.validate(); |
| | | if (!formValidate) return; |
| | | let codeValidate = true; |
| | | // 进行码值申请校验 |
| | | // if (this.showCodeApply) { |
| | | // codeValidate = await this.$refs.CodeApply.validate(); |
| | | // if (!codeValidate) { |
| | | // this.activeName = "codeApply"; |
| | | // return false; |
| | | // } |
| | | // } |
| | | 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); |
| | | } |
| | | }, |
| | | getDefaultValueAndFormValues(form) { |
| | | let defaultValue = {}; |