cameraList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <BasicTable @register="registerTable" @row-click="handlerowClick" @expand="handleExpanded">
  3. <template #toolbar>
  4. <a-button type="primary" @click="exportExcel" v-if="getCheckPerm('camera-order-export')">
  5. 导出</a-button
  6. >
  7. </template>
  8. <template #expandedRowRender="{ record }">
  9. <div>
  10. <a-descriptions title="订单信息" :column="2">
  11. <a-descriptions-item label="下单时间"> {{ record.orderTime }}</a-descriptions-item>
  12. <a-descriptions-item label="订单号"> {{ record.orderSn }} </a-descriptions-item>
  13. <a-descriptions-item label="用户账号"> {{ record.userName }} </a-descriptions-item>
  14. <a-descriptions-item label="订单状态"> {{ record.paymentStatus }} </a-descriptions-item>
  15. <a-descriptions-item label="手机号码"> {{ record.shipMobile }} </a-descriptions-item>
  16. <a-descriptions-item label="地址">
  17. {{ record.shipAreaPath }}{{ record.shipAddress }}
  18. </a-descriptions-item>
  19. <a-descriptions-item label="收件人"> {{ record.shipName }} </a-descriptions-item>
  20. </a-descriptions>
  21. <a-descriptions title="商品信息" :column="2">
  22. <a-descriptions-item label="" :span="2" v-for="goods in record.itemGoods" :key="goods">
  23. <div style="display: flex; align-items: center">
  24. <TableImg
  25. style="margin: 0"
  26. :size="120"
  27. :simpleShow="true"
  28. :imgList="[goods.goodsPic]"
  29. />
  30. <div style="margin-left: 30px">
  31. <p>{{ goods.goodsName }}</p>
  32. <p>{{ goods.goodsPrice }}* {{ goods.goodsCount }}</p>
  33. </div>
  34. </div>
  35. </a-descriptions-item>
  36. </a-descriptions>
  37. </div>
  38. </template>
  39. <template #bodyCell="{ column, record }">
  40. <template v-if="column.key === 'action'">
  41. <TableAction
  42. stopButtonPropagation
  43. :actions="[
  44. {
  45. label: '删除',
  46. //icon: 'ic:outline-delete-outline',
  47. onClick: handleDelete.bind(null, record),
  48. },
  49. ]"
  50. :dropDownActions="[
  51. {
  52. label: '启用',
  53. popConfirm: {
  54. title: '是否启用?',
  55. confirm: handleOpen.bind(null, record),
  56. },
  57. },
  58. ]"
  59. />
  60. </template>
  61. </template>
  62. </BasicTable>
  63. </template>
  64. <script lang="ts">
  65. import { defineComponent, h, reactive, ref } from 'vue';
  66. import {
  67. BasicTable,
  68. useTable,
  69. TableAction,
  70. BasicColumn,
  71. TableImg,
  72. FormProps,
  73. } from '/@/components/Table';
  74. import { PageWrapper } from '/@/components/Page';
  75. import { Time } from '/@/components/Time';
  76. import { Descriptions } from 'ant-design-vue';
  77. import { useI18n } from '/@/hooks/web/useI18n';
  78. import { useMessage } from '/@/hooks/web/useMessage';
  79. import { Switch } from 'ant-design-vue';
  80. import { downloadByData } from '/@/utils/file/download';
  81. import { CameraList, CameraItem, CameraExport } from '/@/api/order';
  82. import { usePermissionStore } from '/@/store/modules/permission';
  83. import { cameraColumns, orderSearchForm } from '../account/details/data';
  84. export default defineComponent({
  85. components: {
  86. BasicTable,
  87. TableAction,
  88. PageWrapper,
  89. TableImg,
  90. [Descriptions.name]: Descriptions,
  91. [Descriptions.Item.name]: Descriptions.Item,
  92. },
  93. setup() {
  94. const { t } = useI18n();
  95. const isSearch = ref(false);
  96. const { createConfirm } = useMessage();
  97. const permissionStore = usePermissionStore();
  98. const { getCheckPerm } = permissionStore;
  99. const expandedItem = reactive({});
  100. const [registerTable] = useTable({
  101. api: CameraList,
  102. title: '相机列表',
  103. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  104. columns: cameraColumns,
  105. useSearchForm: true,
  106. formConfig: orderSearchForm,
  107. showIndexColumn: false,
  108. showTableSetting: true,
  109. canResize: true,
  110. expandRowByClick: true,
  111. rowKey: 'id',
  112. beforeFetch: (T) => {
  113. const { ctivated, tradeNum, userName, orderSn } = T;
  114. if (ctivated || tradeNum || userName || orderSn) {
  115. isSearch.value = true;
  116. } else {
  117. isSearch.value = false;
  118. }
  119. if (T.ctivated) {
  120. T.startTime = T.ctivated[0];
  121. T.endTime = T.ctivated[1];
  122. }
  123. return T;
  124. },
  125. fetchSetting: {
  126. pageField: 'pageNum',
  127. sizeField: 'pageSize',
  128. listField: 'list',
  129. totalField: 'total',
  130. },
  131. });
  132. function handleDelete(record: Recordable) {
  133. console.log('点击了删除', record);
  134. }
  135. function handleOpen(record: Recordable) {
  136. console.log('点击了启用', record);
  137. }
  138. function handleExpanded(_, record: Recordable) {
  139. handlerowClick(record);
  140. }
  141. function exportExcel() {
  142. createConfirm({
  143. iconType: 'warning',
  144. title: () => h('span', '温馨提示'),
  145. content: () => h('span', isSearch.value ? '确认导出搜索结果?' : '确认导出全部?'),
  146. onOk: async () => {
  147. CameraExport();
  148. },
  149. });
  150. }
  151. function handlerowClick(record: Recordable) {
  152. CameraItem({ id: record.id }).then((res) => {
  153. if (res.length) {
  154. let itemGoods = res;
  155. Reflect.set(record, 'itemGoods', itemGoods);
  156. // Reflect.set(record, 'goodsName', item.goodsName);
  157. // Reflect.set(record, 'goodsPic', item.goodsPic);
  158. // Reflect.set(record, 'goodsPrice', item.goodsPrice);
  159. }
  160. });
  161. }
  162. return {
  163. registerTable,
  164. handleDelete,
  165. handleOpen,
  166. exportExcel,
  167. handlerowClick,
  168. expandedItem,
  169. handleExpanded,
  170. getCheckPerm,
  171. };
  172. },
  173. });
  174. </script>