order-book-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. emit('close');
  199. } else {
  200. ElMessage.error(res.data.msg)
  201. }
  202. });
  203. }
  204. //单选框选择变化
  205. function handleAuditInfo(value, row) {
  206. if (value == 1) {
  207. row.com = [];
  208. nextTick(() => {
  209. handleAudit(row);
  210. });
  211. } else if (value == 3 && row.com.length > 0) {
  212. nextTick(() => {
  213. handleAudit(row);
  214. });
  215. }
  216. }
  217. //选择审核原因
  218. function handleSelectReason(value, row) {
  219. if (row.sts == 3) {
  220. row.com = value;
  221. nextTick(() => {
  222. handleAudit(row);
  223. });
  224. }
  225. }
  226. const emit = defineEmits(['update:detail', 'refresh']);
  227. const columns = ref([
  228. {
  229. type: 'index',
  230. columnKey: 'index',
  231. width: 60,
  232. align: 'center'
  233. },
  234. {
  235. label: '信息',
  236. prop: 'baseInfo',
  237. slot: 'baseInfo',
  238. minWidth: 560,
  239. align: 'center'
  240. },
  241. {
  242. label: '操作',
  243. prop: 'action',
  244. slot: 'action',
  245. width: 220,
  246. align: 'center'
  247. },
  248. {
  249. label: '数量',
  250. prop: 'num',
  251. minWidth: 90,
  252. align: 'center',
  253. formatter: (row) => {
  254. return `× ${row.num}`;
  255. }
  256. },
  257. {
  258. label: '审核信息',
  259. prop: 'auditInfo',
  260. slot: 'auditInfo',
  261. align: 'center',
  262. minWidth: 317
  263. },
  264. {
  265. label: '审核金额',
  266. prop: 'recyclePrice',
  267. align: 'center',
  268. minWidth: 100,
  269. formatter: (row) => {
  270. return row.sts == 1 ? `¥ ${row.recyclePrice}` : '0';
  271. }
  272. }
  273. ]);
  274. //获取审核原因的字典 book_audit_reason
  275. const auditReason = ref([]);
  276. const getAuditReason = async () => {
  277. const res = await request.get('/system/dict/data/type/book_audit_reason');
  278. auditReason.value = res.data.data;
  279. console.log(res, 'xxxx')
  280. };
  281. getAuditReason();
  282. //查看当当、淘宝、豆瓣链接
  283. const handleViewUrl = (row, type) => {
  284. let url = '';
  285. if (type == 'dd') {
  286. url = `https://search.dangdang.com/?key=${row.isbn}&act=input`;
  287. } else if (type == 'tb') {
  288. url = `https://s.taobao.com/search?page=1&q=${row.isbn}&sort=sale-desc&tab=all`;
  289. } else if (type == 'db') {
  290. url = `https://search.douban.com/book/subject_search?search_text=${row.isbn}`;
  291. } else if (type == 'kw') {
  292. url = `https://search.kongfz.com/product_result/?key=${row.isbn}&status=0&_stpmt=eyJzZWFyY2hfdHlwZSI6ImFjdGl2ZSJ9`;
  293. }
  294. window.open(url, '_blank');
  295. };
  296. //加入回收书单
  297. const handleAddBookList = (row) => {
  298. ElMessageBox.confirm('确认加入回收书单?', '提示', {
  299. confirmButtonText: '确定',
  300. cancelButtonText: '关闭',
  301. type: 'warning'
  302. }).then(() => {
  303. request.post('/book/bookRecycleInfo/addIn', {
  304. isbnList: [row.isbn]
  305. }).then(() => {
  306. ElMessage.success('操作成功');
  307. // 更新列表数据
  308. const index = props.detail.detailVoList.findIndex(item => item.isbn === row.isbn);
  309. if (index > -1) {
  310. const newList = [...props.detail.detailVoList];
  311. newList[index] = { ...newList[index], bookStatus: 2 };
  312. dataList.value = newList;
  313. }
  314. });
  315. });
  316. };
  317. const currentRow = ref(null);
  318. //修改回收折扣
  319. const modifyRef = ref();
  320. const handleModifyDiscount = (row) => {
  321. currentRow.value = row;
  322. modifyRef.value?.handleOpen(row);
  323. };
  324. //指定回收折扣
  325. const specifiedRef = ref();
  326. const handleSpecifiedDiscount = (row) => {
  327. currentRow.value = row;
  328. specifiedRef.value?.handleOpen(row);
  329. };
  330. //加入黑名单
  331. const blacklistRef = ref();
  332. const handleBlackList = (row) => {
  333. currentRow.value = row;
  334. blacklistRef.value?.handleOpen(row);
  335. };
  336. //查看回收日志
  337. const recycleLogRef = ref();
  338. const handleRecycleLog = (row) => {
  339. recycleLogRef.value?.handleOpen(row);
  340. };
  341. //查看售价日志
  342. const salesLogRef = ref();
  343. const handleSalesLog = (row) => {
  344. salesLogRef.value?.handleOpen(row);
  345. };
  346. const handleRefresh = (type) => {
  347. if (!currentRow.value) return;
  348. const index = dataList.value.findIndex(item => item.isbn === currentRow.value.isbn);
  349. if (index > -1) {
  350. const newList = [...dataList.value];
  351. if (type === 'specified' || type === 'modify') {
  352. newList[index] = { ...newList[index], settingStatus: 1 };
  353. } else if (type === 'blacklist') {
  354. newList[index] = { ...newList[index], bookStatus: 3 };
  355. }
  356. dataList.value = newList;
  357. }
  358. };
  359. defineExpose({
  360. handleOtherAuditGood
  361. });
  362. </script>
  363. <style lang="scss" scoped>
  364. .mb-10 {
  365. margin-bottom: 7px;
  366. }
  367. .reason-select {
  368. :deep(.el-select__wrapper) {
  369. height: 120px !important;
  370. }
  371. :deep(.el-select__placeholder) {
  372. top: 0;
  373. text-wrap: wrap;
  374. white-space: normal;
  375. text-overflow: initial;
  376. }
  377. }
  378. .order-books {
  379. .action-btns {
  380. display: flex;
  381. flex-wrap: wrap;
  382. gap: 10px;
  383. .el-button {
  384. margin: 0;
  385. color: #fff;
  386. }
  387. }
  388. // 处理合并单元格效果
  389. .el-table {
  390. td.el-table__cell {
  391. &.first-row {
  392. border-bottom: none;
  393. }
  394. }
  395. .first-row~tr {
  396. td.el-table__cell:nth-child(4) {
  397. display: none;
  398. }
  399. }
  400. }
  401. }
  402. </style>