Przeglądaj źródła

新建访客基本信息,删除访客

tags/AL.0.8.0_20240113_base
yuan 1 rok temu
rodzic
commit
b432a25889
6 zmienionych plików z 93 dodań i 6 usunięć
  1. +1
    -0
      components.d.ts
  2. +3
    -0
      src/pages/contact-edit/index.scss
  3. +31
    -1
      src/pages/contact-edit/index.vue
  4. +32
    -1
      src/pages/contact-new/index.vue
  5. +12
    -0
      src/pages/contact/index.vue
  6. +14
    -4
      src/stores/contact-item.ts

+ 1
- 0
components.d.ts Wyświetl plik

@@ -13,6 +13,7 @@ declare module 'vue' {
Counter: typeof import('./src/components/Counter.vue')['default']
ExternalLink: typeof import('./src/components/ExternalLink.vue')['default']
Notification: typeof import('./src/components/notification/index.vue')['default']
NutActionSheet: typeof import('@nutui/nutui-taro')['ActionSheet']
NutAvatar: typeof import('@nutui/nutui-taro')['Avatar']
NutButton: typeof import('@nutui/nutui-taro')['Button']
NutCalendar: typeof import('@nutui/nutui-taro')['Calendar']


+ 3
- 0
src/pages/contact-edit/index.scss Wyświetl plik

@@ -15,3 +15,6 @@ page {
font-size: 36px
}

.nut-action-sheet__item {
color: red !important;
}

+ 31
- 1
src/pages/contact-edit/index.vue Wyświetl plik

@@ -4,12 +4,14 @@ import './index.scss'
import {useContactItemStore} from "../../stores/contact-item";
import { useContactsStore } from "../../stores/contacts";
import Taro from "@tarojs/taro";
import {ref} from "vue";


const contactData = Router.getData()
const contact = useContactItemStore()
const contacts = useContactsStore()
contact.setContact(contactData)
const showDeleteConfirmMenu = ref(false)

const goBack = () => {
Router.back()
@@ -36,6 +38,31 @@ const onSaveClicked = () => {
console.log("error", error)
})
}
const onDeleteVisitor = () => {
showDeleteConfirmMenu.value = true
//
}
const onDeleteConfirm = (item) => {
console.log(item)
Taro.showLoading({
title: 'loading',
})

contact.deleteVisitor().then(r => {
contacts.loadContactsFromServer().then( contactsResult => {
Taro.hideLoading()
Router.back()
})
}).catch(error => {
Taro.hideLoading()
Taro.showToast({
title: '网络异常,请稍候重试',
icon: 'none',
duration: 2000
})
console.log("error", error)
})
}
</script>

<template>
@@ -78,11 +105,14 @@ const onSaveClicked = () => {
</view>

<view class="p-3 pb-5">
<nut-button block color="red">删除联系人</nut-button>
<nut-button block color="red" @tap="onDeleteVisitor">删除联系人</nut-button>
</view>
</view>
</view>

<nut-action-sheet v-model:visible="showDeleteConfirmMenu" :menu-items="[{name: '确认删除'}]" cancel-txt="取消" @choose="onDeleteConfirm">
</nut-action-sheet>






+ 32
- 1
src/pages/contact-new/index.vue Wyświetl plik

@@ -1,11 +1,42 @@
<script setup>
import { Router } from 'tarojs-router-next'
import './index.scss'
import {useContactItemStore} from "../../stores/contact-item";
import {useContactsStore} from "../../stores/contacts";
import Taro from "@tarojs/taro";

const goBack = () => {
Router.back()
}

const contact = useContactItemStore()
contact.setContact(contact.getEmptyContactData())

const contacts = useContactsStore()

const onSaveClicked = () => {
Taro.showLoading({
title: 'loading',
})

console.log("onSaveClicked")
console.log(contact.contact)
contact.createVisitor().then(r => {
contacts.loadContactsFromServer().then( contactsResult => {
Taro.hideLoading()
Router.back()
})
}).catch(error => {
Taro.hideLoading()
Taro.showToast({
title: '网络异常,请稍候重试',
icon: 'none',
duration: 2000
})
console.log("error", error)
})
}

</script>

<template>
@@ -22,7 +53,7 @@ const goBack = () => {
<view class="text-black-50">新建来访联系人,并设置到访时间</view>
</view>
<view class="d-flex align-items-end">
<view class="text-primary save-button">保存</view>
<view class="text-primary save-button" @tap="onSaveClicked">保存</view>
</view>
</view>



+ 12
- 0
src/pages/contact/index.vue Wyświetl plik

@@ -4,6 +4,8 @@ import { Router } from 'tarojs-router-next'
import {reactive, ref} from 'vue';
import './index.scss'
import { useContactsStore, ContactData } from '../../stores/contacts'
import { registerRouterBackListener } from 'tarojs-router-next'



import {gql} from "graphql-tag";
@@ -56,6 +58,16 @@ function init() {
state.isContactDataLoadError = false
state.isContactDataLoading = false
})


registerRouterBackListener((to, from) => {
if ((from.url === "/pages/contact-new/index" && to.url === "/pages/contact/index")
|| (from.url === "/pages/contact-edit/index" && to.url === "/pages/contact/index")
) {
state.searchQuery = ""
generateContactGroupList(contacts.allContacts)
}
})
}

const onAuthErrorRefresh = () => {


+ 14
- 4
src/stores/contact-item.ts Wyświetl plik

@@ -40,9 +40,7 @@ export const useContactItemStore = defineStore('contact-item', () => {
isVip: $isVIP,
flexVisit: $flexVisit,
resourceId: $resourceId
} ) {
result
}
} )
}
`

@@ -61,6 +59,12 @@ export const useContactItemStore = defineStore('contact-item', () => {
}
`

const DELETE_VISITOR = gql`
mutation DeleteVisitor($id: Long! ) {
deleteVisitor( id: $id )
}
`

function createVisitor() {
const name = contact.value.name
const nickName = contact.value.nickName
@@ -85,6 +89,12 @@ export const useContactItemStore = defineStore('contact-item', () => {
return GQLRequest.query(UPDATE_VISITOR, {id, name, nickName, phone, company, isVIP, flexVisit })
}

function deleteVisitor() {
const id = contact.value.id

return GQLRequest.query(DELETE_VISITOR, { id })
}


return { contact, setContact, createVisitor, updateVisitor}
return { contact, setContact, createVisitor, updateVisitor, deleteVisitor, getEmptyContactData}
})

Ładowanie…
Anuluj
Zapisz