zouyu
2023-09-07 b580f0402ff66d0c5b74460edcb920a516b1ce6e
Merge branch 'master' of http://192.168.218.113:9001/r/lims-before
已修改8个文件
1286 ■■■■ 文件已修改
src/router/index.js 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/index.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/experiment/nonConformingFeedback/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/experiment/planAssignments/plan.vue 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/experiment/reportAuditing/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/organizational/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/standardLibrary/index.vue 1240 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js
@@ -48,7 +48,7 @@
          path: 'index',
          name: 'StandardLibrary',
          component: () => import('@/views/standardLibrary/index'),
          meta: { title: '标准库', icon: 'el-icon-s-help' }
          meta: { title: '标准库', icon: 'el-icon-s-management' }
        },
        // {
        //   path: 'specificationDetails/:id',
@@ -64,7 +64,7 @@
      component: Layout,
      redirect: '/inspectionManagement/commissionInspection',
      name: 'InspectionManagement',
      meta: { title: '报检管理', icon: 'el-icon-s-help' },
      meta: { title: '报检管理', icon: 'el-icon-s-order' },
      children: [
        {
          path: 'commissionInspection',
@@ -85,7 +85,7 @@
      component: Layout,
      redirect: '/experiment/inspectionApplication',
      name: 'Experiment',
      meta: { title: '试验管理', icon: 'el-icon-s-help' },
      meta: { title: '试验管理', icon: 'el-icon-s-marketing' },
      children: [
        {
          path: 'inspectionApplication',
@@ -143,7 +143,7 @@
      component: Layout,
      redirect: '/laboratory/ledger',
      name: 'Laboratory',
      meta: { title: '实验室管理', icon: 'el-icon-s-help' },
      meta: { title: '实验室管理', icon: 'el-icon-cpu' },
      children: [
        {
          path: 'ledger',
@@ -221,7 +221,7 @@
      component: Layout,
      redirect: '/chart/center',
      name: 'Chart',
      meta: { title: '智能图表', icon: 'el-icon-s-help' },
      meta: { title: '智能图表', icon: 'el-icon-s-data' },
      children: [
        {
          path: 'center',
@@ -261,7 +261,7 @@
          name: 'ToDo',
          component: () => import('@/views/message/toDo/index'),
          // meta: { title: '消息待办', icon: 'tree' }
          meta: { title: '我的待办', icon: 'el-icon-s-help' },
          meta: { title: '我的待办', icon: 'el-icon-s-promotion' },
        },
        // {
        //   path: 'message',
@@ -282,7 +282,7 @@
          name: 'MyInformation',
          component: () => import('@/views/personal/myInformation/index'),
          // meta: { title: '个人管理', icon: 'el-icon-s-help' }
          meta: { title: '我的信息', icon: 'el-icon-s-help' }
          meta: { title: '我的信息', icon: 'el-icon-user-solid' }
        },
        // {
        //   path: 'myBusiness',
src/views/basicData/index.vue
@@ -24,26 +24,23 @@
                        @click="deleteListClick">删除</el-button>
                </el-form-item>
            </el-form>
            <el-dialog :visible.sync="centerDialogVisible" width="30%" right :before-close="handleClose"
            <el-dialog :visible.sync="centerDialogVisible" width="45%" right :before-close="handleClose"
                :title="isUpdate ? '更新' : '新增'" :hide-required-asterisk="false">
                <el-form :model="form" :rules="rules" ref="ruleForm" class="addForm">
                    <el-form-item prop="material" required>
                        <span>样品名称:</span>
                <el-form style="width: 100%;" label-width="100px" :model="form" :rules="rules" ref="ruleForm" class="addForm" label-position="left">
                    <el-form-item label="样品名称:" prop="material" required>
                        <el-autocomplete class="inline-input" v-model="form.material" :fetch-suggestions="querySearch1"
                            placeholder="请输入样品名称" style="width: calc(100% - 70px);"></el-autocomplete>
                    </el-form-item>
                    <el-form-item>
                        <span>项目分组:</span>
                    <el-form-item label="项目分组:">
                        <el-autocomplete class="inline-input" v-model="form.father" :fetch-suggestions="querySearch2"
                            placeholder="请输入项目分组" style="width: calc(100% - 70px);"></el-autocomplete>
                    </el-form-item>
                    <el-row :gutter="24">
                        <el-col :span="12"><el-form-item prop="name" required><span>项目名称:</span>
                        <el-col :span="12"><el-form-item label="项目名称:" prop="name" required>
                                <el-input style="width: calc(100% - 70px);" v-model="form.name"
                                    placeholder="请输入项目名称"></el-input></el-form-item></el-col>
                        <el-col :span="12">
                            <el-form-item prop="unit">
                                <span v-html="'单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位:'"></span>
                            <el-form-item label="单位" prop="unit">
                                <el-input style="width: calc(100% - 70px);" v-model="form.unit"
                                    placeholder="请输入单位"></el-input></el-form-item></el-col>
                    </el-row>
src/views/experiment/nonConformingFeedback/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="content-main">
    <div class="top-bar">
      <el-form ref="form" style="width: 1000px;margin-top: 10px;" :inline="true">
      <el-form ref="form" style="width: 100%;margin-top: 10px;" :inline="true">
          <el-form-item label="样式编号:">
            <el-input size="small" v-model="materialCode" placeholder="请输入样式编号"></el-input>
          </el-form-item>
src/views/experiment/planAssignments/plan.vue
@@ -63,6 +63,7 @@
            </el-form>
            <el-button size="small" type="primary" @click="selectDataList">查询</el-button>
            <el-button size="small" @click="cleanBtn">重置</el-button>
            <el-checkbox style="margin-left: 10px;" @change="selectDataList" v-model="isLookMe">只看我</el-checkbox>
        </div>
        <div class="thing">
            <el-table :data="tableData" style="width: 100%;" row-key="code" default-expand-all
@@ -229,7 +230,8 @@
                upInsDia: false,
                upIndex2: 0,
                users: [],
                devices: []
                devices: [],
                isLookMe: false
            }
        },
        mounted() {
@@ -241,6 +243,7 @@
            selectDataList() {
                var str = {}
                str.code = this.search.code
                str.isLookMe=this.isLookMe
                str.status = this.search.testValue
                try {
                    if (this.search.date.length != 0) {
src/views/experiment/reportAuditing/index.vue
@@ -177,7 +177,7 @@
      this.getData();
    },
    //通过
    async checkskip(row) {
     checkskip(row) {
      console.log(this.tableRow);
      this.reportTable[this.tableRow.$index].status=1
      this.transmitData(this.tableRow.row.id,1)
@@ -186,10 +186,10 @@
          message: '通过成功',
          type: 'success'
        });
         this.getData();
    },
    //不通过
    async nocheckskip(row) {
     nocheckskip(row) {
      console.log(this.tableRow);
      this.reportTable[this.tableRow.$index].status=0
      this.transmitData(this.tableRow.row.id,2)
@@ -198,7 +198,7 @@
          message: '待通过',
          type: 'warning'
        });
        this.getData();
    },
    //审核
    async transmitData(id, result) {
src/views/laboratory/organizational/index.vue
@@ -317,6 +317,7 @@
}
.filter-tree {
  margin-top: 6px;
  // display: inline-block;
}
.table_top_div {
  height: 80px;
src/views/login/index.vue
@@ -218,7 +218,6 @@
            this.$message.success("登录成功")
            this.btnload = false
            this.$router.push({ path: this.redirect || '/' })
            // this.$router.push('/')
          }).catch((error) => {
            this.$message.error(error.message)
            this.btnload = false
src/views/standardLibrary/index.vue
@@ -4,10 +4,11 @@
            <div class="library-bom" style="width: 300px">
                <el-row :gutter="10">
                    <el-col :span="19">
                    <el-input size="small" clearable v-model="filterText" placeholder="输入关键字进行过滤"></el-input>
                        <el-input size="small" clearable v-model="filterText" placeholder="输入关键字进行过滤"></el-input>
                    </el-col>
                    <el-col :span="5">
                        <el-button size="small" type="primary" icon="el-icon-plus" @click="addTreeFormVisible = true"></el-button>
                        <el-button size="small" type="primary" icon="el-icon-plus"
                            @click="addTreeFormVisible = true"></el-button>
                    </el-col>
                </el-row>
                <el-button size="small" type="text">全部</el-button>
@@ -39,9 +40,8 @@
                        <el-table-column label="项目名称" sortable>
                            <template scope="scope">
                                <el-tag>
                                    <div class="firstDiv" :style="`color: ${
                      scope.row.code == '[1]' ? '#16a7ff' : '#58c173'
                    }`">
                                    <div class="firstDiv" :style="`color: ${scope.row.code == '[1]' ? '#16a7ff' : '#58c173'
                                        }`">
                                        {{ scope.row.code == "[1]" ? "01" : "02" }}
                                    </div>
                                    <span style="color: black">{{ scope.row.name }}</span>
@@ -51,14 +51,16 @@
                        <el-table-column prop="unit" label="单位" sortable></el-table-column>
                        <el-table-column label="标准值" sortable>
                            <template scope="scope">
                                <el-input v-if="scope.row.edit === true || scope.row.code === '[2]'" @blur="requiredOnfocus(scope)"
                                    v-model="scope.row.required" placeholder="请输入标准值"></el-input>
                                <el-input v-if="scope.row.edit === true || scope.row.code === '[2]'"
                                    @blur="requiredOnfocus(scope)" v-model="scope.row.required"
                                    placeholder="请输入标准值"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column prop="internal" label="内控值" sortable>
                            <template scope="scope">
                                <el-input v-if="scope.row.edit === true || scope.row.code === '[2]'" @blur="requiredOnfocus(scope)"
                                    v-model="scope.row.internal" placeholder="请输入内控值"></el-input>
                                <el-input v-if="scope.row.edit === true || scope.row.code === '[2]'"
                                    @blur="requiredOnfocus(scope)" v-model="scope.row.internal"
                                    placeholder="请输入内控值"></el-input>
                            </template>
                        </el-table-column>
                    </el-table>
@@ -72,17 +74,17 @@
        <el-dialog class="addTree" title="添加标准指标" width="28%" :visible.sync="addTreeFormVisible">
            <el-form v-model="addTreeForm" label-position="top">
                <el-form-item label="标准类型">
                    <el-cascader  v-model="addTreeForm.addTypeArr" :options="formTypeOptions"
                        :props="{ ...defaultProps, checkStrictly: true }" clearable @change="changeCascader"/>
                    <el-cascader v-model="addTreeForm.addTypeArr" :options="formTypeOptions"
                        :props="{ ...defaultProps, checkStrictly: true }" clearable @change="changeCascader" />
                </el-form-item>
                <el-form-item v-show="addTreeForm.addTypeArr.length < 2" label="物料名称">
                    <el-input @change="changeSample" v-model="addTreeForm.materialName" />
                </el-form-item>
                <el-form-item v-show="addTreeForm.addTypeArr.length < 3" label="执行标准">
                    <el-input  v-model="addTreeForm.standardName" />
                    <el-input v-model="addTreeForm.standardName" />
                </el-form-item>
                <el-form-item v-show="addTreeForm.addTypeArr.length < 4" label="规格型号">
                    <el-input  v-model="addTreeForm.specificationsName" />
                    <el-input v-model="addTreeForm.specificationsName" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
@@ -101,7 +103,8 @@
                    <el-col :span="12">
                        <el-form-item prop="name">
                            <span>项目名称:</span>
                            <el-input style="width: calc(100% - 70px);" v-model="form.name" placeholder="请输入项目名称"></el-input>
                            <el-input style="width: calc(100% - 70px);" v-model="form.name"
                                placeholder="请输入项目名称"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
@@ -121,649 +124,682 @@
</template>
<script>
    import {
        getMaterialList,
        getProductList,
        addMaterial,
        addStandards,
        addSpecifications,
        deleteListApi,
        blurUpdateApi,
        getVersion,
        addVersion,
        addProduct
    } from "@/api/standardLibrary";
    import {
        addStandardProjectGroupApi,
    } from "@/api/basicData/index";
    export default {
        data() {
            return {
                projectGroupingOptions:[],
                form: {
                    father: "", // 项目分组
                    name: "", // 项目名称
                    unit: "", // 单位
                },
                rules: {
                    fater:[{required:true,message:"请选择项目名称",trigger:"blur"}],
                    name: [
                        {required: true,message: "请输入项目名称",trigger: "blur"},
                        {min: 2,max: 25,message: "长度在 2 到 25 个字符",trigger: "blur",},
                    ],
                    unit: [
                        {required: true,message: "请输入单位",trigger: "blur"},
                        {min: 1,max: 25,message: "长度在 1 到 25 个字符",trigger: "blur"}
                    ],
                },
                centerDialogVisible : false,
                filterNodeData: [],
                options: [],
                versionValue: "",
                deleteList: [],
                msg: "",
                isAllSelect: false,
                addTreeFormVisible: false,
                filterText: "",
                // 标准库bom树
                standardTree: [],
                // bom的,默认配置值
                defaultProps: {
                    children: "children",
                    label: "name",
                    value: "id",
                },
                tableData: [],
                oldtableData: [],
                tablespecifications: [],
                // 选中的节点数据
                selectData: {},
                formTypeOptions: [],
                addTreeForm: {
                    addTypeArr: [],
                    specificationsName: "",
                    materialName: "",
                    standardName: "",
import {
    getMaterialList,
    getProductList,
    addMaterial,
    addStandards,
    addSpecifications,
    deleteListApi,
    blurUpdateApi,
    getVersion,
    addVersion,
    addProduct
} from "@/api/standardLibrary";
import {
    addStandardProjectGroupApi,
} from "@/api/basicData/index";
export default {
    data() {
        return {
            projectGroupingOptions: [],
            form: {
                father: "", // 项目分组
                name: "", // 项目名称
                unit: "", // 单位
            },
            rules: {
                fater: [{ required: true, message: "请选择项目名称", trigger: "blur" }],
                name: [
                    { required: true, message: "请输入项目名称", trigger: "blur" },
                    { min: 2, max: 25, message: "长度在 2 到 25 个字符", trigger: "blur", },
                ],
                unit: [
                    { required: true, message: "请输入单位", trigger: "blur" },
                    { min: 1, max: 25, message: "长度在 1 到 25 个字符", trigger: "blur" }
                ],
            },
            centerDialogVisible: false,
            filterNodeData: [],
            options: [],
            versionValue: "",
            deleteList: [],
            msg: "",
            isAllSelect: false,
            addTreeFormVisible: false,
            filterText: "",
            // 标准库bom树
            standardTree: [],
            // bom的,默认配置值
            defaultProps: {
                children: "children",
                label: "name",
                value: "id",
            },
            tableData: [],
            oldtableData: [],
            tablespecifications: [],
            // 选中的节点数据
            selectData: {},
            formTypeOptions: [],
            addTreeForm: {
                addTypeArr: [],
                specificationsName: "",
                materialName: "",
                standardName: "",
            }
        };
    },
    watch: {
        filterText(val) {
            this.$refs.tree.filter(val);
        },
        addTreeFormVisible(newVal) {
            if (newVal === false) {
                this.clear();
            }
        },
        centerDialogVisible: {
            handler(newVal, oldVal) {
                if (newVal == true) {
                    addStandardProjectGroupApi().then((res) => {
                        this.projectGroupingOptions = res.data;
                    });
                } else {
                    // 请求成功清除数据
                    this.form = {};
                    // 提交成功清除检验
                    this.$refs.ruleForm.resetFields();
                }
            },
        },
    },
    created() {
        this.getStandardTree();
    },
    mounted() {
    },
    methods: {
        querySearch(queryString, cb) {
            var restaurants = []
            this.projectGroupingOptions.forEach(a => {
                restaurants.push({
                    value: a
                })
            })
            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        createFilter(queryString) {
            return (restaurant) => {
                return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
            };
        },
        watch: {
            filterText(val) {
                this.$refs.tree.filter(val);
            },
            addTreeFormVisible(newVal){
                if(newVal === false){
                    this.clear();
                }
            },
            centerDialogVisible: {
                handler(newVal, oldVal) {
                    if (newVal == true) {
                        addStandardProjectGroupApi().then((res) => {
                            this.projectGroupingOptions = res.data;
                        });
                    } else {
                        // 请求成功清除数据
                        this.form = {};
                        // 提交成功清除检验
                        this.$refs.ruleForm.resetFields();
                    }
                },
            },
        clear() {
            this.addTreeFormVisible = false;
            this.addTreeForm.addTypeArr = [];
            this.addTreeForm.specificationsName = '';
            this.addTreeForm.materialName = ''
            this.addTreeForm.standardName = ''
        },
        created() {
            this.getStandardTree();
        },
        mounted() {
        },
        methods: {
            querySearch(queryString, cb) {
                var restaurants = []
                this.projectGroupingOptions.forEach(a => {
                    restaurants.push({
                        value: a
                    })
                })
                var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
                // 调用 callback 返回建议列表的数据
                cb(results);
            },
            createFilter(queryString) {
                return (restaurant) => {
                    return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
                };
            },
            clear(){
                this.addTreeFormVisible = false;
                this.addTreeForm.addTypeArr=[];
                this.addTreeForm.specificationsName='';
                this.addTreeForm.materialName=''
                this.addTreeForm.standardName=''
            },
            changeSample(){
                let selectType=this.standardTree.filter(item=>{
                    return item.id===this.addTreeForm.addTypeArr[0]
                })[0];
                if(this.addTreeForm.addTypeArr.length==1){
                    let samples=selectType.children.filter(item=>{
                        return item.name===this.addTreeForm.materialName
                    })[0]
                    if(samples===undefined||samples===[]){
                        this.$message({
                                  message: '请先在基础数据中添加该【'+this.addTreeForm.materialName+'】样品',
                                  type: 'warning'
                            });
                         return false;
                    }
                }
                return true
            },
            oneSize(){},
            twoSize(){
                return true;
            },
            threeSize(){
                return true;
            },
            async initSelect() {
                this.options = [];
                this.versionValue = "";
                const response = await getVersion({
                    specificationsId: this.selectData.id,
                });
                if (response.code === 200 && response.data.length > 0) {
                    this.getTableByClick(this.selectData, response.data[0]);
                    for (let i = 0; i < response.data.length; i++) {
                        this.options.push({
                            value: response.data[i],
                            label: "V" + response.data[i],
                        });
                        this.versionValue = response.data[0];
                    }
                }
            },
            changeSelect() {
                this.tableData = [];
                this.getTableByClick(this.selectData, this.versionValue);
            },
            async submitAdd(){
                await addProduct({
                    father : this.form.father,
                    name : this.form.name,
                    specificationId: this.selectData.id,
                    unit : this.form.unit,
                    version : this.versionValue
                }).then(res=>{
                    console.log(res);
                    this.$message.success(res.message);
                    this.centerDialogVisible = false;
                    this.getTableByClick(this.selectData, this.versionValue);
                }).catch(error=>{
                    this.$message.error(error.message);
                })
            },
            async insertVersion() {
                const resp = await addVersion({
                    specificationsId: this.selectData.id,
                    version: this.versionValue
                });
                if (resp.code === 200) {
                    this.initSelect();
        changeSample() {
            let selectType = this.standardTree.filter(item => {
                return item.id === this.addTreeForm.addTypeArr[0]
            })[0];
            if (this.addTreeForm.addTypeArr.length == 1) {
                let samples = selectType.children.filter(item => {
                    return item.name === this.addTreeForm.materialName
                })[0]
                if (samples === undefined || samples === []) {
                    this.$message({
                        type: "success",
                        message: resp.message,
                        message: '请先在基础数据中添加该【' + this.addTreeForm.materialName + '】样品',
                        type: 'warning'
                    });
                    return false;
                }
            },
            addVersionFun() {
                this.$confirm("确认添加新的版本号吗?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    })
                    .then(() => {
                        this.insertVersion();
                    })
                    .catch(() => {});
            },
            filterNode(value, data,node) {
                if (!value) return true;
                return data.name.indexOf(value) !== -1;
            },
            // 获取bom树的标准数据
            async getStandardTree() {
                let {
                    data
                } = await getMaterialList();
                if (data.length < 2) {
                    if (data.length == 0) {
                        data = [{
                            type: 0
                        }, {
                            type: 1
                        }]
                    } else {
                        data[1] = {
                            type: data[0].type == 1 ? 0 : 1
                        }
                    }
                }
                this.standardTree = data.map((item) => {
                    let name = null;
                    switch (item.type) {
                        case 0:
                            name = "原材料";
                            break;
                        case 1:
                            name = "成品";
                            break;
                    }
                    return {
                        ...item,
                        id: item.type,
                        name,
                    };
                });
                // formTypeOptions
                // 默认第一个四级节点搜索,新增配置项
                const treeOptions = JSON.parse(JSON.stringify(this.standardTree));
                this.getDefault(treeOptions, 0);
                this.formTypeOptions = treeOptions;
                this.$nextTick().then(() => {
                    const firstNode = document.querySelector(
                        ".el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node"
                    );
                    try {
                        firstNode.click();
                    } catch (e) {
                        //TODO handle the exception
                    }
                });
            },
            getDefault(arr, index) {
                for (const item of arr) {
                    if (item.children && item.children?.length > 0) {
                        // 有子节点
                        this.getDefault(item.children, index + 1);
                        if (index === 2) {
                            item.children = null;
                        }
                    }
                }
            },
            // 点击bom树节点方法
            async nodeClick(data, node, element) {
                // 是子节点
                if (node.level === 4) {
                    this.getParentData(node.parent, node.data.name);
                    // 存下选中节点
                    this.selectData = data;
                    this.getTableByClick(data, this.versionValue);
                    this.initSelect();
                }
                if (!("children" in data)) {
                    return;
                }
            },
            // 获取树路径
            getParentData(node, name) {
                if (node !== null) {
                    if (node.data.name !== undefined) {
                        this.msg = node.data.name + " > " + name;
                    }
                    this.getParentData(node.parent, this.msg);
                }
            },
            async getTableByClick(data, versionVal) {
                await getProductList({
                    specificationsId: data.id,
                    version: versionVal,
                }).then((res) => {
                    res.data.forEach((i) => {
                        if (i.name === undefined) {
                            i.name = i.children[0].name;
                            i.unit = i.children[0].unit;
                            i.id = i.children[0].id;
                            i.required = i.children[0].required;
                            i.internal = i.children[0].internal;
                            i.edit = true;
                            delete i.children;
                        }
            }
            return true
        },
        oneSize() { },
        twoSize() {
            return true;
        },
        threeSize() {
            return true;
        },
        async initSelect() {
            this.options = [];
            this.versionValue = "";
            const response = await getVersion({
                specificationsId: this.selectData.id,
            });
            if (response.code === 200 && response.data.length > 0) {
                this.getTableByClick(this.selectData, response.data[0]);
                for (let i = 0; i < response.data.length; i++) {
                    this.options.push({
                        value: response.data[i],
                        label: "V" + response.data[i],
                    });
                    this.tableData = res.data;
                    this.selectDataList();
                });
            },
            specificationDetails(row) {
                // 跳转产品规格详情页
                this.$router.push(`/standardLibrary/SpecificationDetails/${row.id}`);
            },
            renderContent(h, {
                node,
                data,
                store
            }) {
                // 判断是否是父节点或文件夹
                const isFolder = "children" in data;
                return ( <span class="tree-node"> {
                        isFolder ? ( <i class = {node.expanded ?"el-icon-folder-opened blue-folder" : "el-icon-folder blue-folder"} ></i>
                        ) : ( <i class = "el-icon-document blue-folder" > </i>)
                    } <div class = "tree-lable" > [{node.level}] {data.name} </div> </span>
                );
            },
            async subAddTreeForm() {
                if(this.addTreeForm.addTypeArr.length==0){
                    this.$message({
                                  message: '请先选择标准类型!',
                                  type: 'warning'
                            });
                    return
                    this.versionValue = response.data[0];
                }
                let handelerSample=this.changeSample()
                if(!handelerSample){
                    return;
                }
                let res = null;
                try {
                    switch (this.addTreeForm.addTypeArr.length) {
                        case 1:
                            res = await addMaterial({
                                ...this.addTreeForm,
                                type: this.addTreeForm.addTypeArr[0],
                            });
                            break;
                        case 2:
                            res = await addStandards({
                                ...this.addTreeForm,
                                materialId: this.addTreeForm.addTypeArr[1],
                            });
                            break;
                        case 3:
                            res = await addSpecifications({
                                ...this.addTreeForm,
                                standardId: this.addTreeForm.addTypeArr[2],
                            });
                            break;
                    }
                } catch (error) {
                    this.$message.error("添加失败");
                }
                this.$message.success("添加成功");
                this.addTreeFormVisible = false;
                this.getStandardTree();
            }
        },
        changeSelect() {
            this.tableData = [];
            this.getTableByClick(this.selectData, this.versionValue);
        },
        async submitAdd() {
            await addProduct({
                father: this.form.father,
                name: this.form.name,
                specificationId: this.selectData.id,
                unit: this.form.unit,
                version: this.versionValue
            }).then(res => {
                console.log(res);
                this.$message.success(res.message);
                this.centerDialogVisible = false;
                this.getTableByClick(this.selectData, this.versionValue);
                this.addTreeForm.addTypeArr=[];
                this.addTreeForm.specificationsName=''
                this.addTreeForm.materialName=''
                this.addTreeForm.standardName=''
                // console.log(this.addTreeForm);
            },
            changeCascader(data) {
                this.addTreeForm.addTypeArr = data;
            },
            selectDataList() {
                let i=0
                this.tableData.forEach((a) => {
                    a.id="0"+i
                    a.code = "[1]";
                    i++;
                    if (a.children != undefined) {
                        a.children.forEach((b) => {
                            b.code = "[2]";
                        });
                    }
            }).catch(error => {
                this.$message.error(error.message);
            })
        },
        async insertVersion() {
            const resp = await addVersion({
                specificationsId: this.selectData.id,
                version: this.versionValue
            });
            if (resp.code === 200) {
                this.initSelect();
                this.$message({
                    type: "success",
                    message: resp.message,
                });
            },
            // 表格树全部选中配置
            // 全选/取消选操作
            selectAll(val) {
                this.isAllSelect = !this.isAllSelect;
                let data = this.tableData;
                this.toggleSelect(data, this.isAllSelect, "all");
            },
            //选择某行
            selectTr(selection, row) {
                this.$set(row, "isChecked", !row.isChecked);
                this.$nextTick(() => {
                    this.isAllSelect = row.isChecked;
                    this.toggleSelect(row, row.isChecked, "tr");
                });
            },
            //递归子级
            toggleSelect(data, flag, type) {
                if (type === "all") {
                    if (data.length > 0) {
                        data.forEach((item) => {
                            this.toggleSelection(item, flag);
                            if (item.children && item.children.length > 0) {
                                this.toggleSelect(item.children, flag, type);
                            }
                        });
                    }
            }
        },
        addVersionFun() {
            this.$confirm("确认添加新的版本号吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.insertVersion();
                })
                .catch(() => { });
        },
        filterNode(value, data, node) {
            if (!value) return true;
            return data.name.indexOf(value) !== -1;
        },
        // 获取bom树的标准数据
        async getStandardTree() {
            let {
                data
            } = await getMaterialList();
            if (data.length < 2) {
                if (data.length == 0) {
                    data = [{
                        type: 0
                    }, {
                        type: 1
                    }]
                } else {
                    if (data.children && data.children.length > 0) {
                        data.children.forEach((item) => {
                            item.isChecked = !item.isChecked;
                            this.$refs.multipleTable.toggleRowSelection(item, flag);
                            this.toggleSelect(item, flag, type);
                        });
                    data[1] = {
                        type: data[0].type == 1 ? 0 : 1
                    }
                }
            },
            //改变选中
            toggleSelection(row, flag) {
                this.$set(row, "isChecked", flag);
                this.$nextTick(() => {
                    if (flag) {
                        this.$refs.multipleTable.toggleRowSelection(row, flag);
                    } else {
                        this.$refs.multipleTable.clearSelection();
            }
            this.standardTree = data.map((item) => {
                let name = null;
                switch (item.type) {
                    case 0:
                        name = "原材料";
                        break;
                    case 1:
                        name = "成品";
                        break;
                }
                return {
                    ...item,
                    id: item.type,
                    name,
                };
            });
            // formTypeOptions
            // 默认第一个四级节点搜索,新增配置项
            const treeOptions = JSON.parse(JSON.stringify(this.standardTree));
            this.getDefault(treeOptions, 0);
            this.formTypeOptions = treeOptions;
            this.$nextTick().then(() => {
                const firstNode = document.querySelector(
                    ".el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node"
                );
                try {
                    firstNode.click();
                } catch (e) {
                    //TODO handle the exception
                }
            });
        },
        getDefault(arr, index) {
            for (const item of arr) {
                if (item.children && item.children?.length > 0) {
                    // 有子节点
                    this.getDefault(item.children, index + 1);
                    if (index === 2) {
                        item.children = null;
                    }
                }
            }
        },
        // 点击bom树节点方法
        async nodeClick(data, node, element) {
            // 是子节点
            if (node.level === 4) {
                this.getParentData(node.parent, node.data.name);
                // 存下选中节点
                this.selectData = data;
                this.getTableByClick(data, this.versionValue);
                this.initSelect();
            }
            if (!("children" in data)) {
                return;
            }
        },
        // 获取树路径
        getParentData(node, name) {
            if (node !== null) {
                if (node.data.name !== undefined) {
                    this.msg = node.data.name + " > " + name;
                }
                this.getParentData(node.parent, this.msg);
            }
        },
        async getTableByClick(data, versionVal) {
            await getProductList({
                specificationsId: data.id,
                version: versionVal,
            }).then((res) => {
                res.data.forEach((i) => {
                    if (i.name === undefined) {
                        i.name = i.children[0].name;
                        i.unit = i.children[0].unit;
                        i.id = i.children[0].id;
                        i.required = i.children[0].required;
                        i.internal = i.children[0].internal;
                        i.edit = true;
                        delete i.children;
                    }
                });
            },
            handleSelectionChange(val) {
                this.deleteList = [];
                val.forEach((v) => {
                    if (v.id !== undefined) {
                        this.deleteList.push(v.id);
                    }
                this.tableData = res.data;
                this.selectDataList();
            });
        },
        specificationDetails(row) {
            // 跳转产品规格详情页
            this.$router.push(`/standardLibrary/SpecificationDetails/${row.id}`);
        },
        renderContent(h, {
            node,
            data,
            store
        }) {
            // 判断是否是父节点或文件夹
            const isFolder = "children" in data;
            return (<span class="tree-node"> {
                isFolder ? (<i class={node.expanded ? "el-icon-folder-opened blue-folder" : "el-icon-folder blue-folder"} ></i>
                ) : (<i class="el-icon-document blue-folder" > </i>)
            } <div class="tree-lable" > [{node.level}] {data.name} </div> </span>
            );
        },
        async subAddTreeForm() {
            if (this.addTreeForm.addTypeArr.length == 0) {
                this.$message({
                    message: '请先选择标准类型!',
                    type: 'warning'
                });
            },
            // 表格树全部选中配置  结束
            deleteListClick() {
                if(this.deleteList.length==0){
                    this.$message.error('请选择要删除的项目')
                return
            }
            let handelerSample = this.changeSample()
            if (!handelerSample) {
                return;
            }
            let res = null;
            try {
                switch (this.addTreeForm.addTypeArr.length) {
                    case 1:
                        res = await addMaterial({
                            ...this.addTreeForm,
                            type: this.addTreeForm.addTypeArr[0],
                        });
                        break;
                    case 2:
                        res = await addStandards({
                            ...this.addTreeForm,
                            materialId: this.addTreeForm.addTypeArr[1],
                        });
                        break;
                    case 3:
                        res = await addSpecifications({
                            ...this.addTreeForm,
                            standardId: this.addTreeForm.addTypeArr[2],
                        });
                        break;
                }
            } catch (error) {
                this.$message.error("添加失败");
            }
            this.$message.success("添加成功");
            this.addTreeFormVisible = false;
            this.getStandardTree();
            this.getTableByClick(this.selectData, this.versionValue);
            this.addTreeForm.addTypeArr = [];
            this.addTreeForm.specificationsName = ''
            this.addTreeForm.materialName = ''
            this.addTreeForm.standardName = ''
            // console.log(this.addTreeForm);
        },
        changeCascader(data) {
            this.addTreeForm.addTypeArr = data;
        },
        selectDataList() {
            let i = 0
            this.tableData.forEach((a) => {
                a.id = "0" + i
                a.code = "[1]";
                i++;
                if (a.children != undefined) {
                    a.children.forEach((b) => {
                        b.code = "[2]";
                    });
                }
            });
        },
        // 表格树全部选中配置
        // 全选/取消选操作
        selectAll(val) {
            this.isAllSelect = !this.isAllSelect;
            let data = this.tableData;
            this.toggleSelect(data, this.isAllSelect, "all");
        },
        //选择某行
        selectTr(selection, row) {
            this.$set(row, "isChecked", !row.isChecked);
            this.$nextTick(() => {
                this.isAllSelect = row.isChecked;
                this.toggleSelect(row, row.isChecked, "tr");
            });
        },
        //递归子级
        toggleSelect(data, flag, type) {
            if (type === "all") {
                if (data.length > 0) {
                    data.forEach((item) => {
                        this.toggleSelection(item, flag);
                        if (item.children && item.children.length > 0) {
                            this.toggleSelect(item.children, flag, type);
                        }
                    });
                }
            } else {
                if (data.children && data.children.length > 0) {
                    data.children.forEach((item) => {
                        item.isChecked = !item.isChecked;
                        this.$refs.multipleTable.toggleRowSelection(item, flag);
                        this.toggleSelect(item, flag, type);
                    });
                }
            }
        },
        //改变选中
        toggleSelection(row, flag) {
            this.$set(row, "isChecked", flag);
            this.$nextTick(() => {
                if (flag) {
                    this.$refs.multipleTable.toggleRowSelection(row, flag);
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
            });
        },
        handleSelectionChange(val) {
            this.deleteList = [];
            val.forEach((v) => {
                if (v.id !== undefined) {
                    this.deleteList.push(v.id);
                }
            });
        },
        // 表格树全部选中配置  结束
        deleteListClick() {
            if (this.deleteList.length == 0) {
                this.$message.error('请选择要删除的项目')
                return
            }
            deleteListApi(this.deleteList).then((res) => {
                this.$message({
                    message: res.message,
                    type: "success",
                });
                this.getTableByClick(this.selectData, this.versionValue);
            });
        },
        async requiredOnfocus(scope) {
            console.log(scope);
            let obj = {
                id: scope.row.id,
                required: scope.row.required,
                internal: scope.row.internal,
            };
            let arr = ['>', '<', '='];
            if (obj.required === null || obj.required === undefined) {
                this.$message({
                    message: '标准值不能为空!',
                    type: 'warning'
                });
                return
            } else {
                let required = obj.required.charAt(0)
                if (!arr.includes(required)) {
                    this.$message({
                        message: '标准值参数不符合!',
                        type: 'warning'
                    });
                    return
                }
                deleteListApi(this.deleteList).then((res) => {
                    this.$message({
                        message: res.message,
                        type: "success",
                    });
                    this.getTableByClick(this.selectData, this.versionValue);
            }
            if (obj.internal === null || obj.internal === undefined) {
                this.$message({
                    message: '内控值不能为空!',
                    type: 'warning'
                });
            },
            async requiredOnfocus(scope) {
                let obj = {
                    id: scope.row.id,
                    required: scope.row.required,
                    internal: scope.row.internal,
                };
                await blurUpdateApi(obj).then((res) => {
                return
            } else {
                let internal = obj.internal.charAt(0)
                if (!arr.includes(internal)) {
                    this.$message({
                        message: res.message,
                        type: "success",
                        message: '内控值参数不符合!',
                        type: 'warning'
                    });
                    this.getTableByClick(this.selectData, this.versionValue);
                    return
                }
            }
            await blurUpdateApi(obj).then((res) => {
                this.$message({
                    message: res.message,
                    type: "success",
                });
            },
                this.getTableByClick(this.selectData, this.versionValue);
            });
        },
    };
    },
};
</script>
<style lang="scss" scoped>
    // el-table表格对齐
    ::v-deep .el-table__row:not([class*="el-table__row--level-"]) {
        td:nth-child(2) {
            padding-left: 23px !important;
        }
// el-table表格对齐
::v-deep .el-table__row:not([class*="el-table__row--level-"]) {
    td:nth-child(2) {
        padding-left: 23px !important;
    }
}
    .standard-library-main {
        width: 100vh;
.standard-library-main {
    width: 100vh;
    height: 100%;
    // 页面中心内容区域
    .content-main {
        display: flex;
        height: 100%;
        min-height: calc(100vh - 88px);
        max-height: calc(100vh - 88px);
        padding: 15px;
        // 页面中心内容区域
        .content-main {
            display: flex;
            height: 100%;
            min-height: calc(100vh - 88px);
            max-height: calc(100vh - 88px);
            padding: 15px;
        >div {
            padding: 20px;
            background: #fff;
        }
            >div {
                padding: 20px;
                background: #fff;
            }
        .library-bom {
            // padding-right: 10px;
            width: 300px;
            overflow-y: auto;
            // height: 100%;
            max-height: 100%;
            .library-bom {
                // padding-right: 10px;
                width: 300px;
                overflow-y: auto;
                // height: 100%;
                max-height: 100%;
            // margin-right: 12px;
            // overflow-y: scroll;
            .el-tree {
                // margin-top:
                width: 100%;
                // margin-right: 12px;
                // overflow-y: scroll;
                .el-tree {
                    // margin-top:
                    width: 100%;
                ::v-deep .el-tree-node__content {
                    height: 24px !important;
                    font-size: 18px;
                    // display: inline-block !important;
                    padding: 2px;
                    ::v-deep .el-tree-node__content {
                        height: 24px !important;
                        font-size: 18px;
                        // display: inline-block !important;
                        padding: 2px;
                    // color: #333;
                    .tree-node {
                        display: flex;
                        align-items: center;
                        height: 20px;
                    }
                        // color: #333;
                        .tree-node {
                            display: flex;
                            align-items: center;
                            height: 20px;
                        }
                    .tree-lable {
                        height: 100%;
                        line-height: 23px;
                        font-size: 12px;
                        padding-left: 8px;
                    }
                        .tree-lable {
                            height: 100%;
                            line-height: 23px;
                            font-size: 12px;
                            padding-left: 8px;
                        }
                        .blue-folder {
                            color: rgb(64, 158, 255);
                        }
                    .blue-folder {
                        color: rgb(64, 158, 255);
                    }
                }
            }
        }
            .library-table {
                // height: 100%;
                width: 170vh;
                max-height: 100%;
                // flex: 8;
                margin-left: 12px;
        .library-table {
            // height: 100%;
            width: 170vh;
            max-height: 100%;
            // flex: 8;
            margin-left: 12px;
            display: flex;
            flex-direction: column;
            // overflow-y: scroll;
            .table-header {
                display: flex;
                justify-content: space-between;
                width: 100%;
                .el-form-item {
                    margin-bottom: 30px !important;
                }
            }
            .table-box {
                flex: 1;
                background: #fff;
                // padding: 20px 20px 10px 20px;
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                // overflow-y: scroll;
                .table-header {
                >div:nth-child(3) {
                    // height: 20px;
                    display: flex;
                    justify-content: space-between;
                    width: 100%;
                    .el-form-item {
                        margin-bottom: 30px !important;
                    }
                }
                .table-box {
                    flex: 1;
                    background: #fff;
                    // padding: 20px 20px 10px 20px;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    >div:nth-child(3) {
                        // height: 20px;
                        display: flex;
                        justify-content: end;
                        margin: 10px 0;
                    }
                    justify-content: end;
                    margin: 10px 0;
                }
            }
        }
    }
        .addTree {
            .el-form-item {
                margin-bottom: 10px;
            }
    .addTree {
        .el-form-item {
            margin-bottom: 10px;
        }
            .el-cascader {
                width: 100%;
            }
        .el-cascader {
            width: 100%;
        }
    }
}
    .search-bar {
        .el-input {
            position: relative;
            font-size: 0.07292rem;
            display: inline-block;
            width: 70%;
        }
.search-bar {
    .el-input {
        position: relative;
        font-size: 0.07292rem;
        display: inline-block;
        width: 70%;
    }
}
    .firstDiv {
        float: left;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #eff5ff;
        margin-top: 5px;
        justify-content: center;
        display: flex;
        align-items: center;
        margin-right: 8px;
.firstDiv {
    float: left;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #eff5ff;
    margin-top: 5px;
    justify-content: center;
    display: flex;
    align-items: center;
    margin-right: 8px;
}
.el-tag.el-tag {
    border-color: transparent;
    background-color: transparent;
}
.el-tag.el-tag:hover {
    border-color: transparent;
    background-color: transparent;
}
.serve-btn {
    width: 100%;
    padding-bottom: 6px;
    text-align: right;
    .el-select {
        margin-right: 10px;
    }
}
    .el-tag.el-tag {
        border-color: transparent;
        background-color: transparent;
    }
    .el-tag.el-tag:hover {
        border-color: transparent;
        background-color: transparent;
    }
    .serve-btn {
        width: 100%;
        padding-bottom: 6px;
        text-align: right;
        .el-select {
            margin-right: 10px;
        }
    }
    .tipMsg {
        float: left;
        font-size: 16px;
        font-weight: 500;
        color: #999999;
    }
.tipMsg {
    float: left;
    font-size: 16px;
    font-weight: 500;
    color: #999999;
}
</style>