index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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="fullType">
  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:stockFullAlert:batchAddBooklist'"
  20. @click="handleOptBooklist('add')"
  21. >
  22. 加入回收书单
  23. </el-button>
  24. <el-button
  25. type="danger"
  26. plain
  27. v-permission="'recycle:stockFullAlert:batchAddBlacklist'"
  28. @click="handleOptBlacklist('add')"
  29. >
  30. 加黑名单
  31. </el-button>
  32. <el-button
  33. type="warning"
  34. plain
  35. v-permission="'recycle:stockFullAlert:batchPauseRecycle'"
  36. @click="handleOptRecycle('pause')"
  37. >
  38. 暂停回收
  39. </el-button>
  40. <el-button
  41. color="#7728f5"
  42. plain
  43. v-permission="'recycle:stockFullAlert:oneUpdate'"
  44. @click="handleOneUpdate()"
  45. >
  46. 一键更新
  47. </el-button>
  48. <el-button
  49. color="#0e40f5"
  50. plain
  51. v-permission="'recycle:stockFullAlert: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" @refresh="reload"></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)" v-permission="'recycle:stockFullAlert:recycleLog'"
  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)" v-permission="'recycle:stockFullAlert:salesLog'"
  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:stockFullAlert:modifyDiscount'"
  94. @click="handleModifyDiscount(row)"
  95. >修改回收折扣</el-button
  96. >
  97. <el-button
  98. color="#333333"
  99. v-permission="'recycle:stockFullAlert: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:stockFullAlert: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:stockFullAlert:modifyMaxRecycle'"
  115. @click="handleModifyMaxRecycle(row)"
  116. >修改最大回收量</el-button
  117. >
  118. <el-button
  119. color="#bd3124"
  120. v-permission="'recycle:stockFullAlert: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:stockFullAlert:startRecycle'"
  128. @click="handleOptRecycle('start', row)"
  129. v-else
  130. >开启回收</el-button
  131. >
  132. <el-button
  133. color="#e99d42"
  134. v-permission="
  135. 'recycle:stockFullAlert:modifyOrderRecycle'
  136. "
  137. @click="handleModifyOrderRecycle(row)"
  138. >修改订单回收量</el-button
  139. >
  140. <el-button
  141. color="#4095e5"
  142. v-permission="'recycle:stockFullAlert:removeBooklist'"
  143. @click="handleOptBooklist('remove', row)"
  144. >移除回收书单</el-button
  145. >
  146. <el-button
  147. color="#567722"
  148. v-permission="'recycle:stockFullAlert:remind'"
  149. @click="handleRemind(row)"
  150. >一个月后提醒</el-button
  151. >
  152. </div>
  153. </template>
  154. </common-table>
  155. <orderRecycleLog ref="recycleLogRef" />
  156. <orderSalesLog ref="salesLogRef" />
  157. <modifyOrderRecycle ref="orderRecycleRef" @refresh="reload" />
  158. <modifyMaxRecycle ref="maxRecycleRef" @refresh="reload" />
  159. <modifyDiscount ref="modifyDiscountRef" @refresh="reload" />
  160. <orderBlacklist ref="blacklistRef" @refresh="reload" />
  161. <oneUpdate ref="oneUpdateRef" @submit="handleOneUpdateSubmit" />
  162. </ele-page>
  163. </template>
  164. <script setup>
  165. import { ref, reactive, getCurrentInstance } from 'vue';
  166. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  167. import bookSearch from '@/views/recycle/components/book-search.vue';
  168. import bookStatInfo from '@/views/recycle/components/book-stat-info.vue';
  169. import orderRecycleLog from '@/views/recycleOrder/detail/order-recycle-log.vue';
  170. import orderSalesLog from '@/views/recycleOrder/detail/order-sales-log.vue';
  171. import modifyOrderRecycle from '@/views/recycle/components/modify-order-recycle.vue';
  172. import modifyMaxRecycle from '@/views/recycle/components/modify-max-recycle.vue';
  173. import modifyDiscount from '@/views/recycle/components/modify-discount.vue';
  174. import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
  175. import oneUpdate from '@/views/recycle/components/one-update.vue';
  176. import { useBookOperation } from '@/utils/use-book-operation';
  177. import { ElMessage } from 'element-plus';
  178. const { proxy } = getCurrentInstance();
  179. defineOptions({ name: 'stockFullAlert' });
  180. const fullType = ref('0');
  181. function handleStatusChange(value) {
  182. pageRef.value.reload({ fullType: value });
  183. }
  184. /** 表格列配置 */
  185. const columns = ref([
  186. {
  187. type: 'selection',
  188. columnKey: 'selection',
  189. width: 50,
  190. align: 'center',
  191. fixed: 'left'
  192. },
  193. {
  194. label: '图片',
  195. prop: 'cover',
  196. width: 120,
  197. slot: 'cover'
  198. },
  199. {
  200. label: '信息',
  201. prop: 'baseInfo',
  202. width: 540,
  203. slot: 'baseInfo'
  204. },
  205. { label: '回收折扣', prop: 'recycleDiscount' },
  206. { label: '预估金额', prop: 'recyclePrice' },
  207. { label: '最大回收量', prop: 'recycleMax', minWidth: 100 },
  208. { label: '当前剩余回收量', prop: 'restRecycleNum', minWidth: 100 },
  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: 'stockFullAlertTable',
  233. params: {
  234. alarmType: '1',
  235. delStatus: '1',
  236. fullType: fullType.value,
  237. history:'0'
  238. }
  239. });
  240. //刷新表格
  241. function reload(where) {
  242. where.fullType = fullType.value;
  243. pageRef.value?.reload(where);
  244. }
  245. //导出excel
  246. function handleExportExcel() {
  247. pageRef.value?.exportData('图书收满预警');
  248. }
  249. // 使用图书操作混入
  250. const {
  251. blacklistRef,
  252. discountRef,
  253. paramsRef,
  254. handleOptBooklist,
  255. handleOptBlacklist,
  256. handleOptRecycle,
  257. handleOptType,
  258. handleAddDiscount,
  259. handleSetParams,
  260. modifyDiscountRef,
  261. handleModifyDiscount,
  262. handleViewUrl
  263. } = useBookOperation(pageRef);
  264. //一个月后提醒
  265. function handleRemind(row) {
  266. pageRef.value?.messageBoxConfirm({
  267. message: '确定一个月后提醒吗?',
  268. fetch: () =>
  269. proxy.$http.post('/book/stockAlarm/setAlarmTime', {
  270. id: row.id,
  271. })
  272. });
  273. }
  274. //一键更新
  275. const oneUpdateRef = ref(null);
  276. function handleOneUpdate() {
  277. oneUpdateRef.value?.handleOpen();
  278. }
  279. //处理一键更新提交
  280. function handleOneUpdateSubmit(data) {
  281. data.alarmType = 1;
  282. proxy.$http.post('/book/stockAlarm/alarmReload', data).then((res) => {
  283. if (res.data.code == 200) {
  284. ElMessage.success('操作成功');
  285. } else {
  286. ElMessage.error(res.data.msg);
  287. }
  288. });
  289. }
  290. //查看回收日志
  291. const recycleLogRef = ref();
  292. const handleRecycleLog = (row) => {
  293. recycleLogRef.value?.handleOpen(row);
  294. };
  295. //查看售价日志
  296. const salesLogRef = ref();
  297. const handleSalesLog = (row) => {
  298. salesLogRef.value?.handleOpen(row);
  299. };
  300. //修改订单回收量
  301. const orderRecycleRef = ref();
  302. const handleModifyOrderRecycle = (row) => {
  303. orderRecycleRef.value?.handleOpen(row);
  304. };
  305. //修改最大回收量
  306. const maxRecycleRef = ref();
  307. const handleModifyMaxRecycle = (row) => {
  308. maxRecycleRef.value?.handleOpen(row);
  309. };
  310. </script>
  311. <style lang="scss" scoped>
  312. .book-btns {
  313. gap: 6px;
  314. .el-button {
  315. min-width: 100px;
  316. font-size: 12px;
  317. color: #ffffff;
  318. padding: 4px 6px;
  319. margin-right: 0;
  320. }
  321. }
  322. </style>