Compare commits
2 Commits
64479793ea
...
06f834e8c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06f834e8c9 | ||
|
|
945b479309 |
@@ -12,14 +12,14 @@ const tmenu = [
|
||||
|
||||
{
|
||||
label: 'Şablon Tasarımı',
|
||||
icon: 'business',
|
||||
icon: 'design_services',
|
||||
grantKey: 'Tmpl',
|
||||
to: '/tmpl'
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Bordro Eşleme',
|
||||
icon: 'business',
|
||||
icon: 'summarize',
|
||||
grantKey: 'Map',
|
||||
to: '/map'
|
||||
},
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, reactive, toRaw } from 'vue'
|
||||
import { onMounted, reactive } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { api } from 'boot/axios'
|
||||
import { catchAxiosError, showAxiosError } from 'src/libjs/lib/axios'
|
||||
@@ -109,7 +109,6 @@ const tmpl = reactive({
|
||||
kriterler: {},
|
||||
})
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getCompanyList()
|
||||
})
|
||||
@@ -145,7 +144,7 @@ const load = function () {
|
||||
ld.canProcess = false
|
||||
$q.dialog({
|
||||
title: 'Hata',
|
||||
message: 'Şirket için tanımlı şablon yok'
|
||||
message: 'Şirket için tanımlı şablon yok',
|
||||
}).onOk(() => {
|
||||
// console.log('OK')
|
||||
}).onCancel(() => {
|
||||
@@ -186,7 +185,6 @@ const load = function () {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
let workbook = null
|
||||
|
||||
const loadFile = function () {
|
||||
@@ -199,7 +197,6 @@ const loadFile = function () {
|
||||
|
||||
*/
|
||||
|
||||
|
||||
reader.onload = function (e) {
|
||||
const uin = new Uint8Array(e.target.result)
|
||||
|
||||
@@ -212,7 +209,7 @@ const loadFile = function () {
|
||||
$q.loading.show()
|
||||
reader.readAsArrayBuffer(ld.xlsFileName)
|
||||
} catch (err) {
|
||||
showAxiosError(err)
|
||||
console.log(err)
|
||||
} finally {
|
||||
$q.loading.hide()
|
||||
}
|
||||
@@ -223,7 +220,7 @@ const doProcess = function () {
|
||||
$q.loading.show()
|
||||
processXLS()
|
||||
} catch (err) {
|
||||
showAxiosError(err)
|
||||
console.log(err)
|
||||
} finally {
|
||||
$q.loading.hide()
|
||||
}
|
||||
@@ -245,17 +242,48 @@ const processXLS = function () {
|
||||
const bordroRow = {}
|
||||
|
||||
// sabit alanları verelim
|
||||
tmpl.alanlar.filter(a=>{return a.showInSlip}).forEach(a=>{
|
||||
tmpl.alanlar.filter(a => {return a.showInSlip}).forEach(a => {
|
||||
if (a.colNro >= 0) {
|
||||
bordroRow[a.fieldName] = row[a.colNro]
|
||||
} else {
|
||||
const tmpValues = []
|
||||
a.combinedFieldsNro.forEach(cf => {
|
||||
let tmpVal = row[cf]
|
||||
if ((tmpVal === null) || (tmpVal === undefined)) {
|
||||
tmpVal = ''
|
||||
}
|
||||
tmpValues.push(tmpVal)
|
||||
})
|
||||
|
||||
bordroRow[a.fieldName] = tmpValues.join(' ').trim()
|
||||
}
|
||||
})
|
||||
|
||||
// veri alanlarını verelim
|
||||
tmpl.alanlar.filter(a=>{return a.colType === 'veri'}).forEach(veri=>{
|
||||
tmpl.alanlar.filter(a => {return a.colType === 'veri'}).forEach(veri => {
|
||||
// Hesap kodunu bulalım
|
||||
let hesapKod = ''
|
||||
Object.keys(tmpl.kriterler).forEach(k => {
|
||||
const kriter = tmpl.kriterler[k]
|
||||
const kriterVal = row[kriter.colNro]
|
||||
|
||||
let kriterVal = ''
|
||||
|
||||
if (kriter.colNro >= 0) {
|
||||
// sabit kriter alanı
|
||||
kriterVal = row[kriter.colNro]
|
||||
} else {
|
||||
const tmpValues = []
|
||||
tmpl.kriterler[k].combinedFieldsNro.forEach(cf => {
|
||||
let tmpKriterVal = row[cf]
|
||||
if ((tmpKriterVal === null) || (tmpKriterVal === undefined)) {
|
||||
tmpKriterVal = ''
|
||||
}
|
||||
tmpValues.push(tmpKriterVal)
|
||||
})
|
||||
|
||||
kriterVal = tmpValues.join(' ').trim()
|
||||
}
|
||||
|
||||
const map = kriter.mappings[kriterVal]
|
||||
|
||||
if ((map !== undefined) && (map !== null)) {
|
||||
@@ -270,10 +298,11 @@ const processXLS = function () {
|
||||
})
|
||||
|
||||
bordroRow['Hesap'] = hesapKod
|
||||
bordroRow['Masraf Açıklama'] = veri.fieldName
|
||||
bordroRow['Tutar'] = row[veri.colNro]
|
||||
bordroRow['B/A'] = veri.ba
|
||||
|
||||
bordro.push({...bordroRow})
|
||||
bordro.push({ ...bordroRow })
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -281,10 +310,9 @@ const processXLS = function () {
|
||||
|
||||
const newSheet = utils.json_to_sheet(bordro)
|
||||
const newWB = utils.book_new()
|
||||
utils.book_append_sheet(newWB, newSheet, "veri")
|
||||
writeFile(newWB, "bordro.xlsx", { compression: true })
|
||||
utils.book_append_sheet(newWB, newSheet, 'veri')
|
||||
writeFile(newWB, 'bordro.xlsx', { compression: true })
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -89,7 +89,41 @@
|
||||
<q-markup-table flat bordered>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Kolon No</th>
|
||||
<th>
|
||||
<q-btn flat
|
||||
color="positive"
|
||||
dense
|
||||
icon="add"
|
||||
>
|
||||
<q-tooltip>Yeni birleşik alan ekle</q-tooltip>
|
||||
</q-btn>
|
||||
<q-popup-edit
|
||||
v-model="ld.combinedFields"
|
||||
buttons
|
||||
v-slot="scope"
|
||||
@update:modelValue="addCombinedField()"
|
||||
anchor="top start"
|
||||
style="min-width: 350px; !important;"
|
||||
persistent
|
||||
>
|
||||
<q-select
|
||||
multiple
|
||||
use-chips
|
||||
v-model="scope.value"
|
||||
:options="fieldOptions"
|
||||
dense
|
||||
autofocus
|
||||
counter
|
||||
@keyup.enter="scope.set"
|
||||
style="min-width: 300px; !important;"
|
||||
map-options
|
||||
option-label="fieldName"
|
||||
option-value="colNro"
|
||||
/>
|
||||
</q-popup-edit>
|
||||
|
||||
Kolon No
|
||||
</th>
|
||||
<th>Alan</th>
|
||||
<th>Kontrol</th>
|
||||
<th>Fişte Göster</th>
|
||||
@@ -98,8 +132,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="r in tmpl.alanlar" :key="r.fieldName">
|
||||
<td class="text-center" style="width: 70px;">{{ r.colNro }}</td>
|
||||
<tr v-for="(r, rndx) in tmpl.alanlar" :key="r.fieldName">
|
||||
<td class="text-center" style="width: 70px;">
|
||||
|
||||
|
||||
{{ r.colNro }}
|
||||
<q-btn
|
||||
v-if="r.colNro < 0"
|
||||
icon="delete"
|
||||
color="negative"
|
||||
flat
|
||||
size="sm"
|
||||
dense
|
||||
@click="delCombinedField(rndx)"
|
||||
/>
|
||||
</td>
|
||||
<td>{{ r.fieldName }}</td>
|
||||
<td class="text-center" style="width: 70px;">
|
||||
<q-radio
|
||||
@@ -255,6 +302,8 @@ const ld = reactive({
|
||||
alreadySelectedValFields: {},
|
||||
|
||||
showFields: false,
|
||||
|
||||
combinedFields: [],
|
||||
})
|
||||
|
||||
const tmpl = reactive({
|
||||
@@ -371,13 +420,6 @@ const load = function () {
|
||||
|
||||
const loadFile = function () {
|
||||
const reader = new FileReader()
|
||||
/*
|
||||
reader.addEventListener('load', (event) => {
|
||||
console.log(event.target.result)
|
||||
});
|
||||
reader.readAsDataURL(ld.xlsFile);
|
||||
|
||||
*/
|
||||
|
||||
reader.onload = function (e) {
|
||||
const uin = new Uint8Array(e.target.result)
|
||||
@@ -413,6 +455,9 @@ const processXLS = function () {
|
||||
colType: '',
|
||||
ba: 'B',
|
||||
showInSlip: false,
|
||||
combinedFields: [],
|
||||
combinedFieldsNro: [],
|
||||
formula: '',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -429,10 +474,13 @@ const processXLS = function () {
|
||||
|
||||
tmpl.alanlar.push({
|
||||
colNro: ndx,
|
||||
fieldName: name,
|
||||
showInSlip: false,
|
||||
fieldName: name.trim(),
|
||||
colType: '',
|
||||
ba: 'B',
|
||||
showInSlip: false,
|
||||
combinedFields: [],
|
||||
combinedFieldsNro: [],
|
||||
formula: '',
|
||||
})
|
||||
|
||||
lastCol = ndx
|
||||
@@ -455,6 +503,9 @@ const fillCriteria = function () {
|
||||
tmpl.kriterler[f.fieldName] = {
|
||||
colNro: f.colNro,
|
||||
|
||||
combinedFields: [...(f.combinedFields || [])],
|
||||
combinedFieldsNro: [...(f.combinedFieldsNro || [])],
|
||||
|
||||
valFields: [],
|
||||
/*
|
||||
[
|
||||
@@ -478,10 +529,29 @@ const fillCriteria = function () {
|
||||
const kval = row[tmpl.kontrolKolonu]
|
||||
if ((kval !== null) && (kval !== undefined) && (kval !== '')) {
|
||||
Object.keys(tmpl.kriterler).forEach(k => {
|
||||
const kriterVal = row[tmpl.kriterler[k].colNro]
|
||||
|
||||
let kriterVal = ''
|
||||
if (tmpl.kriterler[k].colNro >= 0) {
|
||||
// sabit kriter alanı
|
||||
kriterVal = row[tmpl.kriterler[k].colNro]
|
||||
} else {
|
||||
// birleştirilmiş / combine kriter alanı
|
||||
const tmpValues = []
|
||||
tmpl.kriterler[k].combinedFieldsNro.forEach(cf => {
|
||||
let tmpKriterVal = row[cf]
|
||||
if ((tmpKriterVal === null ) || (tmpKriterVal === undefined)) {
|
||||
tmpKriterVal = ''
|
||||
}
|
||||
tmpValues.push(tmpKriterVal)
|
||||
})
|
||||
|
||||
kriterVal = tmpValues.join(' ').trim()
|
||||
}
|
||||
|
||||
if ((kriterVal !== null) && (kriterVal !== undefined) && (kriterVal !== '')) {
|
||||
tmpl.kriterler[k].mappings[kriterVal] = {}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -512,6 +582,46 @@ const delMapping = function (k, valField) {
|
||||
})
|
||||
}
|
||||
|
||||
const fieldOptions = computed(() => {
|
||||
const ls = tmpl.alanlar.filter(f => {return f.colNro >= 0})
|
||||
const opts = []
|
||||
ls.forEach(f => {
|
||||
opts.push({ colNro: f.colNro, fieldName: f.fieldName })
|
||||
})
|
||||
return opts
|
||||
})
|
||||
|
||||
const addCombinedField = function () {
|
||||
ld.isDirty = true
|
||||
|
||||
const combinedFields = []
|
||||
const combinedFieldsNro = []
|
||||
|
||||
ld.combinedFields.forEach(f => {
|
||||
combinedFields.push(f.fieldName)
|
||||
combinedFieldsNro.push(f.colNro)
|
||||
})
|
||||
const fName = combinedFields.join(' : ')
|
||||
|
||||
tmpl.alanlar.push({
|
||||
colNro: -1,
|
||||
fieldName: fName,
|
||||
colType: '',
|
||||
ba: 'B',
|
||||
showInSlip: false,
|
||||
combinedFields: [...combinedFields],
|
||||
combinedFieldsNro: [...combinedFieldsNro],
|
||||
formula: '',
|
||||
})
|
||||
|
||||
ld.combinedFields.splice(0)
|
||||
}
|
||||
|
||||
const delCombinedField = function (ndx) {
|
||||
ld.isDirty = true
|
||||
tmpl.alanlar.splice(ndx, 1)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user