2019-11-05 23:53:18 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import { Component, Prop } from 'vue-property-decorator'
|
|
|
|
|
|
|
|
|
|
import { tools } from '../../store/Modules/tools'
|
|
|
|
|
import { toolsext } from '@src/store/Modules/toolsext'
|
|
|
|
|
import { IColGridTable } from '../../model'
|
|
|
|
|
import { fieldsTable } from '../../store/Modules/fieldsTable'
|
|
|
|
|
import { CMyChipList } from '../CMyChipList'
|
|
|
|
|
import { CDateTime } from '../CDateTime'
|
|
|
|
|
import { CMyToggleList } from '../CMyToggleList'
|
|
|
|
|
import { CMySelect } from '../CMySelect'
|
2019-12-04 02:04:54 +01:00
|
|
|
import { CMyEditor } from '../CMyEditor'
|
2019-12-27 12:43:42 +01:00
|
|
|
import { CGallery } from '../CGallery'
|
2019-11-05 23:53:18 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
name: 'CMyPopupEdit',
|
2019-12-27 12:43:42 +01:00
|
|
|
components: {CMyChipList, CDateTime, CMyToggleList, CMySelect, CMyEditor, CGallery }
|
2019-11-05 23:53:18 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default class CMyPopupEdit extends Vue {
|
|
|
|
|
@Prop({ required: true }) public row
|
|
|
|
|
@Prop({ required: true }) public col
|
|
|
|
|
@Prop({ required: false, default: false }) public canEdit
|
|
|
|
|
@Prop({ required: false, default: '' }) public field
|
|
|
|
|
@Prop({ required: false, default: '' }) public subfield
|
2019-12-04 02:04:54 +01:00
|
|
|
@Prop({ required: false, default: false }) public showall
|
2019-12-27 12:43:42 +01:00
|
|
|
@Prop({ required: false, default: 'row' }) public view
|
|
|
|
|
@Prop({ required: false, default: '5' }) public minuteinterval
|
2019-11-05 23:53:18 +01:00
|
|
|
|
|
|
|
|
public myvalue = ''
|
|
|
|
|
|
|
|
|
|
get tools() {
|
|
|
|
|
return tools
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-27 12:43:42 +01:00
|
|
|
get isviewfield() {
|
|
|
|
|
return this.view === 'field'
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 23:53:18 +01:00
|
|
|
get db_fieldsTable() {
|
|
|
|
|
return fieldsTable
|
|
|
|
|
}
|
|
|
|
|
public changeval(newval) {
|
|
|
|
|
this.$emit('update:row', newval)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public mounted() {
|
|
|
|
|
if ((this.subfield !== '') && (this.subfield !== '')) {
|
|
|
|
|
if (this.row[this.field] === undefined) {
|
|
|
|
|
this.row[this.field] = {}
|
|
|
|
|
this.myvalue = ''
|
|
|
|
|
} else {
|
|
|
|
|
this.myvalue = this.row[this.field][this.subfield]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (this.field !== '')
|
|
|
|
|
this.myvalue = this.row[this.field]
|
|
|
|
|
else
|
|
|
|
|
this.myvalue = this.row
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OpenEdit() {
|
2019-11-12 21:33:18 +01:00
|
|
|
// console.log('OpenEdit')
|
2019-11-05 23:53:18 +01:00
|
|
|
this.$emit('show')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SaveValueInt(newVal, valinitial) {
|
|
|
|
|
|
2019-12-27 12:43:42 +01:00
|
|
|
console.log('SaveValueInt', newVal)
|
2019-11-05 23:53:18 +01:00
|
|
|
|
|
|
|
|
// Update value in table memory
|
|
|
|
|
if (this.subfield !== '') {
|
|
|
|
|
if (this.row[this.field] === undefined)
|
|
|
|
|
this.row[this.field] = {}
|
|
|
|
|
this.row[this.field][this.subfield] = newVal
|
|
|
|
|
} else {
|
|
|
|
|
if (this.field !== '')
|
|
|
|
|
this.row[this.field] = newVal
|
|
|
|
|
else
|
|
|
|
|
this.row = newVal
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$emit('save', newVal, valinitial)
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 02:04:54 +01:00
|
|
|
public Savedb(newVal, valinitial) {
|
|
|
|
|
|
|
|
|
|
// console.log('Savedb', newVal)
|
|
|
|
|
|
|
|
|
|
this.$emit('showandsave', this.row, this.col, newVal, valinitial)
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 23:53:18 +01:00
|
|
|
public visuValByType(val, col: IColGridTable, row) {
|
|
|
|
|
if (col === undefined || row === undefined)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
// let val = ''
|
|
|
|
|
// if (col.subfield !== '') {
|
|
|
|
|
// if (row[col.field] === undefined)
|
|
|
|
|
// row[col.field] = {}
|
|
|
|
|
//
|
|
|
|
|
// val = row[col.field][col.subfield]
|
|
|
|
|
// } else {
|
|
|
|
|
// val = row[col.field]
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
if (col.fieldtype === tools.FieldType.date) {
|
|
|
|
|
if (val === undefined) {
|
|
|
|
|
return '[]'
|
|
|
|
|
} else {
|
|
|
|
|
return tools.getstrDateTime(val)
|
|
|
|
|
}
|
|
|
|
|
} else if (col.fieldtype === tools.FieldType.boolean) {
|
|
|
|
|
return (val) ? this.$t('dialog.yes') : this.$t('dialog.no')
|
|
|
|
|
} else if (col.fieldtype === tools.FieldType.binary) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getArrStrByValueBinary(this, col, val)
|
|
|
|
|
} else if (col.fieldtype === tools.FieldType.select) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getValueByTable(col, val)
|
2019-11-15 00:32:39 +01:00
|
|
|
} else if (col.fieldtype === tools.FieldType.multiselect) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getMultiValueByTable(col, val)
|
2019-11-05 23:53:18 +01:00
|
|
|
} else {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[]'
|
|
|
|
|
else if (val === '') {
|
|
|
|
|
return '[]'
|
|
|
|
|
} else {
|
2019-12-04 02:04:54 +01:00
|
|
|
let mystr = ''
|
|
|
|
|
if (this.showall) {
|
|
|
|
|
return val
|
|
|
|
|
} else {
|
|
|
|
|
mystr = tools.firstchars(val, tools.MAX_CHARACTERS)
|
|
|
|
|
}
|
2019-11-05 23:53:18 +01:00
|
|
|
if (val) {
|
|
|
|
|
if (val.length > tools.MAX_CHARACTERS)
|
|
|
|
|
mystr += '...'
|
|
|
|
|
} else {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
return mystr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getclassCol(col) {
|
|
|
|
|
if (col) {
|
2019-12-27 12:43:42 +01:00
|
|
|
let mycl = (col.disable || this.isviewfield) ? '' : 'colmodif'
|
2019-11-05 23:53:18 +01:00
|
|
|
mycl += (col.fieldtype === tools.FieldType.date) ? ' coldate flex flex-container' : ''
|
|
|
|
|
|
|
|
|
|
return mycl
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-15 00:32:39 +01:00
|
|
|
|
|
|
|
|
public changeCol() {
|
|
|
|
|
|
|
|
|
|
}
|
2019-11-05 23:53:18 +01:00
|
|
|
}
|