order-book-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <ele-data-table row-key="userId" :columns="columns" :data="dataList" border class="order-books"
  3. :span-method="handleSpanMethod">
  4. <template #baseInfo="{ row }">
  5. <div class="base-info flex justify-between">
  6. <div class="base-info-left flex flex-1">
  7. <el-image style="width: 80px; height: 100px" fit="cover" :src="row.cover" />
  8. <div class="base-info-left-con flex flex-col items-start ml-3">
  9. <div><el-text type="primary">{{ row.bookName }}</el-text></div>
  10. <div><el-text>ISBN:{{ row.isbn }}</el-text></div>
  11. <div class="base-info-btns flex">
  12. <el-button size="small" color="#4f4f4f" v-if="row.bookStatus != 3"
  13. @click="handleBlackList([row.isbn])">加入黑名单</el-button>
  14. <el-button size="small" color="#4f4f4f" v-if="row.bookStatus == 3">已在黑名单</el-button>
  15. <el-button size="small" type="success" v-if="row.bookStatus == 1"
  16. @click="handleAddBookList(row)">加入回收书单</el-button>
  17. <el-button size="small" color="#2d430a" v-if="row.bookStatus == 2">已在回收书单</el-button>
  18. <el-button size="small" type="warning" v-if="row.settingStatus == 0"
  19. @click="handleSpecifiedDiscount(row)">指定回收折扣</el-button>
  20. <el-button size="small" color="#7728f5" v-if="row.settingStatus == 1"
  21. @click="handleModifyDiscount(row)">修改回收折扣</el-button>
  22. </div>
  23. <div><el-text type="danger">(已回收数量:{{ row.recycleNum }}当前库存:{{
  24. row.stockNum
  25. }})</el-text></div>
  26. </div>
  27. </div>
  28. <div class="base-info-right w-36 shrink-0">
  29. <div class="common-text flex">
  30. <el-text>定  价:</el-text>
  31. <el-text>¥ {{ row.bookPrice }}</el-text>
  32. </div>
  33. <div class="common-text flex">
  34. <el-text>回收折扣:</el-text>
  35. <el-text>¥ {{ row.recycleDiscount }}折</el-text>
  36. </div>
  37. <div class="common-text flex">
  38. <el-text>预估金额:</el-text>
  39. <el-text>¥ {{ row.recyclePrice }}</el-text>
  40. </div>
  41. <div class="common-text flex">
  42. <el-text>销售价格:</el-text>
  43. <el-text>¥ {{ row.salePrice || '-' }}</el-text>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <template #action="{ row }">
  49. <div class="action-btns">
  50. <el-button class="mb-10" color="#4f4f4f" @click="">审核图片</el-button>
  51. <el-button class="mb-10" color="#a4adb3" @click="handleViewUrl(row, 'dd')">查看当当</el-button>
  52. <el-button class="mb-10" color="#e99d42" @click="handleRecycleLog(row)">回收日志</el-button>
  53. <el-button class="mb-10" color="#f27606" @click="handleViewUrl(row, 'tb')">查看淘宝</el-button>
  54. <el-button color="#0f7dc7" @click="handleSalesLog(row)">售价日志</el-button>
  55. <el-button color="#399420" @click="handleViewUrl(row, 'db')">查看豆瓣</el-button>
  56. </div>
  57. </template>
  58. <template #auditInfo="{ row }">
  59. <div class="audit-info flex justify-center">
  60. <el-radio-group v-model="row.sts" style="width: 120px"
  61. :disabled="!(detail.status == 8 || detail.status == 9)"
  62. @change="(value) => handleAuditInfo(value, row)">
  63. <el-radio :value="1">品相良好</el-radio>
  64. <el-radio :value="2" disabled>品相一般</el-radio>
  65. <el-radio :value="3">品相极差</el-radio>
  66. </el-radio-group>
  67. <el-select v-model="row.com" style="width: 180px" placeholder="请选择品相极差的原因" multiple
  68. :disabled="!(detail.status == 8 || detail.status == 9) || row.sts !== 3" class="reason-select"
  69. @change="(value) => handleSelectReason(value, row)">
  70. <el-option v-for="item in auditReason" :key="item.dictValue" :label="item.dictValue"
  71. :value="item.dictValue" />
  72. </el-select>
  73. </div>
  74. </template>
  75. </ele-data-table>
  76. <orderModifyDiscount ref="specifiedRef" @refresh="handleRefresh('specified')" />
  77. <setParams ref="modifyRef" @refresh="handleRefresh('modify')" />
  78. <orderBlacklist ref="blacklistRef" @refresh="handleRefresh('blacklist')" />
  79. <orderRecycleLog ref="recycleLogRef" />
  80. <orderSalesLog ref="salesLogRef" />
  81. </template>
  82. <script setup>
  83. import { ref, reactive, watch, nextTick } from 'vue';
  84. import orderModifyDiscount from '@/views/recycle/components/modify-discount.vue';
  85. import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
  86. import orderRecycleLog from '@/views/recycleOrder/detail/order-recycle-log.vue';
  87. import orderSalesLog from '@/views/recycleOrder/detail/order-sales-log.vue';
  88. import setParams from '@/views/recycle/components/set-params.vue';
  89. import request from '@/utils/request';
  90. const props = defineProps({
  91. detail: {
  92. type: Object,
  93. default: () => ({
  94. detailVoList: []
  95. })
  96. }
  97. });
  98. const dataList = ref([]);
  99. // 处理detailVoList数据
  100. const processDetailList = (list) => {
  101. if (!list) return [];
  102. const result = [];
  103. let currentIndex = 0;
  104. list.forEach(item => {
  105. let auditInfo = item.auditCommentList
  106. // 根据num拆分对象
  107. for (let i = 0; i < item.num; i++) {
  108. let audit = auditInfo ? auditInfo[i] ? auditInfo[i] : { sts: 0, com: [] } : { sts: 0, com: [] }
  109. // 如果com存在且包含逗号,则分割为数组
  110. if (audit.com && typeof audit.com === 'string') {
  111. audit.com = audit.com.split(',').filter(Boolean);
  112. } else if (!Array.isArray(audit.com)) {
  113. audit.com = [];
  114. }
  115. result.push({
  116. ...item,
  117. ...audit,
  118. _index: i,
  119. _groupIndex: currentIndex,
  120. _isFirstRow: i === 0
  121. });
  122. }
  123. currentIndex++;
  124. });
  125. return result;
  126. };
  127. // 修改watch为immediate模式,并使用nextTick
  128. watch(() => props.detail.detailVoList, (newVal) => {
  129. if (!newVal) return;
  130. nextTick(() => {
  131. dataList.value = processDetailList(newVal);
  132. });
  133. }, { deep: true, immediate: true });
  134. // 处理单元格合并
  135. const handleSpanMethod = ({ row, column, rowIndex }) => {
  136. if (column.property === 'num') {
  137. // 找到当前行所在组的所有行
  138. const currentGroup = dataList.value.filter(item => item._groupIndex === row._groupIndex);
  139. if (row._isFirstRow) {
  140. // 如果是组内第一行,设置合并行数
  141. return {
  142. rowspan: currentGroup.length,
  143. colspan: 1
  144. };
  145. } else {
  146. // 组内其他行不显示
  147. return {
  148. rowspan: 0,
  149. colspan: 0
  150. };
  151. }
  152. }
  153. return {
  154. rowspan: 1,
  155. colspan: 1
  156. };
  157. };
  158. //审核书籍
  159. function handleAudit(row) {
  160. const payload = {
  161. orderId: props.detail.orderId,
  162. isbn: row.isbn,
  163. inx: row._index,
  164. sts: row.sts,
  165. com: Array.isArray(row.com) ? row.com.join(',') : ''
  166. };
  167. request.post('/order/orderInfo/adminCheckOrder', payload).then((res) => {
  168. if (res.data.code == 200) {
  169. ElMessage.success('操作成功');
  170. } else {
  171. ElMessage.error(res.data.msg)
  172. }
  173. });
  174. }
  175. //其余审核良好 列表中sts为0的设置为1,并提交
  176. function handleOtherAuditGood() {
  177. let stsList = [];
  178. dataList.value.forEach(item => {
  179. if (item.sts == 0) {
  180. item.sts = 1;
  181. stsList.push({
  182. orderId: props.detail.orderId,
  183. isbn: item.isbn,
  184. sts: 1,
  185. com: '',
  186. inx: item._index
  187. });
  188. }
  189. });
  190. let data = {
  191. orderIds: [props.detail.orderId],
  192. checkType: 2
  193. }
  194. //后端接口批量审核
  195. request.post('/order/orderInfo/adminCheckBatch', data).then((res) => {
  196. if (res.data.code == 200) {
  197. ElMessage.success('操作成功');
  198. } else {
  199. ElMessage.error(res.data.msg)
  200. }
  201. });
  202. }
  203. //单选框选择变化
  204. function handleAuditInfo(value, row) {
  205. if (value == 1) {
  206. row.com = [];
  207. nextTick(() => {
  208. handleAudit(row);
  209. });
  210. } else if (value == 3 && row.com.length > 0) {
  211. nextTick(() => {
  212. handleAudit(row);
  213. });
  214. }
  215. }
  216. //选择审核原因
  217. function handleSelectReason(value, row) {
  218. if (row.sts == 3) {
  219. row.com = value;
  220. nextTick(() => {
  221. handleAudit(row);
  222. });
  223. }
  224. }
  225. const emit = defineEmits(['update:detail', 'refresh']);
  226. const columns = ref([
  227. {
  228. type: 'index',
  229. columnKey: 'index',
  230. width: 60,
  231. align: 'center'
  232. },
  233. {
  234. label: '信息',
  235. prop: 'baseInfo',
  236. slot: 'baseInfo',
  237. minWidth: 560,
  238. align: 'center'
  239. },
  240. {
  241. label: '操作',
  242. prop: 'action',
  243. slot: 'action',
  244. width: 220,
  245. align: 'center'
  246. },
  247. {
  248. label: '数量',
  249. prop: 'num',
  250. minWidth: 90,
  251. align: 'center',
  252. formatter: (row) => {
  253. return `× ${row.num}`;
  254. }
  255. },
  256. {
  257. label: '审核信息',
  258. prop: 'auditInfo',
  259. slot: 'auditInfo',
  260. align: 'center',
  261. minWidth: 317
  262. },
  263. {
  264. label: '审核金额',
  265. prop: 'recyclePrice',
  266. align: 'center',
  267. minWidth: 100,
  268. formatter: (row) => {
  269. return row.sts == 1 ? `¥ ${row.recyclePrice}` : '0';
  270. }
  271. }
  272. ]);
  273. //获取审核原因的字典 book_audit_reason
  274. const auditReason = ref([]);
  275. const getAuditReason = async () => {
  276. const res = await request.get('/system/dict/data/type/book_audit_reason');
  277. auditReason.value = res.data.data;
  278. console.log(res, 'xxxx')
  279. };
  280. getAuditReason();
  281. //查看当当、淘宝、豆瓣链接
  282. const handleViewUrl = (row, type) => {
  283. let url = '';
  284. if (type == 'dd') {
  285. url = `https://search.dangdang.com/?key=${row.isbn}&act=input`;
  286. } else if (type == 'tb') {
  287. url = `https://s.taobao.com/search?page=1&q=${row.isbn}&sort=sale-desc&tab=all`;
  288. } else if (type == 'db') {
  289. url = `https://search.douban.com/book/subject_search?search_text=${row.isbn}`;
  290. } else if (type == 'kw') {
  291. url = `https://search.kongfz.com/product_result/?key=${row.isbn}&status=0&_stpmt=eyJzZWFyY2hfdHlwZSI6ImFjdGl2ZSJ9`;
  292. }
  293. window.open(url, '_blank');
  294. };
  295. //加入回收书单
  296. const handleAddBookList = (row) => {
  297. ElMessageBox.confirm('确认加入回收书单?', '提示', {
  298. confirmButtonText: '确定',
  299. cancelButtonText: '关闭',
  300. type: 'warning'
  301. }).then(() => {
  302. request.post('/book/bookRecycleInfo/addIn', {
  303. isbnList: [row.isbn]
  304. }).then(() => {
  305. ElMessage.success('操作成功');
  306. // 更新列表数据
  307. const index = props.detail.detailVoList.findIndex(item => item.isbn === row.isbn);
  308. if (index > -1) {
  309. const newList = [...props.detail.detailVoList];
  310. newList[index] = { ...newList[index], bookStatus: 2 };
  311. dataList.value = newList;
  312. }
  313. });
  314. });
  315. };
  316. const currentRow = ref(null);
  317. //修改回收折扣
  318. const modifyRef = ref();
  319. const handleModifyDiscount = (row) => {
  320. currentRow.value = row;
  321. modifyRef.value?.handleOpen(row);
  322. };
  323. //指定回收折扣
  324. const specifiedRef = ref();
  325. const handleSpecifiedDiscount = (row) => {
  326. currentRow.value = row;
  327. specifiedRef.value?.handleOpen(row);
  328. };
  329. //加入黑名单
  330. const blacklistRef = ref();
  331. const handleBlackList = (row) => {
  332. currentRow.value = row;
  333. blacklistRef.value?.handleOpen(row);
  334. };
  335. //查看回收日志
  336. const recycleLogRef = ref();
  337. const handleRecycleLog = (row) => {
  338. recycleLogRef.value?.handleOpen(row);
  339. };
  340. //查看售价日志
  341. const salesLogRef = ref();
  342. const handleSalesLog = (row) => {
  343. salesLogRef.value?.handleOpen(row);
  344. };
  345. const handleRefresh = (type) => {
  346. if (!currentRow.value) return;
  347. const index = dataList.value.findIndex(item => item.isbn === currentRow.value.isbn);
  348. if (index > -1) {
  349. const newList = [...dataList.value];
  350. if (type === 'specified' || type === 'modify') {
  351. newList[index] = { ...newList[index], settingStatus: 1 };
  352. } else if (type === 'blacklist') {
  353. newList[index] = { ...newList[index], bookStatus: 3 };
  354. }
  355. dataList.value = newList;
  356. }
  357. };
  358. defineExpose({
  359. handleOtherAuditGood
  360. });
  361. </script>
  362. <style lang="scss" scoped>
  363. .mb-10 {
  364. margin-bottom: 7px;
  365. }
  366. .reason-select {
  367. :deep(.el-select__wrapper) {
  368. height: 120px !important;
  369. }
  370. :deep(.el-select__placeholder) {
  371. top: 0;
  372. text-wrap: wrap;
  373. white-space: normal;
  374. text-overflow: initial;
  375. }
  376. }
  377. .order-books {
  378. .action-btns {
  379. display: flex;
  380. flex-wrap: wrap;
  381. gap: 10px;
  382. .el-button {
  383. margin: 0;
  384. color: #fff;
  385. }
  386. }
  387. // 处理合并单元格效果
  388. .el-table {
  389. td.el-table__cell {
  390. &.first-row {
  391. border-bottom: none;
  392. }
  393. }
  394. .first-row~tr {
  395. td.el-table__cell:nth-child(4) {
  396. display: none;
  397. }
  398. }
  399. }
  400. }
  401. </style>