| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- <template>
- <el-dialog title="编辑设备信息"
- :visible.sync="dialogvisible"
- width="75%"
- :before-close="handleCloseEdit">
- <el-form size="mini"
- :model="testlistform"
- :rules="rulestestlistform"
- label-width="130px"
- ref="testlistform">
- <el-row :gutter="20"
- class="donorsaddformcss">
- <el-col :span="8">
- <el-form-item label="设备编码"
- prop="Code"
- label-width="120px">
- <el-input v-model="testlistform.Code"
- placeholder="请输入设备编码"
- :disabled="true"
- style="width:100%"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="设备名称"
- prop="Name"
- label-width="120px">
- <el-input v-model="testlistform.Name"
- placeholder="请输入设备名称"
- style="width:100%"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="型号"
- prop="Model"
- label-width="120px">
- <el-input v-model="testlistform.Model"
- placeholder="请输入型号"
- style="width:100%"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="品牌名称"
- prop="Brand"
- label-width="120px">
- <el-input v-model="testlistform.Brand"
- placeholder="请输入品牌名称"
- style="width:100%"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="设备状态"
- prop="State"
- label-width="120px">
- <el-select v-model="testlistform.State"
- placeholder="请选择设备状态"
- style="width:100%">
- <el-option v-for="item in statelist"
- :key="item.Id"
- :label="item.stateName"
- :value="item.Id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="校准时间"
- label-width="120px"
- prop="CalibrationTime">
- <el-date-picker v-model="testlistform.CalibrationTime"
- type="datetime"
- style="width:100%"
- placeholder="请选择校准时间">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="责任人"
- label-width="120px">
- <el-input v-model="testlistform.Responsible"
- placeholder="请输入责任人">
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="实验室位置"
- prop="RoomType"
- label-width="120px">
- <el-select v-model="testlistform.Location"
- placeholder="请选择实验室类型"
- style="width:100%">
- <el-option v-for="item in typeList"
- :key="item.Id"
- :label="item.RoomName"
- :value="item.RoomName"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="备注信息"
- label-width="120px">
- <el-input v-model="testlistform.Remarks"
- type="textarea"
- :rows=3
- placeholder="请输入备注信息"
- style="width:100%"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <span slot="footer">
- <el-button size="mini"
- type="primary"
- @click="savedata">保存</el-button>
- <el-button size="mini"
- @click="handleCloseEdit">关闭</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import axios from 'axios'
- import uploadajax from '@/assets/js/uploadajax.js'
- import InstrumentApi from '@/api/instrument'
- import {
- getRoomNumber
- } from '@/api/instrumentroom'
- export default {
- name: 'instrumentadd',
- props: {
- InstrumentId: {
- default: 0
- }
- },
- data () {
- return {
- fileList: [],
- FileUrl: {},
- uploadFile: {},
- dialogvisible: false,
- formtype: '1',
- disabledbarcode: false,
- typeList: [],
- testlistform: {
- Code: '',
- Name: '',
- Supplier: '',
- SupplierId: '',
- Model: '',
- Brand: '',
- Classification: '',
- State: 1,
- Remarks: '',
- CalibrationDeadlineType: 2,
- CalibrationTime: new Date(),
- CalibrationDeadline: 1,
- HeartbeatTime: new Date(),
- TimeNotification: 0
- },
- Advancetime: 0,
- triggerlist: {},
- TimeNotification: false, // 有效期提醒
- classificationlist: [],
- getsupplierlist: [],
- statelist: [{
- stateName: '正常',
- Id: 1
- }, {
- stateName: '维修',
- Id: 2
- }, {
- stateName: '闲置',
- Id: 3
- }],
- timeType: [{
- stateName: '天',
- Id: 1
- }, {
- stateName: '周',
- Id: 2
- }, {
- stateName: '月',
- Id: 3
- }, {
- stateName: '年',
- Id: 4
- }],
- rulestestlistform: {
- Code: [{
- required: true,
- message: '请输入设备编码',
- trigger: 'blur'
- }],
- Name: [{
- required: true,
- message: '请输入设备名称',
- trigger: 'blur'
- }],
- Model: [{
- required: true,
- message: '请输入型号',
- trigger: 'blur'
- }],
- Brand: [{
- required: true,
- message: '请输入品牌名称',
- trigger: 'blur'
- }],
- State: [{
- required: true,
- message: '请输入设备状态',
- trigger: 'blur'
- }],
- Classification: [{
- required: true,
- message: '请输入设备大类',
- trigger: 'blur'
- }]
- }
- }
- },
- created () {
- // this.getEntity(this.InstrumentId)
- // this.getclassificationlist()
- this.getroomtypelist()
- },
- methods: {
- // 获取所有实验室类型
- getroomtypelist () {
- let _this = this
- let params = {
- }
- getRoomNumber(params)
- .then(res => {
- _this.typeList = res.info
- // this.searchroomdata()
- })
- .catch(err => {
- console.error(err)
- })
- },
- // 操作规程文件上传
- uploadrequest (option) {
- let _this = this
- axios.post(this.$uploadFile, {})
- .then(function (res) {
- if (res.data && res.data.fid && res.data.fid !== '') {
- option.action = `http://${res.data.url}/${res.data.fid}`
- _this.uploadFile = {
- uid: option.file.uid,
- url: res.data.publicUrl,
- fid: res.data.fid
- }
- uploadajax(option)
- } else {
- _this.$message({
- type: 'warning',
- message: '未上传成功!请刷新界面重新上传!'
- })
- }
- })
- .catch(function (error) {
- console.log(error)
- _this.$message({
- type: 'warning',
- message: '未上传成功!请重新上传!'
- })
- })
- },
- handleRemove (file, fileList) {
- this.testlistform.FileUrl = ''
- this.testlistform.FileName = ''
- this.FileUrl = {}
- },
- handleUploadSuccess (res, file) {
- this.testlistform.FileUrl = `${this.uploadFile.url}/${this.uploadFile.fid}`
- this.testlistform.FileName = file.name
- this.FileUrl = URL.createObjectURL(file.raw)
- },
- savedata () {
- let _this = this
- this.$refs.testlistform.validate(valid => {
- if (valid) {
- InstrumentApi.UpdateInstrument(this.testlistform, {})
- .then(res => {
- this.dialogvisible = false
- _this.$message({
- type: 'success',
- message: '保存成功'
- })
- // 刷新
- // this.$emit('initDatas')
- this.$emit('closeEditDialog')
- })
- .catch(err => {
- // handle error
- console.error(err)
- })
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- getEntity (pid) {
- let _this = this
- let query = {
- id: pid
- }
- InstrumentApi.getOneInstrument(query)
- .then(response => {
- _this.testlistform = response.records
- // _this.testlistform.CalibrationTime = new Date(response.CalibrationTime)
- if (_this.testlistform.FileName !== '') {
- let file = {
- name: _this.testlistform.FileName,
- url: _this.testlistform.FileUrl
- }
- _this.fileList.push(file)
- }
- }).catch(err => {
- // handle error
- console.error(err)
- })
- },
- // // 查询action
- // getttriggernow (id) {
- // gettriggerlist({}, id)
- // .then(res => {
- // let _this = this
- // _this.Advancetime = res.items.Advancetime
- // // 查询子表 有效期
- // _this.addTriggerl(_this.testlistform.Id, _this.testlistform.Code, _this.testlistform.TimeNotification, _this.testlistform.Name, _this.Advancetime, _this.testlistform.CalibrationTime, _this.testlistform.CalibrationDeadline, _this.testlistform.CalibrationDeadlineType)
- // })
- // .catch(err => {
- // console.error(err)
- // })
- // },
- // getclassificationlist () {
- // // 获取样本单位
- // let _this = this
- // let params = {
- // code: 'InstrumentItem'
- // }
- // classificationlist(params)
- // .then(res => {
- // _this.classificationlist = res.info
- // })
- // },
- // // 添加报警
- // addTriggerl (ID, Code, TimeNotification, Name, Advancetime, CalibrationTime, CalibrationDeadline, CalibrationDeadlineType) {
- // // eslint-disable-next-line no-undef
- // let _this = this
- // _this.triggerlist.Aid = '4802'
- // _this.triggerlist.DId = ID
- // _this.triggerlist.Advancetime = Advancetime// action 报警提前时间
- // _this.triggerlist.TimeNotification = TimeNotification // 保质期到期提醒
- // _this.triggerlist.ProductDate = CalibrationTime// '校准日期',
- // _this.triggerlist.AccCode = Code // '物品编码',
- // _this.triggerlist.Name = Name // '名称',
- // _this.triggerlist.ValidityLong = CalibrationDeadline // '有效时长',
- // _this.triggerlist.ValidityLongType = CalibrationDeadlineType// '有效时长类型:1天;2周;3月;4年',
- // _this.triggerlist.Category = 3 // '种类 1、耗材;2:试剂'
- // if (CalibrationDeadlineType === 1) {
- // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline))
- // } else if (CalibrationDeadlineType === 2) {
- // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 7))
- // } else if (CalibrationDeadlineType === 3) {
- // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 30))
- // } else if (CalibrationDeadlineType === 4) {
- // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 365))
- // }
- // addTrigger(_this.triggerlist)
- // .then(function (response) {
- // })
- // },
- // 计算日期
- addDate (date, days) {
- if (days === undefined || days === '') {
- days = 1
- }
- var dates = new Date(date)
- dates.setDate(dates.getDate() + days)
- var month = dates.getMonth() + 1
- var day = dates.getDate()
- var mm = "'" + month + "'"
- var dd = "'" + day + "'"
- // 单位数前面加0
- if (mm.length === 3) {
- month = '0' + month
- }
- if (dd.length === 3) {
- day = '0' + day
- }
- var time = dates.getFullYear() + '-' + month + '-' + day
- return time
- },
- // // 获取供应商
- // getSupplier () {
- // let _this = this
- // let params = {
- // customerName: 'Supplier'
- // }
- // getsupplierlist(params)
- // .then(res => {
- // _this.getsupplierlist = res.info
- // })
- // },
- // 返回当前页
- handleCloseEdit () {
- // this.$refs['uploader'].clearFiles()
- this.fileList = []
- this.$emit('closeEditDialog')
- }
- // deletedataforDid (val) {
- // deletetriggerlistfordid(val)
- // .then(res => {
- // })
- // .catch(err => {
- // // handle error
- // console.error(err)
- // })
- // }
- }
- // watch: {
- // InstrumentId: function (newVal) {
- // this.getEntity(newVal)
- // }
- // }
- }
- </script>
- <style lang="scss">
- .button {
- padding: 0;
- float: right;
- }
- </style>
|