remove unused

This commit is contained in:
AceDataCloud committed 2023-04-07 13:05:35 +08:00
1 parent 301dab1ca5
commit ea1c3413a5
88 files changed
+29 -5766

No files matched your search

-208
View File
@@ -1,208 +0,0 @@
<template>
<el-form label-width="100px">
<el-form-item :label="$t('application.field.service')">
<span v-if="application.type === applicationType.API">
{{ application?.api?.title }}
</span>
<span v-if="application.type === applicationType.PROXY">
{{ application?.proxy?.title }}
</span>
</el-form-item>
<el-form-item :label="$t('application.field.package')">
<el-radio-group v-if="application.type === applicationType.API" v-model="form.packageId">
<el-radio-button v-for="(pkg, pkgIndex) in application?.api?.packages" :key="pkgIndex" :label="pkg.id">
{{ pkg.amount }}{{ $t(`api.unit.${application?.api?.unit}`) }}
</el-radio-button>
<el-radio-button label="custom">
{{ $t('application.button.custom') }}
</el-radio-button>
</el-radio-group>
<el-radio-group v-else-if="application.type === applicationType.PROXY" v-model="form.packageId">
<el-radio-button v-for="(pkg, pkgIndex) in application?.proxy?.packages" :key="pkgIndex" :label="pkg.id">
{{ pkg.amount }}{{ $t(`proxy.unit.${application?.proxy?.unit}`) }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.packageId === 'custom'" :label="$t('application.field.amount')">
<el-input-number v-model="form.amount" :min="1" :max="10000" controls-position="right" />
</el-form-item>
<el-form-item :label="$t('service.field.price')">
<div v-if="application.type === applicationType.API">
<price
v-if="form.packageId === 'custom'"
:price="application?.api?.price"
:unit="$t(`api.unit.${application?.api?.unit}`)"
/>
<price v-else :price="package?.price" />
</div>
<div v-if="application.type === applicationType.PROXY">
<price :price="package?.price" />
</div>
</el-form-item>
<el-divider border-style="dashed" />
<el-form-item :label="$t('application.field.shouldPayPrice')">
<span v-if="form.packageId === 'custom'" :class="{ price: true, unfree: price > 0, free: price === 0 }">
¥{{ price.toFixed(2) }}
</span>
<span v-else-if="package" :class="{ price: true, unfree: package?.price > 0, free: package?.price === 0 }">
¥{{ package?.price?.toFixed(2) }}
</span>
</el-form-item>
<el-form-item>
<el-button type="primary" size="large" class="btn-create" :loading="creating" @click="onCreateOrder">
{{ $t('application.button.createOrder') }}
</el-button>
</el-form-item>
</el-form>
</template>
<script lang="ts">
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage, orderOperator } from '@/operators';
import { defineComponent } from 'vue';
import { ElMessage } from 'element-plus';
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
import { ElForm, ElFormItem, ElButton, ElInputNumber, ElDivider, ElRadioGroup, ElRadioButton } from 'element-plus';
import Price from '@/components/common/Price.vue';
interface IData {
form: {
amount: number;
packageId: string | undefined;
};
creating: boolean;
applicationType: typeof IApplicationType;
}
export default defineComponent({
name: 'CreateOrderDialog',
components: {
ElForm,
ElFormItem,
ElInputNumber,
ElButton,
ElDivider,
ElRadioGroup,
ElRadioButton,
Price
},
props: {
application: {
type: Object as () => IApplication,
required: true
}
},
data(): IData {
return {
form: {
amount: 1000,
packageId: undefined
},
creating: false,
applicationType: IApplicationType
};
},
computed: {
price() {
if (this.application?.type === IApplicationType.API) {
if (this.application.api?.price && this.form.amount) {
return this.form.amount * this.application.api?.price;
}
}
if (this.application?.type === IApplicationType.PROXY) {
if (this.application.proxy?.price && this.form.amount) {
return this.form.amount * this.application.proxy?.price;
}
}
return 0;
},
package() {
if (this.application?.type === IApplicationType.API) {
if (this.application.api?.packages && this.form.packageId) {
const filterPackages = this.application.api?.packages.filter((item) => item.id === this.form.packageId);
if (filterPackages.length > 0) {
return filterPackages[0];
}
}
}
if (this.application?.type === IApplicationType.PROXY) {
if (this.application.proxy?.packages && this.form.packageId) {
const filterPackages = this.application.proxy?.packages.filter((item) => item.id === this.form.packageId);
if (filterPackages.length > 0) {
return filterPackages[0];
}
}
}
return undefined;
}
},
mounted() {
this.onInit();
},
methods: {
onInit() {
if (this.application.type === IApplicationType.API) {
if (this.application?.api?.packages && this.application?.api?.packages.length > 0) {
this.form.packageId = this.application?.api?.packages[0].id;
} else {
this.form.packageId = 'custom';
}
}
if (this.application.type === IApplicationType.PROXY) {
if (this.application?.proxy?.packages && this.application?.proxy?.packages.length > 0) {
this.form.packageId = this.application?.proxy?.packages[0].id;
}
}
},
onChangePackage(pkg: IPackage) {
console.log('pkg', pkg);
},
onCreateOrder() {
if (!this.application?.id) {
return;
}
this.creating = true;
orderOperator
.create({
application_id: this.application?.id,
amount: this.form.amount,
...(this.form.packageId !== 'custom' && this.package
? {
package_id: this.package.id
}
: {})
})
.then(({ data: data }: { data: IOrderDetailResponse }) => {
this.creating = false;
const order = data;
this.$router.push({
name: ROUTE_CONSOLE_ORDER_DETAIL,
params: {
id: order.id
}
});
})
.catch(() => {
ElMessage.error(this.$t('order.message.createFailed'));
this.creating = false;
});
}
}
});
</script>
<style lang="scss" scoped>
.price {
font-size: 20px;
font-weight: bold;
&.unfree {
color: #ff5441;
}
&.free {
color: #29c287;
}
}
.btn-create {
width: 150px;
}
</style>
-111
View File
@@ -1,111 +0,0 @@
<template>
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="500px" center>
<el-row class="paycodes">
<el-col :span="12">
<div class="paycode wechat">
<qr-code v-if="modelValue?.wechatpay_url" :value="modelValue?.wechatpay_url" :size="200" class="m-auto" />
<p class="help-text">{{ $t('order.message.wechatPayHelp') }}</p>
</div>
</el-col>
<el-col :span="12">
<div class="help-img">
<img src="https://midas.gtimg.cn/enterprise/images/ep_sys_wx_tip.jpg" />
</div>
</el-col>
</el-row>
</el-dialog>
</template>
<script lang="ts">
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
import { defineComponent } from 'vue';
import { ElDialog, ElRow, ElCol } from 'element-plus';
import QrCode from 'qrcode.vue';
interface IData {
refreshTimer: number | undefined;
}
export default defineComponent({
name: 'PayOrderDialog',
components: {
ElDialog,
QrCode,
ElRow,
ElCol
},
props: {
modelValue: {
type: Object as () => IOrder,
required: true
},
visible: {
type: Boolean,
required: false,
default: false
}
},
emits: ['hide', 'update:modelValue'],
data(): IData {
return {
refreshTimer: undefined
};
},
mounted() {
this.onRefresh();
},
unmounted() {
if (this.refreshTimer) {
clearTimeout(this.refreshTimer);
}
},
methods: {
onRefresh() {
if (!this.modelValue.id) {
console.error('id does not exist');
return;
}
orderOperator
.refresh(this.modelValue.id)
.then(({ data: data }: { data: IOrderDetailResponse }) => {
// if not paid, check for next loop
if (data.state !== OrderState.PAID) {
setTimeout(() => {
this.onRefresh();
}, 2000);
} else {
// paid, just notify parent, and hide the dialog
this.$emit('hide');
}
this.$emit('update:modelValue', data);
})
.catch(() => {
setTimeout(() => {
this.onRefresh();
}, 2000);
});
}
}
});
</script>
<style lang="scss" scoped>
.paycodes {
padding: 30px 0;
width: 500px;
margin: auto;
.wechat {
.help-text {
display: block;
background-color: #00c800;
color: white;
font-size: 14px;
height: 35px;
width: 240px;
text-align: center;
line-height: 35px;
margin: 10px auto 0 auto;
}
}
}
</style>