parent
9279a7d6cb
commit
f58303e37f
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-04 16:37:25
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-04 16:38:00
|
||||
* @Description: file content
|
||||
-->
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
<script setup lang="jsx"></script>
|
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-04 16:34:07
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-04 16:34:13
|
||||
* @Description: file content
|
||||
-->
|
||||
<template></template>
|
||||
<script lang="jsx">
|
||||
export default {};
|
||||
</script>
|
@ -0,0 +1,124 @@
|
||||
<!--
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-04 16:42:21
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-06 11:08:35
|
||||
* @Description: file content
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-form ref="formEl" label-width="160px" :model="form" :rules="rules">
|
||||
<el-form-item label="商户平台" prop="mchCode">
|
||||
<el-radio-group v-model="form.mchCode" :disabled="idEdit">
|
||||
<el-radio v-for="item in opts.platform" :key="item.code" :label="item.code" border>
|
||||
{{ item.text }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="商户名称" prop="mchName">
|
||||
<el-input v-model="form.mchName" maxlength="64" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="商户ID" prop="mchId">
|
||||
<el-input v-model="form.mchId" maxlength="64" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="商户状态" prop="disabled">
|
||||
<el-select v-model="form.isDisabled" :clearable="false">
|
||||
<el-option v-for="item in opts.status" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<Ali v-if="form.mchCode === 'alipay'" ref="aliFormEl" v-model="form.aliMchData" :detai="aliMchData" />
|
||||
<Wx v-if="form.mchCode === 'wxpay'" v-model="form.wxMchData" ref="wxFormEl" />
|
||||
<el-form-item>
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button :disabled="loading" :loading="submitting" type="primary" @click="handleSave">保存</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="jsx">
|
||||
import Ali from './ali.vue';
|
||||
import Wx from './wx.vue';
|
||||
const store = useStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
// 页面字典表数据
|
||||
const opts = computed(() => store.state.merchant.opts);
|
||||
const defaultForm = {
|
||||
isDisabled: false,
|
||||
mchCode: route.params.id ? '' : 'wxpay',
|
||||
mchName: '',
|
||||
mchId: '',
|
||||
aliMchData: {},
|
||||
wxMchData: {},
|
||||
};
|
||||
const form = reactive({ ...defaultForm });
|
||||
const rules = reactive({
|
||||
mchName: [{ required: true, message: '商户名称不能为空' }],
|
||||
mchId: [{ required: true, message: '商户ID不能为空' }],
|
||||
});
|
||||
const idEdit = computed(() => Boolean(route.params.id));
|
||||
|
||||
const formEl = ref();
|
||||
const aliFormEl = ref();
|
||||
const wxFormEl = ref();
|
||||
|
||||
store.dispatch('merchant/getMerchantPlatform');
|
||||
onActivated(() => {
|
||||
handlelLoadData();
|
||||
});
|
||||
/**
|
||||
* 如果是编辑需要加载初始数据加载
|
||||
*/
|
||||
const handlelLoadData = async () => {
|
||||
let id = route.params.id;
|
||||
if (id && form.id !== id) {
|
||||
let res = await store.dispatch('merchant/detail', id);
|
||||
if (res.mchCode === 'alipay') {
|
||||
const publicKey = res.aliMchData.publicKey;
|
||||
if (publicKey) {
|
||||
res.aliMchData.hasPublicKey = publicKey;
|
||||
delete res.aliMchData.publicKey;
|
||||
}
|
||||
} else {
|
||||
const { apiKey, apiKeyV3, serialNo } = res.wxMchData;
|
||||
res.wxMchData.hasApiKey = apiKey;
|
||||
delete res.wxMchData.apiKey;
|
||||
res.wxMchData.hasApiKeyV3 = apiKeyV3;
|
||||
delete res.wxMchData.apiKeyV3;
|
||||
res.wxMchData.hasSerialNo = serialNo;
|
||||
delete res.wxMchData.serialNo;
|
||||
}
|
||||
Object.assign(form, res);
|
||||
}
|
||||
};
|
||||
const handleSave = async () => {
|
||||
let validate = false;
|
||||
if (form.mchCode === 'wxpay') {
|
||||
validate = wxFormEl.value.validate;
|
||||
} else {
|
||||
validate = aliFormEl.value.validate;
|
||||
}
|
||||
Promise.all([formEl.value.validate(), validate()])
|
||||
.then(async () => {
|
||||
const res = await store.dispatch('merchant/save', form);
|
||||
if (res) {
|
||||
handleCancel();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const handleCancel = () => {
|
||||
Object.assign(form, defaultForm);
|
||||
wxFormEl.value && wxFormEl.value.resetFields();
|
||||
aliFormEl.value && aliFormEl.value.resetFields();
|
||||
formEl.value.resetFields();
|
||||
router.push({ name: 'PayMerchant' });
|
||||
};
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.form-container {
|
||||
.el-form {
|
||||
// width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in new issue