| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="book-audit" @click="playGlobalSound">
- <view class="bg-white flex flex-a-c" style="padding: 20rpx; border-radius: 10rpx">
- <image :src="detail.cover" mode="aspectFill" style="width: 80px; height: 100px"></image>
- <view class="flex flex-d flex-1 ml-20">
- <text class="common-title mb-20">{{ detail.bookName }}</text>
- <text class="text-sm"
- >ISBN: <text class="color-primary">{{ detail.isbn }}</text>
- </text>
- <text class="text-sm mt-6"
- >作者: <text>{{ detail.author }}</text>
- </text>
- <text class="text-sm mt-6"
- >出版社: <text>{{ detail.publish }}</text>
- </text>
- </view>
- </view>
- <view class="mt-20 bg-white price-info" style="border-radius: 10rpx">
- <view class="flex">
- <view class="flex flex-a-c flex-1">
- <text class="label">定价</text>
- <text class="content">¥{{ detail.price }}</text>
- </view>
- <view class="flex flex-a-c flex-1">
- <text class="label">回收折扣</text>
- <text class="content">{{ detail.recycleDiscount }}折</text>
- </view>
- </view>
- <view class="flex flex-a-c">
- <view class="flex flex-a-c flex-1">
- <text class="label">预估金额</text>
- <text class="content">¥{{ auditBook.expectMoney }}</text>
- </view>
- <view class="flex flex-a-c flex-1">
- <text class="label">审核金额</text>
- <text class="content">¥{{ auditBook.finalMoney || 0 }}</text>
- </view>
- </view>
- </view>
- <view class="mt-20">
- <u-subsection
- :list="list"
- mode="subsection"
- :current="current"
- @change="handleSectionChange"
- ></u-subsection>
- <AuditInfo
- v-show="current == 0"
- :detail="auditBook"
- :auditList="auditBook.auditCommentList"
- ref="auditInfoRef"
- />
- <FileInfo v-show="current == 2" :orderId="orderId" :annexType="2" :isbn="isbnScan" />
- </view>
- <view class="fixed-bottom">
- <u-button type="warning" size="large" @click="handleScanCode">扫码</u-button>
- <u-button type="primary" size="large" @click="handleAudit">确定</u-button>
- </view>
- </view>
- </template>
- <script setup>
- import { ref, nextTick } from "vue";
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import AuditInfo from "./components/AuditInfo.vue";
- import FileInfo from "./components/FileInfo.vue";
- const detail = ref({});
- function playGlobalSound(){
- uni.$u.playClickSound()
- }
- // 获取图书详情 /app/book/getSimpleBookInfoByIsbn/{isbn}
- const getBookInfo = (isbn) => {
- uni.$u.http.get(`/app/book/getBookByIsbn/${isbn}`).then((res) => {
- if (res.code == 200) {
- detail.value = res.data;
- }
- });
- };
- //获取图书信息和审核信息
- const auditBook = ref({});
- const getBookInfoAndAuditInfo = (isbn, orderId) => {
- uni.$u.http.get(`/app/orderinfo/getBookCheckInfo?isbn=${isbn}&&orderId=${orderId}`).then((res) => {
- if (res.code == 200) {
- auditBook.value = res.data;
- nextTick(() => {
- auditInfoRef.value?.initAuditList(auditBook.value);
- });
- }
- });
- };
- const list = ref(["图书审核", "绑码", "附件信息"]);
- const current = ref(0);
- const handleSectionChange = (index) => {
- current.value = index;
- };
- //图书审核
- const auditData = ref([]);
- const handleAuditSelected = (data) => {
- auditData.value = data.map((item, index) => {
- item.idx = index;
- item.com = Array.isArray(item.com) ? item.com.join(",") : item.com;
- return item;
- });
- };
- //存储已经扫码的图书
- const scannedBooks = ref([]);
- //isbn正则校验是否符合
- function checkIsbn(isbn) {
- const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
- if (isbn13Regex.test(isbn)) {
- return true;
- }
- return false;
- }
- //扫码之后的逻辑
- function handleScan(isbn) {
- if (!checkIsbn(isbn)) {
- let text = `不是正确的ISBN码`;
- uni.$u.ttsModule.speak(text);
- return;
- }
- let isbns = orderDetail.value.detailVoList.map((item) => item.isbn);
- if (isbns.includes(isbn)) {
- let book = orderDetail.value.detailVoList.find((item) => item.isbn == isbn);
- if (book.auditCommentList?.length > 0) {
- let noAuditNum = book.auditCommentList.filter((item) => item.sts == 0).length;
- console.log(noAuditNum, 'noAuditNum')
- if (noAuditNum == 0) {
- let text = `${isbn}已超出订单中的数量`;
- uni.$u.ttsModule.speak(text);
- return;
- }
- //扫描到套装书
- if (book.suit == 1) {
- let text = `${isbn}请注意套装书是否齐全`;
- uni.$u.ttsModule.speak(text);
- }
- //扫描到需要取出的书
- if (book.bookWarn == 1) {
- let text = `请注意${isbn}需要取出`;
- uni.$u.ttsModule.speak(text);
- }
- scannedBooks.value.push(isbn);
- uni.setStorageSync("scannedBooks", scannedBooks.value);
- uni.navigateTo({
- url: `/pages/index/detail/batch-audit?orderId=${orderId.value}`,
- });
- }
- } else {
- let text = `此订单中不存在${isbn}这本书 `;
- uni.$u.ttsModule.speak(text);
- }
- }
- //扫码
- function handleScanCode() {
- uni.scanCode({
- success: (res) => {
- handleScan(res.result);
- },
- });
- }
- const auditInfoRef = ref();
- //审核 /app/orderinfo/checkOrder
- const handleAudit = () => {
- let checkList = auditInfoRef.value?.formatReason(auditData.value);
- let checkUserInfo = uni.getStorageSync("checkUserInfo");
- if (checkUserInfo.userId) {
- checkUserId.value = checkUserInfo.userId;
- } else {
- uni.$u.toast("请先选择审核人");
- }
- //审核极差的必须选择原因
- let poorList = checkList.filter((item) => item.sts == 3);
- if (poorList.length > 0 && !poorList.every((item) => item.com)) {
- uni.$u.ttsModule.speak("请选择品相");
- return;
- }
- uni.$u.http
- .post("/app/orderinfo/checkOrder", {
- checkUserId: checkUserId.value,
- orderId: orderId.value,
- checkList: checkList,
- })
- .then((res) => {
- if (res.code == 200) {
- uni.showToast({ title: "审核成功", icon: "none" });
- uni.$u.ttsModule.speak("审核成功");
- uni.navigateBack();
- } else {
- uni.$u.toast(res.msg);
- }
- });
- };
- const checkUserId = ref();
- const orderId = ref();
- const orderDetail = ref({});
- let isbnScan = ref("");
- onLoad((options) => {
- options.isbn && getBookInfo(options.isbn);
- scannedBooks.value = [options.isbn];
- isbnScan.value = options.isbn;
- orderId.value = options.orderId;
- getBookInfoAndAuditInfo(options.isbn, options.orderId);
- orderDetail.value = uni.getStorageSync("orderDetail");
- // #ifdef APP-PLUS
- uni.$u.useGlobalEvent((e) => {
- if (e.barcode) {
- handleScan(e.barcode);
- }
- });
- // #endif
- });
- onShow(() => {
- if (isbnScan.value) {
- checkUserId.value = uni.getStorageSync("userInfo")?.userId;
- orderDetail.value = uni.getStorageSync("orderDetail");
- }
- uni.$u.updateActivePageOnShow();
- });
- </script>
- <style lang="scss" scoped>
- .book-audit {
- padding: 20rpx;
- box-sizing: border-box;
- padding-bottom: 140rpx;
- .price-info {
- border-radius: 10rpx;
- .label {
- width: 150rpx;
- background-color: #cecece;
- padding: 16rpx 10rpx;
- text-align: center;
- border: 1rpx solid #e6e6e6;
- }
- .content {
- flex: 1;
- text-align: center;
- padding: 16rpx 10rpx;
- border: 1rpx solid #e6e6e6;
- }
- }
- }
- </style>
|