personneledit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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="100px"
  10. ref="testlistform">
  11. <el-row :gutter="20"
  12. class="donorsaddformcss">
  13. <el-col :span="8">
  14. <el-form-item label="人员姓名"
  15. prop="PersonnelName"
  16. label-width="120px">
  17. <el-input v-model="testlistform.PersonnelName"
  18. placeholder="请输入人员姓名"
  19. style="width:100%"></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="人员编号"
  24. prop="PersonneCode"
  25. label-width="120px">
  26. <el-input v-model="testlistform.PersonneCode"
  27. placeholder="请输入人员编号"
  28. style="width:100%"></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="电话"
  33. prop="Telephone"
  34. label-width="120px">
  35. <el-input v-model="testlistform.Telephone"
  36. placeholder="请输入电话"
  37. style="width:100%"></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="8">
  41. <el-form-item label="邮箱"
  42. prop="Mailbox"
  43. label-width="120px">
  44. <el-input v-model="testlistform.Mailbox"
  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. prop="CardId"
  52. label-width="120px">
  53. <el-input v-model="testlistform.CardId"
  54. placeholder="请输入身份证号"
  55. style="width:100%"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="联系地址"
  60. prop="Address"
  61. label-width="120px">
  62. <el-input v-model="testlistform.Address"
  63. placeholder="请输入联系地址"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. </el-form>
  68. <span slot="footer">
  69. <el-button size="mini"
  70. type="primary"
  71. @click="savedata">保存</el-button>
  72. <el-button size="mini"
  73. @click="handleCloseEdit">关闭</el-button>
  74. </span>
  75. </el-dialog>
  76. </template>
  77. <script>
  78. import axios from 'axios'
  79. import uploadajax from '@/assets/js/uploadajax.js'
  80. import PersonnelApi from '@/api/personnel'
  81. export default {
  82. name: 'personneledit',
  83. props: {
  84. PersonnelId: {
  85. default: 0
  86. }
  87. },
  88. data () {
  89. return {
  90. fileList: [],
  91. FileUrl: {},
  92. uploadFile: {},
  93. dialogvisible: false,
  94. formtype: '1',
  95. disabledbarcode: false,
  96. testlistform: {
  97. },
  98. Advancetime: 0,
  99. triggerlist: {},
  100. TimeNotification: false, // 有效期提醒
  101. classificationlist: [],
  102. getsupplierlist: [],
  103. rulestestlistform: {
  104. PersonnelName: [{
  105. required: true,
  106. message: '请输入人员姓名',
  107. trigger: 'blur'
  108. }],
  109. PersonneCode: [{
  110. required: true,
  111. message: '请输入人员编号',
  112. trigger: 'blur'
  113. }],
  114. Telephone: [{
  115. required: true,
  116. message: '请输入电话',
  117. trigger: 'blur'
  118. }],
  119. Mailbox: [{
  120. required: true,
  121. message: '请输入邮箱',
  122. trigger: 'blur'
  123. }],
  124. CardId: [{
  125. required: true,
  126. message: '请输入身份证号',
  127. trigger: 'blur'
  128. }],
  129. Address: [{
  130. required: true,
  131. message: '请输入联系地址',
  132. trigger: 'blur'
  133. }]
  134. }
  135. }
  136. },
  137. created () {
  138. },
  139. methods: {
  140. // 操作规程文件上传
  141. uploadrequest (option) {
  142. let _this = this
  143. axios.post(this.$uploadFile, {})
  144. .then(function (res) {
  145. if (res.data && res.data.fid && res.data.fid !== '') {
  146. option.action = `http://${res.data.url}/${res.data.fid}`
  147. _this.uploadFile = {
  148. uid: option.file.uid,
  149. url: res.data.publicUrl,
  150. fid: res.data.fid
  151. }
  152. uploadajax(option)
  153. } else {
  154. _this.$message({
  155. type: 'warning',
  156. message: '未上传成功!请刷新界面重新上传!'
  157. })
  158. }
  159. })
  160. .catch(function (error) {
  161. console.log(error)
  162. _this.$message({
  163. type: 'warning',
  164. message: '未上传成功!请重新上传!'
  165. })
  166. })
  167. },
  168. handleRemove (file, fileList) {
  169. this.testlistform.FileUrl = ''
  170. this.testlistform.FileName = ''
  171. this.FileUrl = {}
  172. },
  173. handleUploadSuccess (res, file) {
  174. this.testlistform.FileUrl = `${this.uploadFile.url}/${this.uploadFile.fid}`
  175. this.testlistform.FileName = file.name
  176. this.FileUrl = URL.createObjectURL(file.raw)
  177. },
  178. savedata () {
  179. let _this = this
  180. PersonnelApi.UpdatePersonnel(this.testlistform, {})
  181. .then(res => {
  182. // savedataedit(_this.testlistform.Id, _this.testlistform)
  183. // _this.$axios.put('/personnel/saveeditinstument/' + _this.testlistform.Id, _this.testlistform)
  184. // .then(res => {
  185. // response
  186. // if (res.info.code === 0) {
  187. // if (_this.TimeNotification) {
  188. // // _this.getttriggernow(4802)
  189. // }
  190. // _this.$message({
  191. // type: 'success',
  192. // message: res.info.message
  193. // })
  194. // window.history.go(-1)
  195. // } else {
  196. // _this.$message({
  197. // type: 'warning',
  198. // message: res.info.message
  199. // })
  200. // }
  201. this.dialogvisible = false
  202. this.fileList = []
  203. // 刷新
  204. // this.$emit('initDatas')
  205. this.$emit('closeEditDialog')
  206. })
  207. .catch(err => {
  208. // handle error
  209. console.error(err)
  210. })
  211. },
  212. getEntity (pid) {
  213. let _this = this
  214. let query = {
  215. id: pid
  216. }
  217. PersonnelApi.getOnePersonnel(query)
  218. .then(response => {
  219. _this.testlistform = response.records
  220. _this.testlistform.CalibrationTime = new Date(response.CalibrationTime)
  221. if (_this.testlistform.FileName !== '') {
  222. let file = {
  223. name: _this.testlistform.FileName,
  224. url: _this.testlistform.FileUrl
  225. }
  226. _this.fileList.push(file)
  227. }
  228. }).catch(err => {
  229. // handle error
  230. console.error(err)
  231. })
  232. },
  233. // // 查询action
  234. // getttriggernow (id) {
  235. // gettriggerlist({}, id)
  236. // .then(res => {
  237. // let _this = this
  238. // _this.Advancetime = res.items.Advancetime
  239. // // 查询子表 有效期
  240. // _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)
  241. // })
  242. // .catch(err => {
  243. // console.error(err)
  244. // })
  245. // },
  246. // getclassificationlist () {
  247. // // 获取样本单位
  248. // let _this = this
  249. // let params = {
  250. // code: 'PersonnelItem'
  251. // }
  252. // classificationlist(params)
  253. // .then(res => {
  254. // _this.classificationlist = res.info
  255. // })
  256. // },
  257. // // 添加报警
  258. // addTriggerl (ID, Code, TimeNotification, Name, Advancetime, CalibrationTime, CalibrationDeadline, CalibrationDeadlineType) {
  259. // // eslint-disable-next-line no-undef
  260. // let _this = this
  261. // _this.triggerlist.Aid = '4802'
  262. // _this.triggerlist.DId = ID
  263. // _this.triggerlist.Advancetime = Advancetime// action 报警提前时间
  264. // _this.triggerlist.TimeNotification = TimeNotification // 保质期到期提醒
  265. // _this.triggerlist.ProductDate = CalibrationTime// '校准日期',
  266. // _this.triggerlist.AccCode = Code // '物品编码',
  267. // _this.triggerlist.Name = Name // '姓名',
  268. // _this.triggerlist.ValidityLong = CalibrationDeadline // '有效时长',
  269. // _this.triggerlist.ValidityLongType = CalibrationDeadlineType// '有效时长类型:1天;2周;3月;4年',
  270. // _this.triggerlist.Category = 3 // '种类 1、耗材;2:试剂'
  271. // if (CalibrationDeadlineType === 1) {
  272. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline))
  273. // } else if (CalibrationDeadlineType === 2) {
  274. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 7))
  275. // } else if (CalibrationDeadlineType === 3) {
  276. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 30))
  277. // } else if (CalibrationDeadlineType === 4) {
  278. // _this.triggerlist.RemindTime = new Date(_this.addDate(CalibrationTime, CalibrationDeadline * 365))
  279. // }
  280. // addTrigger(_this.triggerlist)
  281. // .then(function (response) {
  282. // })
  283. // },
  284. // 计算日期
  285. addDate (date, days) {
  286. if (days === undefined || days === '') {
  287. days = 1
  288. }
  289. var dates = new Date(date)
  290. dates.setDate(dates.getDate() + days)
  291. var month = dates.getMonth() + 1
  292. var day = dates.getDate()
  293. var mm = "'" + month + "'"
  294. var dd = "'" + day + "'"
  295. // 单位数前面加0
  296. if (mm.length === 3) {
  297. month = '0' + month
  298. }
  299. if (dd.length === 3) {
  300. day = '0' + day
  301. }
  302. var time = dates.getFullYear() + '-' + month + '-' + day
  303. return time
  304. },
  305. // // 获取供应商
  306. // getSupplier () {
  307. // let _this = this
  308. // let params = {
  309. // customerName: 'Supplier'
  310. // }
  311. // getsupplierlist(params)
  312. // .then(res => {
  313. // _this.getsupplierlist = res.info
  314. // })
  315. // },
  316. // 返回当前页
  317. handleCloseEdit () {
  318. // this.$refs['uploader'].clearFiles()
  319. this.fileList = []
  320. this.$emit('closeEditDialog')
  321. },
  322. deletedataforDid (val) {
  323. deletetriggerlistfordid(val)
  324. .then(res => {
  325. })
  326. .catch(err => {
  327. // handle error
  328. console.error(err)
  329. })
  330. }
  331. }
  332. // watch: {
  333. // PersonnelId: function (newVal) {
  334. // this.getEntity(newVal)
  335. // }
  336. // }
  337. }
  338. </script>
  339. <style lang="scss">
  340. .button {
  341. padding: 0;
  342. float: right;
  343. }
  344. </style>