index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <ele-page flex-table>
  3. <book-search @search="reload" :isBookTag="true"></book-search>
  4. <common-table
  5. ref="pageRef"
  6. :pageConfig="pageConfig"
  7. :columns="columns"
  8. :tools="false"
  9. >
  10. <template #toolbar>
  11. <el-radio-group @change="handleStatusChange" v-model="history">
  12. <el-radio-button label="价格预警" value="0" />
  13. <el-radio-button label="已处理价格预警" value="1" />
  14. </el-radio-group>
  15. <span class="ml-8"></span>
  16. <el-button
  17. type="success"
  18. plain
  19. v-permission="'recycle:priceAlert:batchAddBooklist'"
  20. @click="handleOptBooklist('add')"
  21. >
  22. 加入回收书单
  23. </el-button>
  24. <el-button
  25. color="#cba43f"
  26. plain
  27. v-permission="'recycle:priceAlert:batchAddSocial'"
  28. @click="handleOptType(1)"
  29. >
  30. 加社科库
  31. </el-button>
  32. <el-button
  33. color="#bd3125"
  34. plain
  35. v-permission="'recycle:priceAlert:batchAddTeach'"
  36. @click="handleOptType(2)"
  37. >
  38. 加教材库
  39. </el-button>
  40. <el-button
  41. color="#7728f5"
  42. plain
  43. v-permission="'recycle:priceAlert:oneUpdate'"
  44. @click="handleOneUpdate()"
  45. >
  46. 一键更新
  47. </el-button>
  48. <el-button
  49. color="#0e40f5"
  50. plain
  51. v-permission="'recycle:priceAlert:exprot'"
  52. @click="handleExportExcel()"
  53. >
  54. 导出Excel
  55. </el-button>
  56. </template>
  57. <template #cover="{ row }">
  58. <el-image
  59. style="width: 90px; height: 120px; border-radius: 4px"
  60. fit="cover"
  61. :src="row.cover"
  62. />
  63. </template>
  64. <template #baseInfo="{ row }">
  65. <book-stat-info :row="row"></book-stat-info>
  66. </template>
  67. <template #view="{ row }">
  68. <div class="grid grid-cols-2 gap-2 book-btns">
  69. <el-button color="#951d1d" @click="handleViewUrl(row, 'kw')"
  70. >查看孔网</el-button
  71. >
  72. <el-button color="#e99d42" @click="handleRecycleLog(row)"
  73. >回收日志</el-button
  74. >
  75. <el-button color="#f27606" @click="handleViewUrl(row, 'tb')"
  76. >查看淘宝</el-button
  77. >
  78. <el-button color="#0f7dc7" @click="handleSalesLog(row)"
  79. >售价日志</el-button
  80. >
  81. <el-button color="#399420" @click="handleViewUrl(row, 'db')"
  82. >查看豆瓣</el-button
  83. >
  84. <el-button color="#a4adb3" @click="handleViewUrl(row, 'dd')"
  85. >查看当当</el-button
  86. >
  87. </div>
  88. </template>
  89. <template #action="{ row }">
  90. <div class="grid grid-cols-2 gap-2 book-btns">
  91. <el-button
  92. color="#7728f5"
  93. v-permission="'recycle:priceAlert:modifyDiscount'"
  94. @click="handleModifyDiscount(row)"
  95. >修改回收折扣</el-button
  96. >
  97. <el-button
  98. color="#333333"
  99. v-permission="'recycle:priceAlert:addBlacklist'"
  100. @click="handleOptBlacklist('add', row)"
  101. v-if="row.bookStatus == 1 || row.bookStatus == 2"
  102. >加入黑名单</el-button
  103. >
  104. <el-button
  105. type="success"
  106. v-permission="'recycle:priceAlert:removeBlacklist'"
  107. @click="handleOptBlacklist('remove', row)"
  108. v-if="row.bookStatus == 3"
  109. >
  110. 移除黑名单
  111. </el-button>
  112. <el-button
  113. color="#3ab54a"
  114. v-permission="'recycle:priceAlert:modifyMaxRecycle'"
  115. @click="handleModifyMaxRecycle(row)"
  116. >修改最大回收量</el-button
  117. >
  118. <el-button
  119. color="#bd3124"
  120. v-permission="'recycle:priceAlert:pauseRecycle'"
  121. @click="handleOptRecycle('pause', row)"
  122. v-if="row.recycleStatus == 1"
  123. >暂停回收</el-button
  124. >
  125. <el-button
  126. color="#bd3124"
  127. v-permission="'recycle:priceAlert:startRecycle'"
  128. @click="handleOptRecycle('start', row)"
  129. v-else
  130. >开启回收</el-button
  131. >
  132. <el-button
  133. color="#e99d42"
  134. v-permission="'recycle:priceAlert:modifyOrderRecycle'"
  135. @click="handleModifyOrderRecycle(row)"
  136. >修改订单回收量</el-button
  137. >
  138. <el-button
  139. color="#4095e5"
  140. v-permission="'recycle:priceAlert:removeBooklist'"
  141. @click="handleOptBooklist('remove', row)"
  142. >移除回收书单</el-button
  143. >
  144. <el-button
  145. color="#567722"
  146. v-permission="'recycle:priceAlert:remind'"
  147. @click="handleRemind(row)"
  148. >一个月后提醒</el-button
  149. >
  150. </div>
  151. </template>
  152. </common-table>
  153. <orderRecycleLog ref="recycleLogRef" />
  154. <orderSalesLog ref="salesLogRef" />
  155. <modifyOrderRecycle ref="orderRecycleRef" @refresh="reload" />
  156. <modifyMaxRecycle ref="maxRecycleRef" @refresh="reload" />
  157. <modifyDiscount ref="modifyDiscountRef" @refresh="reload" />
  158. <orderBlacklist ref="blacklistRef" @refresh="reload" />
  159. </ele-page>
  160. </template>
  161. <script setup>
  162. import { ref, reactive, getCurrentInstance } from 'vue';
  163. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  164. import bookSearch from '@/views/recycle/components/book-search.vue';
  165. import bookStatInfo from '@/views/recycle/components/book-stat-info.vue';
  166. import orderRecycleLog from '@/views/recycleOrder/detail/order-recycle-log.vue';
  167. import orderSalesLog from '@/views/recycleOrder/detail/order-sales-log.vue';
  168. import modifyOrderRecycle from '@/views/recycle/components/modify-order-recycle.vue';
  169. import modifyMaxRecycle from '@/views/recycle/components/modify-max-recycle.vue';
  170. import modifyDiscount from '@/views/recycle/components/modify-discount.vue';
  171. import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
  172. import dayjs from 'dayjs';
  173. import { useBookOperation } from '@/utils/use-book-operation';
  174. const { proxy } = getCurrentInstance();
  175. defineOptions({ name: 'priceAlert' });
  176. const history = ref('0');
  177. function handleStatusChange(value) {
  178. pageRef.value.reload({ history: value });
  179. }
  180. /** 表格列配置 */
  181. const columns = ref([
  182. {
  183. type: 'selection',
  184. columnKey: 'selection',
  185. width: 50,
  186. align: 'center',
  187. fixed: 'left'
  188. },
  189. {
  190. label: '图片',
  191. prop: 'cover',
  192. width: 120,
  193. slot: 'cover'
  194. },
  195. {
  196. label: '信息',
  197. prop: 'baseInfo',
  198. width: 540,
  199. slot: 'baseInfo'
  200. },
  201. {
  202. label: '售价',
  203. prop: 'productPrice',
  204. formatter: (row) => (row.productPrice ? '¥' + row.productPrice : 0)
  205. },
  206. { label: '最大回收量', prop: 'recycleMax', minWidth: 100 },
  207. { label: '剩余回收量', prop: 'restRecycleNum', minWidth: 100 },
  208. { label: '最近预警时间', prop: 'lastScanTime', minWidth: 120 },
  209. { label: '预警次数', prop: 'alarmNum', minWidth: 90 },
  210. { label: '销量', prop: 'salesNum', minWidth: 90 },
  211. {
  212. columnKey: 'view',
  213. label: '查看',
  214. width: 234,
  215. slot: 'view',
  216. fixed: 'right'
  217. },
  218. {
  219. columnKey: 'action',
  220. label: '操作',
  221. width: 234,
  222. slot: 'action',
  223. fixed: 'right'
  224. }
  225. ]);
  226. /** 页面组件实例 */
  227. const pageRef = ref(null);
  228. const pageConfig = reactive({
  229. pageUrl: '/book/stockAlarm/pagelist',
  230. exportUrl: '/book/stockAlarm/export',
  231. fileName: '回收价格预警',
  232. cacheKey: 'priceAlertTable',
  233. params: {
  234. alarmType: 3,
  235. history: '0',
  236. delStatus: '1'
  237. }
  238. });
  239. //刷新表格
  240. function reload(where) {
  241. pageRef.value?.reload(where);
  242. }
  243. //导出excel
  244. function handleExportExcel() {
  245. pageRef.value?.exportData('回收价格预警');
  246. }
  247. // 使用图书操作混入
  248. const {
  249. blacklistRef,
  250. discountRef,
  251. paramsRef,
  252. handleOptBooklist,
  253. handleOptBlacklist,
  254. handleOptRecycle,
  255. handleOptType,
  256. handleAddDiscount,
  257. handleSetParams,
  258. modifyDiscountRef,
  259. handleModifyDiscount,
  260. handleViewUrl
  261. } = useBookOperation(pageRef);
  262. //一个月后提醒
  263. function handleRemind(row) {
  264. pageRef.value?.messageBoxConfirm({
  265. message: '确定一个月后提醒吗?',
  266. fetch: () =>
  267. proxy.$http.post('/book/stockAlarm/setAlarmTime', {
  268. id: row.id,
  269. alarmType: 3
  270. })
  271. });
  272. }
  273. //一键更新
  274. function handleOneUpdate() {
  275. let data = {
  276. alarmType: 3,
  277. reloadTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
  278. };
  279. pageRef.value?.messageBoxConfirm({
  280. message: '确定一键更新吗?',
  281. fetch: () => proxy.$http.post('/book/stockAlarm/alarmReload', data)
  282. });
  283. }
  284. //查看回收日志
  285. const recycleLogRef = ref();
  286. const handleRecycleLog = (row) => {
  287. recycleLogRef.value?.handleOpen(row);
  288. };
  289. //查看售价日志
  290. const salesLogRef = ref();
  291. const handleSalesLog = (row) => {
  292. salesLogRef.value?.handleOpen(row);
  293. };
  294. //修改订单回收量
  295. const orderRecycleRef = ref();
  296. const handleModifyOrderRecycle = (row) => {
  297. orderRecycleRef.value?.handleOpen(row);
  298. };
  299. //修改最大回收量
  300. const maxRecycleRef = ref();
  301. const handleModifyMaxRecycle = (row) => {
  302. maxRecycleRef.value?.handleOpen(row);
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .book-btns {
  307. gap: 6px;
  308. .el-button {
  309. min-width: 100px;
  310. font-size: 12px;
  311. color: #ffffff;
  312. padding: 4px 6px;
  313. margin-right: 0;
  314. }
  315. }
  316. </style>