Browse Source

自动生成bug-02

master
xuhuajiao 3 years ago
parent
commit
2467c9e2e3
  1. 57
      src/views/components/category/PreviewForm.vue

57
src/views/components/category/PreviewForm.vue

@ -79,6 +79,7 @@ import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { FetchFindAllSubsetById } from '@/api/archivesConfig/dictDetail'
import { parseTime } from '@/utils/index.js'
export default {
name: 'PreviewForm',
components: { draggable, Treeselect },
@ -129,8 +130,8 @@ export default {
setParentsId: null,
result: null,
autoMatic: null,
isType: 'category',
autoEditString: [],
isAutoLastString: null,
normalizer(node) {
if (node.childMenus == null || node.childMenus === 'null') {
delete node.childMenus
@ -152,14 +153,18 @@ export default {
},
formPreviewData: function() {
this.editFormRow()
this.FetchNoFormatField()
if (this.isType !== 'arcives') {
this.FetchNoFormatField(this.selectedCategory.id)
}
}
},
created() {
this.editFormRow()
},
mounted() {
this.FetchNoFormatField()
if (this.isType !== 'arcives') {
this.FetchNoFormatField(this.selectedCategory.id)
}
},
methods: {
//
@ -200,6 +205,7 @@ export default {
//
handleAuto() {
let string = ''
const getAutoFiledVal = []
this.autoMatic.forEach(async val => {
if (!this.addOrUpdateForm[val.fieldName]) {
string += ''
@ -209,36 +215,45 @@ export default {
await FetchFindAllSubsetById({ id: fieldInfo.dictionaryConfigId.id }).then(res => {
const option = this.getNode(res, this.addOrUpdateForm[val.fieldName])
if (option) {
string += '' + option[0].dicCode + val.connector
const obj = {}
obj.name = val.fieldName
obj.val = option[0].dicCode + val.connector
obj.sequence = val.sequence
// string += '' + option[0].dicCode + val.connector
getAutoFiledVal.push(obj)
}
})
} else {
string += '' + this.addOrUpdateForm[val.fieldName] + val.connector
const obj = {}
obj.name = val.fieldName
obj.val = this.addOrUpdateForm[val.fieldName] + val.connector
obj.sequence = val.sequence
// string += '' + this.addOrUpdateForm[val.fieldName] + val.connector
getAutoFiledVal.push(obj)
}
}
//
getAutoFiledVal.sort(this.compare('sequence'))
string = getAutoFiledVal.map((item) => item.val).join('')
this.formPreviewData.map(item => {
if (item.isAutomatic) {
this.autoEditString = []
this.autoEditString.push(this.addOrUpdateForm[item.fieldName])
console.log('autoEditString', this.autoEditString)
console.log(this.autoEditString[0].lastIndexOf('-'))
this.isAutoLastString = this.autoEditString[0].substring(this.autoEditString[0].lastIndexOf('-') + 1)
console.log('autoEditString', this.isAutoLastString)
let lastString
if (this.isAutoLastString) {
lastString = string + this.isAutoLastString
} else {
lastString = string
}
this.$set(this.addOrUpdateForm, item.fieldName, lastString)
this.$set(this.addOrUpdateForm, item.fieldName, string)
}
})
})
},
//
compare(property) {
return function(a, b) {
var value1 = a[property]
var value2 = b[property]
return value1 - value2
}
},
//
FetchNoFormatField() {
getNoFormatField({ categoryId: this.selectedCategory.id }).then(res => {
FetchNoFormatField(categoryId) {
getNoFormatField({ categoryId: categoryId }).then(res => {
this.autoMatic = res
// this.handleAuto()
})

Loading…
Cancel
Save