index.vue 18 KB

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