zhangxp
2023-08-23 269904d54d259f5c6f8e776d98821187a72f9eb8
Source/UBCS-WEB/src/components/code-dialog-page/maxSerialnumDialog.vue
@@ -1,27 +1,26 @@
<template>
    <el-dialog title="最大流水号" width="30%" append-to-body="true" :visible.sync="dialogVisible">
        <el-form :label-position="right" label-width="80px" :model="formModel">
            <el-form-item label="流水号">
        <el-form :label-position="right" ref="ruleForm" label-width="80px" :model="formModel" :rules="rules">
            <el-form-item label="流水号" prop="maxSecNum">
                <el-input v-model="formModel.maxSecNum"></el-input>
            </el-form-item>
        </el-form>
        <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
            <el-tab-pane label="最大流水号" name="codeApply">
                <form-template v-bind="$attrs" type="add" :selfColumnType="selfColumnType"
                :trendsSpan="24"
                <form-template v-bind="$attrs" type="add" :selfColumnType="selfColumnType" :trendsSpan="24"
                    :selfColumnConfig="selfColumnConfig" ref="CodeApply" @getFormData="getCodeApplyFormData"
                    @referConfigDataUpdate="referConfigDataUpdate"></form-template>
            </el-tab-pane>
        </el-tabs>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
            <el-button type="primary" :loading="confirmLoadding" @click="comfirm">确 定</el-button>
        </div>
    </el-dialog>
</template>
<script>
import FormTemplate from "@/components/FormTemplate/FormTemplate";
import { getCodePrice ,saveMaxSerialNum} from "@/api/code/maxSerialNum.js"
import { getCodePrice, saveMaxSerialNum } from "@/api/code/maxSerialNum.js"
export default {
    name: 'maxSerialnumDialog',
    components: {
@@ -59,12 +58,18 @@
        return {
            dialogVisible: this.visible,
            activeName: 'codePrice',
            confirmLoadding: false,
            codeApplyForm: {},
            secVOList: [],
            formModel: {
                maxSecNum: '',
                codeRuleOid: this.ruleOid,
                codeRuleOid: '',
                secDTOList: []
            },
            rules: {
                maxSecNum: [
                    { required: true, message: '请输入流水号', trigger: 'blur' }
                ],
            },
            selfColumnType: {
                codefixedsec: "combox",
@@ -125,7 +130,7 @@
                );
                if (this.secVOList.length > 0) {
                    // this.showCodeApply = true;
                    this.$nextTick(() => {
                        this.$refs.CodeApply.templateRender(this.secVOList);
                    });
@@ -140,6 +145,55 @@
        getCodeApplyFormData(codeApplyForm) {
            this.codeApplyForm = codeApplyForm;
        },
        // 取消
        cancel() {
            this.dialogVisible = false
            this.formModel['secDTOList'] = []
            this.formModel['codeRuleOid'] = ''
            this.formModel['maxSecNum'] = ''
            this.$refs.ruleForm.clearValidate('maxSecNum')
        },
        // 确认
        async comfirm() {
            console.log(this.codeApplyForm)
            const objcodekey = Object.keys(this.codeApplyForm)
            console.log(objcodekey)
            const filteredObj = objcodekey.reduce((acc, key) => {
                const pattern = /[\u4e00-\u9fa5]/; // 匹配中文字符的正则表达式
                if (!pattern.test(key)) {
                    acc[key] = this.codeApplyForm[key];
                }
                return acc;
            }, {});
            const arrCode = Object.entries(filteredObj).map(([key, value]) => {
                return {
                    secOid: key,
                    secValue: value
                }
            })
            this.formModel['secDTOList'] = arrCode
            this.formModel['codeRuleOid'] = this.ruleOid
            console.log(this.formModel)
            this.confirmLoadding = true
            const rule = await this.$refs.CodeApply.validate()
            this.$refs.ruleForm.validate(res => {
                if (rule && res) {
                    console.log(rule)
                    saveMaxSerialNum(this.formModel).then(res => {
                        if (res.data.success) {
                            this.$message.success('操作成功!');
                            this.confirmLoadding = false
                            this.cancel()
                        }
                    })
                } else {
                    this.confirmLoadding = false
                }
            })
        },
        // 参照组件数据变更
        referConfigDataUpdate(data) {
            // console.log(data)
@@ -151,7 +205,6 @@
                }
                return item;
            });
            // console.log(this.secVOList)
            this.$refs.CodeApply.templateRender(this.secVOList);
        },
        isRequired(item) {