book-audit.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="book-audit" @click="playGlobalSound">
  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, onUnmounted } 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. function playGlobalSound(){
  68. uni.$u.playClickSound()
  69. }
  70. // 获取图书详情 /app/book/getSimpleBookInfoByIsbn/{isbn}
  71. const getBookInfo = (isbn) => {
  72. uni.$u.http.get(`/app/book/getBookByIsbn/${isbn}`).then((res) => {
  73. if (res.code == 200) {
  74. detail.value = res.data;
  75. }
  76. });
  77. };
  78. //获取图书信息和审核信息
  79. const auditBook = ref({});
  80. const getBookInfoAndAuditInfo = (isbn, orderId) => {
  81. uni.$u.http.get(`/app/orderinfo/getBookCheckInfo?isbn=${isbn}&&orderId=${orderId}`).then((res) => {
  82. if (res.code == 200) {
  83. auditBook.value = res.data;
  84. nextTick(() => {
  85. auditInfoRef.value?.initAuditList(auditBook.value);
  86. });
  87. }
  88. });
  89. };
  90. const list = ref(["图书审核", "绑码", "附件信息"]);
  91. const current = ref(0);
  92. const handleSectionChange = (index) => {
  93. current.value = index;
  94. };
  95. //isbn正则校验是否符合
  96. function checkIsbn(isbn) {
  97. const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
  98. if (isbn13Regex.test(isbn)) {
  99. return true;
  100. }
  101. return false;
  102. }
  103. //扫码之后的逻辑
  104. function handleScan(isbn) {
  105. if (!checkIsbn(isbn)) {
  106. let text = `不是正确的ISBN码`;
  107. uni.$u.ttsModule.speak(text);
  108. return;
  109. }
  110. //取 isbn 的后四位字符串进行播报
  111. let isbnStr = `${isbn.slice(-4)}`;
  112. let isbns = orderDetail.value.detailVoList.map((item) => item.isbn);
  113. if (isbns.includes(isbn)) {
  114. let book = orderDetail.value.detailVoList.find((item) => item.isbn == isbn);
  115. if (book.auditCommentList?.length > 0) {
  116. let noAuditNum = book.auditCommentList.filter((item) => item.sts == 0).length;
  117. console.log(noAuditNum, 'noAuditNum')
  118. if (noAuditNum == 0) {
  119. let text = `${isbnStr}已超出订单中的数量`;
  120. uni.$u.ttsModule.speak(text);
  121. return;
  122. }
  123. //扫描到套装书
  124. if (book.suit == 1) {
  125. let text = `${isbnStr}请注意套装书是否齐全`;
  126. uni.$u.ttsModule.speak(text);
  127. }
  128. //扫描到需要取出的书
  129. if (book.bookWarn == 1) {
  130. let text = `请注意${isbnStr}需要取出`;
  131. uni.$u.ttsModule.speak(text);
  132. }
  133. uni.navigateTo({
  134. url: `/pages/index/detail/batch-audit?orderId=${orderId.value}&isbn=${isbn}&&isbn2=${isbnScan.value}`,
  135. });
  136. }
  137. } else {
  138. let text = `此订单中不存在${isbnStr}这本书 `;
  139. uni.$u.ttsModule.speak(text);
  140. }
  141. }
  142. //扫码
  143. function handleScanCode() {
  144. uni.scanCode({
  145. success: (res) => {
  146. handleScan(res.result);
  147. },
  148. });
  149. }
  150. const auditInfoRef = ref();
  151. //审核 /app/orderinfo/checkOrder
  152. const handleAudit = () => {
  153. let checkList = auditInfoRef.value?.formatReason();
  154. let checkUserInfo = uni.getStorageSync("checkUserInfo");
  155. if (checkUserInfo.userId) {
  156. checkUserId.value = checkUserInfo.userId;
  157. } else {
  158. uni.$u.toast("请先选择审核人");
  159. }
  160. //审核极差的必须选择原因
  161. let poorList = checkList.filter((item) => item.sts == 3);
  162. if (poorList.length > 0 && !poorList.every((item) => item.com)) {
  163. uni.$u.ttsModule.speak("请选择品相");
  164. return;
  165. }
  166. uni.$u.http
  167. .post("/app/orderinfo/checkOrder", {
  168. checkUserId: checkUserId.value,
  169. orderId: orderId.value,
  170. checkList: checkList,
  171. })
  172. .then((res) => {
  173. if (res.code == 200) {
  174. uni.showToast({ title: "审核成功", icon: "none" });
  175. uni.$u.ttsModule.speak("审核成功");
  176. uni.navigateBack();
  177. } else {
  178. uni.$u.toast(res.msg);
  179. }
  180. });
  181. };
  182. const checkUserId = ref();
  183. const orderId = ref();
  184. const orderDetail = ref({});
  185. let isbnScan = ref("");
  186. onLoad((options) => {
  187. options.isbn && getBookInfo(options.isbn);
  188. isbnScan.value = options.isbn;
  189. orderId.value = options.orderId;
  190. getBookInfoAndAuditInfo(options.isbn, options.orderId);
  191. orderDetail.value = uni.getStorageSync("orderDetail");
  192. });
  193. // #ifdef APP-PLUS
  194. const { unregister, register } = uni.$u.useEventListener((e) => {
  195. handleScan(e.barcode);
  196. },true);
  197. // #endif
  198. onShow(() => {
  199. register();
  200. if (isbnScan.value) {
  201. checkUserId.value = uni.getStorageSync("userInfo")?.userId;
  202. orderDetail.value = uni.getStorageSync("orderDetail");
  203. }
  204. });
  205. onUnmounted(() => {
  206. // #ifdef APP-PLUS
  207. unregister();
  208. // #endif
  209. });
  210. </script>
  211. <style lang="scss" scoped>
  212. .book-audit {
  213. padding: 20rpx;
  214. box-sizing: border-box;
  215. padding-bottom: 140rpx;
  216. .price-info {
  217. border-radius: 10rpx;
  218. .label {
  219. width: 150rpx;
  220. background-color: #cecece;
  221. padding: 16rpx 10rpx;
  222. text-align: center;
  223. border: 1rpx solid #e6e6e6;
  224. }
  225. .content {
  226. flex: 1;
  227. text-align: center;
  228. padding: 16rpx 10rpx;
  229. border: 1rpx solid #e6e6e6;
  230. }
  231. }
  232. }
  233. </style>