2019-12-04 02:05:08 +01:00
|
|
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
|
|
|
|
|
|
|
|
|
import { tools } from '../../store/Modules/tools'
|
|
|
|
|
import { toolsext } from '@src/store/Modules/toolsext'
|
|
|
|
|
|
|
|
|
|
import { QEditor } from 'quasar'
|
|
|
|
|
import { CMyEditor } from '../CMyEditor'
|
|
|
|
|
import MixinBase from '../../mixins/mixin-base'
|
|
|
|
|
import { fieldsTable } from '../../store/Modules/fieldsTable'
|
|
|
|
|
import { IColGridTable } from '../../model'
|
|
|
|
|
import { CMySelect } from '../CMySelect'
|
2019-12-29 01:54:00 +01:00
|
|
|
import { GlobalStore, UserStore } from '../../store/Modules'
|
2019-12-04 02:05:08 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
name: 'CMyFieldDb',
|
|
|
|
|
components: { CMyEditor, CMySelect }
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default class CMyFieldDb extends MixinBase {
|
|
|
|
|
@Prop({ required: true }) public title
|
|
|
|
|
@Prop({ required: true }) public mykey: string
|
2019-12-29 01:54:00 +01:00
|
|
|
@Prop({ required: false, default: '' }) public mysubkey: string
|
2019-12-04 02:05:08 +01:00
|
|
|
@Prop({ required: true }) public type: number
|
|
|
|
|
@Prop({ required: false, default: false }) public serv: boolean
|
|
|
|
|
@Prop({ required: false, default: false }) public disable: boolean
|
|
|
|
|
@Prop({ required: false, default: '' }) public jointable: string
|
2019-12-29 01:54:00 +01:00
|
|
|
@Prop({ required: false, default: '' }) public table: string
|
2019-12-04 02:05:08 +01:00
|
|
|
|
|
|
|
|
public $t
|
|
|
|
|
public myvalue = ''
|
|
|
|
|
public col: IColGridTable = { name: 'test' }
|
|
|
|
|
public canEdit: boolean = true
|
2019-12-29 23:29:56 +01:00
|
|
|
public countryname = ''
|
2019-12-04 02:05:08 +01:00
|
|
|
|
|
|
|
|
public created() {
|
2019-12-29 01:54:00 +01:00
|
|
|
this.myvalue = this.getValDb(this.mykey, this.serv, '', this.table, this.mysubkey)
|
2019-12-04 02:05:08 +01:00
|
|
|
this.col.jointable = this.jointable
|
|
|
|
|
this.col.fieldtype = this.type
|
|
|
|
|
this.col.label = this.title
|
2019-12-29 23:29:56 +01:00
|
|
|
|
2019-12-04 02:05:08 +01:00
|
|
|
// console.log('created', this.myvalue)
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 00:44:43 +01:00
|
|
|
public getclassCol(col) {
|
|
|
|
|
if (col) {
|
|
|
|
|
let mycl = (this.disable || col.disable) ? '' : 'colmodif '
|
|
|
|
|
mycl += (col.fieldtype === tools.FieldType.date) ? ' coldate flex flex-container ' : ''
|
|
|
|
|
|
|
|
|
|
return mycl
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 02:05:08 +01:00
|
|
|
public visuValByType(val) {
|
|
|
|
|
if (this.col.fieldtype === tools.FieldType.date) {
|
|
|
|
|
if (val === undefined) {
|
|
|
|
|
return '[]'
|
|
|
|
|
} else {
|
|
|
|
|
return tools.getstrDateTime(val)
|
|
|
|
|
}
|
|
|
|
|
} else if (this.col.fieldtype === tools.FieldType.boolean) {
|
|
|
|
|
return (val) ? this.$t('dialog.yes') : this.$t('dialog.no')
|
|
|
|
|
} else if (this.col.fieldtype === tools.FieldType.binary) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getArrStrByValueBinary(this, this.col, val)
|
|
|
|
|
} else if (this.col.fieldtype === tools.FieldType.select) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getValueByTable(this.col, val)
|
|
|
|
|
} else if (this.col.fieldtype === tools.FieldType.multiselect) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return fieldsTable.getMultiValueByTable(this.col, val)
|
|
|
|
|
} else if (this.col.fieldtype === tools.FieldType.password) {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '[---]'
|
|
|
|
|
else
|
|
|
|
|
return '***************'
|
|
|
|
|
} else {
|
|
|
|
|
if (val === undefined)
|
|
|
|
|
return '-'
|
|
|
|
|
else if (val === '') {
|
|
|
|
|
return '-'
|
|
|
|
|
} else {
|
|
|
|
|
let mystr = tools.firstchars(val, 5000)
|
|
|
|
|
if (val) {
|
|
|
|
|
if (val.length > 5000)
|
|
|
|
|
mystr += '...'
|
|
|
|
|
} else {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
return mystr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get mycl() {
|
|
|
|
|
if (this.disable) {
|
|
|
|
|
return 'cldisable'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get myvalprinted() {
|
|
|
|
|
return this.visuValByType(this.myvalue)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public savefield(value, initialval) {
|
|
|
|
|
this.myvalue = value
|
2019-12-29 01:54:00 +01:00
|
|
|
this.setValDb(this.mykey, this.myvalue, this.type, this.serv, this.table, this.mysubkey)
|
2019-12-04 02:05:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-29 23:29:56 +01:00
|
|
|
public selectcountry({name, iso2, dialCode}) {
|
|
|
|
|
// console.log(name, iso2, dialCode)
|
|
|
|
|
this.myvalue = iso2
|
|
|
|
|
this.countryname = name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public intcode_change(coderec) {
|
|
|
|
|
this.myvalue = '+' + coderec.dialCode
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 02:05:08 +01:00
|
|
|
}
|