index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <style scoped lang="scss">
  2. .system-container {
  3. :deep(.el-card__body) {
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: space-between;
  7. flex: 1;
  8. overflow: auto;
  9. .el-table {
  10. flex: 1;
  11. }
  12. }
  13. }
  14. .page-content {
  15. margin-bottom: 20px;
  16. }
  17. .page-pager {
  18. background-color: #fff;
  19. height: 24px;
  20. }
  21. </style>
  22. <template>
  23. <div class="system-container layout-padding">
  24. <el-card shadow="hover" class="layout-padding-auto">
  25. <el-form
  26. :model="state.formQuery"
  27. ref="queryRef"
  28. size="default" label-width="0px" class="mt5 mb5">
  29. <el-input
  30. v-model="state.formQuery.phone"
  31. placeholder="用户手机号"
  32. clearable
  33. @blur="loadData(true)"
  34. class="wd150 mr10">
  35. </el-input>
  36. <ext-d-select
  37. v-model="state.formQuery.status"
  38. placeholder="发票状态"
  39. type="Invoice.status"
  40. clearable
  41. @blur="loadData(true)"
  42. class="wd150 mr10">
  43. </ext-d-select>
  44. <ext-d-select
  45. v-model="state.formQuery.invoiceType"
  46. placeholder="发票类型"
  47. type="Invoice.type"
  48. clearable
  49. @blur="loadData(true)"
  50. class="wd150 mr10">
  51. </ext-d-select>
  52. <el-input
  53. v-model="state.formQuery.email"
  54. placeholder="接收发票邮箱"
  55. clearable
  56. @blur="loadData(true)"
  57. class="wd150 mr10">
  58. </el-input>
  59. <el-input
  60. v-model="state.formQuery.invoiceTitle"
  61. placeholder="发票抬头名称"
  62. clearable
  63. @blur="loadData(true)"
  64. class="wd150 mr10">
  65. </el-input>
  66. <el-input
  67. v-model="state.formQuery.taxId"
  68. placeholder="公司税号"
  69. clearable
  70. @blur="loadData(true)"
  71. class="wd150 mr10">
  72. </el-input>
  73. <el-input
  74. v-model="state.formQuery.biller"
  75. placeholder="开票人"
  76. clearable
  77. @blur="loadData(true)"
  78. class="wd150 mr10">
  79. </el-input>
  80. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  81. <SvgIcon name="ele-Search"/>
  82. 查询
  83. </el-button>
  84. </el-form>
  85. <el-table
  86. border
  87. stripe="stripe"
  88. :height="state.tableData.height"
  89. highlight-current-row
  90. current-row-key="id"
  91. row-key="id"
  92. :data="state.tableData.data"
  93. v-loading="state.tableData.loading"
  94. @selection-change="handleTableSelectionChange"
  95. @sort-change="handleTableSortChange">
  96. <template #empty>
  97. <el-empty></el-empty>
  98. </template>
  99. <el-table-column
  100. v-for="field in state.tableData.columns"
  101. :key="field.prop"
  102. :type="field.type"
  103. :label="field.label"
  104. :column-key="field.prop"
  105. :width="field.width"
  106. :min-width="field.minWidth"
  107. :fixed="field.fixed"
  108. :sortable="field.sortable"
  109. :show-overflow-tooltip="!field.fixed&&field.width>150"
  110. >
  111. <template #default="{row}">
  112. <template v-if="field.prop==='expand'">
  113. <el-row class="pd10">
  114. <el-col :span="12">
  115. <h4 class="pd5">关联订单明细</h4>
  116. <el-table :data="row.orderDetails" width="400" border>
  117. <el-table-column label="充电订单" prop="startChargeSeq"/>
  118. <el-table-column label="订单总金额" prop="totalMoney">
  119. <template #default="{row}">{{ u.fmt.fmtMoney(row.totalMoney) }}</template>
  120. </el-table-column>
  121. <el-table-column label="总电量/度" prop="totalPower"/>
  122. <el-table-column label="电费" prop="elecMoney">
  123. <template #default="{row}">{{ u.fmt.fmtMoney(row.elecMoney) }}</template>
  124. </el-table-column>
  125. <el-table-column label="服务费" prop="serviceMoney">
  126. <template #default="{row}">{{ u.fmt.fmtMoney(row.serviceMoney) }}</template>
  127. </el-table-column>
  128. <el-table-column label="服务费优惠" prop="serviceMoneyDiscount">
  129. <template #default="{row}">{{ u.fmt.fmtMoney(row.serviceMoneyDiscount) }}</template>
  130. </el-table-column>
  131. </el-table>
  132. </el-col>
  133. </el-row>
  134. </template>
  135. <template v-else-if="field.prop==='status'">
  136. <ext-d-label type="Invoice.status" :model-value="row[field.prop]"></ext-d-label>
  137. <!-- <p style="padding-left: 2em;" v-html="row[field.prop]"></p>-->
  138. </template>
  139. <template v-else-if="field.prop==='invoiceType'">
  140. <ext-d-label type="Invoice.type" :model-value="row[field.prop]"></ext-d-label>
  141. <!-- <p style="padding-left: 2em;" v-html="row[field.prop]"></p>-->
  142. </template>
  143. <template v-else-if="field.prop==='totalMoney'">
  144. {{ u.fmt.fmtMoney(row[field.prop]) }}
  145. </template>
  146. <template v-else-if="field.prop==='invoiceAmount'">
  147. {{ u.fmt.fmtMoney(row[field.prop]) }}
  148. </template>
  149. <template v-else-if="field.prop==='elecMoney'">
  150. {{ u.fmt.fmtMoney(row[field.prop]) }}
  151. </template>
  152. <template v-else-if="field.prop==='serviceMoney'">
  153. {{ u.fmt.fmtMoney(row[field.prop]) }}
  154. </template>
  155. <template v-else-if="field.prop==='action'">
  156. <el-button v-if="row.status===0" v-auth="'invoice.modify'" size="small" plain type="warning" @click="handleInvice(row)">开票</el-button>
  157. <el-button v-if="row.status===0" v-auth="'invoice.modify'" size="small" plain type="danger" @click="handleCancelInvoice(row)">取消</el-button>
  158. <el-button v-if="row.status===1" v-auth="'invoice.modify'" size="small" plain type="success" @click="previewInvoice(row)">查看</el-button>
  159. </template>
  160. <template v-else>
  161. <div>{{ row[field.prop] }}</div>
  162. </template>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  167. </el-card>
  168. </div>
  169. <InvoiceDialog ref="invoiceDialogRef" @refresh="loadData(true)"/>
  170. <canvas ref="pdfViewer"></canvas>
  171. </template>
  172. <script setup lang="ts" name="InvoiceList">
  173. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  174. import {$body, $get} from "/@/utils/request";
  175. import {Msg} from "/@/utils/message";
  176. import u from "/@/utils/u"
  177. import ExtPage from '/@/components/form/ExtPage.vue'
  178. import mittBus from '/@/utils/mitt';
  179. import ExtDSelect from "/@/components/form/ExtDSelect.vue";
  180. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  181. const InvoiceDialog = defineAsyncComponent(() => import("/@/views/admin/invoice/dialog.vue"));
  182. // import pdfjsLib from 'pdfjs-dist'
  183. //定义引用
  184. const queryRef = ref();
  185. const invoiceDialogRef = ref();
  186. const pdfViewer = ref()
  187. //定义变量
  188. const state = reactive({
  189. formQuery: {
  190. status:0
  191. },
  192. pageQuery: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. total: 0
  196. },
  197. tableData: {
  198. height: 500,
  199. data: [] as Array<any>,
  200. loading: false,
  201. columns: [
  202. {type: 'expand', prop: 'expand', width: 30, fixed: 'left'},
  203. {label: '用户手机号', prop: 'mobilePhone', align: 'center', fixed: 'left', width: 120},
  204. {label: '发票ID', prop: 'id', align: 'center', fixed: 'left', width: 110},
  205. {label: '发票申请单号', prop: 'applyId', align: 'center', fixed: 'left', width: 130},
  206. {label: '发票状态', prop: 'status', align: 'center', fixed: 'left', width: 100},
  207. {label: '发票金额', prop: 'invoiceAmount', resizable: true, width: 90},
  208. {label: '订单总额', prop: 'totalMoney', resizable: true, width: 90},
  209. {label: '总服务费', prop: 'serviceMoney', resizable: true, width: 90},
  210. {label: '服务费优惠', prop: 'serviceMoneyDiscount', resizable: true, width: 105},
  211. {label: '开票人', prop: 'biller', resizable: true, width: 80},
  212. {label: '公司税号', prop: 'taxId', resizable: true, width: 110},
  213. {label: '接收发票邮箱', prop: 'email', resizable: true, width: 120},
  214. {label: '电话', prop: 'phone', resizable: true, width: 90},
  215. {label: '发票类型', prop: 'invoiceType', resizable: true, width: 90},
  216. {label: '发票抬头', prop: 'invoiceTitle', resizable: true, width: 110},
  217. /*
  218. {label: '公司地址', prop: 'address', resizable: true, width: 130},
  219. {label: '开户银行', prop: 'bankName', resizable: true, width: 130},
  220. {label: '银行账户', prop: 'bankAccount', resizable: true},
  221. {label: '税额详情信息', prop: 'taxInfo', resizable: true, width: 150},
  222. */
  223. {label: '备注', prop: 'remark', resizable: true},
  224. {label: '创建时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 170},
  225. {label: '更新时间', prop: 'updateTime', sortable: 'custom', resizable: true, width: 170},
  226. {
  227. label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
  228. }
  229. ],
  230. },
  231. })
  232. // 监听双向绑定 modelValue 的变化
  233. // watch(
  234. // () => state.pageIndex,
  235. // () => {
  236. //
  237. // }
  238. // );
  239. //生命周期钩子
  240. onBeforeMount(() => {
  241. })
  242. onMounted(() => {
  243. loadData();
  244. nextTick(() => {
  245. let bodyHeight = document.body.clientHeight;
  246. let queryHeight = queryRef.value.$el.clientHeight;
  247. state.tableData.height = bodyHeight - queryHeight - 320
  248. })
  249. mittBus.on("invoice.refresh", () => {
  250. loadData();
  251. })
  252. });
  253. onBeforeUnmount(() => {
  254. mittBus.off("invoice.refresh")
  255. })
  256. //region 方法区
  257. // 初始化表格数据
  258. const loadData = (refresh: boolean = false) => {
  259. if (refresh) {
  260. state.pageQuery.pageNum = 1;
  261. }
  262. state.tableData.loading = true;
  263. $body(`/finance/listInvoice`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  264. let {list, total} = res;
  265. state.tableData.data = list;
  266. state.pageQuery.total = total;
  267. state.tableData.loading = false;
  268. }).catch(e => {
  269. console.error(e)
  270. state.tableData.loading = false;
  271. })
  272. };
  273. const handleInvice = (row: any) => {
  274. Msg.confirm("请确认是否开票?").then(()=>{
  275. $get(`/finance/handleInvoice/${row.id}`).then((res: any) => {
  276. Msg.message("开票成功")
  277. loadData(true)
  278. }).catch(e => {
  279. console.error(e)
  280. })
  281. })
  282. }
  283. const previewInvoice = (row: any) => {
  284. $get(`/finance/downloadInvoice/${row.id}`).then((res: any) => {
  285. console.log(res)
  286. let {downloadUrl} = res;
  287. if (downloadUrl) {
  288. window.open(downloadUrl, "_blank")
  289. // doPriview(downloadUrl)
  290. }
  291. }).catch(e => {
  292. console.error(e)
  293. })
  294. }
  295. /*
  296. const doPriview=async (url:string) =>{
  297. const canvas = pdfViewer.value;
  298. const loadingTask = pdfjsLib.getDocument(url)
  299. const pdf = await loadingTask.promise
  300. const page = await pdf.getPage(1)
  301. const viewport = page.getViewport({ scale: 1.0 })
  302. const context = canvas.getContext('2d')
  303. canvas.height = viewport.height
  304. canvas.width = viewport.width
  305. const renderTask = page.render({
  306. canvasContext: context,
  307. viewport: viewport
  308. })
  309. await renderTask.promise
  310. }*/
  311. // 打开修改用户弹窗
  312. const onRowClick = (type: string, row: any) => {
  313. invoiceDialogRef.value.open(type, row);
  314. };
  315. const handleTableSelectionChange = (selection: any) => {
  316. console.log("handleTableSelectionChange>>", selection)
  317. // emit("on-check-change", selection)
  318. }
  319. const handleTableSortChange = (column, prop, order) => {
  320. console.log("handleTableSortChange>>", column, prop, order)
  321. // emit("on-sort-change", column)
  322. }
  323. const handleCancelInvoice = (row:any) => {
  324. Msg.confirm("请确认是否取消开票?").then(()=>{
  325. $get(`/finance/cancelApplyInvoice/${row.id}`).then((res: any) => {
  326. Msg.message("取消成功")
  327. loadData(true)
  328. }).catch(e => {
  329. console.error(e)
  330. })
  331. })
  332. }
  333. //endregion
  334. // 暴露变量
  335. // defineExpose({
  336. // loadData,
  337. // });
  338. </script>