|
|
@@ -50,7 +50,7 @@ function handleBookClick(book) {
|
|
|
// return;
|
|
|
// }
|
|
|
uni.navigateTo({
|
|
|
- url: `/pages/index/detail/review-book?isbn=${book.isbn}&orderId=${props.detail.orderId}&auditReviewId=${book.auditReviewComment.auditReviewId}&&index=${book.auditReviewComment.index}`,
|
|
|
+ url: `/pages/index/detail/review-book?isbn=${book.isbn}&orderId=${props.detail.orderId}&auditReviewId=${book.auditReviewComment?.auditReviewId || ''}&index=${book.auditReviewComment?.index ?? ''}`,
|
|
|
});
|
|
|
uni.setStorageSync("auditBook", book);
|
|
|
}
|
|
|
@@ -63,62 +63,70 @@ function getAuditCateNum(cate) {
|
|
|
return auditList.filter((v) => v.sts == cate).length;
|
|
|
}
|
|
|
|
|
|
+function getBookFirstLetter(bookName) {
|
|
|
+ if (!bookName) return "其他";
|
|
|
+
|
|
|
+ let firstChineseChar = null;
|
|
|
+ for (let i = 0; i < bookName.length; i++) {
|
|
|
+ const char = bookName.charAt(i);
|
|
|
+ if (/^[\u4E00-\u9FA5]$/.test(char)) {
|
|
|
+ firstChineseChar = char;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let firstLetter = "";
|
|
|
+ if (firstChineseChar) {
|
|
|
+ const pinyin = toPinyin.chineseToPinYin(firstChineseChar);
|
|
|
+ firstLetter = toPinyin.chineseToInitials(pinyin);
|
|
|
+ if (!firstLetter && pinyin) {
|
|
|
+ firstLetter = pinyin.charAt(0).toUpperCase();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const char = bookName.charAt(0);
|
|
|
+ if (/^[A-Za-z]$/.test(char)) {
|
|
|
+ firstLetter = char.toUpperCase();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!firstLetter || !/^[A-Z]$/.test(firstLetter)) {
|
|
|
+ firstLetter = "其他";
|
|
|
+ }
|
|
|
+ return firstLetter;
|
|
|
+}
|
|
|
+
|
|
|
+function isBookReviewed(book) {
|
|
|
+ const sts = book.auditReviewComment?.sts;
|
|
|
+ return sts != null && sts !== 0 && sts !== "0";
|
|
|
+}
|
|
|
+
|
|
|
+function getReviewSts(book) {
|
|
|
+ return Number(book.auditReviewComment?.sts);
|
|
|
+}
|
|
|
+
|
|
|
//格式化书籍列表
|
|
|
const formatBookList = (list) => {
|
|
|
const poorBooks = { title: "极差", list: [], backgroundColor: "#de868f", id: "poor" };
|
|
|
const goodBooks = { title: "良好", list: [], backgroundColor: "#81b337", id: "good" };
|
|
|
const otherBooks = [];
|
|
|
- //获取所有的首字母
|
|
|
- const allFirstLetter = [];
|
|
|
|
|
|
const handleBookCategorization = (book) => {
|
|
|
- let firstLetter;
|
|
|
- // 找到第一个中文
|
|
|
- let firstChineseChar = null;
|
|
|
- for (let i = 0; i < book.bookName.length; i++) {
|
|
|
- const char = book.bookName.charAt(i);
|
|
|
- if (/^[\u4E00-\u9FA5]$/.test(char)) {
|
|
|
- // 检查是否为中文
|
|
|
- firstChineseChar = char;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 如果找到中文,使用其拼音首字母
|
|
|
- if (firstChineseChar) {
|
|
|
- firstLetter = toPinyin.chineseToInitials(toPinyin.chineseToPinYin(firstChineseChar));
|
|
|
- } else {
|
|
|
- // 如果没有找到中文,使用第一个字符
|
|
|
- const char = book.bookName.charAt(0);
|
|
|
- if (/^[A-Za-z]$/.test(char)) {
|
|
|
- firstLetter = char.toUpperCase();
|
|
|
- } else {
|
|
|
- firstLetter = char;
|
|
|
- }
|
|
|
- }
|
|
|
+ const firstLetter = getBookFirstLetter(book.bookName);
|
|
|
|
|
|
let bool = otherBooks.some((item) => item.title == firstLetter);
|
|
|
if (!bool) {
|
|
|
otherBooks.push({ id: firstLetter, title: firstLetter, list: [{ ...book }] });
|
|
|
- allFirstLetter.push(firstLetter);
|
|
|
- emit("get-all-firstLetter", allFirstLetter);
|
|
|
} else {
|
|
|
otherBooks.find((item) => item.title == firstLetter).list.push(book);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
list.forEach((book) => {
|
|
|
- book.goodNum = list?.filter((v) => v.sts == 1).length || 0;
|
|
|
- book.badNum = list?.filter((v) => v.sts == 3).length || 0;
|
|
|
-
|
|
|
- // Check if book is fully audited (all items have been reviewed)
|
|
|
- const totalAudited = list?.filter((v) => v.sts !== 0).length || 0;
|
|
|
- const isFullyAudited = totalAudited === list.length;
|
|
|
-
|
|
|
- if (isFullyAudited) {
|
|
|
- if (book.auditReviewComment?.sts === 3) {
|
|
|
+ if (isBookReviewed(book)) {
|
|
|
+ const sts = getReviewSts(book);
|
|
|
+ if (sts === 3) {
|
|
|
poorBooks.list.push(book);
|
|
|
- } else if (book.auditReviewComment?.sts === 1) {
|
|
|
+ } else if (sts === 1) {
|
|
|
goodBooks.list.push(book);
|
|
|
} else {
|
|
|
handleBookCategorization(book);
|
|
|
@@ -143,6 +151,7 @@ watch(
|
|
|
let poor = poorBooks.list.length > 0 ? poorBooks : {};
|
|
|
let good = goodBooks.list.length > 0 ? goodBooks : {};
|
|
|
formatList.value = [...otherBooks, poor, good];
|
|
|
+ emit("get-all-firstLetter", otherBooks.map((item) => item.id));
|
|
|
},
|
|
|
{ immediate: true, deep: true }
|
|
|
);
|