Fixiaobai
2023-09-19 88859106604b03bed968f2f55508e3a5b83f4ce9
src/components/view/processInspectionUpdate.vue
@@ -103,8 +103,8 @@
            > -->
                </el-col>
            </el-row>
            <el-table :data="inspectionItems" max-height="420" :span-method="handleSpanMethod" height="calc(100vh - 550px)"
                style="width: 100%">
            <el-table border :data="inspectionItems" max-height="420" :span-method="handleSpanMethod"
                height="calc(100vh - 550px)" style="width: 100%">
                <el-table-column type="index" label="序号" width="60"></el-table-column>
                <el-table-column label="项目" prop="father"></el-table-column>
                <el-table-column prop="name" label="指标"></el-table-column>
@@ -123,9 +123,17 @@
                </el-table-column>
                <el-table-column prop="dname" label="试验设备" min-width="100">
                    <template slot-scope="scope">
                        <el-button type="text" @click="clickTableSelect(scope)">{{
                            scope.row.dname == null ? "请选择" : scope.row.dname
                        }}</el-button>
                        <el-col>
                            <el-button v-if="!scope.row.isSelectDevice" type="text" @click="clickTableSelect(scope)">{{
                                scope.row.dname == null ? "请选择" : scope.row.dname
                            }}</el-button>
                            <el-select @blur="blurNode(scope)" v-else-if="scope.row.isSelectDevice" style="width: 100%;"
                                @change="clickNodeSure(scope.row)" v-model="filterText" placeholder="请选择">
                                <el-option v-for="item in materialOptions" :key="item.id" :label="item.device"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-col>
                    </template>
                </el-table-column>
                <el-table-column label="结论">
@@ -156,8 +164,9 @@
                    </template>
                </el-table-column>
                <el-table-column prop="operation" label="上报">
                    <template slot-scope="scope">
                        <el-button v-if="scope.row.conclusion === null || scope.row.conclusion === undefined" type="primary" @click="escalation" size="small">上报</el-button>
                    <template slot-scope="scope">
                        <el-button v-if="scope.row.conclusion === null || scope.row.conclusion === undefined" type="primary"
                            @click="escalation" size="small">上报</el-button>
                        <el-button v-else type="success" size="small">已上报</el-button>
                    </template>
                </el-table-column>
@@ -165,22 +174,15 @@
        </div>
        <el-dialog title="请选择设备" :visible.sync="centerDialogVisible" width="20%">
            <div class="div_device_dialog">
                <el-input placeholder="输入关键字进行过滤" v-model="filterText" style="margin-bottom: 6px;">
                </el-input>
                <el-tree class="filter-tree" :data="materialOptions" :props="defaultProps" default-expand-all
                    highlight-current @node-click="nodeClick" :filter-node-method="filterNode" ref="tree">
                    <div class="custom-tree-node" slot-scope="{ data }">
                        <span><i :class="`node_i ${data.children ? 'el-icon-folder-opened' : 'el-icon-tickets'
                            }`
                            "></i>
                            {{ data.name }}</span>
                    </div>
                </el-tree>
                <!-- <el-select style="width: 100%;" @change="clickNodeSure()" v-model="filterText" placeholder="请选择">
                    <el-option v-for="item in materialOptions" :key="item.id" :label="item.device" :value="item.id">
                    </el-option>
                </el-select> -->
            </div>
            <span slot="footer" class="dialog-footer">
            <!-- <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="clickNodeSure()">确 定</el-button>
            </span>
            </span> -->
        </el-dialog>
    </div>
</template>
@@ -266,21 +268,24 @@
                children: "children",
                label: "name"
            },
            nodeData: "", // node点击保存当前点击数据
            nodeData: {
                id: 0,
                name: null
            }, // node点击保存当前点击数据
            clickSelectDevice: {
                index: "", // 点击选择存储当前行索引
                rpId: "" // 点击选择存储当前行项目Id
                index: null, // 点击选择存储当前行索引
                rpId: null // 点击选择存储当前行项目Id
            }
        };
    },
    watch: {
        filterText(val) {
            this.$refs.tree.filter(val);
        }
        // filterText(val) {
        //     this.$refs.tree.filter(val);
        // }
    },
    created() {
        if(this.rowInfo.result!=null&&this.rowInfo.result!=''){
            this.isUpBtn=true
        if (this.rowInfo.result != null && this.rowInfo.result != '') {
            this.isUpBtn = true
        }
        this.processInspectVo.orderNumber = this.rowInfo.order_number
        this.processInspectVo.material = this.rowInfo.material
@@ -297,10 +302,13 @@
        // console.log(this.detailId);
    },
    mounted() {
        this.getOptions();
        this.getTableData()
    },
    methods: {
        blurNode(scope) {
            // console.log(11);
            // this.$set(this.inspectionItems[scope.$index],'isSelectDevice',false)
        },
        escalation() {
            let arr = this.inspectionItems
            let bl = false
@@ -323,8 +331,14 @@
            this.$axios.post(this.$api.url.processInspectUpdateProcessInspectsById, {
                id: this.detailId
            }).then(res => {
                console.log(res);
                if (res.code == 200) {
                    if (res.message === '项目未检验完!') {
                        this.$message({
                            message: res.message,
                            type: 'warning'
                        });
                        return
                    }
                    this.$message({
                        message: '上报成功',
                        type: 'success'
@@ -355,9 +369,25 @@
            return data.name.indexOf(value) !== -1;
        },
        // 获取设备树内容
        getOptions() {
            this.$axios.get(this.$api.url.rawSelectDevice).then(res => {
        getOptions(row) {
            this.filterText = 0
            this.$axios.get(this.$api.url.inspectionItemChooseDev, {
                params: {
                    father: row.father,
                    name: row.name,
                    technologyId: this.processInspectVo.technologyId
                }
            }).then(res => {
                this.materialOptions = res.data;
                if (this.materialOptions.length === 1&&row.did!=null) {
                    this.$message({
                        message: '该项目下只有一个试验设备,无需选择!',
                        type: 'warning'
                    });
                    return
                }
                row.isSelectDevice = true
                this.filterText = row.did
            });
        },
        //返回
@@ -366,40 +396,59 @@
        },
        // 点击表格选择触发
        clickTableSelect(scope) {
            this.centerDialogVisible = true;
            // return scope;
            // this.centerDialogVisible = true;
            if (this.clickSelectDevice.index != null) {
                this.$set(this.inspectionItems[this.clickSelectDevice.index], 'isSelectDevice', false)
            }
            this.clickSelectDevice.index = scope.$index;
            this.clickSelectDevice.rpId = scope.row.id;
            this.getOptions(scope.row);
        },
        // 点击树里面的确定
        clickNodeSure() {
            if (this.detailId == null) {
                this.inspectionItems[
                    this.clickSelectDevice.index
                ].did = this.nodeData.id;
                this.inspectionItems[
                    this.clickSelectDevice.index
                ].dname = this.nodeData.name;
                this.centerDialogVisible = false;
            } else {
                this.$axios
                    .post(this.$api.url.inspectionItemUpdateDevByInsId, {
                        id: this.clickSelectDevice.rpId,
                        type: 1,
                        devId: this.nodeData.id
                    })
                    .then(res => {
                        this.getTableData()
                        this.centerDialogVisible = false;
                    });
            }
        clickNodeSure(row) {
            console.log(row);
            let select = this.materialOptions.filter(item => {
                return item.id === this.filterText
            })[0]
            this.nodeData.id = select.id
            this.nodeData.name = select.device
            this.$axios
                .post(this.$api.url.inspectionItemUpdateDevByInsId, {
                    id: this.clickSelectDevice.rpId,
                    type: 1,
                    devId: this.nodeData.id
                })
                .then(res => {
                    row.isSelectDevice = false
                    console.log("row", row);
                    this.filterText = 0
                    this.getTableData()
                    this.centerDialogVisible = false;
                });
        },
        changeState(row, index) {
            console.log(row);
            if (row.did != null && row.did != '') {
                // let val = row.empiricalValueAddss.filter(item => {
                //     return item != '' && item != null
                // })
                // let eq = val.filter(item => {
                //     return /^[^><=]/.test(item)
                // })
                // if (eq.length > 0) {
                //     this.$message({
                //         message: "检测值[" + eq + "]格式首位应包含>,<或者=",
                //         type: 'warning'
                //     });
                //     return
                // }
                let str = ""
                row.empiricalValueAddss.forEach(e => {
                    str += e + ","
                })
                if (str.slice(0, -1) === '' || str.slice(0, -1) === null || str.slice(0, -1) === undefined) {
                    return
                }
                this.$axios.post(this.$api.url.inspectionItemlose_focus_update, {
                    deviceId: row.did,
                    inspectionItemId: row.id,
@@ -499,6 +548,15 @@
            })
        },
        getTableData() {
            this.$axios.get(this.$api.url.processInspectSelectProcessInspectsListById, {
                params: {
                    id: this.rowInfo.id
                }
            }).then(res => {
                // console.log(res.data);
                this.processInspectVo.technologyId = res.data[0].techId
                // console.log(this.processInspectVo);
            })
            this.$axios.get(this.$api.url.inspectionItemListUser, {
                params: {
                    id: this.detailId,
@@ -524,6 +582,8 @@
                            c.empiricalValueAddss.push("")
                        }
                        uName.push(c['username'])
                        c.isSelectDevice = false
                        this.filterText = 0
                        arr.push(c)
                    })
                })