normal-order.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. import { h } from 'vue';
  2. import { NFlex, NImage, NTag } from 'naive-ui';
  3. // import { fetchGetAllStoreList } from '@/service/api/goods/desk-category';
  4. import { fetchBackendChannelSelect, fetchGetStoreList } from '@/service/api/xsb-manage/store-info';
  5. import { fetchGetDictDataList } from '@/service/api/system-manage';
  6. // import { useAuth } from '@/hooks/business/auth';
  7. import { useAuthStore } from '@/store/modules/auth';
  8. import { useAuth } from '@/hooks/business/auth';
  9. import type { FormSchema } from '@/components/zt/Form/types/form';
  10. export const SearchForm: FormSchema[] = [
  11. {
  12. label: '业务类型',
  13. field: 'businessType',
  14. component: 'ApiSelect',
  15. componentProps: {
  16. api: fetchGetDictDataList,
  17. labelFeild: 'name',
  18. valueFeild: 'value',
  19. resultFeild: 'data.list',
  20. params: {
  21. typeCode: 'sys_business_type'
  22. }
  23. }
  24. },
  25. {
  26. label: '所属企业',
  27. field: 'channelIdList',
  28. component: 'ApiSelect',
  29. componentProps: {
  30. api: fetchBackendChannelSelect,
  31. multiple: true,
  32. labelFeild: 'name',
  33. valueFeild: 'id'
  34. }
  35. },
  36. {
  37. label: '门店名称',
  38. component: 'ApiSelect',
  39. field: 'shopId',
  40. componentProps: {
  41. api: fetchGetStoreList,
  42. resultFeild: 'data.list',
  43. labelFeild: 'shopName',
  44. valueFeild: 'shopId'
  45. }
  46. },
  47. {
  48. label: '订单编号',
  49. component: 'NInput',
  50. field: 'orderNumber'
  51. },
  52. {
  53. label: '下单时间',
  54. component: 'NDatePicker',
  55. field: 'createTime',
  56. componentProps: {
  57. type: 'datetimerange',
  58. defaultTime: ['00:00:00', '23:59:59']
  59. }
  60. },
  61. {
  62. label: '客户姓名',
  63. component: 'NInput',
  64. field: 'consigneeName'
  65. },
  66. {
  67. label: '客户手机号',
  68. component: 'NInput',
  69. field: 'consigneeMobile'
  70. },
  71. {
  72. label: '买家姓名',
  73. component: 'NInput',
  74. field: 'buyerName'
  75. },
  76. {
  77. label: '买家手机号',
  78. component: 'NInput',
  79. field: 'buyerMobile'
  80. },
  81. {
  82. field: 'userAttrType',
  83. label: '买家属性',
  84. component: 'dictSelect',
  85. componentProps: {
  86. dictCode: 'user_attr_type',
  87. immediate: true
  88. },
  89. show: useAuth().hasAuth('user:attr:type')
  90. },
  91. {
  92. label: '退款类型',
  93. component: 'NSelect',
  94. field: 'refundStatus',
  95. componentProps: {
  96. options: [
  97. {
  98. label: '整单退款',
  99. value: 2
  100. },
  101. {
  102. label: '部分退款',
  103. value: 1
  104. },
  105. {
  106. label: '无售后订单',
  107. value: 0
  108. }
  109. ]
  110. }
  111. },
  112. {
  113. label: '发货情况',
  114. component: 'NSelect',
  115. field: 'deliveryStatus',
  116. componentProps: {
  117. options: [
  118. {
  119. label: '已发货',
  120. value: 'Shipped'
  121. },
  122. {
  123. label: '未发货',
  124. value: 'NoShipped'
  125. },
  126. {
  127. label: '未发货-无需发货',
  128. value: 'NoNeedShipped'
  129. }
  130. ]
  131. },
  132. ifShow({ model }) {
  133. return model.businessType == 'XSB';
  134. }
  135. },
  136. {
  137. label: '配送方式',
  138. component: 'NSelect',
  139. field: 'dvyTypeList',
  140. componentProps: {
  141. multiple: true,
  142. options: [
  143. {
  144. label: '快递',
  145. value: 1
  146. },
  147. {
  148. label: '自提',
  149. value: 2
  150. },
  151. {
  152. label: '即时配送',
  153. value: 3
  154. },
  155. {
  156. label: '其他方式',
  157. value: 4
  158. },
  159. {
  160. label: '商家自送',
  161. value: 10
  162. }
  163. ]
  164. },
  165. ifShow({ model }) {
  166. return model.businessType == 'XSB';
  167. }
  168. },
  169. {
  170. label: '业务状态',
  171. component: 'NSelect',
  172. field: 'hbOrderStatus',
  173. componentProps: {
  174. options: [
  175. {
  176. label: '待支付',
  177. value: 0
  178. },
  179. {
  180. label: '订单已接单(待拣货)',
  181. value: 20
  182. },
  183. {
  184. label: '订单待配送',
  185. value: 30
  186. },
  187. {
  188. label: '订单配送中',
  189. value: 40
  190. },
  191. {
  192. label: '订单取消待审核',
  193. value: 50
  194. },
  195. {
  196. label: '订单取消',
  197. value: 60
  198. },
  199. {
  200. label: '订单已送达',
  201. value: 70
  202. },
  203. {
  204. label: '订单已完成',
  205. value: 80
  206. }
  207. ]
  208. },
  209. ifShow({ model }) {
  210. return model.businessType == 'XSB';
  211. }
  212. }
  213. ];
  214. export const businessType = {
  215. XSB: '星闪豹',
  216. CD: '充电',
  217. DYY: '电影演出',
  218. DJK: '大健康',
  219. XNSP: '虚拟商品',
  220. JY: '加油'
  221. };
  222. /**
  223. * 获取搜索表单schema,业务类型下拉框根据当前用户权限过滤
  224. * ROOT用户:显示全量字典选项
  225. * 非ROOT用户:只显示有权限的业务类型
  226. */
  227. export function getSearchForm(): FormSchema[] {
  228. const authStore = useAuthStore();
  229. const userBusinessTypes = authStore.userInfo.businessTypes;
  230. // businessTypes 为 null 或 undefined 表示不限制(ROOT用户),使用原始ApiSelect拉全量
  231. if (!userBusinessTypes || userBusinessTypes.length === 0) {
  232. return [...SearchForm];
  233. }
  234. // 非ROOT用户:用NSelect + 静态选项,只显示有权限的业务类型
  235. const filteredOptions = userBusinessTypes.map(type => ({
  236. label: businessType[type as keyof typeof businessType] || type,
  237. value: type
  238. }));
  239. return SearchForm.map(schema => {
  240. if (schema.field === 'businessType') {
  241. return {
  242. ...schema,
  243. component: 'NSelect',
  244. componentProps: {
  245. options: filteredOptions
  246. }
  247. };
  248. }
  249. return schema;
  250. });
  251. }
  252. export enum orderStatusEnum {
  253. /**
  254. *
  255. * 待支付
  256. */
  257. WAIT_PAY = 0,
  258. /**
  259. * 待发货
  260. */
  261. WAIT_DELIVERY = 1,
  262. /**
  263. * 订单已接单(待拣货)
  264. */
  265. ORDER_ACCEPT = 20,
  266. /**
  267. * 订单待配送(拣货完成/自提类订单为待自提)
  268. */
  269. ORDER_WAIT_DELIVERY = 30,
  270. /**
  271. * 订单配送中
  272. */
  273. ORDER_DELIVERY = 40,
  274. /**
  275. * 订单取消待审核
  276. */
  277. ORDER_CANCEL_WAIT_AUDIT = 50,
  278. /**
  279. * 订单已取消
  280. */
  281. ORDER_CANCEL = 60,
  282. /**
  283. * 订单已退款
  284. */
  285. ORDER_REFUNDED = 61,
  286. /**
  287. * 订单已过期
  288. */
  289. ORDER_EXPIRED = 62,
  290. /**
  291. * 订单已送达
  292. */
  293. ORDER_ARRIVE = 70,
  294. /**
  295. * 订单已完成
  296. */
  297. ORDER_COMPLETE = 80
  298. }
  299. /**
  300. * 发货按钮显示状态
  301. */
  302. export const ShippingButton = [
  303. orderStatusEnum.WAIT_DELIVERY,
  304. orderStatusEnum.ORDER_ACCEPT,
  305. orderStatusEnum.ORDER_DELIVERY,
  306. orderStatusEnum.ORDER_WAIT_DELIVERY
  307. ];
  308. /**
  309. * // 0-待支付 1-待发货,20-订单已接单(待拣货),30-订单待配送(拣货完成/自提类订单为待自提),40-订单配送中
  310. // ,50-订单取消待审核,60-订单已取消,70-订单已送达,80-订单已完成
  311. */
  312. export const orderStatus = {
  313. [orderStatusEnum.WAIT_PAY]: '待支付',
  314. [orderStatusEnum.WAIT_DELIVERY]: '待发货',
  315. [orderStatusEnum.ORDER_ACCEPT]: '订单已接单(待拣货)',
  316. [orderStatusEnum.ORDER_WAIT_DELIVERY]: '订单待配送(拣货完成/自提类订单为待自提)',
  317. [orderStatusEnum.ORDER_DELIVERY]: '订单配送中',
  318. [orderStatusEnum.ORDER_CANCEL_WAIT_AUDIT]: '订单取消待审核',
  319. [orderStatusEnum.ORDER_CANCEL]: '订单已取消',
  320. [orderStatusEnum.ORDER_ARRIVE]: '订单已送达',
  321. [orderStatusEnum.ORDER_COMPLETE]: '订单已完成'
  322. };
  323. export const refundOrderStatus = {
  324. 0: '进行中',
  325. 1: '已完成',
  326. 2: '积分退款成功,微信退款失败',
  327. 3: '退款订单已取消',
  328. 4: '退款订单驳回'
  329. };
  330. export const returnMoneyStatus = {
  331. 10: '待审核',
  332. 20: '处理中',
  333. 30: '驳回退款',
  334. 40: '撤销退款',
  335. 60: '待退货(一审同意)',
  336. 65: '待确认收货(二审待审核)',
  337. 70: '退款完成'
  338. };
  339. export const auditStatus = {
  340. 1: '申请原因',
  341. 2: '商家待审核,',
  342. 3: '申请已通过',
  343. 4: '用户撤回申请',
  344. 5: '待用户待发货',
  345. 7: '待商家收货',
  346. 10: '审核通过',
  347. 20: '驳回',
  348. 25: '已收货',
  349. 30: '退款成功'
  350. };
  351. export const DJKOrderStatus = {
  352. [orderStatusEnum.WAIT_PAY]: '待支付',
  353. [orderStatusEnum.ORDER_ACCEPT]: '待使用',
  354. [orderStatusEnum.ORDER_CANCEL]: '已取消',
  355. [orderStatusEnum.ORDER_REFUNDED]: '已退款',
  356. [orderStatusEnum.ORDER_EXPIRED]: '已过期',
  357. [orderStatusEnum.ORDER_COMPLETE]: '已核销'
  358. };
  359. export enum yppStatusEnum {
  360. /**
  361. *
  362. * 待支付
  363. */
  364. WAIT_PAY = 0,
  365. /**
  366. * 已支付
  367. */
  368. WAIT_DELIVERY = 1,
  369. /**
  370. * 出票成功
  371. */
  372. SUCCESS = 4,
  373. /**
  374. * 出票失败(退款)
  375. */
  376. REFUND_FAIL = 7,
  377. /**
  378. * 超时未支付(取消)
  379. */
  380. TIMEOUT_CANCEL = 8
  381. }
  382. export const yppStatus = {
  383. [yppStatusEnum.WAIT_PAY]: '待支付',
  384. [yppStatusEnum.WAIT_DELIVERY]: '已支付',
  385. [yppStatusEnum.SUCCESS]: '出票成功',
  386. [yppStatusEnum.REFUND_FAIL]: '出票失败(退款)',
  387. [yppStatusEnum.TIMEOUT_CANCEL]: '超时未支付(取消)'
  388. };
  389. /**
  390. // 1:申请退款 2:退款成功 3:部分退款成功 4:退款失败
  391. *
  392. */
  393. export const refundStatus = {
  394. 1: '申请退款',
  395. 2: '退款成功',
  396. 3: '部分退款成功',
  397. 4: '退款失败'
  398. };
  399. /**
  400. *
  401. * 配送方式
  402. */
  403. export const dvyStatus = {
  404. 1: '快递',
  405. 2: '自提',
  406. 3: '即时配送'
  407. };
  408. export const orderColumns: NaiveUI.TableColumn<Api.delivery.OrderItemElement>[] = [
  409. {
  410. title: '商品',
  411. key: 'goods',
  412. width: 300,
  413. render: row => {
  414. const goodsNodes = [
  415. h(NImage, { src: row.pic, width: 80, height: 80 }),
  416. h('div', { class: 'ml-2 ' }, [
  417. h('div', { class: 'text-15px font-semibold' }, row.skuName),
  418. h('div', { class: 'text-gray' }, `规格:${row.spec || '--'}`)
  419. ])
  420. ];
  421. return h('div', { class: 'flex items-center' }, goodsNodes);
  422. }
  423. },
  424. {
  425. title: '单价(元)',
  426. key: 'price'
  427. // width: 100
  428. },
  429. {
  430. title: '数量',
  431. key: 'prodCount',
  432. // width: 250,
  433. render: row => {
  434. const nodes = [h('div', { class: 'mr-2' }, row.prodCount)];
  435. // if (row.refundSuccessCount) {
  436. // nodes.push(h(NTag, { class: 'ml2', type: 'success' }, () => `退款成功:${row.refundSuccessCount}`));
  437. // }
  438. // if (row.refundIngCount && !row.refundSuccessCount) {
  439. // nodes.push(h(NTag, { class: 'ml2', type: 'error' }, () => `售后处理:${row.refundIngCount}`));
  440. // }
  441. return h(NFlex, { align: 'center' }, () => nodes);
  442. }
  443. },
  444. {
  445. title: '退款成功数量',
  446. key: 'refundSuccessCount'
  447. },
  448. {
  449. title: '小计/元',
  450. key: 'productTotalAmount'
  451. }
  452. ];
  453. export const orderShipColumns: NaiveUI.TableColumn<Api.delivery.OrderItemElement>[] = [
  454. {
  455. title: '商品',
  456. key: 'goods',
  457. width: 300,
  458. render: row => {
  459. const goodsNodes = [
  460. h(NImage, { src: row.pic, width: 80, height: 80 }),
  461. h('div', { class: 'ml-2 ' }, [
  462. h('div', { class: 'text-15px font-semibold' }, row.skuName),
  463. h('div', { class: 'text-gray' }, `规格:${row.spec || '--'}`)
  464. ])
  465. ];
  466. return h('div', { class: 'flex items-center' }, goodsNodes);
  467. }
  468. },
  469. {
  470. title: '原商品数量',
  471. key: 'prodCount',
  472. width: 120,
  473. render: row => {
  474. const nodes = [h('div', { class: 'mr-2' }, row.prodCount)];
  475. // if (row.refundSuccessCount) {
  476. // nodes.push(h(NTag, { class: 'ml2', type: 'success' }, () => `退款成功:${row.refundSuccessCount}`));
  477. // }
  478. // if (row.refundIngCount && !row.refundSuccessCount) {
  479. // nodes.push(h(NTag, { class: 'ml2', type: 'error' }, () => `售后处理:${row.refundIngCount}`));
  480. // }
  481. return h(NFlex, { align: 'center' }, () => nodes);
  482. }
  483. },
  484. {
  485. title: '退款成功数量',
  486. width: 120,
  487. key: 'refundSuccessCount'
  488. },
  489. {
  490. title: '状态',
  491. key: 'status',
  492. width: 120,
  493. render: () => {
  494. return '等待发货';
  495. }
  496. },
  497. {
  498. title: '可发货数量',
  499. key: 'prodCount',
  500. width: 120,
  501. render: row => {
  502. return h('div', { class: '' }, Number(row.prodCount) - Number(row.refundSuccessCount));
  503. }
  504. }
  505. ];
  506. export const orderDJKColumns: NaiveUI.TableColumn<Api.delivery.OrderItemElement>[] = [
  507. {
  508. title: '商品',
  509. key: 'goods',
  510. width: 300,
  511. render: row => {
  512. const goodsNodes = [
  513. h(NImage, { src: row.goodsImg, width: 80, height: 80 }),
  514. h('div', { class: 'ml-2 ' }, [
  515. h('div', { class: 'text-15px font-semibold' }, row.goodsName),
  516. h('div', { class: 'text-gray' }, `规格:${row.goodsCode || '--'}`)
  517. ])
  518. ];
  519. return h('div', { class: 'flex items-center' }, goodsNodes);
  520. }
  521. },
  522. {
  523. title: '单价(元)',
  524. key: 'price',
  525. width: 100
  526. },
  527. {
  528. title: '数量',
  529. key: 'goodsNum',
  530. width: 250,
  531. render: row => {
  532. const nodes = [h('div', { class: 'mr-2' }, row.goodsNum)];
  533. if (row.refundSuccessCount) {
  534. nodes.push(h(NTag, { class: 'ml2', type: 'success' }, () => `退款成功:${row.refundSuccessCount}`));
  535. }
  536. if (row.refundIngCount && !row.refundSuccessCount) {
  537. nodes.push(h(NTag, { class: 'ml2', type: 'error' }, () => `售后处理:${row.refundIngCount}`));
  538. }
  539. return h(NFlex, { align: 'center' }, () => nodes);
  540. }
  541. },
  542. {
  543. title: '小计/元',
  544. key: 'productTotalAmount',
  545. width: 100,
  546. render: (row: any) => {
  547. return h('div', {}, (row.goodsNum * 1000 * (row.price * 1000)) / 1000000);
  548. }
  549. }
  550. ];
  551. export const orderDJKLogColumns: NaiveUI.TableColumn<Api.delivery.OrderItemElement>[] = [
  552. {
  553. title: '时间',
  554. key: 'createTime'
  555. },
  556. {
  557. title: '操作',
  558. key: 'operation'
  559. },
  560. {
  561. title: '操作员',
  562. key: 'operator'
  563. },
  564. {
  565. title: '备注',
  566. key: 'remark'
  567. }
  568. ];
  569. export const deliveryInfo: FormSchema[] = [
  570. {
  571. label: '配送方式',
  572. component: 'NGradientText',
  573. field: 'dvyMethod',
  574. render() {
  575. return h('div', {}, '快递');
  576. }
  577. },
  578. {
  579. label: '收货人姓名',
  580. component: 'NGradientText',
  581. field: 'receiver',
  582. render({ model, field }) {
  583. return h('div', {}, model[field]);
  584. }
  585. },
  586. {
  587. label: '收货人手机号',
  588. component: 'NInput',
  589. field: 'mobile',
  590. render({ model, field }) {
  591. return h('div', {}, model[field]);
  592. }
  593. },
  594. {
  595. label: '收货地址',
  596. component: 'NInput',
  597. field: 'address',
  598. render({ model, field }) {
  599. return h('div', {}, model[field]);
  600. }
  601. }
  602. ];
  603. export const refundOrderColumns: NaiveUI.TableColumn<Api.delivery.OrderItemElement>[] = [
  604. {
  605. title: '退款商品',
  606. key: 'goods',
  607. width: 300,
  608. render: row => {
  609. const goodsNodes = [
  610. h(NImage, { src: row.pic, width: 80, height: 80 }),
  611. h('div', { class: 'ml-2 ' }, [
  612. h('div', { class: 'text-15px font-semibold' }, row.skuName || '--'),
  613. h('div', { class: 'text-gray' }, `规格:${row.spec || '--'}`)
  614. ])
  615. ];
  616. return h('div', { class: 'flex items-center' }, goodsNodes);
  617. }
  618. },
  619. {
  620. title: '购买单价(元)',
  621. key: 'skuPrice',
  622. width: 100
  623. },
  624. {
  625. title: '购买数量',
  626. key: 'productCount',
  627. width: 100,
  628. render: row => {
  629. const nodes = [h('div', { class: 'mr-2' }, row.productCount)];
  630. return h(NFlex, { align: 'center' }, () => nodes);
  631. }
  632. },
  633. {
  634. title: '小计/元',
  635. key: 'skuTotalPrice',
  636. width: 100
  637. },
  638. {
  639. title: '退款数量',
  640. key: 'refundProductCount',
  641. width: 100
  642. },
  643. {
  644. title: '退款金额/元',
  645. key: 'refundSkuTotalPrice',
  646. width: 100
  647. }
  648. ];
  649. /**
  650. * 0:用户手动停止充电;1:客户归属地运营商平台停止充电;2:BMS停止充电;3:充电机设备故障;4:连接器断开;其它:自定义
  651. */
  652. export const chargeMethod = [
  653. '用户手动停止充电',
  654. '客户归属地运营商平台停止充电',
  655. 'BMS停止充电',
  656. '充电机设备故障',
  657. '连接器断开',
  658. '其它'
  659. ];
  660. export const payType = {
  661. 0: '积分支付',
  662. 1: '微信支付',
  663. 2: '支付宝'
  664. };