|
@@ -0,0 +1,383 @@
|
|
|
+<template>
|
|
|
+ <BasicModal
|
|
|
+ v-bind="$attrs"
|
|
|
+ @register="register"
|
|
|
+ title="开票信息"
|
|
|
+ @cancel="resetFields"
|
|
|
+ :confirmLoading="loading"
|
|
|
+ @ok="handleSubmit"
|
|
|
+ >
|
|
|
+ <div class="pt-2px pr-3px">
|
|
|
+ <BasicForm @register="registerForm">
|
|
|
+ <template #text="{ model, field }">
|
|
|
+ {{ model[field] }}
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
+ </div>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, h, onMounted, reactive, ref } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import {
|
|
|
+ partAllList,
|
|
|
+ faultAllList,
|
|
|
+ checkRegister,
|
|
|
+ partInfo,
|
|
|
+ partInfo,
|
|
|
+ invoiceRegister,
|
|
|
+ repairOver,
|
|
|
+ } from '/@/api/spares';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import { uploadApi } from '/@/api/product/index';
|
|
|
+ const { t } = useI18n();
|
|
|
+ export default defineComponent({
|
|
|
+ components: { BasicModal, BasicForm },
|
|
|
+ props: {
|
|
|
+ userData: { type: Object },
|
|
|
+ },
|
|
|
+ emits: ['update', 'register'],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const n = ref(1);
|
|
|
+ const repairId = ref('');
|
|
|
+ const fileFlow = reactive({
|
|
|
+ file: null,
|
|
|
+ invoiceAmount: 0,
|
|
|
+ repairId: null,
|
|
|
+ });
|
|
|
+ const loading = ref(false);
|
|
|
+ const { createMessage, createConfirm } = useMessage();
|
|
|
+ let schemas: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'companyName',
|
|
|
+ component: 'Input',
|
|
|
+ label: '客户名称',
|
|
|
+ slot: 'text',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'repairId',
|
|
|
+ component: 'Input',
|
|
|
+ label: '维修单号',
|
|
|
+ slot: 'text',
|
|
|
+ colProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'deviceType',
|
|
|
+ component: 'Input',
|
|
|
+ label: '设备信息',
|
|
|
+ slot: 'text',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'defineDamage',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ label: '是否开票',
|
|
|
+ defaultValue: 1,
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '是',
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '否',
|
|
|
+ value: 0,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ onChange: (val) => {
|
|
|
+ handleUpShow(val.target.value == 1 ? true : false);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 22,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceType',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ label: '发票类型',
|
|
|
+ defaultValue: 0,
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '普通发票',
|
|
|
+ value: 0,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '专用发票',
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 22,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceHead',
|
|
|
+ component: 'Input',
|
|
|
+ label: '发票抬头',
|
|
|
+ componentProps: {
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceNum',
|
|
|
+ component: 'Input',
|
|
|
+ label: '税号',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'bank',
|
|
|
+ component: 'Input',
|
|
|
+ label: '开户银行',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'bankAccount',
|
|
|
+ component: 'Input',
|
|
|
+ label: '银行账户',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'address',
|
|
|
+ component: 'Input',
|
|
|
+ label: '企业地址',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'phone',
|
|
|
+ component: 'Input',
|
|
|
+ label: '企业电话',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceEmail',
|
|
|
+ component: 'Input',
|
|
|
+ label: '电子邮箱',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请填写接收发票邮箱',
|
|
|
+ maxLength: 50,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddress',
|
|
|
+ component: 'Input',
|
|
|
+ label: '收件地址',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请填写收件地址',
|
|
|
+ maxLength: 50,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddrName',
|
|
|
+ component: 'Input',
|
|
|
+ label: '收件人',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请填写收件人',
|
|
|
+ maxLength: 50,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddrPhone',
|
|
|
+ component: 'Input',
|
|
|
+ label: '收件人电话',
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ rules: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ // @ts-ignore
|
|
|
+ validator: async (rule, value) => {
|
|
|
+ var reg_tel =
|
|
|
+ /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
|
+ // var reg = /\S+@\S+\.\S+/;
|
|
|
+ if (!value) {
|
|
|
+ /* eslint-disable-next-line */
|
|
|
+
|
|
|
+ return Promise.reject(t('common.phone'));
|
|
|
+ }
|
|
|
+ if (!reg_tel.test(value)) {
|
|
|
+ /* eslint-disable-next-line */
|
|
|
+ return Promise.reject(t('common.phoneError'));
|
|
|
+ }
|
|
|
+ return Promise.resolve();
|
|
|
+ },
|
|
|
+ trigger: 'change',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请填写手机号',
|
|
|
+ maxLength: 50,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const [
|
|
|
+ registerForm,
|
|
|
+ {
|
|
|
+ validate,
|
|
|
+ resetFields,
|
|
|
+ setFieldsValue,
|
|
|
+ removeSchemaByFiled,
|
|
|
+ appendSchemaByField,
|
|
|
+ updateSchema,
|
|
|
+ },
|
|
|
+ ] = useForm({
|
|
|
+ labelWidth: 100,
|
|
|
+ schemas: schemas,
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ actionColOptions: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ onMounted(() => {});
|
|
|
+ // getFaultList();
|
|
|
+ let addListFunc = () => {};
|
|
|
+ const [register, { closeModal }] = useModalInner((data) => {
|
|
|
+ repairId.value = data?.repairId;
|
|
|
+ data && onDataReceive(data);
|
|
|
+ });
|
|
|
+ async function getFaultList() {
|
|
|
+ const res = await faultAllList({});
|
|
|
+ fileFlow.faultList = res.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ label: item.faultMsg,
|
|
|
+ value: item.faultId,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function onDataReceive(data) {
|
|
|
+ resetFields();
|
|
|
+ fileFlow.invoiceAmount = data.payAmount;
|
|
|
+ fileFlow.repairId = data.repairId;
|
|
|
+ console.log('openOutModal', fileFlow, data);
|
|
|
+ setFieldsValue({
|
|
|
+ ...data,
|
|
|
+ invoiceHead: data.companyName,
|
|
|
+ deviceType: t(`routes.scene.tableType.${data.cameraType}`) + ' ' + data.cameraSnCode,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const handleUpShow = async (val) => {
|
|
|
+ console.log(val);
|
|
|
+ updateSchema([
|
|
|
+ {
|
|
|
+ field: 'invoiceType',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'companyName',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceNum',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'bank',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'bankAccount',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'address',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'phone',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'invoiceEmail',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddress',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddrName',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'getAddrPhone',
|
|
|
+ ifShow: val,
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ };
|
|
|
+ const handleSubmit = async () => {
|
|
|
+ const params = await validate();
|
|
|
+ try {
|
|
|
+ createConfirm({
|
|
|
+ iconType: 'warning',
|
|
|
+ title: () => h('span', '温馨提示'),
|
|
|
+ content: '确定要开具发票吗?',
|
|
|
+ onOk: async () => {
|
|
|
+ loading.value = true;
|
|
|
+ await invoiceRegister({...params,...fileFlow});
|
|
|
+ loading.value = false;
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
+ closeModal();
|
|
|
+ emit('update');
|
|
|
+ },
|
|
|
+ onCancel: () => {
|
|
|
+ loading.value = false;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ loading.value = false;
|
|
|
+ console.log('not passing', error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ register,
|
|
|
+ registerForm,
|
|
|
+ fileFlow,
|
|
|
+ handleSubmit,
|
|
|
+ addListFunc,
|
|
|
+ resetFields,
|
|
|
+ loading,
|
|
|
+ t,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|