This commit is contained in:
Tsanie Lily 2023-04-28 15:06:47 +08:00
parent 58de68a878
commit 9bf9e7da27
6 changed files with 64 additions and 48 deletions

View File

@ -435,7 +435,7 @@ class CustomerCommunication {
#createContacts(container, option) { #createContacts(container, option) {
const readonly = option.readonly; const readonly = option.readonly;
const recordReadonly = option.recordReadonly; const recordReadonly = option.recordReadonly;
const contacts = createElement('div'); const contacts = createElement('div', 'bar-list-container');
container.append( container.append(
createElement('div', 'contact-bar', createElement('div', 'contact-bar',
createElement('div', 'bar-icon', createElement('div', 'bar-icon',
@ -491,7 +491,7 @@ class CustomerCommunication {
})); }));
button.addEventListener('click', () => { button.addEventListener('click', () => {
const add = new Contact({ const add = new Contact({
company: !nullOrEmpty(this.#data.companyCode), company: !nullOrEmpty(this.#data.companyName),
onSave: item => { onSave: item => {
const exists = this.#gridContact.source.some(s => s.Name === item.Name && s.MobilePhone === item.MobilePhone); const exists = this.#gridContact.source.some(s => s.Name === item.Name && s.MobilePhone === item.MobilePhone);
if (exists) { if (exists) {
@ -535,14 +535,14 @@ class CustomerCommunication {
}), }),
createElement('div', null, createElement('div', null,
createElement('div', div => { createElement('div', div => {
if (nullOrEmpty(this.#data.companyCode)) { if (nullOrEmpty(this.#data.companyName)) {
div.style.display = 'none'; div.style.display = 'none';
} }
div.style.fontWeight = 'bold'; div.style.fontWeight = 'bold';
div.innerText = r('contactFromRecord', 'Contacts from Customer Record'); div.innerText = r('contactFromRecord', 'Contacts from Customer Record');
}), }),
createElement('div', div => { createElement('div', div => {
if (nullOrEmpty(this.#data.companyCode)) { if (nullOrEmpty(this.#data.companyName)) {
div.style.display = 'none'; div.style.display = 'none';
} }
div.className = 'contacts-record'; div.className = 'contacts-record';
@ -606,7 +606,7 @@ class CustomerCommunication {
onclick: function () { onclick: function () {
const edit = new Contact({ const edit = new Contact({
contact: this, contact: this,
company: !nullOrEmpty(This.#data.companyCode), company: !nullOrEmpty(This.#data.companyName),
onSave: (item, _op) => { onSave: (item, _op) => {
const exists = const exists =
This.#gridContact.source.some(s => s !== this && s.Name === item.Name && s.MobilePhone === item.MobilePhone) || This.#gridContact.source.some(s => s !== this && s.Name === item.Name && s.MobilePhone === item.MobilePhone) ||
@ -804,7 +804,7 @@ class CustomerCommunication {
#createFollowers(container, option) { #createFollowers(container, option) {
const readonly = option.readonly; const readonly = option.readonly;
const recordReadonly = option.recordReadonly; const recordReadonly = option.recordReadonly;
const followers = createElement('div'); const followers = createElement('div', 'bar-list-container');
const buttonEditFollower = createElement('button', button => { const buttonEditFollower = createElement('button', button => {
button.className = 'roundbtn button-edit-followers'; button.className = 'roundbtn button-edit-followers';
button.style.backgroundColor = 'rgb(48, 107, 255)'; button.style.backgroundColor = 'rgb(48, 107, 255)';
@ -872,6 +872,7 @@ class CustomerCommunication {
div.className = 'followers-record'; div.className = 'followers-record';
div.style.maxHeight = '400px'; div.style.maxHeight = '400px';
div.style.width = '660px'; div.style.width = '660px';
div.style.overflow = 'auto';
}) })
) )
); );

View File

@ -148,6 +148,11 @@
flex: 1 1 auto; flex: 1 1 auto;
width: calc(100% - 46px); width: calc(100% - 46px);
.bar-list-container {
max-height: 120px;
overflow: auto;
}
.contact-item { .contact-item {
display: flex; display: flex;
align-items: center; align-items: center;
@ -381,11 +386,11 @@
} }
} }
@media (prefers-color-scheme: dark) { /*@media (prefers-color-scheme: dark) {
.comm { .comm {
--dark-fore-color: #000; --dark-fore-color: #000;
--dark-fore-opacity-color: rgba(0, 0, 0, .4); --dark-fore-opacity-color: rgba(0, 0, 0, .4);
--strong-color: #ccc; --strong-color: #ccc;
--light-color: #333; --light-color: #333;
} }
} }*/

View File

@ -515,7 +515,7 @@
} }
} }
@media (prefers-color-scheme: dark) { /*@media (prefers-color-scheme: dark) {
.ui-grid { .ui-grid {
--cell-hover-bg-color: yellow; --cell-hover-bg-color: yellow;
--header-border-color: #525456; --header-border-color: #525456;
@ -532,4 +532,4 @@
--row-selected-bg-color: #190d04; --row-selected-bg-color: #190d04;
--text-disabled-color: gray; --text-disabled-color: gray;
} }
} }*/

View File

@ -10,7 +10,7 @@
} }
:root { :root {
color-scheme: light dark; /*color-scheme: light dark;*/
--color: #201f1e; --color: #201f1e;
--bg-color: #fff; --bg-color: #fff;
@ -40,7 +40,7 @@
--font-family: "Franklin Gothic Book", "San Francisco", "Segoe UI", "Open Sans", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei UI", sans-serif; --font-family: "Franklin Gothic Book", "San Francisco", "Segoe UI", "Open Sans", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei UI", sans-serif;
} }
@media (prefers-color-scheme: dark) { /*@media (prefers-color-scheme: dark) {
:root { :root {
--color: rgb(255 255 255/87%); --color: rgb(255 255 255/87%);
--bg-color: #141414; --bg-color: #141414;
@ -60,4 +60,4 @@
--loading-bg-color: rgb(20 20 20/40%); --loading-bg-color: rgb(20 20 20/40%);
--loading-fore-color: rgb(255 255 255/20%); --loading-fore-color: rgb(255 255 255/20%);
} }
} }*/

View File

@ -296,7 +296,7 @@ class Grid {
let height = this.height; let height = this.height;
if (height === 0) { if (height === 0) {
height = this.#containerHeight; height = this.#containerHeight ??= this.containerHeight;
} else if (isNaN(height) || height < 0) { } else if (isNaN(height) || height < 0) {
height = this.#el.offsetHeight - top; height = this.#el.offsetHeight - top;
} }
@ -308,12 +308,16 @@ class Grid {
this.#bodyClientWidth = body.clientWidth; this.#bodyClientWidth = body.clientWidth;
} }
reload() { get containerHeight() {
let length = this.#currentSource.length; let length = this.#currentSource.length;
if (this.extraRows > 0) { if (this.extraRows > 0) {
length += this.extraRows; length += this.extraRows;
} }
this.#containerHeight = length * (this.rowHeight + 1); return length * (this.rowHeight + 1);
}
reload() {
this.#containerHeight = this.containerHeight;
this.#refs.body.scrollTop = 0; this.#refs.body.scrollTop = 0;
this.#refs.body.scrollLeft = 0; this.#refs.body.scrollLeft = 0;
this.#refs.bodyContent.style.top = '0px'; this.#refs.bodyContent.style.top = '0px';
@ -634,7 +638,7 @@ class Grid {
} }
} }
if (Grid.ColumnTypes.isCheckbox(col.type)) { if (Grid.ColumnTypes.isCheckbox(col.type)) {
cell.appendChild(GridCheckboxColumn.createEdit(e => this.#onRowChanged(e, exists + i, col, e.target.checked))); cell.appendChild(GridCheckboxColumn.createEdit(e => this.#onRowChanged(e, index, col, e.target.checked)));
// this.#colTypes[col.key] = GridCheckboxColumn; // this.#colTypes[col.key] = GridCheckboxColumn;
} else { } else {
let type = this.#colTypes[col.key]; let type = this.#colTypes[col.key];
@ -1532,7 +1536,7 @@ class Grid {
if (this.#currentSource == null) { if (this.#currentSource == null) {
return; return;
} }
const row = this.#currentSource[this.#startIndex + index]; const row = this.#currentSource[index];
const item = row.values; const item = row.values;
if (item == null) { if (item == null) {
return; return;

View File

@ -44,7 +44,13 @@ function isEmail(text) {
} }
function isPhone(text) { function isPhone(text) {
return /^[1-9]\d{9,}$/.test(text); if (/^[1-9]\d{9,}$/.test(text)) {
return true;
}
if (/^\+?[1-9][\d-]{9,}\d$/.test(text) && /^[1-9]\d{9,}$/.test(text.replace('+', '').replace(new RegExp('-', 'g'), ''))) {
return true;
}
return false;
} }
export { export {