project flow completed
This commit is contained in:
@@ -11,3 +11,11 @@ import {Call} from '@wailsio/runtime';
|
|||||||
export async function Create() {
|
export async function Create() {
|
||||||
return Call.ByName("company.Company.Create", ...Array.prototype.slice.call(arguments, 0));
|
return Call.ByName("company.Company.Create", ...Array.prototype.slice.call(arguments, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function Edit
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
**/
|
||||||
|
export async function Edit() {
|
||||||
|
return Call.ByName("company.Company.Edit", ...Array.prototype.slice.call(arguments, 0));
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,14 +24,27 @@ export async function CreateCompany(name, memberNumber, username, password) {
|
|||||||
return Call.ByName("srv.Srv.CreateCompany", ...Array.prototype.slice.call(arguments, 0));
|
return Call.ByName("srv.Srv.CreateCompany", ...Array.prototype.slice.call(arguments, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function EditCompany
|
||||||
|
* @param id {number}
|
||||||
|
* @param name {string}
|
||||||
|
* @param memberNumber {string}
|
||||||
|
* @param username {string}
|
||||||
|
* @param password {string}
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
**/
|
||||||
|
export async function EditCompany(id, name, memberNumber, username, password) {
|
||||||
|
return Call.ByName("srv.Srv.EditCompany", ...Array.prototype.slice.call(arguments, 0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function Rpa
|
* @function Rpa
|
||||||
* @param companyName {string}
|
* @param companyID {number}
|
||||||
* @param month {number}
|
* @param month {number}
|
||||||
* @param year {number}
|
* @param year {number}
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
**/
|
**/
|
||||||
export async function Rpa(companyName, month, year) {
|
export async function Rpa(companyID, month, year) {
|
||||||
return Call.ByName("srv.Srv.Rpa", ...Array.prototype.slice.call(arguments, 0));
|
return Call.ByName("srv.Srv.Rpa", ...Array.prototype.slice.call(arguments, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,24 +40,19 @@ defineEmits([
|
|||||||
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
|
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
id: Number,
|
||||||
name: String,
|
name: String,
|
||||||
memberNumber: Number,
|
memberNumber: Number,
|
||||||
userName: String,
|
userName: String,
|
||||||
password: String
|
password: String
|
||||||
// companyName: String,
|
|
||||||
// initialMemberNumber: Number,
|
|
||||||
// username: String,
|
|
||||||
// password: String
|
|
||||||
})
|
})
|
||||||
const ld = reactive({
|
const ld = reactive({
|
||||||
|
id : props.id || 0,
|
||||||
name: props.name || '',
|
name: props.name || '',
|
||||||
memberNumber: props.memberNumber || 0,
|
memberNumber: props.memberNumber || 0,
|
||||||
userName: props.userName || '',
|
userName: props.userName || '',
|
||||||
password: props.password || '',
|
password: props.password || '',
|
||||||
})
|
})
|
||||||
console.log(props)
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,18 @@
|
|||||||
<q-select v-model="ld.companyID"
|
<q-select v-model="ld.companyID"
|
||||||
label="Şirket"
|
label="Şirket"
|
||||||
option-label="Name"
|
option-label="Name"
|
||||||
option-value="Name"
|
option-value="Id"
|
||||||
:options="ld.companies"
|
:options="ld.companies"
|
||||||
map-options
|
map-options
|
||||||
emit-value
|
emit-value
|
||||||
>
|
>
|
||||||
<template v-slot:after>
|
<template v-slot:after>
|
||||||
|
<q-btn
|
||||||
|
label="Düzenle"
|
||||||
|
color="primary"
|
||||||
|
@click="editCompany"
|
||||||
|
no-caps
|
||||||
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
label="Yeni Şirket Ekle"
|
label="Yeni Şirket Ekle"
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -34,13 +40,6 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-shrink">
|
|
||||||
<q-btn label="Düzenle"
|
|
||||||
@click="editCompany"
|
|
||||||
no-caps
|
|
||||||
color="secondary"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="col-11 text-right">
|
<div class="col-11 text-right">
|
||||||
{{ ld.xlsFile }}
|
{{ ld.xlsFile }}
|
||||||
</div>
|
</div>
|
||||||
@@ -82,9 +81,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, reactive } from 'vue'
|
import { onMounted, reactive } from 'vue'
|
||||||
import Company from 'components/dlg/Company.vue'
|
import Company from 'components/dlg/Company.vue'
|
||||||
import EditCompany from 'components/dlg/EditCompany.vue'
|
import EditCompanyPage from 'components/dlg/EditCompany.vue'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import { Companies, CreateCompany, Rpa, UploadExcel } from 'app/bindings/lib/srv/Srv'
|
import { Companies, CreateCompany, Rpa, UploadExcel ,EditCompany} from 'app/bindings/lib/srv/Srv'
|
||||||
import * as wails from '@wailsio/runtime'
|
import * as wails from '@wailsio/runtime'
|
||||||
|
|
||||||
const $q = useQuasar()
|
const $q = useQuasar()
|
||||||
@@ -102,27 +101,27 @@ onMounted(() => {
|
|||||||
getCompanies()
|
getCompanies()
|
||||||
|
|
||||||
wails.Events.On('logProcess', function (ev) {
|
wails.Events.On('logProcess', function (ev) {
|
||||||
console.log(ev.data)
|
|
||||||
ld.logProcess.push(ev.data)
|
ld.logProcess.push(ev.data)
|
||||||
console.log(ld.logProcess)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const editCompany = function () {
|
const editCompany = function () {
|
||||||
console.log(ld.companyID)
|
const selectedCompanyID = ld.companyID;
|
||||||
|
const selectedCompany = ld.companies.find(company => company.Id === selectedCompanyID);
|
||||||
$q.dialog({
|
$q.dialog({
|
||||||
component: EditCompany,
|
component: EditCompanyPage,
|
||||||
parent: this,
|
parent: this,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
name: ld.companyID.Name,
|
id : parseInt(selectedCompany.Id),
|
||||||
memberNumber: ld.companyID.MemberNumber,
|
name: selectedCompany.Name,
|
||||||
userName : ld.companyID.Username,
|
memberNumber: selectedCompany.MemberNumber,
|
||||||
password : ld.companyID.Password,
|
userName : selectedCompany.Username,
|
||||||
|
password : selectedCompany.Password,
|
||||||
},
|
},
|
||||||
// ----------------------
|
// ----------------------
|
||||||
// props that are passed to component instance
|
// props that are passed to component instance
|
||||||
}).onOk(data => {
|
}).onOk(data => {
|
||||||
CreateCompany(data.name, initialMemberNumber, data.username, data.password).then(()=>{
|
EditCompany(data.id, data.name, data.memberNumber, data.userName, data.password).then(()=>{
|
||||||
getCompanies()
|
getCompanies()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/shopspring/decimal"
|
||||||
|
|
||||||
"github.com/go-rod/rod"
|
"github.com/go-rod/rod"
|
||||||
"github.com/go-rod/rod/lib/launcher"
|
"github.com/go-rod/rod/lib/launcher"
|
||||||
"github.com/go-rod/rod/lib/proto"
|
"github.com/go-rod/rod/lib/proto"
|
||||||
@@ -28,8 +30,9 @@ type errorInfo struct {
|
|||||||
Index int
|
Index int
|
||||||
}
|
}
|
||||||
type BordroPageScript struct {
|
type BordroPageScript struct {
|
||||||
Index string
|
Index string
|
||||||
Value string
|
Value string
|
||||||
|
itemType string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Luca) ErrFunc(index bool) {
|
func (l *Luca) ErrFunc(index bool) {
|
||||||
@@ -121,7 +124,7 @@ func VerifyCaptcha(page *rod.Page) error {
|
|||||||
}
|
}
|
||||||
func NewLucaBot() *Luca {
|
func NewLucaBot() *Luca {
|
||||||
l := launcher.New().
|
l := launcher.New().
|
||||||
Headless(false).
|
Headless(true).
|
||||||
Devtools(true)
|
Devtools(true)
|
||||||
|
|
||||||
//defer l.Cleanup()
|
//defer l.Cleanup()
|
||||||
@@ -334,37 +337,49 @@ func (l *Luca) BordroTableMaping(frame *rod.Page, b *LucaBordro) ([]BordroPageSc
|
|||||||
|
|
||||||
fmt.Print(err)
|
fmt.Print(err)
|
||||||
pageScript := BordroPageScript{
|
pageScript := BordroPageScript{
|
||||||
Value: text,
|
Value: text,
|
||||||
Index: *id,
|
Index: *id,
|
||||||
|
itemType: "input",
|
||||||
}
|
}
|
||||||
scriptIndexArray = append(scriptIndexArray, pageScript)
|
scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
fmt.Println("Text:", text)
|
|
||||||
fmt.Println("ID:", *id)
|
|
||||||
fmt.Println("--------------------")
|
|
||||||
mainText = ""
|
mainText = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if t <= len(table)-2 {
|
if t <= len(table)-2 {
|
||||||
if text != "" {
|
if text != "" {
|
||||||
aad, err := table[t+1].Element("input")
|
inputBox, err := table[t+1].Element("input")
|
||||||
|
selectBox, err := table[t+1].Element("select")
|
||||||
fmt.Print(err)
|
fmt.Print(err)
|
||||||
if aad != nil {
|
if inputBox != nil {
|
||||||
aa, err := aad.Attribute("type")
|
types, err := inputBox.Attribute("type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if *aa != "hidden" {
|
if *types != "hidden" {
|
||||||
id, err := aad.Attribute("id")
|
id, err := inputBox.Attribute("id")
|
||||||
pageScript := BordroPageScript{
|
pageScript := BordroPageScript{
|
||||||
Value: text,
|
Value: text,
|
||||||
Index: *id,
|
Index: *id,
|
||||||
|
itemType: "input",
|
||||||
}
|
}
|
||||||
scriptIndexArray = append(scriptIndexArray, pageScript)
|
scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
fmt.Print(aad, err, id, aa)
|
fmt.Print(inputBox, err, id, types)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if selectBox != nil {
|
||||||
|
id, err := selectBox.Attribute("id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pageScript := BordroPageScript{
|
||||||
|
Value: text,
|
||||||
|
Index: *id,
|
||||||
|
itemType: "selectBox",
|
||||||
|
}
|
||||||
|
scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||||
}
|
}
|
||||||
|
mainText = ""
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -590,22 +605,56 @@ func (l *Luca) BordroYaz(month, year int, b *LucaBordro, lastItem bool) error {
|
|||||||
}
|
}
|
||||||
fmt.Print(rsp)
|
fmt.Print(rsp)
|
||||||
//rsp den dönden değerler ile matchlencek ve yazılcak
|
//rsp den dönden değerler ile matchlencek ve yazılcak
|
||||||
|
firsts := make(map[string]decimal.Decimal)
|
||||||
|
if value, ok := b.Ucretler["Normal Gün"]; ok {
|
||||||
|
// Anahtarı ve değeri yeni map'e ekle
|
||||||
|
firsts["Normal Gün"] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range firsts {
|
||||||
|
fmt.Print(v)
|
||||||
|
for i := 0; i < len(rsp); i++ {
|
||||||
|
if k == rsp[i].Value {
|
||||||
|
el, err := frame3.Element("#" + rsp[i].Index)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = el.Input(v.String())
|
||||||
|
el.Eval(`this.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Enter'}))`)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
for k, v := range b.Ucretler {
|
for k, v := range b.Ucretler {
|
||||||
var elementInsertControl bool = true
|
var elementInsertControl bool = true
|
||||||
tt := v.String()
|
tt := v.String()
|
||||||
fmt.Print(tt)
|
if k == "Normal Gün" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
Wait(frame3, 100)
|
Wait(frame3, 100)
|
||||||
for i := 0; i < len(rsp); i++ {
|
for i := 0; i < len(rsp); i++ {
|
||||||
|
|
||||||
if k == rsp[i].Value {
|
if k == rsp[i].Value {
|
||||||
|
if rsp[i].itemType == "selectBox" {
|
||||||
|
elemBox, err := frame3.Element("#" + rsp[i].Index)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
selectInput = Select{Element: elemBox, Selector: "#" + rsp[i].Index}
|
||||||
|
err = selectInput.SelectItem(v.String())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
elementInsertControl = false
|
||||||
|
break
|
||||||
|
}
|
||||||
el, err := frame3.Element("#" + rsp[i].Index)
|
el, err := frame3.Element("#" + rsp[i].Index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = el.Input(v.String())
|
err = el.Input(v.String())
|
||||||
elementInsertControl = false
|
elementInsertControl = false
|
||||||
//el.Eval(`this.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Enter'}))`)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,8 +677,6 @@ func (l *Luca) BordroYaz(month, year int, b *LucaBordro, lastItem bool) error {
|
|||||||
return errors.New(k + " Sütunu Bulunamadı Taslak Hatası, ")
|
return errors.New(k + " Sütunu Bulunamadı Taslak Hatası, ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Print(v, k)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td.right > button", 1)
|
err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td.right > button", 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
|
Id int `db:"id"`
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
MemberNumber string `db:"member_number"`
|
MemberNumber string `db:"member_number"`
|
||||||
Username string `db:"username"`
|
Username string `db:"username"`
|
||||||
@@ -24,6 +25,17 @@ VALUES (:name, :member_number, :username, :password)
|
|||||||
_, err := run.DB.NamedExec(sq, &c)
|
_, err := run.DB.NamedExec(sq, &c)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
func (c *Company) Edit() error {
|
||||||
|
sq := `
|
||||||
|
UPDATE company SET
|
||||||
|
name = :name,
|
||||||
|
member_number = :member_number,
|
||||||
|
username = :username,
|
||||||
|
password = :password
|
||||||
|
WHERE id = :id;`
|
||||||
|
_, err := run.DB.NamedExec(sq, &c)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
//func GetCompany(companyName string) (Company, error) {
|
//func GetCompany(companyName string) (Company, error) {
|
||||||
// sq := `
|
// sq := `
|
||||||
@@ -37,13 +49,13 @@ VALUES (:name, :member_number, :username, :password)
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
|
|
||||||
func GetCompany(companyName string) (Company, error) {
|
func GetCompany(companyID float64) (Company, error) {
|
||||||
var company Company
|
var company Company
|
||||||
|
|
||||||
sq := `
|
sq := `
|
||||||
SELECT * FROM company WHERE name = ?
|
SELECT * FROM company WHERE id = ?
|
||||||
`
|
`
|
||||||
err := run.DB.Get(&company, sq, companyName)
|
err := run.DB.Get(&company, sq, companyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Company{}, err
|
return Company{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func InitDB(path string) error {
|
|||||||
|
|
||||||
companySchema := `
|
companySchema := `
|
||||||
create table company (
|
create table company (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
name text not null unique,
|
name text not null unique,
|
||||||
member_number text not null,
|
member_number text not null,
|
||||||
username text not null,
|
username text not null,
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ func (s *Srv) CreateCompany(name, memberNumber, username, password string) error
|
|||||||
|
|
||||||
return c.Create()
|
return c.Create()
|
||||||
}
|
}
|
||||||
|
func (s *Srv) EditCompany(id float64, name, memberNumber, username, password string) error {
|
||||||
|
c := &company.Company{
|
||||||
|
Id: int(id),
|
||||||
|
Name: name,
|
||||||
|
MemberNumber: memberNumber,
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Edit()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Srv) UploadExcel() string {
|
func (s *Srv) UploadExcel() string {
|
||||||
dialog := application.OpenFileDialog()
|
dialog := application.OpenFileDialog()
|
||||||
@@ -51,13 +62,13 @@ type userInfo struct {
|
|||||||
accountNo string
|
accountNo string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
func (s *Srv) Rpa(companyID float64, month float64, year float64) error {
|
||||||
type CompanyInfo struct {
|
type CompanyInfo struct {
|
||||||
company *company.Company // float64.Company türünü gömme
|
company *company.Company // float64.Company türünü gömme
|
||||||
month float64 // yeni bir alan ekliyoruz
|
month float64 // yeni bir alan ekliyoruz
|
||||||
year float64
|
year float64
|
||||||
}
|
}
|
||||||
user, err := company.GetCompany(companyName)
|
user, err := company.GetCompany(companyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -69,15 +80,14 @@ func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
|||||||
|
|
||||||
//todo: readb company details by name
|
//todo: readb company details by name
|
||||||
b := bot.NewLucaBot()
|
b := bot.NewLucaBot()
|
||||||
|
emitLog("Aktarım Başladı")
|
||||||
err = b.Login(user, month, year)
|
err = b.Login(user, month, year)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//todo: inform user about process and errors
|
//todo: inform user about process and errors
|
||||||
emitLog("Şifreniz Hatalı")
|
emitLog("Şifreniz Hatalı")
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
err = b.PayrollPageLogin()
|
err = b.PayrollPageLogin()
|
||||||
|
|
||||||
slog.Debug("inputs", "year", year, "month", month)
|
slog.Debug("inputs", "year", year, "month", month)
|
||||||
|
|
||||||
f, err := excelize.OpenFile(s.xlsFileName)
|
f, err := excelize.OpenFile(s.xlsFileName)
|
||||||
@@ -124,8 +134,7 @@ func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
|||||||
key := rows[0][ndx]
|
key := rows[0][ndx]
|
||||||
brd.Ucretler[key], err = decimal.NewFromString(col)
|
brd.Ucretler[key], err = decimal.NewFromString(col)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//todo: kullanıcıya hata logu ver
|
// emitLog(`excel okunurken sorun oluştu`)
|
||||||
//veya tekrar okuma denebilinir
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +154,7 @@ func (s *Srv) Rpa(companyName string, month float64, year float64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
emitLog("İşlem Tamamlandı")
|
||||||
b.ClosingBrowserFromExternalLink()
|
b.ClosingBrowserFromExternalLink()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user