index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <!-- 订单管理 -->
  3. <div class="container">
  4. <div class="head-title">
  5. <span>{{ route.meta.title }} </span>
  6. <span class="head-title-right">
  7. <a-popconfirm :content="$t('lotCard.confirmTitleOrder')" :ok-text="$t('form.Confirm')"
  8. :cancel-text="$t('form.Cancel')" @ok="handleOrderDialog(record)">
  9. <a-button class="m-r-10" type="primary">{{ $t('lotCard.titleOrder') }}</a-button>
  10. </a-popconfirm>
  11. <a-popconfirm :content="$t('lotCard.confirmTitleCancelOrder')" :ok-text="$t('form.Confirm')"
  12. :cancel-text="$t('form.Cancel')" @ok="handleUnsubscribeDialog(record)">
  13. <a-button type="primary">{{ $t('lotCard.titleCancelOrder') }}</a-button>
  14. </a-popconfirm>
  15. </span>
  16. </div>
  17. <!-- 搜索条件区 -->
  18. <div class="search-section">
  19. <a-form :model="searchForm" ref="formRef" layout="inline">
  20. <a-form-item field="ICCID" :label="$t('lotCard.iccid')" :validate-trigger="['change', 'input', 'blur']"
  21. :rules="[{ required: true, message: $t('lotCard.please') + $t('lotCard.iccid') }]">
  22. <a-input v-model="searchForm.ICCID" :placeholder="$t('lotCard.please') + $t('lotCard.iccid')"
  23. allow-clear />
  24. </a-form-item>
  25. <a-form-item field="dataBundleId" :label="$t('lotCard.dataBundleId')">
  26. <a-input v-model="searchForm.cardNumber"
  27. :placeholder="$t('lotCard.please') + $t('lotCard.dataBundleId')" allow-clear />
  28. </a-form-item>
  29. <a-form-item>
  30. <a-space>
  31. <a-button type="primary" @click="handleSearch">{{ $t('form.Search') }}</a-button>
  32. <a-button @click="resetSearch">{{ $t('form.Reset') }}</a-button>
  33. </a-space>
  34. </a-form-item>
  35. </a-form>
  36. </div>
  37. <a-table row-key="id" :data="dataSource" :columns="columns" :pagination="pagination"
  38. :row-selection="rowSelection" v-model:selectedKeys="selectedKeys" :scroll="{ x: 'auto' }">
  39. <template #id="{ record }">
  40. <!-- 订购生成订单 -->
  41. <a-popconfirm :content="$t('lotCard.confirmTitleOrder')" :ok-text="$t('form.Confirm')"
  42. :cancel-text="$t('form.Cancel')" @ok="handleOrderDialog(record)">
  43. <a class="a-link" href="javascript:;" style="margin-right: 1rem">{{
  44. $t('lotCard.titleOrder') }}</a>
  45. </a-popconfirm>
  46. <!-- 取消订单-退订 -->
  47. <a-popconfirm :content="$t('lotCard.confirmTitleCancelOrder')" :ok-text="$t('form.Confirm')"
  48. :cancel-text="$t('form.Cancel')" @ok="handleUnsubscribeDialog(record)">
  49. <a class="a-link" href="javascript:;" style="margin-right: 1rem">{{ $t('lotCard.titleCancelOrder')
  50. }}</a>
  51. </a-popconfirm>
  52. </template>
  53. </a-table>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { onMounted, ref, reactive, getCurrentInstance, nextTick } from "vue";
  58. import { useRoute } from "vue-router";
  59. import { columns } from "./config";
  60. import { Message, Notification } from '@arco-design/web-vue'
  61. import { orderList, setOrderDataPlan, orderCancel } from "@/api/path/lotCard.api"
  62. const { proxy } = getCurrentInstance()
  63. const formRef = ref()
  64. const searchForm = ref({
  65. "orderId": "",
  66. "is_Refuel": "",
  67. "refuelingId": "",
  68. "dataBundleId": "",
  69. "quantity": 0,
  70. "ICCID": "",
  71. "sendLang": "",
  72. "price": "",
  73. "totalAmount": "",
  74. "currency": "",
  75. "userId": 0,
  76. "current": 1,
  77. "size": 10
  78. });
  79. const dataSource = ref([]);
  80. const route = useRoute();
  81. const pagination = ref({
  82. total: 0,
  83. pageSize: 10,
  84. current: 1,
  85. })
  86. const rowSelection = reactive({
  87. type: 'checkbox',
  88. showCheckedAll: true,
  89. onlyCurrent: false,
  90. });
  91. const selectedKeys = ref([])
  92. const dialogRef = ref()
  93. const intData = async () => {
  94. const param = {
  95. current: pagination.value.current,
  96. size: pagination.value.pageSize,
  97. ...searchForm.value,
  98. }
  99. const { data } = await orderList(param)
  100. dataSource.value = data.records || []
  101. pagination.value.total = data.total
  102. }
  103. // 订购生成订单
  104. const handleOrderDialog = async (info) => {
  105. let paramList = []
  106. if (selectedKeys.value.length > 0) {
  107. const list = dataSource.value.filter(item => selectedKeys.value.some(item2 => item.id === item2))
  108. paramList = list.map(item => {
  109. return {
  110. ICCID: item.ICCID,
  111. dataBundleId: item.dataBundleId,
  112. source: item.source,
  113. quantity: 1
  114. }
  115. })
  116. }
  117. if (info && Object.keys(info).length > 0) {
  118. paramList = [{
  119. ICCID: info.ICCID,
  120. dataBundleId: info.dataBundleId,
  121. source: info.source,
  122. quantity: 1
  123. }]
  124. }
  125. if (selectedKeys.value.length > 0 || info && Object.keys(info).length > 0) {
  126. const { code, data } = await setOrderDataPlan(paramList)
  127. if (code == 200) {
  128. Message.success({
  129. content: data,
  130. duration: 2000,
  131. })
  132. }
  133. } else {
  134. Message.warning({
  135. content: $t('lotCard.tipsOrder'),
  136. duration: 2000,
  137. })
  138. }
  139. }
  140. // 退订
  141. const handleUnsubscribeDialog = async (record) => {
  142. // 订阅关系状态
  143. // 1:未激活
  144. // 2: 已过期
  145. // 3: 已激活99:已退款
  146. let param = {}
  147. let statusFlag = true
  148. if (selectedKeys.value.length > 0) {
  149. const list = dataSource.value.filter(item => selectedKeys.value.some(item2 => item.id === item2))
  150. list.forEach(item => {
  151. if (!(item.status == 2 || item.status == 3)) statusFlag = false
  152. })
  153. param = {
  154. ids: selectedKeys.value
  155. }
  156. }
  157. if (record && record.id && !(record.status == 2 || record.status == 3)) {
  158. statusFlag = false
  159. param = {
  160. ids: [record.id]
  161. }
  162. }
  163. if ((selectedKeys.value.length > 0 || record && record.id) && statusFlag) {
  164. const { code, data } = await orderCancel(param)
  165. if (code == 200) {
  166. Message.success({
  167. content: data,
  168. duration: 2000,
  169. })
  170. }
  171. } else {
  172. Message.warning({
  173. content: $t('lotCard.tipsOrder'),
  174. duration: 2000,
  175. })
  176. }
  177. };
  178. const handleSearch = () => {
  179. formRef.value.validate((errors) => {
  180. if (!errors) {
  181. intData()
  182. }
  183. });
  184. }
  185. const resetSearch = () => {
  186. proxy.$refs.formRef.resetFields()
  187. intData()
  188. }
  189. onMounted(() => {
  190. intData()
  191. })
  192. </script>
  193. <style scoped lang="less">
  194. .head-title-right {
  195. .m-r-10 {
  196. margin-right: 10px;
  197. }
  198. }
  199. .search-section {
  200. margin-top: 20px;
  201. margin-bottom: 20px;
  202. }
  203. .container {
  204. .head-title {
  205. display: flex;
  206. justify-content: space-between;
  207. }
  208. .form-row {
  209. display: flex;
  210. .form-row-col {
  211. width: 25%;
  212. display: flex;
  213. align-items: center;
  214. .form-row-label {
  215. width: 120px;
  216. text-align: right;
  217. }
  218. }
  219. }
  220. }
  221. </style>