AuditInfo.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="audit-info">
  3. <view class="font-bold mt-16" style="padding: 0 20rpx">
  4. 该书共{{ detail.num }}本,其中:良好{{ getAuditCateNum(1) }}本,一般{{ getAuditCateNum(2) }}本,极差{{
  5. getAuditCateNum(3)
  6. }}本
  7. </view>
  8. <view v-if="auditCommentList.length > 0" v-for="(audit, index) in auditCommentList" :key="index">
  9. <view class="mt-10 bind-code" style="padding: 10rpx 20rpx"> 第{{ index + 1 }}本的审核意见 </view>
  10. <view class="mt-20 bg-white flex flex-j-a flex-a-c" style="padding: 20rpx; border-radius: 10rpx">
  11. <view class="u-page__tag-item" v-for="(item, idx) in auditList" :key="idx">
  12. <u-tag
  13. size="large"
  14. :text="item.label"
  15. :plain="audit.sts != item.sts"
  16. type="primary"
  17. :name="item.sts"
  18. :class="{ disabled: item.sts == 2 }"
  19. @click="radioClick(audit, index, item.sts)"
  20. >
  21. </u-tag>
  22. </view>
  23. </view>
  24. <view class="mt-20 bg-white" style="padding: 20rpx; border-radius: 10rpx" v-if="audit.sts == 3">
  25. <view class="flex flex-a-c flex-wrap">
  26. <view
  27. class="mr-10 reason-item"
  28. v-for="(item, idx) in reasonList"
  29. :key="idx"
  30. @click="toggleReason(audit, index, item)"
  31. :class="{ selected: audit.comList.includes(item.label) }"
  32. >
  33. {{ item.label }}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script setup>
  41. import { ref, watch, nextTick, onMounted } from "vue";
  42. const props = defineProps({
  43. detail: {
  44. type: Object,
  45. default: () => ({}),
  46. },
  47. auditList: {
  48. type: Array,
  49. default: () => [],
  50. },
  51. });
  52. const auditCommentList = ref([]);
  53. const initAuditList = (detail) => {
  54. if (!detail?.auditCommentList) return;
  55. auditCommentList.value = detail.auditCommentList.map((item, index) => ({
  56. ...item,
  57. idx: index,
  58. isbn: detail.isbn,
  59. comList: item.com ? (typeof item.com === "string" ? item.com.split(",") : item.com) : [],
  60. }));
  61. };
  62. watch(
  63. () => props.detail,
  64. () => {
  65. initAuditList(props.detail);
  66. },
  67. { deep: true, immediate: true }
  68. );
  69. const auditList = ref([
  70. { sts: 1, label: "品相良好" },
  71. { sts: 2, label: "品相一般", disabled: true },
  72. { sts: 3, label: "品相极差" },
  73. ]);
  74. const emit = defineEmits(["selected"]);
  75. const radioClick = (audit, index, sts) => {
  76. if (sts == 2) return;
  77. audit.sts = sts;
  78. if (sts == 1) {
  79. audit.comList = [];
  80. }
  81. auditCommentList.value[index] = audit;
  82. formatReason();
  83. };
  84. const getAuditCateNum = (cate) => {
  85. return props.detail.auditCommentList?.filter((item) => item.sts == cate)?.length || 0;
  86. };
  87. let reasonList = ref([
  88. { sts: 3, label: "明显泛黄水印/发霉/明显异味" },
  89. { sts: 3, label: "老化泛黄褪色/污渍" },
  90. { sts: 3, label: "明显破损/脱胶缺页/书籍变型" },
  91. { sts: 3, label: "无此书" },
  92. { sts: 3, label: "印刷不清晰" },
  93. { sts: 3, label: "无防伪" },
  94. { sts: 3, label: "无外护封/无ISBN" },
  95. { sts: 3, label: "无此书多其他书" },
  96. { sts: 3, label: "笔记杂乱/习题做完" },
  97. { sts: 3, label: "有笔记贴" },
  98. { sts: 3, label: "套装缺册" },
  99. { sts: 3, label: "听力无光盘" },
  100. { sts: 3, label: "图书馆/藏书印章" },
  101. ]);
  102. const formatReason = () => {
  103. let list = auditCommentList.value.map((item, index) => ({
  104. ...item,
  105. idx: index,
  106. com: item.comList.join(","),
  107. }));
  108. return list;
  109. };
  110. const toggleReason = (audit, index, item) => {
  111. const idx = audit.comList.indexOf(item.label);
  112. if (idx > -1) {
  113. audit.comList.splice(idx, 1);
  114. } else {
  115. audit.comList.push(item.label);
  116. }
  117. auditCommentList.value[index] = audit;
  118. };
  119. defineExpose({
  120. formatReason,
  121. initAuditList,
  122. });
  123. </script>
  124. <style lang="scss" scoped>
  125. .bind-code {
  126. background-color: #cecece;
  127. border-radius: 4rpx;
  128. }
  129. .reason-item {
  130. background-color: #f0f0f0;
  131. border-radius: 4rpx;
  132. padding: 14rpx 20rpx;
  133. margin-bottom: 16rpx;
  134. }
  135. .selected {
  136. background-color: #d0e8ff;
  137. }
  138. .disabled {
  139. background-color: #d0d0d0;
  140. }
  141. </style>