index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="app-container h-full flex flex-1 flex-col">
  3. <!-- 搜索 -->
  4. <page-search
  5. ref="searchRef"
  6. :search-config="searchConfig"
  7. @query-click="handleQueryClick"
  8. @reset-click="handleResetClick"
  9. >
  10. <template #orderStatus="scope">
  11. <Dict v-model="scope.formData[scope.prop]" code="order_status" v-bind="scope.attrs" />
  12. </template>
  13. </page-search>
  14. <!-- 列表 -->
  15. <page-content
  16. ref="contentRef"
  17. :content-config="contentConfig"
  18. @add-click="handleAddClick"
  19. @export-click="handleExportClick"
  20. @search-click="handleSearchClick"
  21. @toolbar-click="handleToolbarClick"
  22. @operate-click="handleOperateClick"
  23. @filter-change="handleFilterChange"
  24. >
  25. <template #orderStatus="scope">
  26. <DictLabel v-model="scope.row[scope.prop]" code="order_status" />
  27. </template>
  28. <template #orderType="scope">
  29. <DictLabel v-model="scope.row[scope.prop]" code="order_type" />
  30. </template>
  31. </page-content>
  32. <!-- 新增 -->
  33. <page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
  34. <template #orderStatus="scope">
  35. <Dict v-model="scope.formData[scope.prop]" code="order_status" v-bind="scope.attrs" />
  36. </template>
  37. <template #orderType="scope">
  38. <Dict v-model="scope.formData[scope.prop]" code="order_type" v-bind="scope.attrs" />
  39. </template>
  40. </page-modal>
  41. <!-- 编辑 -->
  42. <page-modal
  43. ref="editModalRef"
  44. :modal-config="editModalConfig"
  45. @submit-click="handleSubmitClick"
  46. >
  47. <template #orderStatus="scope">
  48. <Dict v-model="scope.formData[scope.prop]" code="order_status" v-bind="scope.attrs" />
  49. </template>
  50. <template #orderType="scope">
  51. <Dict v-model="scope.formData[scope.prop]" code="order_type" v-bind="scope.attrs" />
  52. </template>
  53. </page-modal>
  54. </div>
  55. </template>
  56. <script setup lang="ts">
  57. defineOptions({ name: "UserOrderInfo" });
  58. import UserOrderInfoAPI, {
  59. UserOrderInfoForm,
  60. UserOrderInfoPageQuery,
  61. } from "@/api/orderManage/user-order-info-api";
  62. import type { IObject, IModalConfig, IContentConfig, ISearchConfig } from "@/components/CURD/types";
  63. import usePage from "@/components/CURD/usePage";
  64. // 组合式 CRUD
  65. const {
  66. searchRef,
  67. contentRef,
  68. addModalRef,
  69. editModalRef,
  70. handleQueryClick,
  71. handleResetClick,
  72. handleAddClick,
  73. handleEditClick,
  74. handleSubmitClick,
  75. handleExportClick,
  76. handleSearchClick,
  77. handleFilterChange,
  78. } = usePage();
  79. // 搜索配置
  80. const searchConfig: ISearchConfig = reactive({
  81. permPrefix: "orderManage:user-order-info",
  82. formItems: [
  83. {
  84. type: "custom",
  85. slotName: "orderStatus",
  86. label: "订单状态", // 1 待支付 2 已支付 3 已取消 4 已退款
  87. prop: "orderStatus",
  88. attrs: {
  89. placeholder: "选择订单状态",
  90. clearable: true,
  91. style: { width: "200px" },
  92. },
  93. },
  94. {
  95. type: "input",
  96. label: "订单编号",
  97. prop: "orderNo",
  98. attrs: {
  99. placeholder: "请输入订单编号",
  100. clearable: true,
  101. style: { width: "200px" },
  102. },
  103. },
  104. {
  105. type: "input",
  106. label: "手机号",
  107. prop: "phone",
  108. attrs: {
  109. placeholder: "请输入手机号",
  110. clearable: true,
  111. style: { width: "200px" },
  112. },
  113. },
  114. ],
  115. });
  116. // 列表配置
  117. const contentConfig: IContentConfig<UserOrderInfoPageQuery> = reactive({
  118. // 权限前缀
  119. permPrefix: "orderManage:user-order-info",
  120. table: {
  121. border: true,
  122. highlightCurrentRow: true,
  123. },
  124. // 主键
  125. pk: "id",
  126. // 列表查询接口
  127. indexAction: UserOrderInfoAPI.getPage,
  128. // 删除接口
  129. deleteAction: UserOrderInfoAPI.deleteByIds,
  130. // 数据解析函数
  131. parseData(res: any) {
  132. return {
  133. total: res.total,
  134. list: res.list,
  135. };
  136. },
  137. // 分页配置
  138. pagination: {
  139. background: true,
  140. layout: "total, sizes, prev, pager, next, jumper",
  141. pageSize: 20,
  142. pageSizes: [10, 20, 30, 50],
  143. },
  144. // 工具栏配置
  145. // toolbar: ["add", "delete"],
  146. defaultToolbar: ["refresh", "filter"],
  147. // 表格列配置
  148. cols: [
  149. { type: "selection", width: 55, align: "center" },
  150. { label: "订单编号", prop: "orderNo" },
  151. { label: "订单金额", prop: "orderMoney" },
  152. { label: "订单剩余金额", prop: "lastMoney" },
  153. { label: "支付时间", prop: "payTime" },
  154. { label: "第三方支付单号", prop: "outTradeNo" },
  155. { label: "手机号", prop: "phone" },
  156. {
  157. label: "订单状态", // 1 待支付 2 已支付 3 已取消 4 已退款
  158. prop: "orderStatus",
  159. templet: "custom",
  160. slotName: "orderStatus",
  161. },
  162. {
  163. label: "订单类型", //1 微信 2 第三方
  164. prop: "orderType",
  165. templet: "custom",
  166. slotName: "orderType",
  167. },
  168. { label: "退款金额", prop: "refundMoney" },
  169. { label: "退款时间", prop: "refundTime" },
  170. { label: "备注", prop: "remark" },
  171. { label: "创建时间", prop: "createTime" },
  172. ],
  173. });
  174. // 新增配置
  175. const addModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
  176. // 权限前缀
  177. permPrefix: "orderManage:user-order-info",
  178. // 主键
  179. pk: "id",
  180. // 弹窗配置
  181. dialog: {
  182. title: "新增",
  183. width: 800,
  184. draggable: true,
  185. },
  186. form: {
  187. labelWidth: 100,
  188. },
  189. // 表单项配置
  190. formItems: [
  191. {
  192. type: "input",
  193. attrs: {
  194. placeholder: "订单编号",
  195. },
  196. label: "订单编号",
  197. prop: "orderNo",
  198. },
  199. {
  200. type: "input",
  201. attrs: {
  202. placeholder: "订单金额",
  203. },
  204. label: "订单金额",
  205. prop: "orderMoney",
  206. },
  207. {
  208. type: "input",
  209. attrs: {
  210. placeholder: "订单剩余金额",
  211. },
  212. label: "订单剩余金额",
  213. prop: "lastMoney",
  214. },
  215. {
  216. type: "input",
  217. attrs: {
  218. placeholder: "支付时间",
  219. },
  220. label: "支付时间",
  221. prop: "payTime",
  222. },
  223. {
  224. type: "input",
  225. attrs: {
  226. placeholder: "第三方支付单号",
  227. },
  228. label: "第三方支付单号",
  229. prop: "outTradeNo",
  230. },
  231. {
  232. type: "custom",
  233. label: "订单状态", // 1 待支付 2 已支付 3 已取消 4 已退款
  234. prop: "orderStatus",
  235. slotName: "orderStatus",
  236. attrs: {
  237. placeholder: "订单状态",
  238. style: { width: "100%" },
  239. },
  240. },
  241. {
  242. type: "custom",
  243. label: "订单类型", // 1 微信 2 第三方
  244. prop: "orderType",
  245. slotName: "orderType",
  246. attrs: {
  247. placeholder: "订单类型",
  248. style: { width: "100%" },
  249. },
  250. },
  251. {
  252. type: "input",
  253. attrs: {
  254. placeholder: "退款金额",
  255. },
  256. label: "退款金额",
  257. prop: "refundMoney",
  258. },
  259. {
  260. type: "input",
  261. attrs: {
  262. placeholder: "退款时间",
  263. },
  264. label: "退款时间",
  265. prop: "refundTime",
  266. },
  267. {
  268. type: "input",
  269. attrs: {
  270. placeholder: "备注",
  271. },
  272. label: "备注",
  273. prop: "remark",
  274. },
  275. {
  276. type: "input",
  277. attrs: {
  278. placeholder: "创建时间",
  279. },
  280. label: "创建时间",
  281. prop: "createTime",
  282. },
  283. ],
  284. // 提交函数
  285. formAction: (data: UserOrderInfoForm) => {
  286. if (data.id) {
  287. // 编辑
  288. return UserOrderInfoAPI.update(data.id as string, data);
  289. } else {
  290. // 新增
  291. return UserOrderInfoAPI.create(data);
  292. }
  293. },
  294. });
  295. // 编辑配置
  296. const editModalConfig: IModalConfig<UserOrderInfoForm> = reactive({
  297. permPrefix: "orderManage:user-order-info",
  298. component: "drawer",
  299. drawer: {
  300. title: "编辑",
  301. size: 500,
  302. },
  303. pk: "id",
  304. formAction(data: any) {
  305. return UserOrderInfoAPI.update(data.id as string, data);
  306. },
  307. formItems: addModalConfig.formItems, // 复用新增的表单项
  308. });
  309. // 处理操作按钮点击
  310. const handleOperateClick = (data: IObject) => {
  311. if (data.name === "edit") {
  312. handleEditClick(data.row, async () => {
  313. return await UserOrderInfoAPI.getFormData(data.row.id);
  314. });
  315. }
  316. };
  317. // 处理工具栏按钮点击(删除等)
  318. const handleToolbarClick = (name: string) => {
  319. console.log(name);
  320. };
  321. </script>