book-audit.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 } 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. //图书审核
  96. const auditData = ref([]);
  97. const handleAuditSelected = (data) => {
  98. auditData.value = data.map((item, index) => {
  99. item.idx = index;
  100. item.com = Array.isArray(item.com) ? item.com.join(",") : item.com;
  101. return item;
  102. });
  103. };
  104. //存储已经扫码的图书
  105. const scannedBooks = ref([]);
  106. //isbn正则校验是否符合
  107. function checkIsbn(isbn) {
  108. const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
  109. if (isbn13Regex.test(isbn)) {
  110. return true;
  111. }
  112. return false;
  113. }
  114. //扫码之后的逻辑
  115. function handleScan(isbn) {
  116. if (!checkIsbn(isbn)) {
  117. let text = `不是正确的ISBN码`;
  118. uni.$u.ttsModule.speak(text);
  119. return;
  120. }
  121. let isbns = orderDetail.value.detailVoList.map((item) => item.isbn);
  122. if (isbns.includes(isbn)) {
  123. let book = orderDetail.value.detailVoList.find((item) => item.isbn == isbn);
  124. if (book.auditCommentList?.length > 0) {
  125. let noAuditNum = book.auditCommentList.filter((item) => item.sts == 0).length;
  126. console.log(noAuditNum, 'noAuditNum')
  127. if (noAuditNum == 0) {
  128. let text = `${isbn}已超出订单中的数量`;
  129. uni.$u.ttsModule.speak(text);
  130. return;
  131. }
  132. //扫描到套装书
  133. if (book.suit == 1) {
  134. let text = `${isbn}请注意套装书是否齐全`;
  135. uni.$u.ttsModule.speak(text);
  136. }
  137. //扫描到需要取出的书
  138. if (book.bookWarn == 1) {
  139. let text = `请注意${isbn}需要取出`;
  140. uni.$u.ttsModule.speak(text);
  141. }
  142. scannedBooks.value.push(isbn);
  143. uni.setStorageSync("scannedBooks", scannedBooks.value);
  144. uni.navigateTo({
  145. url: `/pages/index/detail/batch-audit?orderId=${orderId.value}`,
  146. });
  147. }
  148. } else {
  149. let text = `此订单中不存在${isbn}这本书 `;
  150. uni.$u.ttsModule.speak(text);
  151. }
  152. }
  153. //扫码
  154. function handleScanCode() {
  155. uni.scanCode({
  156. success: (res) => {
  157. handleScan(res.result);
  158. },
  159. });
  160. }
  161. const auditInfoRef = ref();
  162. //审核 /app/orderinfo/checkOrder
  163. const handleAudit = () => {
  164. let checkList = auditInfoRef.value?.formatReason(auditData.value);
  165. let checkUserInfo = uni.getStorageSync("checkUserInfo");
  166. if (checkUserInfo.userId) {
  167. checkUserId.value = checkUserInfo.userId;
  168. } else {
  169. uni.$u.toast("请先选择审核人");
  170. }
  171. //审核极差的必须选择原因
  172. let poorList = checkList.filter((item) => item.sts == 3);
  173. if (poorList.length > 0 && !poorList.every((item) => item.com)) {
  174. uni.$u.ttsModule.speak("请选择品相");
  175. return;
  176. }
  177. uni.$u.http
  178. .post("/app/orderinfo/checkOrder", {
  179. checkUserId: checkUserId.value,
  180. orderId: orderId.value,
  181. checkList: checkList,
  182. })
  183. .then((res) => {
  184. if (res.code == 200) {
  185. uni.showToast({ title: "审核成功", icon: "none" });
  186. uni.$u.ttsModule.speak("审核成功");
  187. uni.navigateBack();
  188. } else {
  189. uni.$u.toast(res.msg);
  190. }
  191. });
  192. };
  193. const checkUserId = ref();
  194. const orderId = ref();
  195. const orderDetail = ref({});
  196. let isbnScan = ref("");
  197. onLoad((options) => {
  198. options.isbn && getBookInfo(options.isbn);
  199. scannedBooks.value = [options.isbn];
  200. isbnScan.value = options.isbn;
  201. orderId.value = options.orderId;
  202. getBookInfoAndAuditInfo(options.isbn, options.orderId);
  203. orderDetail.value = uni.getStorageSync("orderDetail");
  204. // #ifdef APP-PLUS
  205. uni.$u.useGlobalEvent((e) => {
  206. if (e.barcode) {
  207. handleScan(e.barcode);
  208. }
  209. });
  210. // #endif
  211. });
  212. onShow(() => {
  213. if (isbnScan.value) {
  214. checkUserId.value = uni.getStorageSync("userInfo")?.userId;
  215. orderDetail.value = uni.getStorageSync("orderDetail");
  216. }
  217. uni.$u.updateActivePageOnShow();
  218. });
  219. </script>
  220. <style lang="scss" scoped>
  221. .book-audit {
  222. padding: 20rpx;
  223. box-sizing: border-box;
  224. padding-bottom: 140rpx;
  225. .price-info {
  226. border-radius: 10rpx;
  227. .label {
  228. width: 150rpx;
  229. background-color: #cecece;
  230. padding: 16rpx 10rpx;
  231. text-align: center;
  232. border: 1rpx solid #e6e6e6;
  233. }
  234. .content {
  235. flex: 1;
  236. text-align: center;
  237. padding: 16rpx 10rpx;
  238. border: 1rpx solid #e6e6e6;
  239. }
  240. }
  241. }
  242. </style>