book-audit.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="book-audit">
  3. <view class="bg-white flex flex-a-c" style="padding: 20rpx; border-radius: 10rpx">
  4. <image :src="detail.cover" mode="aspectFill" style="width: 80px; height: 100px"></image>
  5. <view class="flex flex-d flex-1 ml-20">
  6. <text class="common-title mb-20">{{ detail.bookName }}</text>
  7. <text class="text-sm"
  8. >ISBN: <text class="color-primary">{{ detail.isbn }}</text>
  9. </text>
  10. <text class="text-sm mt-6"
  11. >作者: <text>{{ detail.author }}</text>
  12. </text>
  13. <text class="text-sm mt-6"
  14. >出版社: <text>{{ detail.publish }}</text>
  15. </text>
  16. </view>
  17. </view>
  18. <view class="mt-20 bg-white price-info" style="border-radius: 10rpx">
  19. <view class="flex">
  20. <view class="flex flex-a-c flex-1">
  21. <text class="label">定价</text>
  22. <text class="content">¥{{ detail.price }}</text>
  23. </view>
  24. <view class="flex flex-a-c flex-1">
  25. <text class="label">回收折扣</text>
  26. <text class="content">{{ detail.recycleDiscount }}折</text>
  27. </view>
  28. </view>
  29. <view class="flex flex-a-c">
  30. <view class="flex flex-a-c flex-1">
  31. <text class="label">预估金额</text>
  32. <text class="content">¥{{ auditBook.expectMoney }}</text>
  33. </view>
  34. <view class="flex flex-a-c flex-1">
  35. <text class="label">审核金额</text>
  36. <text class="content">¥{{ auditBook.finalMoney || 0 }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="mt-20">
  41. <u-subsection
  42. :list="list"
  43. mode="subsection"
  44. :current="current"
  45. @change="handleSectionChange"
  46. ></u-subsection>
  47. <AuditInfo
  48. v-show="current == 0"
  49. :detail="auditBook"
  50. :auditList="auditBook.auditCommentList"
  51. ref="auditInfoRef"
  52. />
  53. <FileInfo v-show="current == 2" :orderId="orderId" :annexType="2" :isbn="isbnScan" />
  54. </view>
  55. <view class="fixed-bottom">
  56. <u-button type="warning" size="large" @click="handleScanCode">扫码</u-button>
  57. <u-button type="primary" size="large" @click="handleAudit">确定</u-button>
  58. </view>
  59. </view>
  60. </template>
  61. <script setup>
  62. import { ref, nextTick } from "vue";
  63. import { onLoad, onShow } from "@dcloudio/uni-app";
  64. import AuditInfo from "./components/AuditInfo.vue";
  65. import FileInfo from "./components/FileInfo.vue";
  66. const detail = ref({});
  67. // 获取图书详情 /app/book/getSimpleBookInfoByIsbn/{isbn}
  68. const getBookInfo = (isbn) => {
  69. uni.$u.http.get(`/app/book/getBookByIsbn/${isbn}`).then((res) => {
  70. if (res.code == 200) {
  71. detail.value = res.data;
  72. }
  73. });
  74. };
  75. //获取图书信息和审核信息
  76. const auditBook = ref({});
  77. const getBookInfoAndAuditInfo = (isbn, orderId) => {
  78. uni.$u.http.get(`/app/orderinfo/getBookCheckInfo?isbn=${isbn}&&orderId=${orderId}`).then((res) => {
  79. if (res.code == 200) {
  80. auditBook.value = res.data;
  81. nextTick(() => {
  82. auditInfoRef.value?.initAuditList(auditBook.value);
  83. });
  84. }
  85. });
  86. };
  87. const list = ref(["图书审核", "绑码", "附件信息"]);
  88. const current = ref(0);
  89. const handleSectionChange = (index) => {
  90. current.value = index;
  91. };
  92. //图书审核
  93. const auditData = ref([]);
  94. const handleAuditSelected = (data) => {
  95. auditData.value = data.map((item, index) => {
  96. item.idx = index;
  97. item.com = Array.isArray(item.com) ? item.com.join(",") : item.com;
  98. return item;
  99. });
  100. };
  101. //存储已经扫码的图书
  102. const scannedBooks = ref([]);
  103. //isbn正则校验是否符合
  104. function checkIsbn(isbn) {
  105. const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
  106. if (isbn13Regex.test(isbn)) {
  107. return true;
  108. }
  109. return false;
  110. }
  111. //扫码之后的逻辑
  112. function handleScan(isbn) {
  113. if (!checkIsbn(isbn)) {
  114. let text = `不是正确的ISBN码`;
  115. uni.$u.ttsModule.speak(text);
  116. return;
  117. }
  118. let isbns = orderDetail.value.detailVoList.map((item) => item.isbn);
  119. if (isbns.includes(isbn)) {
  120. let book = orderDetail.value.detailVoList.find((item) => item.isbn == isbn);
  121. if (book.auditCommentList?.length > 0) {
  122. let noAuditNum = book.auditCommentList.filter((item) => item.sts == 0).length;
  123. console.log(noAuditNum, 'noAuditNum')
  124. if (noAuditNum == 0) {
  125. let text = `${isbn}已超出订单中的数量`;
  126. uni.$u.ttsModule.speak(text);
  127. return;
  128. }
  129. //扫描到套装书
  130. if (book.suit == 1) {
  131. let text = `${isbn}请注意套装书是否齐全`;
  132. uni.$u.ttsModule.speak(text);
  133. }
  134. //扫描到需要取出的书
  135. if (book.bookWarn == 1) {
  136. let text = `请注意${isbn}需要取出`;
  137. uni.$u.ttsModule.speak(text);
  138. }
  139. scannedBooks.value.push(isbn);
  140. uni.setStorageSync("scannedBooks", scannedBooks.value);
  141. uni.navigateTo({
  142. url: `/pages/index/detail/batch-audit?orderId=${orderId.value}`,
  143. });
  144. }
  145. } else {
  146. let text = `此订单中不存在${isbn}这本书 `;
  147. uni.$u.ttsModule.speak(text);
  148. }
  149. }
  150. //扫码
  151. function handleScanCode() {
  152. uni.scanCode({
  153. success: (res) => {
  154. handleScan(res.result);
  155. },
  156. });
  157. }
  158. const auditInfoRef = ref();
  159. //审核 /app/orderinfo/checkOrder
  160. const handleAudit = () => {
  161. let checkList = auditInfoRef.value?.formatReason(auditData.value);
  162. let checkUserInfo = uni.getStorageSync("checkUserInfo");
  163. if (checkUserInfo.userId) {
  164. checkUserId.value = checkUserInfo.userId;
  165. } else {
  166. uni.$u.toast("请先选择审核人");
  167. }
  168. //审核极差的必须选择原因
  169. let poorList = checkList.filter((item) => item.sts == 3);
  170. if (poorList.length > 0 && !poorList.every((item) => item.com)) {
  171. uni.$u.ttsModule.speak("请选择品相");
  172. return;
  173. }
  174. uni.$u.http
  175. .post("/app/orderinfo/checkOrder", {
  176. checkUserId: checkUserId.value,
  177. orderId: orderId.value,
  178. checkList: checkList,
  179. })
  180. .then((res) => {
  181. if (res.code == 200) {
  182. uni.showToast({ title: "审核成功", icon: "none" });
  183. uni.$u.ttsModule.speak("审核成功");
  184. uni.navigateBack();
  185. } else {
  186. uni.$u.toast(res.msg);
  187. }
  188. });
  189. };
  190. const checkUserId = ref();
  191. const orderId = ref();
  192. const orderDetail = ref({});
  193. let isbnScan = ref("");
  194. onLoad((options) => {
  195. options.isbn && getBookInfo(options.isbn);
  196. scannedBooks.value = [options.isbn];
  197. isbnScan.value = options.isbn;
  198. orderId.value = options.orderId;
  199. getBookInfoAndAuditInfo(options.isbn, options.orderId);
  200. orderDetail.value = uni.getStorageSync("orderDetail");
  201. // #ifdef APP-PLUS
  202. uni.$u.useGlobalEvent((e) => {
  203. if (e.barcode) {
  204. handleScan(e.barcode);
  205. }
  206. });
  207. // #endif
  208. });
  209. onShow(() => {
  210. if (isbnScan.value) {
  211. checkUserId.value = uni.getStorageSync("userInfo")?.userId;
  212. orderDetail.value = uni.getStorageSync("orderDetail");
  213. }
  214. uni.$u.updateActivePageOnShow();
  215. });
  216. </script>
  217. <style lang="scss" scoped>
  218. .book-audit {
  219. padding: 20rpx;
  220. box-sizing: border-box;
  221. padding-bottom: 140rpx;
  222. .price-info {
  223. border-radius: 10rpx;
  224. .label {
  225. width: 150rpx;
  226. background-color: #cecece;
  227. padding: 16rpx 10rpx;
  228. text-align: center;
  229. border: 1rpx solid #e6e6e6;
  230. }
  231. .content {
  232. flex: 1;
  233. text-align: center;
  234. padding: 16rpx 10rpx;
  235. border: 1rpx solid #e6e6e6;
  236. }
  237. }
  238. }
  239. </style>