edit dialog added

This commit is contained in:
hysn99
2024-04-02 09:51:14 +03:00
parent 5ec8f05e16
commit 321a76096f
6 changed files with 209 additions and 25 deletions

View File

@@ -0,0 +1,66 @@
<template>
<q-dialog ref="dialogRef" persistent @hide="onDialogHide">
<q-card style="width: 600px;">
<q-card-section class="bg-purple text-white">
<p>Şirket Adı: {{ props.name }}</p>
<!-- <span class="text-h6 text-weight-bolder">{{props.name}}</span> -->
</q-card-section>
<q-card-section>
<q-input v-model="ld.name" label="Şirket Adı"/>
<q-input v-model="ld.memberNumber" label="Üye No"/>
<q-input v-model="ld.userName" label="Kullanıcı Adı"/>
<q-input v-model="ld.password" label="Parola"/>
</q-card-section>
<q-card-actions align="right">
<q-btn label="İptal"
icon="cancel"
no-caps outline
@click="onDialogCancel"
/>
<q-btn label="Kaydet" no-caps outline color="positive"
icon="check"
@click="onDialogOK(toRaw(ld))"/>
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script setup>
import { useDialogPluginComponent } from 'quasar'
import { reactive, toRaw ,defineProps } from 'vue'
defineEmits([
// REQUIRED; need to specify some events that your
// component will emit through useDialogPluginComponent()
...useDialogPluginComponent.emits,
])
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
const props = defineProps({
name: String,
memberNumber: Number,
userName: String,
password: String
// companyName: String,
// initialMemberNumber: Number,
// username: String,
// password: String
})
const ld = reactive({
name: props.name || '',
memberNumber: props.memberNumber || 0,
userName: props.userName || '',
password: props.password || '',
})
console.log(props)
</script>
<style scoped>
</style>

View File

@@ -34,6 +34,13 @@
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>
@@ -75,6 +82,7 @@
<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 { useQuasar } from 'quasar' import { useQuasar } from 'quasar'
import { Companies, CreateCompany, Rpa, UploadExcel } from 'app/bindings/lib/srv/Srv' import { Companies, CreateCompany, Rpa, UploadExcel } from 'app/bindings/lib/srv/Srv'
import * as wails from '@wailsio/runtime' import * as wails from '@wailsio/runtime'
@@ -98,6 +106,25 @@ onMounted(() => {
}) })
}) })
const editCompany = function () {
console.log(ld.companyID)
$q.dialog({
component: EditCompany,
parent: this,
componentProps: {
name: ld.companyID.Name,
memberNumber: ld.companyID.MemberNumber,
userName : ld.companyID.Username,
password : ld.companyID.Password,
},
// ----------------------
// props that are passed to component instance
}).onOk(data => {
CreateCompany(data.name, initialMemberNumber, data.username, data.password).then(()=>{
getCompanies()
})
})
}
const createCompany = function () { const createCompany = function () {
$q.dialog({ $q.dialog({
component: Company, component: Company,
@@ -115,6 +142,7 @@ const getCompanies = function () {
ld.companies.splice(0) ld.companies.splice(0)
Companies().then(res => { Companies().then(res => {
ld.companies.push(...res) ld.companies.push(...res)
console.log(ld.companies)
}) })
} }

View File

@@ -127,7 +127,7 @@ func NewLucaBot() *Luca {
return &Luca{Page: page, Browser: browser} return &Luca{Page: page, Browser: browser}
} }
func (l *Luca) Login(company company.Company) error { func (l *Luca) Login(company company.Company, month float64, year float64) error {
page := l.Page page := l.Page
err := WaitLoad(page) err := WaitLoad(page)
if err != nil { if err != nil {
@@ -182,8 +182,102 @@ func (l *Luca) Login(company company.Company) error {
return err return err
} }
wait = page.WaitRequestIdle(500*time.Millisecond, nil, nil, nil) Wait(page, 1500)
wait()
allPages, err := page.Browser().Pages()
if err != nil {
return err
}
newPage, err := allPages.FindByURL("https://auygs.luca.com.tr/Luca/luca.do")
Wait(newPage, 1500)
err = WaitLoad(newPage)
if err != nil {
return err
}
if err != nil {
return err
}
frm4, err := newPage.Element("#frm4")
if err != nil {
return err
}
frame4, err := frm4.Frame()
companiesSelectBox, err := frame4.Elements("#SirketCombo > option")
if err != nil {
return err
}
var vls string = ""
for j := 0; j < len(companiesSelectBox); j++ {
tex, err := companiesSelectBox[j].Text()
value, err := companiesSelectBox[j].Property("value")
if err != nil {
return err
}
if err != nil {
return err
}
if tex == company.Name {
vls = value.String()
break
}
}
Wait(newPage, 500)
element, err := frame4.Element("#SirketCombo")
if err != nil {
return err
}
selectInput := Select{Element: element, Selector: "#SirketCombo"}
err = selectInput.SelectItem(vls)
if err != nil {
return err
}
err = WaitLoad(frame4)
if err != nil {
return err
}
companiesSelectYear, err := frame4.Elements("#DonemCombo > option")
if err != nil {
return err
}
for j := 0; j < len(companiesSelectYear); j++ {
tex, err := companiesSelectYear[j].Text()
value, err := companiesSelectYear[j].Property("value")
if err != nil {
return err
}
if err != nil {
return err
}
if strings.Contains(tex, strconv.Itoa(int(year))) {
vls = value.String()
break
}
}
Wait(newPage, 500)
element, err = frame4.Element("#DonemCombo")
if err != nil {
return err
}
selectInput = Select{Element: element, Selector: "#DonemCombo"}
err = selectInput.SelectItem(vls)
if err != nil {
return err
}
err = WaitLoad(frame4)
if err != nil {
return err
}
err = ClickItem(frame4, "#SirName > button.no-bold.green > i", 1)
err = WaitLoad(frame4)
if err != nil {
return err
}
return err return err
} }
@@ -199,11 +293,6 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
if err != nil { if err != nil {
return err return err
} }
fs2, err := newPage.Element("#frm2")
if err != nil {
return err
}
frame, err := fs2.Frame()
fs3, err := newPage.Element("#frm3") fs3, err := newPage.Element("#frm3")
if err != nil { if err != nil {
return err return err
@@ -213,20 +302,6 @@ func (l *Luca) BordroYaz(data []*model.Bordro, month float64, year float64) erro
if err != nil { if err != nil {
return err return err
} }
err = ClickItem(frame, "#apy1000m0i1ITD", 1)
if err != nil {
return err
}
fmt.Println(err)
err = ClickItem(frame3, "#apy1000m33i4ITX", 1)
if err != nil {
return err
}
err = newPage.WaitLoad()
if err != nil {
return err
}
Wait(newPage, 1500)
for i := 0; i < len(data); i++ { for i := 0; i < len(data); i++ {
if i != 0 { if i != 0 {

View File

@@ -10,6 +10,11 @@ type Company struct {
Username string `db:"username"` Username string `db:"username"`
Password string `db:"password"` Password string `db:"password"`
} }
type CompanyInfo struct {
company Company
month float64
year float64
}
func (c *Company) Create() error { func (c *Company) Create() error {
sq := ` sq := `

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -62,14 +62,24 @@ func getUser(userId string) *userInfo {
return &info return &info
} }
func (s *Srv) Rpa(companyName string, month float64, year float64) error { func (s *Srv) Rpa(companyName string, month float64, year float64) error {
type CompanyInfo struct {
company *company.Company // float64.Company türünü gömme
month float64 // yeni bir alan ekliyoruz
year float64
}
user, err := company.GetCompany(companyName) user, err := company.GetCompany(companyName)
if err != nil { if err != nil {
return err
} }
// companyInfo := CompanyInfo{
// company: &user,
// month: month,
// year: year,
// }
//todo: readb company details by name //todo: readb company details by name
b := bot.NewLucaBot() b := bot.NewLucaBot()
err = b.Login(user) 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ı")