instrumentedit.vue 13 KB

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