IncubatorManagement.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <!-- 保温箱管理 -->
  3. <div style="overflow-y: auto;">
  4. <actionBar :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm" @openModel="openModel"
  5. @searchProtocol="searchProtocol"></actionBar>
  6. <div class="card_content">
  7. <!-- 表单 -->
  8. <tables :tableList="tableList" :tableData="tableData" @buttonData="buttonData"></tables>
  9. <!-- 分页 -->
  10. <div v-if="Total">
  11. <pagination :total="Total" :currentPage="Pagination.PageIndex" @changeSize="changeSize"
  12. @changeCurrent="changeCurrent">
  13. </pagination>
  14. </div>
  15. </div>
  16. <el-dialog :title="staffTitle" :visible.sync="staffDialogVisible" width="600px" :close-on-click-modal="false"
  17. @close="closeDialog">
  18. <forms ref="childRules" :formNewList="formRuleList" :ruleForm="ruleForm" labelWidth="100px"></forms>
  19. <span slot="footer" class="dialog-footer" v-if="operationType != 'logs'">
  20. <el-button plain @click="staffDialogVisible = false">取 消</el-button>
  21. <el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
  22. </span>
  23. </el-dialog>
  24. <div class="management_card">
  25. <el-dialog :visible.sync="importDialogVisible" width="500px" :close-on-click-modal="false" @close="closeDialogil">
  26. <div class="card_import">
  27. <div class="card_incubat">
  28. <forms ref="incubatorRules" labelPosition="left" :formNewList="stateRuleList" :ruleForm="stateRuleForm"
  29. labelWidth="80px"></forms>
  30. </div>
  31. <div class="card_search_input">
  32. <div class="title_search">名称:</div>
  33. <el-input v-model="nameTitle" placeholder="请输入内容" @input="incubatorInput"></el-input>
  34. </div>
  35. <!-- 表单 -->
  36. <tables ref="refIncubator" :tableList="incubatorList" :tableData="incubatorData"></tables>
  37. <!-- 分页 -->
  38. <div v-if="Total">
  39. <pagination :total="Total1" :currentPage="Paginationil.PageIndex" :pager-countnum="5"
  40. layout="sizes, prev, pager, next" @changeSize="changeSizeil" @changeCurrent="changeCurrentil">
  41. </pagination>
  42. </div>
  43. </div>
  44. <span slot="footer" class="dialog-footer">
  45. <el-button plain @click="importDialogVisible = false">取 消</el-button>
  46. <el-button type="primary" :loading="incubatorLoading" @click="incubatorAdd">导 入</el-button>
  47. </span>
  48. </el-dialog>
  49. </div>
  50. <el-dialog :visible.sync="dialogVisible" width="80%" @close="temperatureClose">
  51. <template slot="title">
  52. <div style="display: flex;align-items: center;">
  53. <span style="margin-right: 10px;font-size: 20px;">温湿度记录</span>
  54. <el-date-picker v-model="timeQuantum" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
  55. :picker-options="pickerOptions" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
  56. align="center" @change="timeChange">
  57. </el-date-picker>
  58. </div>
  59. </template>
  60. <thermography ref="thermo" :waybillNo="waybillNo" :timeData="timeQuantum"></thermography>
  61. </el-dialog>
  62. <centerControl ref="control"></centerControl>
  63. </div>
  64. </template>
  65. <script>
  66. import {
  67. getSysUserBind
  68. } from '@/api/user'
  69. import {
  70. getCoolerBox,
  71. getCoolerBoxDetails,
  72. addCoolerBox,
  73. putCoolerBox,
  74. delCoolerBox,
  75. getDevice,
  76. addCoolerBoxImport
  77. } from '@/api/incubator'
  78. import actionBar from '@/components/actionBar'
  79. import tables from '@/components/tables'
  80. import pagination from '@/components/pagination'
  81. import forms from '@/components/forms'
  82. import thermography from '@/components/thermography'
  83. import centerControl from '@/components/centerControl'
  84. import {
  85. formRules,
  86. employee,
  87. incubator
  88. } from "./incubator.js";
  89. import {
  90. startStatus,
  91. iceraftStatus
  92. } from '@/assets/js/blockSort'
  93. export default {
  94. name: 'IncubatorManagement',
  95. components: {
  96. actionBar,
  97. tables,
  98. pagination,
  99. forms,
  100. thermography,
  101. centerControl
  102. },
  103. data() {
  104. return {
  105. pickerOptions: {
  106. shortcuts: [{
  107. text: '最近一周',
  108. onClick(picker) {
  109. const end = new Date();
  110. const start = new Date();
  111. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  112. picker.$emit('pick', [start, end]);
  113. }
  114. }, {
  115. text: '最近一个月',
  116. onClick(picker) {
  117. const end = new Date();
  118. const start = new Date();
  119. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  120. picker.$emit('pick', [start, end]);
  121. }
  122. }, {
  123. text: '最近三个月',
  124. onClick(picker) {
  125. const end = new Date();
  126. const start = new Date();
  127. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  128. picker.$emit('pick', [start, end]);
  129. }
  130. }]
  131. },
  132. timeQuantum: [this.getTime(new Date(new Date().toLocaleDateString())), this.getTime(new Date())],
  133. operateList: [{
  134. type: 'add',
  135. title: '添加保温箱',
  136. icon: 'el-icon-plus',
  137. }, {
  138. type: 'import',
  139. title: '冷链平台导入',
  140. icon: 'el-icon-upload',
  141. }, {
  142. type: 'screen',
  143. title: '中控大屏',
  144. icon: 'el-icon-position',
  145. colour: 'success'
  146. }],
  147. formList: [{
  148. type: 'input',
  149. label: '名称',
  150. field: 'name',
  151. placeholder: '名称',
  152. }, {
  153. type: 'input',
  154. label: 'SN',
  155. field: 'sn',
  156. placeholder: 'SN',
  157. }, {
  158. type: 'select',
  159. label: '状态',
  160. field: 'status',
  161. placeholder: '请选择状态',
  162. options: iceraftStatus(),
  163. }],
  164. searchRuleForm: {
  165. name: '',
  166. sn: '',
  167. status: '',
  168. },
  169. searchValue: {},
  170. Pagination: {
  171. PageIndex: 1,
  172. PageSize: 10,
  173. },
  174. Total: 0,
  175. tableData: [],
  176. operationType: '',
  177. tableList: employee(),
  178. staffTitle: '添加',
  179. staffDialogVisible: false,
  180. formRuleList: [],
  181. ruleForm: {
  182. name: '',
  183. sn: '',
  184. status: '2',
  185. },
  186. confirmLoading: false,
  187. selectingData: {},
  188. importDialogVisible: false,
  189. incubatorList: incubator(),
  190. incubatorData: [],
  191. Total1: 0,
  192. Paginationil: {
  193. PageIndex: 1,
  194. PageSize: 10,
  195. },
  196. stateRuleList: [{
  197. field: 'status',
  198. label: '状态',
  199. placeholder: '状态',
  200. type: 'radio',
  201. colWidth: 24,
  202. rules: [{
  203. required: true,
  204. message: '选择状态',
  205. trigger: 'change'
  206. }],
  207. options: startStatus()
  208. }],
  209. stateRuleForm: {
  210. status: '2',
  211. },
  212. nameTitle: '',
  213. incubatorLoading: false,
  214. timer: null, //定时器名称
  215. dialogVisible: false,
  216. waybillNo: '',
  217. }
  218. },
  219. beforeDestroy() {
  220. clearInterval(this.timer); // 清除定时器
  221. this.timer = null;
  222. },
  223. mounted() {
  224. const dataList = formRules();
  225. this.formRuleList = dataList;
  226. this.getList()
  227. },
  228. methods: {
  229. getTime(time) {
  230. var date = new Date(time)
  231. var y = date.getFullYear()
  232. var m = date.getMonth() + 1
  233. m = m < 10 ? '0' + m : m
  234. var d = date.getDate()
  235. d = d < 10 ? '0' + d : d
  236. var h = date.getHours()
  237. h = h < 10 ? '0' + h : h
  238. var minute = date.getMinutes()
  239. minute = minute < 10 ? '0' + minute : minute
  240. var s = date.getSeconds()
  241. s = s < 10 ? '0' + s : s
  242. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + s
  243. },
  244. // 搜索
  245. searchProtocol(value) {
  246. this.searchValue = value
  247. this.getList()
  248. },
  249. // 获取运单列表
  250. getList() {
  251. var params = {
  252. page: this.Pagination.PageIndex,
  253. pageSize: this.Pagination.PageSize,
  254. showTemp: true,
  255. ...this.searchValue
  256. }
  257. getCoolerBox(params).then(res => {
  258. if (res.code == 200) {
  259. this.tableData = res.data.list
  260. this.Total = res.data.count
  261. this.timer = setTimeout(() => {
  262. this.getList();
  263. }, 60000)
  264. }
  265. })
  266. },
  267. // 选项赋值
  268. optionMatching(value, field) {
  269. this.formRuleList.forEach((item, index) => {
  270. if (item.field == field) {
  271. item.options = value
  272. }
  273. })
  274. },
  275. // 弹窗表单添加
  276. handleAdd() {
  277. let flag = this.$refs['childRules'].validateForm();
  278. if (flag) {
  279. if (this.operationType == 'add') {
  280. this.confirmLoading = true
  281. var params = {
  282. ...this.ruleForm
  283. }
  284. addCoolerBox(params).then(res => {
  285. if (res.code == 200) {
  286. this.$message({
  287. message: '操作成功',
  288. type: 'success'
  289. });
  290. this.getList()
  291. this.staffDialogVisible = false
  292. }
  293. this.confirmLoading = false
  294. }).catch(() => {
  295. this.confirmLoading = false
  296. })
  297. } else if (this.operationType == 'edit') {
  298. this.confirmLoading = true
  299. var params = {
  300. id: this.selectingData.id,
  301. name: this.ruleForm.name,
  302. sn: this.ruleForm.sn,
  303. status: this.ruleForm.status,
  304. }
  305. putCoolerBox(params).then(res => {
  306. if (res.code == 200) {
  307. this.$message({
  308. message: '操作成功',
  309. type: 'success'
  310. });
  311. this.getList()
  312. }
  313. this.staffDialogVisible = false
  314. this.confirmLoading = false
  315. }).catch(() => {
  316. this.confirmLoading = false
  317. })
  318. }
  319. } else {
  320. this.$message.error('表单信息不完整,请继续填写完整');
  321. }
  322. },
  323. buttonData(row, type) {
  324. this.selectingData = row
  325. this.operationType = type
  326. if (type == 'edit') {
  327. this.staffTitle = '编辑'
  328. this.staffDialogVisible = true
  329. setTimeout(() => {
  330. this.$nextTick(() => {
  331. this.ruleForm = JSON.parse(JSON.stringify(row))
  332. })
  333. })
  334. } else if (type == 'del') {
  335. this.deleteUser(row.id)
  336. } else if (type == 'logs') {
  337. this.staffTitle = '详情'
  338. this.staffDialogVisible = true
  339. this.formRuleList.forEach((item, index) => {
  340. item.disabled = true
  341. })
  342. this.ruleForm = JSON.parse(JSON.stringify(row))
  343. } else if (type == 'record') {
  344. this.dialogVisible = true
  345. this.waybillNo = row.sn
  346. this.$nextTick(() => {
  347. this.$refs.thermo.getProbe()
  348. })
  349. }
  350. },
  351. // 选择时间
  352. timeChange() {
  353. this.$nextTick(() => {
  354. this.$refs.thermo.getTemperature()
  355. })
  356. },
  357. openModel(type) {
  358. if (type == 'add') {
  359. this.staffTitle = '添加'
  360. this.staffDialogVisible = true
  361. this.operationType = type
  362. } else if (type == 'import') {
  363. this.importDialogVisible = true
  364. this.getDeviceList()
  365. }else if(type == 'screen'){
  366. this.$refs.control.controlVisible = true
  367. this.$nextTick(() => {
  368. setTimeout(() => {
  369. this.$refs.control.keyUpSearch()
  370. }, 100)
  371. })
  372. }
  373. },
  374. // 获取设备列表
  375. getDeviceList() {
  376. var params = {
  377. page: this.Paginationil.PageIndex,
  378. pageSize: this.Paginationil.PageSize,
  379. name: this.nameTitle,
  380. }
  381. getDevice(params).then(res => {
  382. if (res.code == 200) {
  383. this.incubatorData = res.data.list
  384. this.Total1 = res.data.count
  385. }
  386. })
  387. },
  388. // 搜索保温箱
  389. incubatorInput(value) {
  390. this.nameTitle = value
  391. this.getDeviceList()
  392. },
  393. // 批量导入保温箱
  394. incubatorAdd() {
  395. const arrID = this.$refs.refIncubator.waybillIds
  396. let arr1 = []
  397. arrID.forEach(item => {
  398. let arr2 = {
  399. sn: item.T_sn,
  400. name: item.T_devName,
  401. }
  402. arr1.push(arr2)
  403. })
  404. let flag = this.$refs['incubatorRules'].validateForm();
  405. if (flag) {
  406. if (arr1.length > 0) {
  407. this.incubatorLoading = true
  408. let params = {
  409. list: arr1,
  410. ...this.stateRuleForm,
  411. }
  412. addCoolerBoxImport(params).then(res => {
  413. if (res.code == 200) {
  414. this.$message({
  415. message: '操作成功',
  416. type: 'success'
  417. });
  418. this.getList()
  419. this.importDialogVisible = false
  420. }
  421. this.incubatorLoading = false
  422. }).catch(() => {
  423. this.incubatorLoading = false
  424. })
  425. } else {
  426. this.$message.warning('请选择需要导入的保温箱');
  427. }
  428. } else {
  429. this.$message.error('表单信息不完整,请继续填写完整');
  430. }
  431. },
  432. // 删除保温箱
  433. deleteUser(id) {
  434. this.$confirm('此操作将永久删除该保温箱, 是否继续?', '提示', {
  435. confirmButtonText: '确定',
  436. cancelButtonText: '取消',
  437. type: 'warning'
  438. }).then(() => {
  439. delCoolerBox({
  440. id: id,
  441. }).then(res => {
  442. if (res.code == 200) {
  443. this.$message({
  444. message: '操作成功',
  445. type: 'success'
  446. });
  447. const precisePage = Math.ceil((this.Total - 1) / this.Pagination.PageSize)
  448. this.Pagination.PageIndex = this.Pagination.PageIndex > precisePage ? precisePage : this
  449. .Pagination.PageIndex
  450. this.Pagination.PageIndex = this.Pagination.PageIndex < 1 ? 1 : this.Pagination.PageIndex
  451. this.getList()
  452. }
  453. })
  454. }).catch(() => {});
  455. },
  456. changeSize(val) {
  457. this.Pagination.PageSize = val
  458. this.getList()
  459. },
  460. changeCurrent(val) {
  461. this.Pagination.PageIndex = val
  462. this.getList()
  463. },
  464. changeSizeil(val) {
  465. this.Paginationil.PageSize = val
  466. this.getDeviceList()
  467. },
  468. changeCurrentil(val) {
  469. this.Paginationil.PageIndex = val
  470. this.getDeviceList()
  471. },
  472. // 清空表单
  473. closeDialog() {
  474. this.formRuleList.forEach((item, index) => {
  475. item.disabled = false
  476. })
  477. this.ruleForm = {}
  478. this.$refs.childRules.resetCheck();
  479. },
  480. // 关闭温湿度记录
  481. temperatureClose() {
  482. this.timeQuantum = [this.getTime(new Date(new Date().toLocaleDateString())), this.getTime(new Date())]
  483. },
  484. closeDialogil() {
  485. this.$refs.incubatorRules.resetCheck();
  486. this.$refs.refIncubator.clearSelected();
  487. }
  488. }
  489. }
  490. </script>
  491. <style lang="scss" scoped>
  492. .card_check_title {
  493. display: flex;
  494. align-items: center;
  495. }
  496. .icon_import {
  497. margin-right: 5px;
  498. font-size: 20px;
  499. }
  500. .card_import {
  501. margin-top: 15px;
  502. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  503. margin-bottom: 20px;
  504. border-radius: 10px;
  505. }
  506. .management_card ::v-deep .el-dialog__body {
  507. padding: 0px 20px !important;
  508. }
  509. .card_incubat {
  510. padding-left: 15px;
  511. border-bottom: 1px solid #EBEEF5;
  512. padding-top: 15px;
  513. margin-bottom: 15px;
  514. }
  515. .card_search_input {
  516. display: flex;
  517. align-items: center;
  518. padding: 15px 20px 15px 20px;
  519. border-bottom: 1px solid #EBEEF5;
  520. }
  521. .title_search {
  522. flex: none;
  523. margin-right: 5px;
  524. }
  525. </style>