diff --git a/components.d.ts b/components.d.ts index a85e835..c2bb993 100644 --- a/components.d.ts +++ b/components.d.ts @@ -27,6 +27,8 @@ declare module 'vue' { NutEmpty: typeof import('@nutui/nutui-taro')['Empty'] NutForm: typeof import('@nutui/nutui-taro')['Form'] NutFormItem: typeof import('@nutui/nutui-taro')['FormItem'] + NutGrid: typeof import('@nutui/nutui-taro')['Grid'] + NutGridItem: typeof import('@nutui/nutui-taro')['GridItem'] NutInput: typeof import('@nutui/nutui-taro')['Input'] NutNavbar: typeof import('@nutui/nutui-taro')['Navbar'] NutRow: typeof import('@nutui/nutui-taro')['Row'] diff --git a/src/app.config.ts b/src/app.config.ts index 973695e..4eff6e9 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -8,7 +8,8 @@ export default defineAppConfig({ 'pages/settings/index', 'pages/login/index', 'pages/web-view/index', - 'pages/contact-pass-records/index' + 'pages/contact-pass-records/index', + 'pages/contact-edit-logs/index' ], window: { backgroundTextStyle: 'light', @@ -32,7 +33,7 @@ export default defineAppConfig({ pagePath: 'pages/invite/index', selectedIconPath: 'images/calendar-plus-solid-397ef5.png', iconPath: 'images/calendar-plus-regular-797979.png', - text: '新邀约' + text: '邀约' }, { pagePath: 'pages/contact/index', diff --git a/src/app.scss b/src/app.scss index 82bc3dd..88f8720 100644 --- a/src/app.scss +++ b/src/app.scss @@ -8,10 +8,10 @@ color: #0056b3 !important; } .card-hover-gray { - background-color: #EEE; + background-color: #EEE !important; } .card-hover-white { - background-color: #FFF; + background-color: #FFF !important; } .btn-secondary:hover { diff --git a/src/components/notification/index.vue b/src/components/notification/index.vue index 31f3c79..f366a05 100644 --- a/src/components/notification/index.vue +++ b/src/components/notification/index.vue @@ -18,7 +18,7 @@ const contacts = useContactsStore() const goContactInfoPage = () => { console.log(item) const contactData = contacts.getContactById(item.userId) - Router.toContactEdit({ data: contactData }) + if (contactData) Router.toContactEdit({ data: contactData }) } @@ -57,7 +57,7 @@ const goContactInfoPage = () => { - +
diff --git a/src/pages/contact-edit-logs/index.config.ts b/src/pages/contact-edit-logs/index.config.ts new file mode 100644 index 0000000..5662c12 --- /dev/null +++ b/src/pages/contact-edit-logs/index.config.ts @@ -0,0 +1,6 @@ +export default definePageConfig({ + navigationBarTitleText: '', + usingComponents: {}, + navigationStyle: 'custom', + disableScroll: true +}) diff --git a/src/pages/contact-edit-logs/index.scss b/src/pages/contact-edit-logs/index.scss new file mode 100644 index 0000000..b41e6ef --- /dev/null +++ b/src/pages/contact-edit-logs/index.scss @@ -0,0 +1,20 @@ +page { + height: 100%; +} + +.nut-navbar { + background: transparent; +} + +.scroll { + flex: 1; + overflow: scroll; +} + +.save-button { + font-size: 36px +} + +.nut-action-sheet__item { + color: red !important; +} diff --git a/src/pages/contact-edit-logs/index.vue b/src/pages/contact-edit-logs/index.vue new file mode 100644 index 0000000..e1d7a58 --- /dev/null +++ b/src/pages/contact-edit-logs/index.vue @@ -0,0 +1,182 @@ + + + + + + + + + diff --git a/src/pages/contact-edit/index.vue b/src/pages/contact-edit/index.vue index 2d62172..7882149 100644 --- a/src/pages/contact-edit/index.vue +++ b/src/pages/contact-edit/index.vue @@ -32,15 +32,16 @@ const onSaveClicked = () => { }).catch(error => { Taro.hideLoading() if (error) { + const errorMessage = (typeof error === "string")? error : "服务器错误,请稍后重试" Taro.showToast({ - title: error, + title: errorMessage, icon: 'none', duration: 2000 }) } else { Taro.showToast({ - title: '网络异常,请稍候重试', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }) @@ -70,7 +71,7 @@ const onBlockConfirm = (item) => { }).catch(error => { Taro.hideLoading() Taro.showToast({ - title: '网络异常,请稍候重试', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }) @@ -81,8 +82,8 @@ const onClickPassRecords = () => { Router.toContactPassRecords({ data: contactData }) } -const onClickEditRecords = () => { - Router.toContactEdit({ data: contactData }) +const onClickEditLogs = () => { + Router.toContactEditLogs({ data: contactData }) } const onDeleteConfirm = (item) => { @@ -99,7 +100,7 @@ const onDeleteConfirm = (item) => { }).catch(error => { Taro.hideLoading() Taro.showToast({ - title: '网络异常,请稍候重试', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }) @@ -141,7 +142,7 @@ const onDeleteConfirm = (item) => { - + diff --git a/src/pages/contact-new/index.vue b/src/pages/contact-new/index.vue index 3b875bf..7d9d0b1 100644 --- a/src/pages/contact-new/index.vue +++ b/src/pages/contact-new/index.vue @@ -29,7 +29,7 @@ const onSaveClicked = () => { }).catch(error => { Taro.hideLoading() Taro.showToast({ - title: '网络异常,请稍候重试', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }) diff --git a/src/pages/contact-pass-records/index.vue b/src/pages/contact-pass-records/index.vue index 077398e..fdd7fd7 100644 --- a/src/pages/contact-pass-records/index.vue +++ b/src/pages/contact-pass-records/index.vue @@ -125,6 +125,9 @@ const goBack = () => { 仅显示最近 100 条记录 + + 没有到访记录 + diff --git a/src/pages/invite/index.scss b/src/pages/invite/index.scss index 1251ddd..5e4d9d8 100644 --- a/src/pages/invite/index.scss +++ b/src/pages/invite/index.scss @@ -11,4 +11,15 @@ page { overflow: scroll; } - +.nut-grid-item__content { + padding: 0; + display:unset; +} +.nut-grid-item__content--border { + border-right-width: unset; + border-bottom-width: unset; +} +.nut-grid-item__content--surround { + border-top-width: unset; + border-left-width: unset; +} diff --git a/src/pages/invite/index.vue b/src/pages/invite/index.vue index 2190b9a..c142b6d 100644 --- a/src/pages/invite/index.vue +++ b/src/pages/invite/index.vue @@ -1,11 +1,208 @@ - + + + diff --git a/src/pages/invite/invite.jpeg b/src/pages/invite/invite.jpeg new file mode 100644 index 0000000..5cbcee5 Binary files /dev/null and b/src/pages/invite/invite.jpeg differ diff --git a/src/stores/contact-edit-logs.ts b/src/stores/contact-edit-logs.ts new file mode 100644 index 0000000..85ef365 --- /dev/null +++ b/src/stores/contact-edit-logs.ts @@ -0,0 +1,88 @@ +// https://pinia.esm.dev/introduction.html +import { defineStore } from 'pinia' +import {GQLRequest, PinyinHelper, Session} from "../utils"; +import {gql} from "graphql-tag"; +import {ref, Ref, UnwrapRef} from "vue"; +import dayjs from "dayjs"; +import {PassRecords} from "./pass-records"; + +export interface ContactEditLog { + userName: string + method: string + methodDesc: string + datetime: string + params: string + paramsDesc: string +} + +export const useContactEditLogsStore = defineStore('contact-edit-logs', () => { + + const editLogs: Ref> = ref([]) + + const GQL_QUERY_CONTACT_EDIT_LOGS = gql` + query ($visitorId: ID, $limit: Int ) { + visitorLogs(visitorId: $visitorId, limit: $limit) { + userName + param + method + operateTime + } + } + ` + + function loadContactEditLogsFromServer (visitorId: number) { + return new Promise((resolve, reject) => { + const items: ContactEditLog[] = [] + const limit = 100 + console.log("visitorId", visitorId) + return GQLRequest.query(GQL_QUERY_CONTACT_EDIT_LOGS, {visitorId, limit}) + .then(result => { + if (result.code == 500) { + reject("Network Error") + } else { + console.log(result) + for (let item of result.data.visitorLogs) { + // console.log(item) + items.push({ + userName: item.userName, + method: item.method, + methodDesc: methodToDesc(item.method), + datetime: dayjs(item.operateTime, "YYYY-MM-DDTHH:mm:ss").format("YYYY年MM月DD日 HH:mm:ss"), + params: item.param, + paramsDesc: paramsToDesc(item.method, item.param) + } as ContactEditLog) + } + + editLogs.value = items.sort((a, b) => a.datetime.localeCompare(b.datetime)).reverse(); + console.log("editLogs", editLogs.value) + resolve(editLogs.value) + } + }).catch(e => { + reject(e) + }) + }) + } + + function methodToDesc(method: string) { + if (method === "updateVisitor") return "更新了" + else if (method === "createVisitor") return "创建了" + else if (method === "deleteVisitor") return "删除了" + else return method + } + + function paramsToDesc(method: string, params: string) { + if (method === "updateVisitor" || method === "createVisitor") { + if (params.indexOf("resourceId") !== -1) return "访客照片和信息" + else if (params.indexOf('isBlock":true') !== -1) return "阻止状态" + else if (params.indexOf('isBlock":false') !== -1) return "取消阻止状态" + else return "访客信息" + } + else if (method === "deleteVisitor" ) { + return "此访客" + } + else return params + } + + + return { loadContactEditLogsFromServer } +}) diff --git a/src/stores/contact-item.ts b/src/stores/contact-item.ts index 044dd59..f28a1de 100644 --- a/src/stores/contact-item.ts +++ b/src/stores/contact-item.ts @@ -36,8 +36,8 @@ export const useContactItemStore = defineStore('contact-item', () => { } const CREATE_VISITOR = gql` - mutation CreateVisitor($name: String!, $nickName: String, $phone: String, $company: String, $isVIP: Boolean, $flexVisit: Boolean, $resourceId: Long ) { - createVisitor( input: { + mutation CreateVisitor($staffId: ID!, $name: String!, $nickName: String, $phone: String, $company: String, $isVIP: Boolean, $flexVisit: Boolean, $resourceId: ID ) { + createVisitor( staffId: $staffId, input: { name: $name, nickname: $nickName, phone: $phone, @@ -50,8 +50,8 @@ export const useContactItemStore = defineStore('contact-item', () => { ` const UPDATE_VISITOR = gql` - mutation UpdateVisitor($id: Long!, $name: String!, $nickName: String, $phone: String, $company: String, $isVIP: Boolean, $flexVisit: Boolean, $resourceId: Long ) { - updateVisitor( input: { + mutation UpdateVisitor($staffId: ID!, $id: ID!, $name: String!, $nickName: String, $phone: String, $company: String, $isVIP: Boolean, $flexVisit: Boolean, $resourceId: ID ) { + updateVisitor( staffId: $staffId, input: { id: $id, name: $name, nickname: $nickName, @@ -65,14 +65,14 @@ export const useContactItemStore = defineStore('contact-item', () => { ` const DELETE_VISITOR = gql` - mutation DeleteVisitor($id: Long! ) { - deleteVisitor( id: $id ) + mutation DeleteVisitor( $staffId: ID!, $id: ID! ) { + deleteVisitor( staffId: $staffId, id: $id ) } ` const CHANGE_BLOCK_STATUS = gql` - mutation UpdateVisitor($id: Long!, $isBlock: Boolean ) { - updateVisitor( input: { + mutation UpdateVisitor( $staffId: ID!, $id: ID!, $isBlock: Boolean ) { + updateVisitor( staffId: $staffId, input: { id: $id, isBlock: $isBlock } ) @@ -86,13 +86,15 @@ export const useContactItemStore = defineStore('contact-item', () => { const company = contact.value.company const isVIP = contact.value.isVIP const flexVisit = contact.value.flexVisit + const staffId = Session.get("staff").id + return new Promise((resolve, reject) => { if (contactNewAvatar.value !== "") { uploadFace().then(r => { console.log(r) const resourceId = r.data.resourceId - GQLRequest.query(CREATE_VISITOR, { name, nickName, phone, company, isVIP, flexVisit, resourceId }) + GQLRequest.query(CREATE_VISITOR, { staffId, name, nickName, phone, company, isVIP, flexVisit, resourceId }) .then(r=> resolve(r)) .catch(e=> reject(e)) }).catch(e => { @@ -100,7 +102,7 @@ export const useContactItemStore = defineStore('contact-item', () => { }) } else { - GQLRequest.query(CREATE_VISITOR, { name, nickName, phone, company, isVIP, flexVisit }) + GQLRequest.query(CREATE_VISITOR, { staffId, name, nickName, phone, company, isVIP, flexVisit }) .then(r=> resolve(r)) .catch(e=> reject(e)) } @@ -117,14 +119,14 @@ export const useContactItemStore = defineStore('contact-item', () => { const company = contact.value.company const isVIP = contact.value.isVIP const flexVisit = contact.value.flexVisit - + const staffId = Session.get("staff").id return new Promise((resolve, reject) => { if (contactNewAvatar.value !== "") { uploadFace().then(r => { console.log(r) const resourceId = r.data.resourceId - GQLRequest.query(UPDATE_VISITOR, {id, name, nickName, phone, company, isVIP, flexVisit, resourceId }) + GQLRequest.query(UPDATE_VISITOR, {staffId, id, name, nickName, phone, company, isVIP, flexVisit, resourceId }) .then(r=> resolve(r)) .catch(e=> reject(e)) }).catch(e => { @@ -132,7 +134,7 @@ export const useContactItemStore = defineStore('contact-item', () => { }) } else { - GQLRequest.query(UPDATE_VISITOR, {id, name, nickName, phone, company, isVIP, flexVisit }) + GQLRequest.query(UPDATE_VISITOR, {staffId, id, name, nickName, phone, company, isVIP, flexVisit }) .then(r=> resolve(r)) .catch(e=> reject(e)) } @@ -141,13 +143,16 @@ export const useContactItemStore = defineStore('contact-item', () => { function setBlockStatus(isBlock: Boolean) { const id = contact.value.id - return GQLRequest.query(CHANGE_BLOCK_STATUS, { id, isBlock }) + const staffId = Session.get("staff").id + + return GQLRequest.query(CHANGE_BLOCK_STATUS, { staffId, id, isBlock }) } function deleteVisitor() { const id = contact.value.id + const staffId = Session.get("staff").id - return GQLRequest.query(DELETE_VISITOR, { id }) + return GQLRequest.query(DELETE_VISITOR, { staffId, id }) } function uploadFace() { diff --git a/src/stores/contacts.ts b/src/stores/contacts.ts index f1749a8..d215f56 100644 --- a/src/stores/contacts.ts +++ b/src/stores/contacts.ts @@ -78,10 +78,7 @@ export const useContactsStore = defineStore('contacts', () => { function getContactById(id: number) { for(const contact of allContacts.value) { - console.log(contact) - if (contact.id === id) { - return contact - } + if (contact.id === id) return contact } return undefined } diff --git a/src/stores/pass-records.ts b/src/stores/pass-records.ts index 947d387..3d52f28 100644 --- a/src/stores/pass-records.ts +++ b/src/stores/pass-records.ts @@ -75,7 +75,7 @@ export const usePassRecordsStore = defineStore('pass-records', () => { if (result.code == 500) { reject("Network Error") } else { - console.log(result) + // console.log(result) const resultGroups = ['passRecords8', 'passRecords9'] for (let groupName of resultGroups) { for (let item of result.data[groupName]) { @@ -100,7 +100,7 @@ export const usePassRecordsStore = defineStore('pass-records', () => { passRecords.value = items.sort((a, b) => a.recognizedTime.localeCompare(b.recognizedTime)).reverse(); // console.log(passRecords.value) generatePassRecordsGroupList(passRecords.value) - console.log(groupedPassRecords.value) + // console.log(groupedPassRecords.value) resolve(groupedPassRecords.value) } }).catch(e => {