instrumentedit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <el-dialog title="编辑设备信息"
  3. :visible.sync="dialogvisible"
  4. width="75%"
  5. :before-close="handleCloseEdit">
  6. <el-form size="mini"
  7. :model="testlistform"
  8. :rules="rulestestlistform"
  9. label-width="130px"
  10. ref="testlistform">
  11. <el-row :gutter="20"
  12. class="donorsaddformcss">
  13. <!-- <el-col :span="8">
  14. <el-form-item label="设备大类"
  15. prop="Classification"
  16. label-width="120px">
  17. <el-select ref="reftube"
  18. v-model="testlistform.Classification"
  19. placeholder="请输入设备大类"
  20. style="width:100%">
  21. <el-option v-for="item in classificationlist"
  22. :label="item.Value"
  23. :value="item.Value"
  24. :key="item.Value">
  25. </el-option>
  26. </el-select>
  27. </el-form-item>
  28. </el-col> -->
  29. <el-col :span="8">
  30. <el-form-item label="设备编码"
  31. required
  32. prop="Code"
  33. label-width="120px">
  34. <el-input v-model="testlistform.Code"
  35. placeholder="请输入设备编码"
  36. style="width:100%"></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="设备名称"
  41. required
  42. prop="Name"
  43. label-width="120px">
  44. <el-input v-model="testlistform.Name"
  45. placeholder="请输入设备名称"
  46. style="width:100%"></el-input>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="8">
  50. <el-form-item label="型号"
  51. required
  52. prop="Model"
  53. label-width="120px">
  54. <el-input v-model="testlistform.Model"
  55. placeholder="请输入型号"
  56. style="width:100%"></el-input>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="8">
  60. <el-form-item label="品牌名称"
  61. prop="Brand"
  62. label-width="120px">
  63. <el-input v-model="testlistform.Brand"
  64. placeholder="请输入品牌名称"
  65. style="width:100%"></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <!-- <el-col :span="8">
  69. <el-form-item label="供应商"
  70. prop="SupplierId"
  71. label-width="120px">
  72. <el-select ref="reftube"
  73. v-model="testlistform.SupplierId"
  74. placeholder="请输入设备大类"
  75. style="width:100%">
  76. <el-option v-for="item in getsupplierlist"
  77. :label="item.CustomerName"
  78. :value="item.Id"
  79. :key="item.Id">
  80. </el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-col> -->
  84. <el-col :span="8">
  85. <el-form-item label="设备状态"
  86. required
  87. prop="State"
  88. label-width="120px">
  89. <el-select v-model="testlistform.State"
  90. placeholder="请选择设备状态"
  91. style="width:100%">
  92. <el-option v-for="item in statelist"
  93. :key="item.Id"
  94. :label="item.stateName"
  95. :value="item.Id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="8">
  101. <el-form-item label="校准时间"
  102. label-width="120px"
  103. prop="CalibrationTime">
  104. <el-date-picker v-model="testlistform.CalibrationTime"
  105. type="datetime"
  106. style="width:100%"
  107. placeholder="请选择校准时间">
  108. </el-date-picker>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="8">
  112. <el-form-item label="校准使用期限"
  113. label-width="120px">
  114. <el-input v-model="testlistform.CalibrationDeadline"
  115. placeholder="请输入校准使用期限"
  116. style="width: 49%"></el-input>
  117. <el-select v-model="testlistform.CalibrationDeadlineType"
  118. placeholder="请选择设备状态"
  119. style="width: 49%;float:right">
  120. <el-option v-for="item in timeType"
  121. :key="item.Id"
  122. :label="item.stateName"
  123. :value="item.Id">
  124. </el-option>
  125. </el-select>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="8">
  129. <el-form-item label="责任人"
  130. label-width="120px">
  131. <el-input v-model="testlistform.Responsible"
  132. placeholder="请输入责任人">
  133. </el-input>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="8">
  137. <el-form-item label="实验室位置"
  138. prop="RoomType"
  139. label-width="120px">
  140. <el-select v-model="testlistform.Location"
  141. placeholder="请选择实验室类型"
  142. style="width:100%">
  143. <el-option v-for="item in typeList"
  144. :key="item.Id"
  145. :label="item.RoomName"
  146. :value="item.RoomName"></el-option>
  147. </el-select>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="24">
  151. <el-form-item label="备注信息"
  152. label-width="120px">
  153. <el-input v-model="testlistform.Remarks"
  154. type="textarea"
  155. :rows=3
  156. placeholder="请输入备注信息"
  157. style="width:100%"></el-input>
  158. </el-form-item>
  159. </el-col>
  160. </el-row>
  161. </el-form>
  162. <span slot="footer">
  163. <el-button size="mini"
  164. type="primary"
  165. @click="savedata">保存</el-button>
  166. <el-button size="mini"
  167. @click="handleCloseEdit">关闭</el-button>
  168. </span>
  169. </el-dialog>
  170. </template>
  171. <script>
  172. import axios from 'axios'
  173. import uploadajax from '@/assets/js/uploadajax.js'
  174. import InstrumentApi from '@/api/instrument'
  175. import {
  176. getRoomNumber
  177. } from '@/api/instrumentroom'
  178. export default {
  179. name: 'instrumentadd',
  180. props: {
  181. InstrumentId: {
  182. default: 0
  183. }
  184. },
  185. data () {
  186. return {
  187. fileList: [],
  188. FileUrl: {},
  189. uploadFile: {},
  190. dialogvisible: false,
  191. formtype: '1',
  192. disabledbarcode: false,
  193. typeList: [],
  194. testlistform: {
  195. Code: '',
  196. Name: '',
  197. Supplier: '',
  198. SupplierId: '',
  199. Model: '',
  200. Brand: '',
  201. Classification: '',
  202. State: 1,
  203. Remarks: '',
  204. CalibrationDeadlineType: 2,
  205. CalibrationTime: new Date(),
  206. CalibrationDeadline: 1,
  207. HeartbeatTime: new Date(),
  208. TimeNotification: 0
  209. },
  210. Advancetime: 0,
  211. triggerlist: {},
  212. TimeNotification: false, // 有效期提醒
  213. classificationlist: [],
  214. getsupplierlist: [],
  215. statelist: [{
  216. stateName: '正常',
  217. Id: 1
  218. }, {
  219. stateName: '维修',
  220. Id: 2
  221. }, {
  222. stateName: '闲置',
  223. Id: 3
  224. }],
  225. timeType: [{
  226. stateName: '天',
  227. Id: 1
  228. }, {
  229. stateName: '周',
  230. Id: 2
  231. }, {
  232. stateName: '月',
  233. Id: 3
  234. }, {
  235. stateName: '年',
  236. Id: 4
  237. }],
  238. rulestestlistform: {
  239. Code: [{
  240. required: true,
  241. message: '请输入设备编码',
  242. trigger: 'blur'
  243. }],
  244. Name: [{
  245. required: true,
  246. message: '请输入设备名称',
  247. trigger: 'blur'
  248. }],
  249. // Supplier: [{
  250. // required: true,
  251. // message: '请输入供应商',
  252. // trigger: 'blur'
  253. // }],
  254. Model: [{
  255. required: true,
  256. message: '请输入型号',
  257. trigger: 'blur'
  258. }],
  259. Brand: [{
  260. required: true,
  261. message: '请输入品牌名称',
  262. trigger: 'blur'
  263. }],
  264. State: [{
  265. required: true,
  266. message: '请输入设备状态',
  267. trigger: 'blur'
  268. }],
  269. Classification: [{
  270. required: true,
  271. message: '请输入设备大类',
  272. trigger: 'blur'
  273. }]
  274. }
  275. }
  276. },
  277. created () {
  278. // this.getEntity(this.InstrumentId)
  279. // this.getclassificationlist()
  280. this.getroomtypelist()
  281. },
  282. methods: {
  283. // 获取所有实验室类型
  284. getroomtypelist () {
  285. let _this = this
  286. let params = {
  287. }
  288. getRoomNumber(params)
  289. .then(res => {
  290. // for (let type of res.info) {
  291. // _this.typeList[type.Value] = type.RoomType
  292. // }
  293. _this.typeList = res.info
  294. // this.searchroomdata()
  295. })
  296. .catch(err => {
  297. console.error(err)
  298. })
  299. },
  300. // 操作规程文件上传
  301. uploadrequest (option) {
  302. let _this = this
  303. axios.post(this.$uploadFile, {})
  304. .then(function (res) {
  305. if (res.data && res.data.fid && res.data.fid !== '') {
  306. option.action = `http://${res.data.url}/${res.data.fid}`
  307. _this.uploadFile = {
  308. uid: option.file.uid,
  309. url: res.data.publicUrl,
  310. fid: res.data.fid
  311. }
  312. uploadajax(option)
  313. } else {
  314. _this.$message({
  315. type: 'warning',
  316. message: '未上传成功!请刷新界面重新上传!'
  317. })
  318. }
  319. })
  320. .catch(function (error) {
  321. console.log(error)
  322. _this.$message({
  323. type: 'warning',
  324. message: '未上传成功!请重新上传!'
  325. })
  326. })
  327. },
  328. handleRemove (file, fileList) {
  329. this.testlistform.FileUrl = ''
  330. this.testlistform.FileName = ''
  331. this.FileUrl = {}
  332. },
  333. handleUploadSuccess (res, file) {
  334. this.testlistform.FileUrl = `${this.uploadFile.url}/${this.uploadFile.fid}`
  335. this.testlistform.FileName = file.name
  336. this.FileUrl = URL.createObjectURL(file.raw)
  337. },
  338. savedata () {
  339. InstrumentApi.UpdateInstrument(this.testlistform, {})
  340. .then(res => {
  341. // savedataedit(_this.testlistform.Id, _this.testlistform)
  342. // _this.$axios.put('/instrument/saveeditinstument/' + _this.testlistform.Id, _this.testlistform)
  343. // .then(res => {
  344. // response
  345. // if (res.info.code === 0) {
  346. // if (_this.TimeNotification) {
  347. // // _this.getttriggernow(4802)
  348. // }
  349. // _this.$message({
  350. // type: 'success',
  351. // message: res.info.message
  352. // })
  353. // window.history.go(-1)
  354. // } else {
  355. // _this.$message({
  356. // type: 'warning',
  357. // message: res.info.message
  358. // })
  359. // }
  360. this.dialogvisible = false
  361. this.fileList = []
  362. // 刷新
  363. // this.$emit('initDatas')
  364. this.$emit('closeEditDialog')
  365. })
  366. .catch(err => {
  367. // handle error
  368. console.error(err)
  369. })
  370. },
  371. getEntity (pid) {
  372. let _this = this
  373. let query = {
  374. id: pid
  375. }
  376. InstrumentApi.getOneInstrument(query)
  377. .then(response => {
  378. _this.testlistform = response.records
  379. _this.testlistform.CalibrationTime = new Date(response.CalibrationTime)
  380. if (_this.testlistform.FileName !== '') {
  381. let file = {
  382. name: _this.testlistform.FileName,
  383. url: _this.testlistform.FileUrl
  384. }
  385. _this.fileList.push(file)
  386. }
  387. }).catch(err => {
  388. // handle error
  389. console.error(err)
  390. })
  391. },
  392. // // 查询action
  393. // getttriggernow (id) {
  394. // gettriggerlist({}, id)
  395. // .then(res => {
  396. // let _this = this
  397. // _this.Advancetime = res.items.Advancetime
  398. // // 查询子表 有效期
  399. // _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)
  400. // })
  401. // .catch(err => {
  402. // console.error(err)
  403. // })
  404. // },
  405. // getclassificationlist () {
  406. // // 获取样本单位
  407. // let _this = this
  408. // let params = {
  409. // code: 'InstrumentItem'
  410. // }
  411. // classificationlist(params)
  412. // .then(res => {
  413. // _this.classificationlist = res.info
  414. // })
  415. // },
  416. // // 添加报警
  417. // addTriggerl (ID, Code, TimeNotification, Name, Advancetime, CalibrationTime, CalibrationDeadline, CalibrationDeadlineType) {
  418. // // eslint-disable-next-line no-undef
  419. // let _this = this
  420. // _this.triggerlist.Aid = '4802'
  421. // _this.triggerlist.DId = ID
  422. // _this.triggerlist.Advancetime = Advancetime// action 报警提前时间
  423. // _this.triggerlist.TimeNotification = TimeNotification // 保质期到期提醒
  424. // _this.triggerlist.ProductDate = CalibrationTime// '校准日期',
  425. // _this.triggerlist.AccCode = Code // '物品编码',
  426. // _this.triggerlist.Name = Name // '名称',
  427. // _this.triggerlist.ValidityLong = CalibrationDeadline // '有效时长',
  428. // _this.triggerlist.ValidityLongType = CalibrationDeadlineType// '有效时长类型:1天;2周;3月;4年',
  429. // _this.triggerlist.Category = 3 // '种类 1、耗材;2:试剂'
  430. // if (CalibrationDeadlineType === 1) {
  431. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline))
  432. // } else if (CalibrationDeadlineType === 2) {
  433. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 7))
  434. // } else if (CalibrationDeadlineType === 3) {
  435. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 30))
  436. // } else if (CalibrationDeadlineType === 4) {
  437. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 365))
  438. // }
  439. // addTrigger(_this.triggerlist)
  440. // .then(function (response) {
  441. // })
  442. // },
  443. // 计算日期
  444. addDate (date, days) {
  445. if (days === undefined || days === '') {
  446. days = 1
  447. }
  448. var dates = new Date(date)
  449. dates.setDate(dates.getDate() + days)
  450. var month = dates.getMonth() + 1
  451. var day = dates.getDate()
  452. var mm = "'" + month + "'"
  453. var dd = "'" + day + "'"
  454. // 单位数前面加0
  455. if (mm.length === 3) {
  456. month = '0' + month
  457. }
  458. if (dd.length === 3) {
  459. day = '0' + day
  460. }
  461. var time = dates.getFullYear() + '-' + month + '-' + day
  462. return time
  463. },
  464. // // 获取供应商
  465. // getSupplier () {
  466. // let _this = this
  467. // let params = {
  468. // customerName: 'Supplier'
  469. // }
  470. // getsupplierlist(params)
  471. // .then(res => {
  472. // _this.getsupplierlist = res.info
  473. // })
  474. // },
  475. // 返回当前页
  476. handleCloseEdit () {
  477. // this.$refs['uploader'].clearFiles()
  478. this.fileList = []
  479. this.$emit('closeEditDialog')
  480. }
  481. // deletedataforDid (val) {
  482. // deletetriggerlistfordid(val)
  483. // .then(res => {
  484. // })
  485. // .catch(err => {
  486. // // handle error
  487. // console.error(err)
  488. // })
  489. // }
  490. }
  491. // watch: {
  492. // InstrumentId: function (newVal) {
  493. // this.getEntity(newVal)
  494. // }
  495. // }
  496. }
  497. </script>
  498. <style lang="scss">
  499. .button {
  500. padding: 0;
  501. float: right;
  502. }
  503. </style>