Fixiaobai
2023-08-21 95fe284d1b3c11b573653f1564d0e084e7de5bb5
	modified:   src/api/laboratory/measure.js
modified: src/api/util/requestUtil.js
modified: src/components/Breadcrumb/index.vue
modified: src/layout/components/AppMain.vue
modified: src/layout/index.vue
new file: src/utils/dateUtil.js
modified: src/utils/request.js
modified: src/views/laboratory/measure/Add.vue
modified: src/views/laboratory/measure/index.vue
已修改8个文件
已添加1个文件
433 ■■■■ 文件已修改
src/api/laboratory/measure.js 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/util/requestUtil.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Breadcrumb/index.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/AppMain.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/index.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/dateUtil.js 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/measure/Add.vue 170 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/measure/index.vue 158 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/laboratory/measure.js
@@ -33,4 +33,22 @@
    method: 'get',
    params
  })
}
}
//获取user列表和仪器列表
export function getListUserAndListIns(params) {
  return request({
    url: '/metering-plan/getListUserAndListIns',
    method: 'get',
    params
  })
}
//添加计划以及计量信息
export function addPlanAndMeasure(data) {
  return request({
    url: '/metering-plan/addPlanAndMeasure',
    method: 'post',
    data
  })
}
src/api/util/requestUtil.js
@@ -15,4 +15,13 @@
        data
    })
}
export function postFile(path, data) {
    return request({
        url: path,
        method: 'post',
        headers: {
            'Content-Type': 'multipart/form-data'
          },
        data
    })
}
src/components/Breadcrumb/index.vue
@@ -12,6 +12,7 @@
  </el-col>
  <el-col :span="12" style="background-color: #fff;display: flex;justify-content: end; align-items: center;">
    <el-button v-if="backPlan" type="primary" icon="el-icon-refresh-left" size="mini" plain @click="backPlanUp">返回</el-button>
    <el-button v-if="add" size="mini" @click="breadd" style="width: 60px;" type="primary">保存</el-button>
  <el-col :span="1"></el-col>
  </el-col>
</div>
@@ -24,7 +25,8 @@
  data() {
    return {
      levelList: null,
      backPlan: false
      backPlan: false,
      add: false
    }
  },
  watch: {
@@ -40,6 +42,13 @@
        this.$parent.combackPlan()
        this.backPlan=false
    },
    breadd(){
        this.add=false
        this.$parent.indexAdd()
    },
    showadd(){
      this.add=true
    },
    triggerBtnPlan(){
      this.backPlan?this.backPlan=false:this.backPlan=true
    },
src/layout/components/AppMain.vue
@@ -20,6 +20,12 @@
    },
    triggerMainBtnPlan(){
      this.$parent.triggerCombackBtn()
    },
    mainAdd(){
      this.$refs.child.measureAdd()
    },
    mainShowAdd(){
      this.$parent.showIndexAdd()
    }
  }
}
src/layout/index.vue
@@ -58,6 +58,12 @@
    combackPlan(){
        this.$refs.main.childMethod()
    },
    indexAdd(){
      this.$refs.main.mainAdd()
    },
    showIndexAdd(){
      this.$refs.breadcrumb.showadd()
    },
    triggerCombackBtn(){
      this.$refs.breadcrumb.triggerBtnPlan()
    }
src/utils/dateUtil.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
export function dateFormat(longTypeDate) {
    var dateTypeDate = "";
    var date = new Date();
    date.setTime(longTypeDate);
    dateTypeDate += date.getFullYear();   //å¹´
    dateTypeDate += "-" + getMonth(date); //月
    dateTypeDate += "-" + getDay(date);   //日
    return dateTypeDate;
}
//返回 01-12 çš„æœˆä»½å€¼
function getMonth(date) {
    var month = "";
    month = date.getMonth() + 1; //getMonth()得到的月份是0-11
    if (month < 10) {
        month = "0" + month;
    }
    return month;
}
//返回01-30的日期
function getDay(date) {
    var day = "";
    day = date.getDate();
    if (day < 10) {
        day = "0" + day;
    }
    return day;
}
function datetimeFormat(longTypeDate) {
    var dateTypeDate = "";
    var date = new Date();
    date.setTime(longTypeDate);
    dateTypeDate += date.getFullYear();   //å¹´
    dateTypeDate += "-" + this.getMonth(date); //月
    dateTypeDate += "-" + this.getDay(date);   //日
    return dateTypeDate;
}
function format(d) {
    var y = d.getFullYear();
    var m = d.getMonth() + 1;
    if (m < 10) {
        m = "0" + m;
    }
    var day = d.getDate();
    if (day < 10) {
        day = "0" + day;
    }
    return y + "-" + m + "-" + day;
}
src/utils/request.js
@@ -18,7 +18,7 @@
      // let each request carry token
      // ['X-Token'] is a custom headers key
      // please modify it according to the actual situation
      config.headers['token'] = getToken()
      config.headers['X-Token'] = getToken()
    }
    config.headers['link'] = store.state.settings.link
    // console.log('config' ,config)
src/views/laboratory/measure/Add.vue
@@ -8,15 +8,15 @@
                <el-form-item>
                    <el-col :span="6" style="display: flex;justify-content: space-around;">
                        <span>负责人:</span>
                        <el-select v-model="planAddInfo.measurePerson" placeholder="请选择活动区域">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        <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-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 v-model="planAddInfo.planDate" type="daterange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期">
                        </el-date-picker>
                    </el-col>
                    <el-col :span="5"></el-col>
@@ -36,39 +36,54 @@
                    :show-text="false"></el-progress>
            </el-col>
        </el-col>
        <el-col style="width:93%;height: 20vh;margin-top: 30px; margin-left: 40px;">
            <el-button icon="el-icon-plus" @click="addcodePointsTable()" style="margin-bottom: 10px;"
                type="primary">新增计量</el-button>
            <el-table ref="codePointsTable" :cell-style="{ textAlign: 'center' }"
                :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'center' }"
                :data="codePointsTable" style="width: 100%">
                <el-table-column type="index" label="序号" min-width="90" />
                <el-table-column prop="equipmentPointName" label="仪器设备名称" min-width="150">
                <el-table-column type="index" v-model="codePointsTable.index" label="序号" min-width="90" />
                <el-table-column prop="equipmentPointName" label="仪器设备" min-width="150">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPoint }}</span>
                        <el-input v-show="codePointesTableStatus" v-model="scope.row.equipmentPoint" />
                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPointName }}</span>
                        <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>
                    </template>
                </el-table-column>
                <el-table-column prop="measuringRange" label="测量范围" min-width="150">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.measuringRange }}</span>
                        <el-input v-show="codePointesTableStatus" v-model="scope.row.measuringRange" />
                        <el-input disabled v-show="codePointesTableStatus" v-model="scope.row.measuringRange" />
                    </template>
                </el-table-column>
                <el-table-column prop="unit" label="单位" min-width="150">
                <el-table-column prop="termValidity" label="计量周期" min-width="150">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.unit }}</span>
                        <el-input v-show="codePointesTableStatus" v-model="scope.row.unit" />
                        <span v-show="!codePointesTableStatus">{{ scope.row.termValidity }}</span>
                        <el-input disabled v-show="codePointesTableStatus" v-model="scope.row.termValidity" />
                    </template>
                </el-table-column>
                <el-table-column prop="descriptiveness" label="描述" min-width="200">
                <el-table-column prop="result" label="计量结果" min-width="200">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.descriptiveness }}</span>
                        <el-input v-show="codePointesTableStatus" v-model="scope.row.descriptiveness" />
                        <span v-show="!codePointesTableStatus">{{ scope.row.result }}</span>
                        <el-select v-model="scope.row.result" placeholder="请选择">
                            <el-option v-for="item in result" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column prop="descriptiveness" label="操作" min-width="200">
                <el-table-column prop="endDate" label="计量日期" min-width="200">
                    <template slot-scope="scope">
                        <el-tag type="" icon=""></el-tag>
                        <span v-show="!codePointesTableStatus">{{ scope.row.endDate }}</span>
                        <el-date-picker v-model="scope.row.endDate" type="date" placeholder="选择日期">
                        </el-date-picker>
                    </template>
                </el-table-column>
                <el-table-column prop="index" label="操作" min-width="200">
                    <template slot-scope="scope">
                        <span><a @click="removetableIndex(scope.row.index)" style="color: deepskyblue;">作废</a></span>
                    </template>
                </el-table-column>
            </el-table>
@@ -76,41 +91,110 @@
    </div>
</template>
<script>
import {
    getListUserAndListIns, addPlanAndMeasure
} from '@/api/laboratory/measure'
import { dateFormat } from "../../../utils/dateUtil";
export default {
    data() {
        return {
            planAddInfo: {
                plannedOrderNumber: 7897897987,
                measurePerson: '某某人',
                planDate: "2021-09-08 ~ 2024-08-09",
                unit: '某某检测局',
                createPerson: '某某负责人',
                createTime: '2021-09-08'
                plannedOrderNumber: '',
                measurePerson: '',
                planDate: "",
                unit: '',
                createPerson: '',
                createTime: ''
            },
            codePointsTable: [{
                id: '',
                "index": 1,
                "equipmentPointName": '',
                "measuringRange": '',
                "termValidity": "",
                "result": null,
            }],
            result: [{
                label: '合格',
                value: 1
            }, {
                label: '矫正后可用',
                value: 2
            }, {
                label: '不合格',
                value: 3
            }],
            userList: [],
            insList: [],
            instrumentList:[],
            // ç ç‚¹è¡¨æ ¼çš„状态:数据展示false/新增输入true
            codePointesTableStatus: false,
        }
    },
    async created() {
        this.codePointsTable = []
        let res = await getListUserAndListIns()
        res.data.userList.forEach(element => {
            this.userList.push({ label: element.name, value: element.id })
        });
        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() {
            const newObj = {
                index: this.codePointsTable.length + 1,
                equipmentPointName: '',
                measuringRange: '',
                termValidity: "",
                planDate: null,
            }],
            // ç ç‚¹è¡¨æ ¼çš„状态:数据展示false/新增输入true
            codePointesTableStatus: true,
        }
    },
    methods: {
        // æ–°å¢žè®¾å¤‡ç ç‚¹
        addNewCodePoints() {
            //
            if (!this.codePointsTable) {
                this.codePointsTable = []
                result: null,
                endDate: null,
                planDate: null
            }
            const newObj = {}
            newObj.equipmentPointName = ''
            newObj.descriptiveness = ''
            newObj.unit = ''
            newObj.instrumentId = this.equipmentDetail.id
            this.codePointsTable.push(newObj)
            this.codePointesTableStatus = true
        },
        removetableIndex(id) {
            this.codePointsTable = this.codePointsTable.filter(item => {
                return item.index != id;
            })
        },
        async add() {
            console.log(111111);
            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!=''){
                    item.endDate = dateFormat(item.endDate)
                }
            })
            console.log(this.codePointsTable);
            let data = {}
            this.codePointsTable.length>0?data = { measureList: this.codePointsTable, plan: this.planAddInfo }:data = {plan: this.planAddInfo }
            let add = await addPlanAndMeasure(data)
            this.planAddInfo={
                plannedOrderNumber: '',
                measurePerson: '',
                planDate: "",
                unit: '',
                createPerson: '',
                createTime: ''
            }
            this.codePointsTable=[]
            return add.data
        },
        insListChange(i,s){
            console.log(i);
            console.log(s.$index);
            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+'月'
        }
    }
}
src/views/laboratory/measure/index.vue
@@ -117,11 +117,12 @@
          </div>
        </div>
      </div>
      <div style="position: absolute;top:14px;left: 9px;transition: 1s;width: 99%;height: 82vh;background-color: #fff;z-index: 21;">
          <Add/>
      <div
        :style="`position: absolute;top:${addTop}px;left: 9px;transition: 1s;width: 99%;height: 82vh;background-color: #fff;z-index: 21;`">
        <Add ref="add" />
      </div>
      <div id="myMOdel"
        :style="`position: absolute;transition: 1s;top:${mymodelTop}px; left: 9px; width: 99%; height: 65vh; background-color: #fff;z-index: 20;`">
        :style="`position: absolute;transition: 1s;top:${mymodelTop}px; left: 9px; width: 99%; height: 85vh; background-color: #fff;z-index: 20;`">
        <el-col :span="10">
          <p style="font-size: 13px;padding-left: 40px;">计划信息</p>
        </el-col>
@@ -188,16 +189,77 @@
            <el-table-column prop="imCreateTime" label="创建日期" />
            <el-table-column prop="measurementName" label="创建人" />
            <el-table-column prop="measurementUnit" label="计量单位" />
            <el-table-column prop="equipmentCode" label="计量编号" />
            <el-table-column prop="code" label="计量编号" />
            <el-table-column prop="equipmentCode" label="操作">
              <template slot-scope="scope">
                <a @click="measureUp(scope)" style="color: deepskyblue;">计量</a>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
        <el-col style="width: 93%;margin-left: 40px; margin-top: 90px;display: flex;justify-content: end;">
        <el-col style="width: 93%;margin-left: 40px; margin-top: 250px;display: flex;justify-content: end;">
          <el-pagination @size-change="handleSizeChangePlan" @current-change="handleCurrentChangePllan"
            :current-page="currentPagePlan" :page-sizes="[5, 10, 20]" :page-size="pageSizePlan"
            :current-page="currentPagePlan" :page-sizes="[5, 10]" :page-size="pageSizePlan"
            layout="total, sizes, prev, pager, next, jumper" :total="totalPlan">
          </el-pagination>
        </el-col>
      </div>
      <el-dialog class="measureForm" title="计量" :visible.sync="dialogVisible">
      <el-form label-position="top" ref="upmeasureForm" :model="measureUpInfo">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="检定有效期" prop="date" :rules="[{ required: true, message: '请选择检定有效期', trigger: 'change' }]">
              <el-date-picker v-model="measureUpInfo.date" type="daterange" range-separator="至" start-placeholder="开始日期"
                end-placeholder="结束日期" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="不确定度" prop="uncertainty"
              :rules="[{ required: true, message: '请填写不确定度', trigger: 'blur' }]">
              <el-input placeholder="请填写不确定度" v-model="measureUpInfo.uncertainty" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结果" prop="result" :rules="[{ required: true, message: '请选择结果', trigger: 'change' }]">
              <el-select v-model="measureUpInfo.result" clearable filterable :allow-create="true" placeholder="请选择结果"
                style="width:100%">
                <el-option v-for="item in result" :key="item.id" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="性能指标">
              <el-input v-model="measureUpInfo.performanceIndex" type="textarea" :rows="2" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="measureUpInfo.remarks" type="textarea" :rows="2" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="">
              <el-upload class="upload-demo" action="#" :on-change="handleUpload" :auto-upload="false">
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addMeasure">ç¡® å®š</el-button>
        <el-button @click="dialogVisible=false">取 æ¶ˆ</el-button>
      </span>
    </el-dialog>
    </div>
  </div>
</template>
@@ -211,6 +273,26 @@
  },
  data() {
    return {
      dialogVisible: false,
      tableIndex: null,
      measureUpInfo:{
        result: null,
        date: null,
        uncertainty: null,
        performanceIndex: null,
        remarks: null,
        file: null
      },
      result: [{
        label: '合格',
        value: 1
      }, {
        label: '矫正后可用',
        value: 2
      }, {
        label: '不合格',
        value: 3
      }],
      searchData: {
        code: '',
        name: '',
@@ -232,9 +314,8 @@
      currentPagePlan: 1,
      pageSizePlan: 5,
      totalPlan: 0,
      drawer: false,
      direction: 'rtl',
      lookVisible: true,
      lookVisible: false,
      measureData: [],
      planInfo: {
        plannedOrderNumber: 7897897987,
@@ -244,7 +325,8 @@
        createPerson: '某某负责人',
        createTime: '2021-09-08'
      },
      mymodelTop: -600,//14
      mymodelTop: -700,//14
      addTop: -700,
      planId: 0
    }
  },
@@ -253,7 +335,29 @@
    // this.getPlanPageList()
  },
  methods: {
    upResult(){
        this.measureData[this.tableIndex].result=this.resultUp
    },
    measureUp(scope) {
      console.log(scope);
      this.dialogVisible = true
      this.tableIndex=scope.$index
      this.measureUpInfo.result=scope.row.result
    },
    measureAdd() {
      let add = this.$refs.add.add()
      if (add) {
        this.addTop = -700
        this.$message({
          message: '操作成功!',
          type: 'success'
        });
        this.lookVisible = false
      }
    },
    async handleSizeChangePlan(num) {
      console.log(num);
      this.pageSizePlan = num
      await this.limitGetPlanMeasureInstrument()
    },
@@ -262,14 +366,18 @@
      await this.limitGetPlanMeasureInstrument()
    },
    addPlan() {
      this.drawer = true
      this.addTop = 14
      this.lookVisible = true
      this.$parent.mainShowAdd()
    },
    async limitGetPlanMeasureInstrument() {
      let res = await limitGetPlanMeasureRequest({
      let param = {
        id: this.planId,
        currentPage: this.currentPagePlan,
        pageSize: this.pageSize
      })
        pageSize: this.pageSizePlan
      }
      console.log(param);
      let res = await limitGetPlanMeasureRequest(param)
      this.totalPlan = res.data.taotal
      this.measureData = res.data.list
    },
@@ -299,7 +407,7 @@
    },
    combackLookPlan() {
      this.lookVisible = false
      this.mymodelTop = -600
      this.mymodelTop = -700
    },
    blurSearch() {
      if (this.radioValue === 1) {
@@ -309,17 +417,21 @@
    handleClose() {
      this.drawer = false
    },
    handleCurrentChange() {
      this.getStandingPageList()
    handleCurrentChange(num) {
      this.currentPage = num
      this.radioValue ? this.getPlanPageList() : this.getStandingPageList()
    },
    handleSizeChange() {
      this.getStandingPageList()
    handleSizeChange(num) {
      this.pageSize = num
      this.radioValue ? this.getPlanPageList() : this.getStandingPageList()
    },
    async getStandingPageList() {
      const res = await getStandingPageList({
      let param = {
        currentPage: this.currentPage, pageSize: this.pageSize,
        code: this.searchData.code, name: this.searchData.name, unit: this.searchData.measureunit
      })
      }
      console.log(param);
      const res = await getStandingPageList(param)
      this.measureLedgerTable = res.data.records
      this.total = res.data.total
      this.measureLedgerTable.forEach(item => {
@@ -362,10 +474,12 @@
      this.reset()
    },
    async getPlanPageList() {
      const res = await getPlanPageList({
      let param = {
        currentPage: this.currentPage, pageSize: this.pageSize,
        code: this.searchData.code, name: this.searchData.name, unit: this.searchData.measureunit
      })
      }
      console.log(param);
      const res = await getPlanPageList(param)
      res.data.list.forEach(item => {
        item.palanDate = item.beginTime + " ~ " + item.endTime
      })