index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <!--智能终端-->
  2. <template>
  3. <div class="app-container IntelligentTerminal">
  4. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  5. <el-form-item label="关键字" prop="searchValue">
  6. <el-input
  7. maxLength="30"
  8. v-model="queryParamsData.searchValue"
  9. placeholder="设备编号/实验室"
  10. clearable
  11. size="small"
  12. style="width: 240px"
  13. />
  14. </el-form-item>
  15. <el-form-item label="学院" prop="deptId">
  16. <el-select v-model="queryParamsData.deptId" clearable placeholder="请选择学院">
  17. <el-option
  18. v-for="item in optionsListOne"
  19. :key="item.deptId"
  20. :label="item.deptName"
  21. :value="item.deptId">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="状态" prop="terminalStatus">
  26. <el-select v-model="queryParamsData.operate" clearable placeholder="请选择状态">
  27. <el-option
  28. v-for="item in optionsListTwo"
  29. :key="item.id"
  30. :label="item.name"
  31. :value="item.id">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  37. <p class="reset-button-one" @click="resetQuery">重置</p>
  38. </el-form-item>
  39. <el-form-item style="float: right;">
  40. <el-col :span="1.5" v-hasPermi="['laboratory:hardware5:add']">
  41. <p class="add-button-one-90"
  42. @click="pageToggle(1)"
  43. ><i class="el-icon-plus"></i>新增</p>
  44. </el-col>
  45. </el-form-item>
  46. <el-form-item style="float: right;">
  47. <el-dropdown @command="importButton" v-hasPermi="['laboratory:hardware5:import']">
  48. <div class="form-dropdown-box">
  49. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  50. <p>导入</p>
  51. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  52. </div>
  53. <el-dropdown-menu slot="dropdown">
  54. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">下载模板</el-dropdown-item>
  55. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导入数据</el-dropdown-item>
  56. </el-dropdown-menu>
  57. </el-dropdown>
  58. </el-form-item>
  59. </el-form>
  60. <el-table border :data="tableList" ref="multipleTable">
  61. <el-table-column label="设备编号" align="center" prop="hardwareNum"/>
  62. <el-table-column label="学院" align="center" prop="deptName" width="250"/>
  63. <el-table-column label="位置" align="center" prop="posi" width="250" show-overflow-tooltip/>
  64. <el-table-column label="设备状态" align="center" prop="status" width="100">
  65. <template slot-scope="scope">{{scope.row.operate.name}}</template>
  66. </el-table-column>
  67. <el-table-column label="创建时间" align="center" prop="createTime" width="250"/>
  68. <el-table-column label="创建人" align="center" prop="createBy" width="150"/>
  69. <el-table-column label="操作" align="center" width="140" class-name="small-padding fixed-width" v-if="tableButtonType">
  70. <template slot-scope="scope">
  71. <div class="table-button-box">
  72. <p class="table-button-null"></p>
  73. <p class="table-button-p" v-hasPermi="['laboratory:hardware5:edit']" @click="pageToggle(2,scope.row)">编辑</p>
  74. <p class="table-button-p" v-hasPermi="['laboratory:hardware5:remove']" @click="pageToggle(3,scope.row)">删除</p>
  75. <p class="table-button-null"></p>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <pagination :page-sizes="[20, 30, 40, 50]"
  81. v-show="total>0"
  82. :total="total"
  83. :page.sync="queryParams.pageNum"
  84. :limit.sync="queryParams.pageSize"
  85. @pagination="getList"
  86. />
  87. <!--导入窗口-->
  88. <el-dialog title="导入数据" :visible.sync="importOpen" @close="importOpenOff" width="600px" append-to-body class="import-dialog-box"
  89. :close-on-click-modal="false">
  90. <div class="el-upload__text" style="margin:0 0 20px 58px;">提示:导入后的数据将覆盖原有数据</div>
  91. <el-upload
  92. class="import-dialog-upLoad-box"
  93. :drag="true"
  94. :data="upImportData"
  95. :action="uploadImgUrl"
  96. :show-file-list="false"
  97. :on-success="handleAvatarSuccess"
  98. :headers="headers"
  99. :before-upload="beforeAvatarUpload">
  100. <i class="el-icon-upload"></i>
  101. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  102. <!--<div class="el-upload__tip" slot="tip">-->
  103. <!--<el-checkbox v-model="upImportData.upDate">是否更新已经存在的数据</el-checkbox>-->
  104. <!--</div>-->
  105. <div class="el-upload__tip" slot="tip">数据导入模板.xlsx<span style="color:#0183FA;cursor: pointer" @click="importTemplate">下载</span></div>
  106. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  107. <div class="img-text-box">
  108. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  109. <p>{{getImportData.textName}}</p>
  110. </div>
  111. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  112. <div class="img-text-box">
  113. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  114. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  115. </div>
  116. </div>
  117. </el-upload>
  118. <div slot="footer" class="teacher-import-dialog-button-box">
  119. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  120. </div>
  121. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  122. </el-dialog>
  123. <!--新增/编辑-->
  124. <el-dialog :title="dialogTitle" :visible.sync="addDialogType" v-if="addDialogType" width="520px" append-to-body class="add-dialog-box"
  125. :close-on-click-modal="false">
  126. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  127. <el-form-item label="设备编号:" prop="hardwareNum">
  128. <el-input v-model="form.hardwareNum" placeholder="最大50个字符,包含大小写字母、数字" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="50" style="width:360px;"/>
  129. </el-form-item>
  130. <el-form-item label="实验室:" prop="subjectId">
  131. <el-select
  132. style="width:360px;"
  133. v-model="form.subjectId"
  134. filterable
  135. remote
  136. clearable
  137. @focus="selectFocus"
  138. reserve-keyword
  139. @clear="clearClick"
  140. placeholder="搜索选择实验室"
  141. :remote-method="getSelectList"
  142. :loading="loading">
  143. <el-option
  144. v-for="item in selectList"
  145. :key="item.id"
  146. :label="item.name"
  147. :value="item.id">
  148. </el-option>
  149. </el-select>
  150. </el-form-item>
  151. </el-form>
  152. <div slot="footer" class="dialog-footer">
  153. <el-button type="primary" @click="submitForm">确 定</el-button>
  154. <el-button @click="cancel">取 消</el-button>
  155. </div>
  156. </el-dialog>
  157. </div>
  158. </template>
  159. <script>
  160. import { hxpSmartTerminal,filterDept,getSubList,addHxpSmartTerminal,putHxpSmartTerminal,getHxpSmartTerminal,delHxpSmartTerminal } from "@/api/medicUniversity-3_1/index";
  161. import { listHardware, delHardware, addHardware, updateHardware } from "@/api/medicUniversity-3_1/index";
  162. import {subjectDictList } from "@/api/laboratory/record";
  163. import { listDepartments } from "@/api/system/dept";
  164. import { getToken } from "@/utils/auth";
  165. export default {
  166. name: "IntelligentTerminal",
  167. data() {
  168. return {
  169. client:{},
  170. // table操作按钮校验
  171. tableButtonType:this.hasPermiDom(['laboratory:hardware5:edit','laboratory:hardware5:remove']),
  172. //上传相关配置
  173. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/laboratory/hardware/importData", // 上传地址
  174. headers: {
  175. Authorization: "Bearer " + getToken(),
  176. },
  177. // 遮罩层
  178. loading:false,
  179. //页面状态
  180. pageType:1,
  181. // 搜索数据
  182. queryParamsData:{
  183. pageNum:1,
  184. pageSize:20,
  185. },
  186. // 搜索实际发送数据
  187. queryParams:{
  188. pageNum:1,
  189. pageSize:20,
  190. },
  191. //数据数量
  192. total:0,
  193. //数据数组
  194. tableList:[],
  195. //学院列表
  196. optionsListOne:[],
  197. //状态列表
  198. optionsListTwo:[{id:"ONLINE",name:"在线"},{id:"OFFLINE",name:"离线"}],
  199. //导入弹层开关
  200. importOpen:false,
  201. //导入数据
  202. upImportData:{
  203. sysUserEnable:true,
  204. upDate:false,
  205. terminalType:"AI_TERMINAL",
  206. },
  207. getImportData:{
  208. downFile:false,
  209. successNum:0,
  210. failureNum:0,
  211. textName:"",
  212. },
  213. //编辑新增相关
  214. dialogTitle:"",
  215. addDialogType:false,
  216. form:{},
  217. selectList:[],
  218. selectListData:[],
  219. rules:{
  220. hardwareNum: [
  221. { required: true, trigger: "blur", message: "最大20个字符,包含大小写字母、数字" },
  222. { required: true, message: "最大20个字符,包含大小写字母、数字", validator: this.spaceJudgment, trigger: "blur" }
  223. ],
  224. subjectId: [
  225. { required: true, trigger: "blur", message: "搜索选择实验室" },
  226. ],
  227. },
  228. };
  229. },
  230. created() {
  231. },
  232. mounted(){
  233. this.filterDept();
  234. this.listDepartments();
  235. this.getList();
  236. },
  237. methods: {
  238. selectFocus(){
  239. if(!this.selectList[0]){
  240. this.filterDept();
  241. }
  242. },
  243. //获取学院列表
  244. listDepartments(){
  245. listDepartments().then(response => {
  246. this.optionsListOne = response.data;
  247. });
  248. },
  249. pageToggle(type,item){
  250. let self = this;
  251. if(type == 1){
  252. //新增
  253. this.dialogTitle = '新增';
  254. this.$set(this,'form',{
  255. hardwareNum:"",
  256. subjectId:""
  257. });
  258. this.clearClick();
  259. this.addDialogType = true;
  260. }else if(type == 2){
  261. // 编辑
  262. this.dialogTitle = '编辑';
  263. let obj = {
  264. id:item.id,
  265. subjectId:item.subjectId,
  266. hardwareNum:item.hardwareNum,
  267. };
  268. this.$set(this,'form',obj);
  269. this.clearClick();
  270. this.addDialogType = true;
  271. }else if(type == 3){
  272. // 删除
  273. this.$confirm('确认要删除吗?', "警告", {
  274. confirmButtonText: "确定",
  275. cancelButtonText: "取消",
  276. type: "warning"
  277. }).then(function() {
  278. delHardware(item.id).then(response => {
  279. if (response.code == 200){
  280. self.msgSuccess(response.msg);
  281. self.getList();
  282. }
  283. });
  284. }).then(() => {
  285. }).catch(() => {});
  286. }
  287. },
  288. //查询当前院系
  289. filterDept(){
  290. filterDept().then(response => {
  291. let idText = "";
  292. for(let i=0;i<response.data.length;i++){
  293. if(i==0){
  294. idText = idText + response.data[i].deptId;
  295. }else{
  296. idText = idText +','+ response.data[i].deptId;
  297. }
  298. }
  299. //查询院系下实验室
  300. subjectDictList(idText).then(response => {
  301. //当前列表
  302. this.selectList = JSON.parse(JSON.stringify(response.data));
  303. //原始列表数据
  304. this.selectListData = JSON.parse(JSON.stringify(response.data));
  305. });
  306. });
  307. },
  308. /** 实验室-本地懒加载 */
  309. getSelectList(val) {
  310. let self = this;
  311. let list = [];
  312. for(let i=0;i<self.selectListData.length;i++){
  313. if(self.selectListData[i].name.indexOf(val) != -1){
  314. list.push(self.selectListData[i]);
  315. }
  316. }
  317. this.selectList = JSON.parse(JSON.stringify(list))
  318. },
  319. //实验室选中清除
  320. clearClick(){
  321. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  322. },
  323. submitForm(){
  324. this.$refs["form"].validate((valid) => {
  325. if (valid) {
  326. if(this.form.id){
  327. //编辑
  328. this.form.type = "AI_TERMINAL";
  329. updateHardware(this.form).then(response => {
  330. if (response.code == 200){
  331. this.addDialogType = false;
  332. this.msgSuccess(response.msg);
  333. this.getList();
  334. }
  335. });
  336. }else{
  337. //新增
  338. this.form.type = "AI_TERMINAL";
  339. addHardware(this.form).then(response => {
  340. if (response.code == 200){
  341. this.addDialogType = false;
  342. this.msgSuccess(response.msg);
  343. this.resetQuery();
  344. }
  345. });
  346. }
  347. }
  348. })
  349. },
  350. cancel(){
  351. this.addDialogType = false;
  352. },
  353. //获取数据列表
  354. getList(){
  355. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  356. this.queryParamsData.type = 'AI_TERMINAL';
  357. listHardware(this.queryParamsData).then(response => {
  358. this.total = response.total;
  359. this.tableList = response.rows;
  360. });
  361. },
  362. /** 搜索按钮操作 */
  363. handleQuery() {
  364. this.queryParamsData.pageNum = 1;
  365. this.queryParamsData.pageSize = 20;
  366. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  367. this.getList();
  368. },
  369. /** 重置按钮操作 */
  370. resetQuery() {
  371. this.$set(this,'queryParamsData',{});
  372. this.$set(this,'queryParams',{});
  373. this.handleQuery();
  374. },
  375. //导入页面关闭
  376. importOpenOff(){
  377. this.importOpen = false;
  378. this.getImportData.downFile = false;
  379. this.getImportData.successNum = 0;
  380. this.getImportData.failureNum = 0;
  381. this.getImportData.textName = "";
  382. },
  383. /** 导入按钮操作 */
  384. importButton(item){
  385. if(item.command == 1){
  386. // 下载模板
  387. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  388. }else if(item.command == 2){
  389. // 导入数据
  390. console.log('导入数据');
  391. this.importOpen = true;
  392. }
  393. },
  394. /** 下载模板操作 */
  395. importTemplate() {
  396. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  397. },
  398. /*下载失败列表*/
  399. failureExcel(){
  400. this.download('/laboratory/hardware/importErrorData', {}, `失败报表.xlsx`)
  401. },
  402. //****************************************导入功能**************************************
  403. handleAvatarSuccess(res, file) {
  404. if(res.code == 200){
  405. if(res.data.downFile){
  406. this.getImportData.downFile = res.data.downFile
  407. this.getImportData.successNum = res.data.successNum
  408. this.getImportData.failureNum = res.data.failureNum
  409. }else{
  410. this.msgSuccess(res.msg);
  411. this.importOpen = false;
  412. this.resetQuery();
  413. }
  414. // this.getImportData.downFile = res.data.downFile
  415. // this.getImportData.successNum = res.data.successNum
  416. // this.getImportData.failureNum = res.data.failureNum
  417. // this.importOpen = false;
  418. // this.getList();
  419. }else{
  420. this.msgError(res.msg);
  421. }
  422. this.loading = false;
  423. },
  424. beforeAvatarUpload(file) {
  425. let type = false;
  426. console.log('file',file);
  427. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  428. this.getImportData.textName = file.name;
  429. type = true;
  430. this.loading = true;
  431. }else{
  432. this.msgError('只能上传xls/xlsx格式文件')
  433. type = false;
  434. }
  435. return type;
  436. },
  437. },
  438. }
  439. </script>
  440. <style scoped lang="scss">
  441. .IntelligentTerminal{
  442. flex:1;
  443. display: flex;
  444. flex-direction: column;
  445. overflow: hidden!important;
  446. padding:20px !important;
  447. p{
  448. margin:0;
  449. padding:0;
  450. }
  451. .form-box{
  452. .form-dropdown-box{
  453. display: flex;
  454. margin:0;
  455. padding:0 10px;
  456. cursor: pointer;
  457. height:40px;
  458. img:nth-child(1){
  459. width:16px;
  460. height:16px;
  461. margin-top:12px;
  462. }
  463. p{
  464. width:47px;
  465. text-align: center;
  466. font-size:14px;
  467. margin:0;
  468. line-height:40px;
  469. }
  470. img:nth-child(3){
  471. width:10px;
  472. height:6px;
  473. margin-top:17px;
  474. }
  475. }
  476. }
  477. .button-box{
  478. display: flex;
  479. }
  480. }
  481. </style>
  482. <style lang="scss">
  483. .import-dialog-box{
  484. .import-dialog-upLoad-box{
  485. .el-upload{
  486. width:450px;
  487. margin:0 55px;
  488. .el-upload-dragger{
  489. width:450px;
  490. .el-icon-upload{
  491. font-size:100px;
  492. color:#CBE6FE;
  493. }
  494. .el-upload__text{
  495. margin-top:20px;
  496. }
  497. }
  498. }
  499. .el-upload__tip{
  500. margin-left:60px;
  501. font-size:14px;
  502. margin-top:10px;
  503. }
  504. .el-upload-text-box{
  505. background: #F5F5F5;
  506. border-radius: 10px;
  507. margin:15px 30px 0;
  508. padding:0 20px 15px;
  509. overflow: hidden;
  510. *{
  511. margin:0;
  512. }
  513. .img-text-box{
  514. display: flex;
  515. margin-top:15px;
  516. img{
  517. width:16px;
  518. height:16px;
  519. margin-right:13px;
  520. }
  521. p{
  522. height:16px;
  523. line-height:16px;
  524. font-size:12px;
  525. }
  526. }
  527. .text-p{
  528. margin-top:15px;
  529. margin-left:29px;
  530. height:16px;
  531. line-height:16px;
  532. font-size:12px;
  533. }
  534. }
  535. }
  536. .teacher-import-dialog-button-box{
  537. display: flex;
  538. width:190px;
  539. margin:0 auto;
  540. p{
  541. width:70px;
  542. height:30px;
  543. line-height:30px;
  544. font-size:14px;
  545. margin:0 auto;
  546. }
  547. }
  548. .teacher-import-dialog-position-box{
  549. width:100%;
  550. height:100%;
  551. position: absolute;
  552. top:0;
  553. left:0;
  554. z-index: 999;
  555. background: rgba(255,255,255,0.4);
  556. border-radius:20px;
  557. }
  558. }
  559. </style>