index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <ele-page flex-table>
  3. <book-search @search="reload"></book-search>
  4. <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns" :tools="false">
  5. <template #toolbar>
  6. <el-radio-group @change="handleStatusChange" v-model="searchType">
  7. <el-radio-button label="全部" value="0" />
  8. <el-radio-button label="已加入回收书单(正在回收)" value="1" />
  9. <el-radio-button label="已加入回收书单(暂停回收)" value="2" />
  10. </el-radio-group>
  11. <span class="ml-8"></span>
  12. <el-button type="danger" plain v-permission="'recycle:specifiedBooks:batchAddBlacklist'"
  13. @click="handleOptBlacklist()">
  14. 加黑名单
  15. </el-button>
  16. <el-button type="warning" plain v-permission="'recycle:specifiedBooks:batchPauseRecycle'"
  17. @click="handleOptRecycle(null, 2)">
  18. 暂停回收
  19. </el-button>
  20. <el-button type="warning" plain v-permission="'recycle:specifiedBooks:batchStartRecycle'"
  21. @click="handleOptRecycle(null, 1)">
  22. 开启回收
  23. </el-button>
  24. <el-button type="success" plain v-permission="'recycle:specifiedBooks:batchAddSocial'"
  25. @click="handleOptType(1)">
  26. 加社科库
  27. </el-button>
  28. <el-button type="primary" plain v-permission="'recycle:specifiedBooks:batchAddTeach'"
  29. @click="handleOptType(2)">
  30. 加教材库
  31. </el-button>
  32. </template>
  33. <template #cover="{ row }">
  34. <el-image style="width: 90px; height: 120px; border-radius: 4px" fit="cover" :src="row.cover" />
  35. </template>
  36. <template #baseInfo="{ row }">
  37. <book-info :row="row" @edit="handleUpdateBook" :showFormat="false"></book-info>
  38. </template>
  39. <template #stock="{ row }">
  40. <book-stock :row="row"></book-stock>
  41. </template>
  42. <template #view="{ row }">
  43. <div class="flex justify-start items-center flex-wrap book-btns">
  44. <el-button color="#951d1d" @click="handleViewUrl(row, 'kw')" v-permission="'recycle:specifiedBooks:viewUrl'">
  45. 查看孔网
  46. </el-button>
  47. <el-button color="#e99d42" @click="handleRecycleLog(row)" v-permission="'recycle:specifiedBooks:viewRecycleLog'">
  48. 回收日志
  49. </el-button>
  50. <el-button color="#f27606" @click="handleViewUrl(row, 'tb')" v-permission="'recycle:specifiedBooks:viewUrl'">
  51. 查看淘宝
  52. </el-button>
  53. <el-button color="#0f7dc7" @click="handleSalesLog(row)" v-permission="'recycle:specifiedBooks:viewSalesLog'">
  54. 售价日志
  55. </el-button>
  56. <el-button color="#399420" @click="handleViewUrl(row, 'db')" v-permission="'recycle:specifiedBooks:viewUrl'">
  57. 查看豆瓣
  58. </el-button>
  59. <el-button color="#a4adb3" @click="handleViewUrl(row, 'dd')" v-permission="'recycle:specifiedBooks:viewUrl'">
  60. 查看当当
  61. </el-button>
  62. </div>
  63. </template>
  64. <template #action="{ row }">
  65. <div class="flex justify-start items-center flex-wrap book-btns">
  66. <el-button color="#7728f5" v-permission="'recycle:specifiedBooks:updateDiscount'"
  67. @click="handleModifyDiscount(row)">
  68. 修改回收折扣
  69. </el-button>
  70. <el-button color="#333333" v-permission="'recycle:specifiedBooks:addBlacklist'"
  71. @click="handleOptBlacklist(row)">
  72. 加入黑名单
  73. </el-button>
  74. <el-button color="#3ab54a" v-permission="'recycle:specifiedBooks:updateMaxRecycle'"
  75. @click="handleModifyMaxRecycle(row)">
  76. 修改最大回收量
  77. </el-button>
  78. <el-button color="#bd3124" v-permission="'recycle:specifiedBooks:pauseRecycle'"
  79. @click="handleOptRecycle(row, 2)" v-if="row.recycleStatus == 1">
  80. 暂停回收
  81. </el-button>
  82. <el-button color="#bd3124" v-permission="'recycle:specifiedBooks:startRecycle'"
  83. @click="handleOptRecycle(row, 1)" v-else>
  84. 开启回收
  85. </el-button>
  86. <el-button color="#e99d42" v-permission="'recycle:specifiedBooks:updateOrderRecycle'"
  87. @click="handleModifyOrderRecycle(row)">
  88. 修改订单回收量
  89. </el-button>
  90. <el-button color="#4095e5" v-permission="'recycle:specifiedBooks:removeBooklist'"
  91. @click="handleOptBooklist(row)">
  92. 移除回收书单
  93. </el-button>
  94. </div>
  95. </template>
  96. </common-table>
  97. <books-edit ref="editRef"></books-edit>
  98. <set-params ref="paramsRef" @refresh="reload"></set-params>
  99. <add-discount ref="discountRef" @refresh="reload"></add-discount>
  100. <orderRecycleLog ref="recycleLogRef" />
  101. <orderSalesLog ref="salesLogRef" />
  102. <modifyOrderRecycle ref="orderRecycleRef" @refresh="reload" />
  103. <modifyMaxRecycle ref="maxRecycleRef" @refresh="reload" />
  104. <modifyDiscount ref="modifyDiscountRef" @refresh="reload" />
  105. <orderBlacklist ref="blacklistRef" @refresh="reload" />
  106. </ele-page>
  107. </template>
  108. <script setup>
  109. import { ref, reactive } from 'vue';
  110. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  111. import booksEdit from '@/views/data/books/components/books-edit.vue';
  112. import bookSearch from '@/views/recycle/components/book-search.vue';
  113. import bookInfo from '@/views/recycle/components/book-info.vue';
  114. import bookOtherInfo from '@/views/recycle/components/book-other-info.vue';
  115. import bookStock from '@/views/recycle/components/book-stock.vue';
  116. import setParams from '@/views/recycle/components/set-params.vue';
  117. import addDiscount from '@/views/recycle/components/add-discount.vue';
  118. import orderRecycleLog from '@/views/recycleOrder/detail/order-recycle-log.vue';
  119. import orderSalesLog from '@/views/recycleOrder/detail/order-sales-log.vue';
  120. import modifyOrderRecycle from '@/views/recycle/components/modify-order-recycle.vue';
  121. import modifyMaxRecycle from '@/views/recycle/components/modify-max-recycle.vue';
  122. import modifyDiscount from '@/views/recycle/components/modify-discount.vue';
  123. import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
  124. defineOptions({ name: 'specifiedBookslist' });
  125. const searchType = ref('0');
  126. const blacklistRef = ref(null);
  127. function handleStatusChange(value) {
  128. searchType.value = value;
  129. pageConfig.params.searchType = value;
  130. pageRef.value.reload();
  131. }
  132. /** 表格列配置 */
  133. const columns = ref([
  134. {
  135. type: 'selection',
  136. columnKey: 'selection',
  137. width: 50,
  138. align: 'center',
  139. fixed: 'left'
  140. },
  141. {
  142. label: '图片',
  143. prop: 'cover',
  144. width: 120,
  145. slot: 'cover'
  146. },
  147. {
  148. label: '信息',
  149. prop: 'baseInfo',
  150. width: 500,
  151. slot: 'baseInfo'
  152. },
  153. {
  154. label: '回收价格',
  155. prop: 'recyclePrice',
  156. sortable: true,
  157. columnKey: 'recyclePrice',
  158. minWidth: 100
  159. },
  160. {
  161. label: '最大回收量',
  162. minWidth: 120,
  163. prop: 'recycleMax',
  164. sortable: true,
  165. columnKey: 'recycleMax'
  166. },
  167. {
  168. label: '当前剩余回收量',
  169. minWidth: 140,
  170. prop: 'restRecycleNum',
  171. sortable: true,
  172. columnKey: 'restRecycleNum'
  173. },
  174. {
  175. label: '销量',
  176. prop: 'salesNum',
  177. sortable: true,
  178. columnKey: 'salesNum'
  179. },
  180. {
  181. label: '查看',
  182. prop: 'view',
  183. slot: 'view',
  184. width: 234,
  185. fixed: 'right'
  186. },
  187. {
  188. columnKey: 'action',
  189. label: '操作',
  190. width: 234,
  191. slot: 'action',
  192. fixed: 'right'
  193. }
  194. ]);
  195. /** 页面组件实例 */
  196. const pageRef = ref(null);
  197. const pageConfig = reactive({
  198. pageUrl: '/book/bookRecycleInfo/designate/pageList',
  199. fileName: '指定图书管理',
  200. cacheKey: 'specifiedBookslistTable',
  201. rowKey: 'isbn',
  202. params: {
  203. searchType: '0'
  204. }
  205. });
  206. //刷新表格
  207. function reload(where) {
  208. pageRef.value?.reload(where);
  209. }
  210. //编辑
  211. const editRef = ref(null);
  212. function handleUpdateBook(row) {
  213. let params = {
  214. id: row.bookId
  215. };
  216. editRef.value?.handleOpen(params);
  217. }
  218. //设置参数
  219. const paramsRef = ref(null);
  220. function handleSetParams(row) {
  221. paramsRef.value?.handleOpen(row);
  222. }
  223. //黑名单操作
  224. function handleOptBlacklist(row) {
  225. let selections = row ? [row] : pageRef.value?.getSelections();
  226. if (!selections || selections.length === 0) {
  227. ElMessage.warning('请选择要操作的图书');
  228. return;
  229. }
  230. const isbnList = selections.map((item) => item.isbn);
  231. // 加入黑名单,打开选择原因弹窗
  232. blacklistRef.value?.handleOpen(isbnList);
  233. }
  234. //回收操作
  235. function handleOptRecycle(row, status) {
  236. let selections = row ? [row] : pageRef.value?.getSelections();
  237. if (!selections || selections.length === 0) {
  238. ElMessage.warning('请选择要操作的图书');
  239. return;
  240. }
  241. const isbnList = selections.map((item) => item.isbn);
  242. const isStop = status === 2;
  243. const url = isStop
  244. ? '/book/bookRecycleInfo/stopRecycle'
  245. : '/book/bookRecycleInfo/openRecycle';
  246. const title = isStop ? '确认暂停回收?' : '确认开启回收?';
  247. pageRef.value?.operatBatch({
  248. title,
  249. method: 'post',
  250. url,
  251. data: { isbnList },
  252. row,
  253. success: () => {
  254. reload();
  255. }
  256. });
  257. }
  258. //类型操作
  259. function handleOptType(type) {
  260. let selections = pageRef.value?.getSelections();
  261. if (!selections || selections.length === 0) {
  262. ElMessage.warning('请选择要操作的图书');
  263. return;
  264. }
  265. const isbnList = selections.map((item) => item.isbn);
  266. const url = type == 1
  267. ? '/book/bookRecycleInfo/changeBookTag2'
  268. : '/book/bookRecycleInfo/changeBookTag1';
  269. const title = type == 1 ? '确认加社科库?' : '确认加教材库?';
  270. pageRef.value?.operatBatch({
  271. title,
  272. method: 'post',
  273. url,
  274. data: { isbnList },
  275. success: () => {
  276. reload();
  277. }
  278. });
  279. }
  280. //指定折扣
  281. const discountRef = ref(null);
  282. function handleAddDiscount() {
  283. let selections = pageRef.value?.getSelections();
  284. if (!selections || selections.length === 0) {
  285. ElMessage.warning('请选择要操作的图书');
  286. return;
  287. }
  288. const isbnList = selections.map((item) => item.isbn);
  289. discountRef.value?.handleOpen({ isbnList });
  290. }
  291. //查看当当、淘宝、豆瓣链接
  292. const handleViewUrl = (row, type) => {
  293. let url = '';
  294. if (type == 'dd') {
  295. url = `https://search.dangdang.com/?key=${row.isbn}&act=input`;
  296. } else if (type == 'tb') {
  297. url = `https://s.taobao.com/search?page=1&q=${row.isbn}&sort=sale-desc&tab=all`;
  298. } else if (type == 'db') {
  299. url = `https://search.douban.com/book/subject_search?search_text=${row.isbn}`;
  300. } else if (type == 'kw') {
  301. url = `https://search.kongfz.com/product_result/?key=${row.isbn}&status=0&_stpmt=eyJzZWFyY2hfdHlwZSI6ImFjdGl2ZSJ9`;
  302. }
  303. window.open(url, '_blank');
  304. };
  305. //查看回收日志
  306. const recycleLogRef = ref();
  307. const handleRecycleLog = (row) => {
  308. recycleLogRef.value?.handleOpen(row);
  309. };
  310. //移除回收书单操作
  311. function handleOptBooklist(row) {
  312. let selections = row ? [row] : pageRef.value?.getSelections();
  313. if (!selections || selections.length === 0) {
  314. ElMessage.warning('请选择要操作的图书');
  315. return;
  316. }
  317. const isbnList = selections.map((item) => item.isbn);
  318. const url = '/book/bookRecycleInfo/removeOut';
  319. const title = '确认移除回收书单?';
  320. pageRef.value?.operatBatch({
  321. title,
  322. method: 'post',
  323. url,
  324. data: { isbnList },
  325. row,
  326. success: () => {
  327. reload();
  328. }
  329. });
  330. }
  331. //查看售价日志
  332. const salesLogRef = ref();
  333. const handleSalesLog = (row) => {
  334. salesLogRef.value?.handleOpen(row);
  335. };
  336. //修改订单回收量
  337. const orderRecycleRef = ref();
  338. const handleModifyOrderRecycle = (row) => {
  339. orderRecycleRef.value?.handleOpen(row);
  340. };
  341. //修改最大回收量
  342. const maxRecycleRef = ref();
  343. const handleModifyMaxRecycle = (row) => {
  344. maxRecycleRef.value?.handleOpen(row);
  345. };
  346. //修改回收折扣
  347. const modifyDiscountRef = ref();
  348. const handleModifyDiscount = (row) => {
  349. modifyDiscountRef.value?.handleOpen(row);
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. .book-btns {
  354. gap: 6px;
  355. .el-button {
  356. min-width: 100px;
  357. font-size: 12px;
  358. color: #ffffff;
  359. padding: 4px 6px;
  360. margin-right: 0;
  361. }
  362. }
  363. </style>