Fixiaobai
2023-09-09 34a7e21b3508ac0f5f011d958210fdb7176d726b
src/views/laboratory/measure/Add.vue
@@ -5,26 +5,30 @@
        </el-col>
        <el-col>
            <el-form :model="planAddInfo" style="padding-left: 150px;">
                <el-form-item>
                <el-col>
                    <el-col :span="6" style="display: flex;justify-content: space-around;">
                        <span>负责人:</span>
                        <el-select v-model="planAddInfo.measurePerson" placeholder="请选择负责人">
                            <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                        <el-form-item label="负责人:" :rules="[{ required: true, message: '请选择负责人', trigger: 'change' }]">
                            <el-select v-model="planAddInfo.measurePerson" placeholder="请选择负责人">
                                <el-option v-for="item in userList" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8" style="display: flex;justify-content: space-around;">
                        <span>计划时间:</span>
                        <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期">
                        </el-date-picker>
                        <el-form-item label="计划时间:" :rules="[{ required: true, message: '请选择计划时间', trigger: 'change' }]">
                            <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="至"
                                start-placeholder="开始日期" end-placeholder="结束日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5"></el-col>
                    <el-col :span="5" style="display: flex;justify-content: space-around;">
                        <span>计量单位:</span>
                        <el-input style="width: 150px;" v-model="planAddInfo.unit" placeholder=""></el-input>
                        <el-form-item label="计量单位:">
                            <el-input style="width: 150px;" v-model="planAddInfo.unit" placeholder=""></el-input>
                        </el-form-item>
                    </el-col>
                </el-form-item>
                </el-col>
            </el-form>
        </el-col>
        <el-col>
@@ -47,7 +51,8 @@
                <el-table-column prop="equipmentPointName" label="仪器设备" min-width="150">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPointName }}</span>
                        <el-select @change="insListChange(scope.row.equipmentPointName,scope)" v-model="scope.row.equipmentPointName" placeholder="请选择仪器设备">
                        <el-select @change="insListChange(scope.row.equipmentPointName, scope)"
                            v-model="scope.row.equipmentPointName" placeholder="请选择仪器设备">
                            <el-option v-for="item in insList" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
@@ -95,6 +100,7 @@
    getListUserAndListIns, addPlanAndMeasure
} from '@/api/laboratory/measure'
import { dateFormat } from "../../../utils/dateUtil";
import { MessageBox, Message } from 'element-ui'
export default {
    data() {
        return {
@@ -125,7 +131,7 @@
            }],
            userList: [],
            insList: [],
            instrumentList:[],
            instrumentList: [],
            // 码点表格的状态:数据展示false/新增输入true
            codePointesTableStatus: false,
        }
@@ -136,11 +142,10 @@
        res.data.userList.forEach(element => {
            this.userList.push({ label: element.name, value: element.id })
        });
        this.instrumentList=res.data.instrumentList
        this.instrumentList = res.data.instrumentList
        res.data.instrumentList.forEach(item => {
            this.insList.push({ label: item.equipmentName, value: item.id })
        })
        console.log(this.insList);
    },
    methods: {
        addcodePointsTable() {
@@ -162,21 +167,28 @@
            })
        },
        async add() {
            console.log(111111);
            if (this.planAddInfo.measurePerson == null || this.planAddInfo.measurePerson == ''||this.planAddInfo.planDate[0]==null||this.planAddInfo.planDate[0]=='') {
                Message({
                    message: "负责人和计划日期不能为空!",
                    type: 'warning',
                    duration: 2 * 1000
                })
                return false
            }
            this.planAddInfo.startTime = dateFormat(this.planAddInfo.planDate[0])
            this.planAddInfo.endTime = dateFormat(this.planAddInfo.planDate[1])
            console.log(this.planAddInfo);
            this.planAddInfo.planDate = null
            this.codePointsTable.forEach(item => {
                if(item.endDate!=null&&item.endDate!=''){
                if (item.endDate != null && item.endDate != '') {
                    item.endDate = dateFormat(item.endDate)
                }
            })
            console.log(this.codePointsTable);
            console.log(this.codePointsTable);
            let data = {}
            this.codePointsTable.length>0?data = { measureList: this.codePointsTable, plan: this.planAddInfo }:data = {plan: this.planAddInfo }
            this.codePointsTable.length > 0 ? data = { measureList: this.codePointsTable, plan: this.planAddInfo } : data = { plan: this.planAddInfo }
            let add = await addPlanAndMeasure(data)
            this.planAddInfo={
            this.planAddInfo = {
                plannedOrderNumber: '',
                measurePerson: '',
                planDate: "",
@@ -184,17 +196,17 @@
                createPerson: '',
                createTime: ''
            }
            this.codePointsTable=[]
            this.codePointsTable = []
            return add.data
        },
        insListChange(i,s){
        insListChange(i, s) {
            console.log(i);
            console.log(s.$index);
            let ins= this.instrumentList.filter(item=>{
                return item.id==i
            let ins = this.instrumentList.filter(item => {
                return item.id == i
            })[0]
            this.codePointsTable[s.$index].measuringRange=ins.measuringRange
            this.codePointsTable[s.$index].termValidity=ins.termValidity+'月'
            this.codePointsTable[s.$index].measuringRange = ins.measuringRange
            this.codePointsTable[s.$index].termValidity = ins.termValidity + '月'
        }
    }
}