123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <BasicModal
- v-bind="$attrs"
- @register="register"
- title="本地版算法授权"
- @visible-change="handleVisibleChange"
- @cancel="resetFields"
- minHeight="900px"
- @ok="handleConfirm"
- >
- <div class="pt-2px pr-3px zdysrk">
- <BasicForm @register="registerForm">
- <template #text="{ model, field }"> {{ model[field] }}{{ fileFlow.type }} </template>
- </BasicForm>
- </div>
- </BasicModal>
- </template>
- <script lang="ts">
- import { defineComponent, nextTick, onMounted, reactive, computed, h } from 'vue';
- import { BasicModal, useModalInner } from '/@/components/Modal';
- import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { remarkschemas, Addschemas } from './data';
- import { InvoiceRegister } from '/@/api/order';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { uploadApi } from '/@/api/product/index';
- import { ResultEnum } from '/@/enums/httpEnum';
- import { authorizeModelingaddOrUpdate } from '/@/api/authorizeModeling';
- import dayjs from 'dayjs';
- import { otherInfoStore } from '/@/store/modules/other';
- import { incrementUseTypeList } from '/@/api/account';
- const { t } = useI18n();
- export default defineComponent({
- components: { BasicModal, BasicForm },
- props: {
- userData: { type: Object },
- },
- emits: ['update', 'register'],
- setup(props, { emit }) {
- const otherInfo = otherInfoStore();
- const overviewInfo = computed(() => otherInfo.getOverviewInfo);
- // const overviewInfo = getOverviewInfo() || {}
- const fileFlow = reactive({
- file: null,
- id: '',
- type: 'down', //down-下载,equity-权益
- });
- const { createMessage, createConfirm } = useMessage();
- const schemas: FormSchema[] = [
- {
- field: 'id',
- component: 'Input',
- show: false,
- label: 'id',
- },
- {
- field: 'authorizeKey',
- component: 'Input',
- required: true,
- label: '授权码',
- colProps: { span: 20 },
- },
- {
- field: 'authorizeTime',
- component: 'Select',
- label: '授权期限',
- required: true,
- defaultValue: '10_1',
- componentProps: {
- options: [
- {
- label: '10天',
- value: '10_1',
- key: '10',
- },
- {
- label: '1个月',
- value: '1_2',
- key: '30',
- },
- {
- label: '3个月',
- value: '3_2',
- key: '90',
- },
- {
- label: '1年',
- value: '1_3',
- key: '365',
- },
- {
- label: '2年',
- value: '2_3',
- key: '730',
- },
- {
- label: '3年',
- value: '3_3',
- key: '1095',
- },
- {
- label: '5年',
- value: '3_5',
- key: '1825',
- },
- ],
- },
- colProps: {
- span: 18,
- },
- },
- ];
- const [registerForm, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({
- labelWidth: 120,
- schemas: [
- {
- field: 'useType',
- component: 'ApiSelect',
- required: true,
- label: '使用类型',
- componentProps: {
- // filterOption: onFilterOption,
- // showSearch: true,
- api: incrementUseTypeList,
- labelField: 'name',
- valueField: 'id',
- immediate: true,
- },
- itemProps: {
- autoLink: false,
- },
- colProps: {
- span: 20,
- },
- },
- ...Addschemas,
- ...schemas,
- ...remarkschemas,
- ],
- showActionButtonGroup: false,
- actionColOptions: {
- span: 24,
- },
- });
- onMounted(() => {});
- let addListFunc = () => {};
- const [register, { closeModal }] = useModalInner((data) => {
- data && onDataReceive(data);
- });
- async function onDataReceive(data) {
- resetFields();
- fileFlow.id = data.id;
- updateSchema([
- {
- field: 'useType',
- componentProps: {
- onChange: (value) => {
- updateSchema({ field: 'projectNum', ifShow: value == '4' });
- },
- },
- },
- {
- field: 'projectNum',
- ifShow: data.useType == '4',
- },
- ]);
- setFieldsValue(data);
- }
- async function handleConfirm() {
- const { id } = await validate();
- createConfirm({
- iconType: 'warning',
- title: () => h('span', '温馨提示'),
- content: () => h('span', `确定要${id ? '编辑' : '新增'}授权吗?`),
- onOk: async () => {
- handleSubmit();
- },
- });
- }
- const handleSubmit = async () => {
- try {
- const params = await validate();
- let authorizeTime = params.authorizeTime.split('_');
- const apiData = {
- ...params,
- userId: params.id,
- authorizeTime: authorizeTime[0],
- authorizeTimeUnit: authorizeTime[1],
- };
- await authorizeModelingaddOrUpdate(apiData);
- closeModal();
- resetFields();
- createMessage.success(t('common.optSuccess'));
- emit('update');
- } catch (error) {
- console.log('not passing', error);
- }
- };
- function handleVisibleChange(v) {
- v && props.userData && nextTick(() => onDataReceive(props.userData));
- }
- return {
- register,
- registerForm,
- fileFlow,
- handleVisibleChange,
- handleSubmit,
- addListFunc,
- resetFields,
- handleConfirm,
- t,
- };
- },
- });
- </script>
- <style lang="less">
- .zdysrk {
- .ant-calendar-picker {
- min-width: 285px;
- }
- }
- </style>
|