IncubatorManagement.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. <template>
  2. <!-- 保温箱管理 -->
  3. <div class="home">
  4. <actionBar :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm" @openModel="openModel"
  5. @searchProtocol="searchProtocol"></actionBar>
  6. <div class="card_content">
  7. <!-- 表单 -->
  8. <tables ref="refWaybill" :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="110px" :copyFlag="copyFlag"
  19. @handleScroll="handleScroll" @remoteMethod="remoteMethod"></forms>
  20. <span slot="footer" class="dialog-footer" v-if="operationType != 'logs'">
  21. <el-button plain @click="staffDialogVisible = false">取 消</el-button>
  22. <el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
  23. </span>
  24. </el-dialog>
  25. <div class="management_card">
  26. <el-dialog :visible.sync="importDialogVisible" width="600px" :close-on-click-modal="false" @close="closeDialogil">
  27. <div class="card_import">
  28. <div class="card_incubat">
  29. <forms ref="incubatorRules" labelPosition="left" :formNewList="stateRuleList" :ruleForm="stateRuleForm"
  30. labelWidth="110px"></forms>
  31. </div>
  32. <div class="card_search_input">
  33. <div class="title_search">名称:</div>
  34. <el-input v-model="nameTitle" placeholder="请输入内容" @input="incubatorInput"></el-input>
  35. </div>
  36. <!-- 表单 -->
  37. <tables ref="refIncubator" :tableList="incubatorList" :tableData="incubatorData"></tables>
  38. <!-- 分页 -->
  39. <div v-if="Total">
  40. <pagination :total="Total1" :currentPage="Paginationil.PageIndex" :pager-countnum="5"
  41. layout="sizes, prev, pager, next" @changeSize="changeSizeil" @changeCurrent="changeCurrentil">
  42. </pagination>
  43. </div>
  44. </div>
  45. <span slot="footer" class="dialog-footer">
  46. <el-button plain @click="importDialogVisible = false">取 消</el-button>
  47. <el-button type="primary" :loading="incubatorLoading" @click="incubatorAdd">导 入</el-button>
  48. </span>
  49. </el-dialog>
  50. </div>
  51. <el-dialog top="5vh" :visible.sync="dialogVisible" width="80%" @close="temperatureClose">
  52. <template slot="title">
  53. <div class="pciker_time" style="display: flex;align-items: center;">
  54. <span style="margin-right: 10px;font-size: 20px;color: #fff;">温湿度记录</span>
  55. <el-date-picker v-model="timeQuantum" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
  56. :picker-options="pickerOptions" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
  57. align="center" @change="timeChange">
  58. </el-date-picker>
  59. </div>
  60. </template>
  61. <thermography ref="thermo" :waybillNo="waybillNo" :timeData="timeQuantum"></thermography>
  62. </el-dialog>
  63. <!-- <centerControl ref="control"></centerControl> -->
  64. </div>
  65. </template>
  66. <script>
  67. import {
  68. getIceRaft,
  69. } from '@/api/freezer'
  70. import {
  71. getCoolerBox,
  72. addCoolerBox,
  73. putCoolerBox,
  74. delCoolerBox,
  75. getDevice,
  76. addCoolerBoxImport
  77. } from '@/api/incubator'
  78. import {
  79. getTemperature
  80. } from '@/api/waybill'
  81. import actionBar from '@/components/actionBar'
  82. import tables from '@/components/tables'
  83. import pagination from '@/components/pagination'
  84. import forms from '@/components/forms'
  85. import thermography from '@/components/thermography'
  86. // import centerControl from '@/components/centerControl'
  87. import {
  88. formRules,
  89. employee,
  90. incubator,
  91. historyRecord,
  92. } from "./incubator.js";
  93. import {
  94. startStatus,
  95. iceraftStatus
  96. } from '@/assets/js/blockSort'
  97. export default {
  98. name: 'IncubatorManagement',
  99. components: {
  100. actionBar,
  101. tables,
  102. pagination,
  103. forms,
  104. thermography,
  105. // centerControl
  106. },
  107. data() {
  108. const baseRuleForm = {
  109. name: '',
  110. sn: '',
  111. status: '2',
  112. cold_spots: '',
  113. cold_temperatures: '',
  114. for_cold_cooler_time: '',
  115. copyNumber: null,
  116. }
  117. return {
  118. pickerOptions: {
  119. shortcuts: [{
  120. text: '最近一周',
  121. onClick(picker) {
  122. const end = new Date();
  123. const start = new Date();
  124. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  125. picker.$emit('pick', [start, end]);
  126. }
  127. }, {
  128. text: '最近一个月',
  129. onClick(picker) {
  130. const end = new Date();
  131. const start = new Date();
  132. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  133. picker.$emit('pick', [start, end]);
  134. }
  135. }, {
  136. text: '最近三个月',
  137. onClick(picker) {
  138. const end = new Date();
  139. const start = new Date();
  140. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  141. picker.$emit('pick', [start, end]);
  142. }
  143. }]
  144. },
  145. timeQuantum: [this.getTime(new Date(new Date().toLocaleDateString())), this.getTime(new Date())],
  146. operateList: [{
  147. type: 'add',
  148. title: '添加保温箱',
  149. icon: 'el-icon-plus',
  150. }, {
  151. type: 'import',
  152. title: '冷链平台导入',
  153. icon: 'el-icon-upload',
  154. }, {
  155. type: 'copyIce',
  156. title: '复制保温箱',
  157. icon: 'el-icon-copy-document',
  158. }, {
  159. type: 'batchEdit',
  160. title: '批量修改',
  161. icon: 'el-icon-edit-outline',
  162. }
  163. // {
  164. // type: 'screen',
  165. // title: '中控大屏',
  166. // icon: 'el-icon-position',
  167. // colour: 'success'
  168. // },
  169. ],
  170. formList: [{
  171. type: 'input',
  172. label: '名称',
  173. field: 'name',
  174. placeholder: '名称',
  175. }, {
  176. type: 'input',
  177. label: 'SN',
  178. field: 'sn',
  179. placeholder: 'SN',
  180. }, {
  181. type: 'select',
  182. label: '状态',
  183. field: 'status',
  184. placeholder: '请选择状态',
  185. options: iceraftStatus(),
  186. }],
  187. searchRuleForm: {
  188. name: '',
  189. sn: '',
  190. status: '',
  191. },
  192. searchValue: {},
  193. Pagination: {
  194. PageIndex: 1,
  195. PageSize: 10,
  196. },
  197. Total: 0,
  198. tableData: [],
  199. operationType: '',
  200. tableList: [],
  201. staffTitle: '添加',
  202. staffDialogVisible: false,
  203. formRuleList: [],
  204. ruleForm: {
  205. ...baseRuleForm
  206. },
  207. initialRuleForm: {
  208. ...baseRuleForm
  209. },
  210. confirmLoading: false,
  211. selectingData: {},
  212. importDialogVisible: false,
  213. incubatorList: incubator(),
  214. incubatorData: [],
  215. Total1: 0,
  216. Paginationil: {
  217. PageIndex: 1,
  218. PageSize: 10,
  219. },
  220. stateRuleData: [{
  221. field: 'cold_temperatures',
  222. label: '预冷温度(℃)',
  223. placeholder: '请输入预冷温度(℃)',
  224. type: 'input',
  225. colWidth: 24,
  226. rules: [{
  227. required: true,
  228. message: '请输入预冷温度(℃)',
  229. trigger: 'blur'
  230. }]
  231. }, {
  232. field: 'cold_spots',
  233. label: '预冷地点',
  234. placeholder: '请输入预冷地点',
  235. type: 'input',
  236. colWidth: 24,
  237. rules: [{
  238. required: true,
  239. message: '请输入预冷地点',
  240. trigger: 'blur'
  241. }]
  242. }, {
  243. field: 'status',
  244. label: '状态',
  245. placeholder: '状态',
  246. type: 'radio',
  247. colWidth: 24,
  248. rules: [{
  249. required: true,
  250. message: '选择状态',
  251. trigger: 'change'
  252. }],
  253. options: startStatus()
  254. }],
  255. stateRuleList: [],
  256. stateRuleForm: {
  257. status: '2',
  258. },
  259. nameTitle: '',
  260. incubatorLoading: false,
  261. timer: null, //定时器名称
  262. dialogVisible: false,
  263. waybillNo: '',
  264. iceTracingVisible: false,
  265. value1: '',
  266. // 历史记录
  267. historyList: historyRecord(),
  268. historyData: [],
  269. historyTotal: 0,
  270. historyPagination: {
  271. PageIndex: 1,
  272. PageSize: 10,
  273. },
  274. userList: {},
  275. icePagination: {
  276. PageIndex: 1,
  277. PageSize: 10,
  278. },
  279. iceTotal: 0,
  280. staffName: '',
  281. limitNo: true,
  282. copyFlag: false,
  283. batchEditRows: [],
  284. defaultFormRuleList: [],
  285. }
  286. },
  287. beforeDestroy() {
  288. clearInterval(this.timer); // 清除定时器
  289. this.timer = null;
  290. },
  291. mounted() {
  292. const arr = localStorage.getItem('userList')
  293. this.userList = JSON.parse(arr)
  294. if (this.userList.dept.isCoolerReleaseCold) {
  295. const dataList = formRules();
  296. this.formRuleList = dataList;
  297. this.stateRuleList = this.stateRuleData
  298. this.tableList = employee()
  299. } else {
  300. const dataList = formRules();
  301. const tablearr = employee();
  302. this.formRuleList = removePointById(dataList, ['cold_spots', 'iceBinding', 'for_cold_cooler_time',
  303. 'cold_temperatures'
  304. ])
  305. this.stateRuleList = removePointById(this.stateRuleData, ['cold_spots', 'iceBinding', 'for_cold_cooler_time',
  306. 'cold_temperatures'
  307. ])
  308. this.tableList = removePointById(tablearr, ['cold_spots', 'iceBinding', 'for_cold_cooler_time',
  309. 'cold_temperatures'
  310. ])
  311. }
  312. this.defaultFormRuleList = JSON.parse(JSON.stringify(this.formRuleList))
  313. function removePointById(arr1, arr2) {
  314. for (let i = 0; i < arr2.length; i++) {
  315. for (let j = 0; j < arr1.length; j++) {
  316. if (arr2[i] == arr1[j].field) {
  317. let indexs = arr1.indexOf(arr1[j]);
  318. arr1.splice(indexs, 1);
  319. }
  320. }
  321. }
  322. return arr1
  323. }
  324. this.getList()
  325. },
  326. methods: {
  327. download() {
  328. getTemperature().then(response => {
  329. if (response.fileName) {
  330. this.pdfDialogVisible = false
  331. //fileName = decodeURIComponent(filename);//对filename进行转码
  332. let fileName = decodeURI(response.fileName);
  333. if (window.navigator.msSaveOrOpenBlob) {
  334. navigator.msSaveBlob(new Blob([response.data]), fileName);
  335. } else {
  336. let url = window.URL.createObjectURL(new Blob([response.data]));
  337. let link = document.createElement('a');
  338. link.style.display = 'none';
  339. link.href = url;
  340. link.setAttribute('download', fileName);
  341. document.body.appendChild(link);
  342. link.click();
  343. }
  344. } else {
  345. this.$message.error('未获取到文件名');
  346. }
  347. })
  348. },
  349. getTime(time) {
  350. var date = new Date(time)
  351. var y = date.getFullYear()
  352. var m = date.getMonth() + 1
  353. m = m < 10 ? '0' + m : m
  354. var d = date.getDate()
  355. d = d < 10 ? '0' + d : d
  356. var h = date.getHours()
  357. h = h < 10 ? '0' + h : h
  358. var minute = date.getMinutes()
  359. minute = minute < 10 ? '0' + minute : minute
  360. var s = date.getSeconds()
  361. s = s < 10 ? '0' + s : s
  362. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + s
  363. },
  364. // 搜索
  365. searchProtocol(value) {
  366. this.searchValue = value
  367. this.getList()
  368. },
  369. // 获取保温箱列表
  370. getList() {
  371. var params = {
  372. page: this.Pagination.PageIndex,
  373. pageSize: this.Pagination.PageSize,
  374. showTemp: true,
  375. ...this.searchValue
  376. }
  377. getCoolerBox(params).then(res => {
  378. if (res.code == 200) {
  379. this.tableData = res.data.list
  380. this.Total = res.data.count
  381. this.timer = setTimeout(() => {
  382. this.getList();
  383. clearInterval(this.timer); // 清除定时器
  384. this.timer = null;
  385. }, 60000)
  386. }
  387. })
  388. },
  389. cloneDefaultFormRules() {
  390. return JSON.parse(JSON.stringify(this.defaultFormRuleList || []))
  391. },
  392. useDefaultFormRules() {
  393. if (this.defaultFormRuleList && this.defaultFormRuleList.length) {
  394. this.formRuleList = this.cloneDefaultFormRules()
  395. }
  396. },
  397. resetRuleFormFields() {
  398. this.ruleForm = JSON.parse(JSON.stringify(this.initialRuleForm))
  399. },
  400. fieldValueFilled(value) {
  401. return value !== '' && value !== null && value !== undefined
  402. },
  403. getBatchFormRules() {
  404. const editableFields = ['cold_temperatures', 'cold_spots', 'for_cold_cooler_time', 'status']
  405. const base = this.cloneDefaultFormRules()
  406. return base.filter(item => editableFields.includes(item.field)).map(item => {
  407. const newItem = {
  408. ...item
  409. }
  410. if (newItem.rules) {
  411. newItem.rules = newItem.rules.map(rule => ({
  412. ...rule,
  413. required: false
  414. }))
  415. }
  416. return newItem
  417. })
  418. },
  419. hasFieldPermission(field) {
  420. return this.defaultFormRuleList && this.defaultFormRuleList.some(item => item.field === field)
  421. },
  422. hasBatchEditChanges() {
  423. const changeableFields = ['status']
  424. if (this.hasFieldPermission('cold_temperatures')) {
  425. changeableFields.push('cold_temperatures', 'cold_spots', 'for_cold_cooler_time')
  426. }
  427. return changeableFields.some(field => this.fieldValueFilled(this.ruleForm[field]))
  428. },
  429. buildBatchEditParams(row) {
  430. const params = {
  431. id: row.id,
  432. name: row.name,
  433. sn: row.sn,
  434. status: this.fieldValueFilled(this.ruleForm.status) ? this.ruleForm.status : row.status,
  435. }
  436. if (this.hasFieldPermission('cold_temperatures')) {
  437. params.cold_temperatures = this.fieldValueFilled(this.ruleForm.cold_temperatures) ? this.ruleForm.cold_temperatures : row.cold_temperatures
  438. params.cold_spots = this.fieldValueFilled(this.ruleForm.cold_spots) ? this.ruleForm.cold_spots : row.cold_spots
  439. params.for_cold_cooler_time = this.fieldValueFilled(this.ruleForm.for_cold_cooler_time) ? Number(this.ruleForm.for_cold_cooler_time) : row.for_cold_cooler_time
  440. }
  441. return params
  442. },
  443. // 选项赋值
  444. optionMatching(value, field) {
  445. this.formRuleList.forEach((item, index) => {
  446. if (item.field == field) {
  447. item.options = value
  448. }
  449. })
  450. },
  451. // 弹窗表单添加
  452. handleAdd() {
  453. let flag = this.$refs['childRules'].validateForm();
  454. if (flag) {
  455. if (this.operationType == 'add') {
  456. this.confirmLoading = true
  457. var params = {
  458. ...this.ruleForm
  459. }
  460. params.for_cold_cooler_time = Number(this.ruleForm.for_cold_cooler_time)
  461. addCoolerBox(params).then(res => {
  462. if (res.code == 200) {
  463. this.$message({
  464. message: '操作成功',
  465. type: 'success'
  466. });
  467. this.getList()
  468. this.ruleForm.copyNumber--
  469. if (this.ruleForm.copyNumber == 0 || this.ruleForm.copyNumber == null || this.ruleForm.copyNumber == undefined || this.ruleForm.copyNumber == 0) {
  470. this.staffDialogVisible = false
  471. }
  472. }
  473. this.confirmLoading = false
  474. }).catch(() => {
  475. this.confirmLoading = false
  476. })
  477. } else if (this.operationType == 'edit') {
  478. this.confirmLoading = true
  479. var params = {
  480. id: this.selectingData.id,
  481. name: this.ruleForm.name,
  482. sn: this.ruleForm.sn,
  483. status: this.ruleForm.status,
  484. cold_spots: this.ruleForm.cold_spots,
  485. cold_temperatures: this.ruleForm.cold_temperatures,
  486. for_cold_cooler_time: Number(this.ruleForm.for_cold_cooler_time),
  487. }
  488. console.log(params, 23)
  489. putCoolerBox(params).then(res => {
  490. if (res.code == 200) {
  491. this.$message({
  492. message: '操作成功',
  493. type: 'success'
  494. });
  495. this.getList()
  496. }
  497. this.staffDialogVisible = false
  498. this.confirmLoading = false
  499. }).catch(() => {
  500. this.confirmLoading = false
  501. })
  502. } else if (this.operationType == 'batchEdit') {
  503. if (!this.batchEditRows.length) {
  504. this.$message.warning('请先选择需要批量修改的保温箱')
  505. return
  506. }
  507. if (!this.hasBatchEditChanges()) {
  508. this.$message.warning('请至少填写一个需要修改的字段')
  509. return
  510. }
  511. this.confirmLoading = true
  512. const requests = this.batchEditRows.map(row => {
  513. const params = this.buildBatchEditParams(row)
  514. return putCoolerBox(params)
  515. })
  516. Promise.all(requests).then(() => {
  517. this.$message({
  518. message: '批量修改成功',
  519. type: 'success'
  520. });
  521. this.getList()
  522. if (this.$refs.refWaybill) {
  523. this.$refs.refWaybill.clearSelected()
  524. }
  525. this.staffDialogVisible = false
  526. }).catch(() => {
  527. this.$message.error('批量修改失败')
  528. }).finally(() => {
  529. this.confirmLoading = false
  530. })
  531. }
  532. } else {
  533. this.$message.error('表单信息不完整,请继续填写完整');
  534. }
  535. },
  536. buttonData(row, type) {
  537. this.selectingData = row
  538. this.operationType = type
  539. this.useDefaultFormRules()
  540. if (type == 'edit') {
  541. this.staffTitle = '编辑'
  542. this.staffDialogVisible = true
  543. if (this.userList.dept.isCoolerReleaseCold) {
  544. this.obtainIceRaft()
  545. }
  546. setTimeout(() => {
  547. this.$nextTick(() => {
  548. this.ruleForm = JSON.parse(JSON.stringify(row))
  549. })
  550. })
  551. } else if (type == 'del') {
  552. this.deleteUser(row.id)
  553. } else if (type == 'logs') {
  554. this.staffTitle = '详情'
  555. this.staffDialogVisible = true
  556. this.formRuleList.forEach((item, index) => {
  557. item.disabled = true
  558. })
  559. this.ruleForm = JSON.parse(JSON.stringify(row))
  560. } else if (type == 'record') {
  561. this.dialogVisible = true
  562. this.waybillNo = row.sn
  563. this.$nextTick(() => {
  564. this.$refs.thermo.getProbe()
  565. })
  566. } else if (type == 'ascend') {
  567. this.iceTracingVisible = true
  568. }
  569. },
  570. // 选择时间
  571. timeChange() {
  572. this.$nextTick(() => {
  573. this.$refs.thermo.getTemperature()
  574. })
  575. },
  576. openModel(type) {
  577. if (type == 'add') {
  578. this.staffTitle = '添加'
  579. this.staffDialogVisible = true
  580. this.operationType = type
  581. this.useDefaultFormRules()
  582. this.resetRuleFormFields()
  583. if (this.userList.dept.isCoolerReleaseCold) {
  584. this.obtainIceRaft()
  585. }
  586. } else if (type == 'import') {
  587. this.importDialogVisible = true
  588. this.getDeviceList()
  589. } else if (type == 'screen') {
  590. // this.$refs.control.controlVisible = true
  591. // this.$nextTick(() => {
  592. // setTimeout(() => {
  593. // this.$refs.control.keyUpSearch()
  594. // this.$refs.control.getList()
  595. // }, 100)
  596. // })
  597. } else if (type == 'copyIce') {
  598. this.operationType = 'add'
  599. const arrID = this.$refs.refWaybill.waybillIds
  600. if (arrID.length == 0) {
  601. this.$message({
  602. message: '请先选择需要复制的冰排',
  603. type: 'warning'
  604. });
  605. return
  606. }
  607. if (arrID.length > 1) {
  608. this.$message({
  609. message: '只能选择一条冰排进行复制',
  610. type: 'warning'
  611. });
  612. return
  613. }
  614. if (arrID.length == 1) {
  615. this.copyFlag = true
  616. this.staffTitle = '添加'
  617. this.staffDialogVisible = true
  618. this.useDefaultFormRules()
  619. this.resetRuleFormFields()
  620. if (this.userList.dept.isCoolerReleaseCold) {
  621. this.obtainIceRaft()
  622. }
  623. setTimeout(() => {
  624. this.$nextTick(() => {
  625. this.ruleForm = JSON.parse(JSON.stringify(arrID[0]))
  626. })
  627. })
  628. }
  629. } else if (type == 'batchEdit') {
  630. const selectedRows = this.$refs.refWaybill ? this.$refs.refWaybill.waybillIds : []
  631. if (!selectedRows || selectedRows.length === 0) {
  632. this.$message({
  633. message: '请先选择需要批量修改的保温箱',
  634. type: 'warning'
  635. });
  636. return
  637. }
  638. this.operationType = 'batchEdit'
  639. this.copyFlag = false
  640. this.batchEditRows = JSON.parse(JSON.stringify(selectedRows))
  641. this.formRuleList = this.getBatchFormRules()
  642. this.resetRuleFormFields()
  643. this.ruleForm.status = ''
  644. this.staffTitle = '批量修改'
  645. this.staffDialogVisible = true
  646. }
  647. },
  648. // 触底事件
  649. handleScroll() {
  650. if (this.limitNo) {
  651. this.obtainIceRaft()
  652. }
  653. },
  654. // 搜索
  655. remoteMethod(value, type) {
  656. this.resetSelect(type)
  657. this.staffName = value
  658. this.obtainIceRaft()
  659. },
  660. // 重置选择冰排
  661. resetSelect(type) {
  662. this.formRuleList.forEach(item => {
  663. if (item.field == type) {
  664. item.options = []
  665. }
  666. })
  667. this.icePagination.PageIndex = 1
  668. this.limitNo = true
  669. this.staffName = ''
  670. },
  671. // 获取冰排列表
  672. obtainIceRaft() {
  673. var params = {
  674. page: this.icePagination.PageIndex,
  675. pageSize: 10,
  676. code: this.staffName,
  677. }
  678. getIceRaft(params).then(res => {
  679. if (res.code == 200) {
  680. let arr = res.data.list
  681. let arrList = []
  682. arr.forEach(item1 => {
  683. var arrData = {
  684. label: null,
  685. value: null,
  686. }
  687. arrData.label = item1.code
  688. arrData.value = item1.code
  689. // arrData.value = item1.id
  690. arrList.push(arrData)
  691. })
  692. if (this.limitNo == true) {
  693. this.formRuleList.forEach(item => {
  694. if (item.field == 'iceBinding') {
  695. item.options = item.options.concat(arrList);
  696. let some = [];
  697. item.options.forEach(el => {
  698. if (!some.some(e => e.value == el.value)) {
  699. some.push(el)
  700. }
  701. })
  702. item.options = some
  703. }
  704. })
  705. }
  706. if (arrList.length >= 10) {
  707. this.icePagination.PageIndex = ++this.icePagination.PageIndex;
  708. } else {
  709. // 已经没数据了 不需要增加数据
  710. this.limitNo = false;
  711. }
  712. }
  713. })
  714. },
  715. // 获取设备列表
  716. getDeviceList() {
  717. var params = {
  718. page: this.Paginationil.PageIndex,
  719. pageSize: this.Paginationil.PageSize,
  720. name: this.nameTitle,
  721. }
  722. getDevice(params).then(res => {
  723. if (res.code == 200) {
  724. this.incubatorData = res.data.list
  725. this.Total1 = res.data.count
  726. }
  727. })
  728. },
  729. // 搜索保温箱
  730. incubatorInput(value) {
  731. this.nameTitle = value
  732. this.getDeviceList()
  733. },
  734. // 批量导入保温箱
  735. incubatorAdd() {
  736. const arrID = this.$refs.refIncubator.waybillIds
  737. let arr1 = []
  738. arrID.forEach(item => {
  739. let arr2 = {
  740. sn: item.T_sn,
  741. name: item.T_devName,
  742. }
  743. arr1.push(arr2)
  744. })
  745. let flag = this.$refs['incubatorRules'].validateForm();
  746. if (flag) {
  747. if (arr1.length > 0) {
  748. this.incubatorLoading = true
  749. let params = {
  750. list: arr1,
  751. ...this.stateRuleForm,
  752. }
  753. addCoolerBoxImport(params).then(res => {
  754. if (res.code == 200) {
  755. this.$message({
  756. message: '操作成功',
  757. type: 'success'
  758. });
  759. this.getList()
  760. this.importDialogVisible = false
  761. }
  762. this.incubatorLoading = false
  763. }).catch(() => {
  764. this.incubatorLoading = false
  765. })
  766. } else {
  767. this.$message.warning('请选择需要导入的保温箱');
  768. }
  769. } else {
  770. this.$message.error('表单信息不完整,请继续填写完整');
  771. }
  772. },
  773. // 删除保温箱
  774. deleteUser(id) {
  775. this.$confirm('此操作将永久删除该保温箱, 是否继续?', '提示', {
  776. confirmButtonText: '确定',
  777. cancelButtonText: '取消',
  778. type: 'warning'
  779. }).then(() => {
  780. delCoolerBox({
  781. id: id,
  782. }).then(res => {
  783. if (res.code == 200) {
  784. this.$message({
  785. message: '操作成功',
  786. type: 'success'
  787. });
  788. const precisePage = Math.ceil((this.Total - 1) / this.Pagination.PageSize)
  789. this.Pagination.PageIndex = this.Pagination.PageIndex > precisePage ? precisePage : this
  790. .Pagination.PageIndex
  791. this.Pagination.PageIndex = this.Pagination.PageIndex < 1 ? 1 : this.Pagination.PageIndex
  792. this.getList()
  793. }
  794. })
  795. }).catch(() => { });
  796. },
  797. changeSize(val) {
  798. this.Pagination.PageSize = val
  799. this.getList()
  800. },
  801. changeCurrent(val) {
  802. this.Pagination.PageIndex = val
  803. this.getList()
  804. },
  805. changeSizeil(val) {
  806. this.Paginationil.PageSize = val
  807. this.getDeviceList()
  808. },
  809. changeCurrentil(val) {
  810. this.Paginationil.PageIndex = val
  811. this.getDeviceList()
  812. },
  813. // 清空表单
  814. closeDialog() {
  815. this.formRuleList.forEach((item, index) => {
  816. item.disabled = false
  817. })
  818. this.copyFlag = false
  819. this.batchEditRows = []
  820. this.resetRuleFormFields()
  821. this.useDefaultFormRules()
  822. if (this.$refs.childRules) {
  823. this.$refs.childRules.resetCheck();
  824. }
  825. },
  826. // 关闭温湿度记录
  827. temperatureClose() {
  828. this.timeQuantum = [this.getTime(new Date(new Date().toLocaleDateString())), this.getTime(new Date())]
  829. },
  830. closeDialogil() {
  831. this.$refs.incubatorRules.resetCheck();
  832. this.$refs.refIncubator.clearSelected();
  833. }
  834. }
  835. }
  836. </script>
  837. <style lang="scss" scoped>
  838. .card_check_title {
  839. display: flex;
  840. align-items: center;
  841. }
  842. .icon_import {
  843. margin-right: 5px;
  844. font-size: 20px;
  845. }
  846. .card_import {
  847. margin-top: 15px;
  848. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  849. margin-bottom: 20px;
  850. border-radius: 10px;
  851. }
  852. .management_card ::v-deep .el-dialog__body {
  853. padding: 0px 20px !important;
  854. }
  855. .card_incubat {
  856. padding-left: 15px;
  857. padding-right: 15px;
  858. border-bottom: 1px solid #EBEEF5;
  859. padding-top: 15px;
  860. margin-bottom: 15px;
  861. }
  862. .card_search_input {
  863. display: flex;
  864. align-items: center;
  865. padding: 15px 20px 15px 20px;
  866. border-bottom: 1px solid #EBEEF5;
  867. }
  868. .title_search {
  869. flex: none;
  870. margin-right: 5px;
  871. }
  872. </style>