index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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="最大20个字符,包含大小写字母、数字" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="20" 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 { listDepartments } from "@/api/system/dept";
  163. import { getToken } from "@/utils/auth";
  164. export default {
  165. name: "IntelligentTerminal",
  166. data() {
  167. return {
  168. client:{},
  169. // table操作按钮校验
  170. tableButtonType:this.hasPermiDom(['laboratory:hardware5:edit','laboratory:hardware5:remove']),
  171. //上传相关配置
  172. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/laboratory/hardware/importData", // 上传地址
  173. headers: {
  174. Authorization: "Bearer " + getToken(),
  175. },
  176. // 遮罩层
  177. loading:false,
  178. //页面状态
  179. pageType:1,
  180. // 搜索数据
  181. queryParamsData:{
  182. pageNum:1,
  183. pageSize:20,
  184. },
  185. // 搜索实际发送数据
  186. queryParams:{
  187. pageNum:1,
  188. pageSize:20,
  189. },
  190. //数据数量
  191. total:0,
  192. //数据数组
  193. tableList:[],
  194. //学院列表
  195. optionsListOne:[],
  196. //状态列表
  197. optionsListTwo:[{id:"ONLINE",name:"在线"},{id:"OFFLINE",name:"离线"}],
  198. //导入弹层开关
  199. importOpen:false,
  200. //导入数据
  201. upImportData:{
  202. sysUserEnable:true,
  203. upDate:false,
  204. terminalType:"AI_TERMINAL",
  205. },
  206. getImportData:{
  207. downFile:false,
  208. successNum:0,
  209. failureNum:0,
  210. textName:"",
  211. },
  212. //编辑新增相关
  213. dialogTitle:"",
  214. addDialogType:false,
  215. form:{},
  216. selectList:[],
  217. selectListData:[],
  218. rules:{
  219. hardwareNum: [
  220. { required: true, trigger: "blur", message: "最大20个字符,包含大小写字母、数字" },
  221. { required: true, message: "最大20个字符,包含大小写字母、数字", validator: this.spaceJudgment, trigger: "blur" }
  222. ],
  223. subjectId: [
  224. { required: true, trigger: "blur", message: "搜索选择实验室" },
  225. ],
  226. },
  227. };
  228. },
  229. created() {
  230. },
  231. mounted(){
  232. this.filterDept();
  233. this.listDepartments();
  234. this.getList();
  235. },
  236. methods: {
  237. selectFocus(){
  238. if(!this.selectList[0]){
  239. this.filterDept();
  240. }
  241. },
  242. //获取学院列表
  243. listDepartments(){
  244. listDepartments().then(response => {
  245. this.optionsListOne = response.data;
  246. });
  247. },
  248. pageToggle(type,item){
  249. let self = this;
  250. if(type == 1){
  251. //新增
  252. this.dialogTitle = '新增';
  253. this.$set(this,'form',{
  254. hardwareNum:"",
  255. subjectId:""
  256. });
  257. this.clearClick();
  258. this.addDialogType = true;
  259. }else if(type == 2){
  260. // 编辑
  261. this.dialogTitle = '编辑';
  262. let obj = {
  263. id:item.id,
  264. subjectId:item.subjectId,
  265. hardwareNum:item.hardwareNum,
  266. };
  267. this.$set(this,'form',obj);
  268. this.clearClick();
  269. this.addDialogType = true;
  270. }else if(type == 3){
  271. // 删除
  272. this.$confirm('确认要删除吗?', "警告", {
  273. confirmButtonText: "确定",
  274. cancelButtonText: "取消",
  275. type: "warning"
  276. }).then(function() {
  277. delHardware(item.id).then(response => {
  278. if (response.code == 200){
  279. self.msgSuccess(response.msg);
  280. self.getList();
  281. }
  282. });
  283. }).then(() => {
  284. }).catch(() => {});
  285. }
  286. },
  287. //查询当前院系
  288. filterDept(){
  289. filterDept().then(response => {
  290. let idText = "";
  291. for(let i=0;i<response.data.length;i++){
  292. if(i==0){
  293. idText = idText + response.data[i].deptId;
  294. }else{
  295. idText = idText +','+ response.data[i].deptId;
  296. }
  297. }
  298. //查询院系下实验室
  299. getSubList(idText).then(response => {
  300. //当前列表
  301. this.selectList = JSON.parse(JSON.stringify(response.data));
  302. //原始列表数据
  303. this.selectListData = JSON.parse(JSON.stringify(response.data));
  304. });
  305. });
  306. },
  307. /** 实验室-本地懒加载 */
  308. getSelectList(val) {
  309. let self = this;
  310. let list = [];
  311. for(let i=0;i<self.selectListData.length;i++){
  312. if(self.selectListData[i].name.indexOf(val) != -1){
  313. list.push(self.selectListData[i]);
  314. }
  315. }
  316. this.selectList = JSON.parse(JSON.stringify(list))
  317. },
  318. //实验室选中清除
  319. clearClick(){
  320. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  321. },
  322. submitForm(){
  323. this.$refs["form"].validate((valid) => {
  324. if (valid) {
  325. if(this.form.id){
  326. //编辑
  327. this.form.type = "AI_TERMINAL";
  328. updateHardware(this.form).then(response => {
  329. if (response.code == 200){
  330. this.addDialogType = false;
  331. this.msgSuccess(response.msg);
  332. this.getList();
  333. }
  334. });
  335. }else{
  336. //新增
  337. this.form.type = "AI_TERMINAL";
  338. addHardware(this.form).then(response => {
  339. if (response.code == 200){
  340. this.addDialogType = false;
  341. this.msgSuccess(response.msg);
  342. this.resetQuery();
  343. }
  344. });
  345. }
  346. }
  347. })
  348. },
  349. cancel(){
  350. this.addDialogType = false;
  351. },
  352. //获取数据列表
  353. getList(){
  354. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  355. this.queryParamsData.type = 'AI_TERMINAL';
  356. listHardware(this.queryParamsData).then(response => {
  357. this.total = response.total;
  358. this.tableList = response.rows;
  359. });
  360. },
  361. /** 搜索按钮操作 */
  362. handleQuery() {
  363. this.queryParamsData.pageNum = 1;
  364. this.queryParamsData.pageSize = 20;
  365. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  366. this.getList();
  367. },
  368. /** 重置按钮操作 */
  369. resetQuery() {
  370. this.$set(this,'queryParamsData',{});
  371. this.$set(this,'queryParams',{});
  372. this.handleQuery();
  373. },
  374. //导入页面关闭
  375. importOpenOff(){
  376. this.importOpen = false;
  377. this.getImportData.downFile = false;
  378. this.getImportData.successNum = 0;
  379. this.getImportData.failureNum = 0;
  380. this.getImportData.textName = "";
  381. },
  382. /** 导入按钮操作 */
  383. importButton(item){
  384. if(item.command == 1){
  385. // 下载模板
  386. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  387. }else if(item.command == 2){
  388. // 导入数据
  389. console.log('导入数据');
  390. this.importOpen = true;
  391. }
  392. },
  393. /** 下载模板操作 */
  394. importTemplate() {
  395. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  396. },
  397. /*下载失败列表*/
  398. failureExcel(){
  399. this.download('/laboratory/hardware/importErrorData', {}, `失败报表.xlsx`)
  400. },
  401. //****************************************导入功能**************************************
  402. handleAvatarSuccess(res, file) {
  403. if(res.code == 200){
  404. if(res.data.downFile){
  405. this.getImportData.downFile = res.data.downFile
  406. this.getImportData.successNum = res.data.successNum
  407. this.getImportData.failureNum = res.data.failureNum
  408. }else{
  409. this.msgSuccess(res.msg);
  410. this.importOpen = false;
  411. this.resetQuery();
  412. }
  413. // this.getImportData.downFile = res.data.downFile
  414. // this.getImportData.successNum = res.data.successNum
  415. // this.getImportData.failureNum = res.data.failureNum
  416. // this.importOpen = false;
  417. // this.getList();
  418. }else{
  419. this.msgError(res.msg);
  420. }
  421. this.loading = false;
  422. },
  423. beforeAvatarUpload(file) {
  424. let type = false;
  425. console.log('file',file);
  426. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  427. this.getImportData.textName = file.name;
  428. type = true;
  429. this.loading = true;
  430. }else{
  431. this.msgError('只能上传xls/xlsx格式文件')
  432. type = false;
  433. }
  434. return type;
  435. },
  436. },
  437. }
  438. </script>
  439. <style scoped lang="scss">
  440. .IntelligentTerminal{
  441. flex:1;
  442. display: flex;
  443. flex-direction: column;
  444. overflow: hidden!important;
  445. padding:20px !important;
  446. p{
  447. margin:0;
  448. padding:0;
  449. }
  450. .form-box{
  451. .form-dropdown-box{
  452. display: flex;
  453. margin:0;
  454. padding:0 10px;
  455. cursor: pointer;
  456. height:40px;
  457. img:nth-child(1){
  458. width:16px;
  459. height:16px;
  460. margin-top:12px;
  461. }
  462. p{
  463. width:47px;
  464. text-align: center;
  465. font-size:14px;
  466. margin:0;
  467. line-height:40px;
  468. }
  469. img:nth-child(3){
  470. width:10px;
  471. height:6px;
  472. margin-top:17px;
  473. }
  474. }
  475. }
  476. .button-box{
  477. display: flex;
  478. }
  479. }
  480. </style>
  481. <style lang="scss">
  482. .import-dialog-box{
  483. .import-dialog-upLoad-box{
  484. .el-upload{
  485. width:450px;
  486. margin:0 55px;
  487. .el-upload-dragger{
  488. width:450px;
  489. .el-icon-upload{
  490. font-size:100px;
  491. color:#CBE6FE;
  492. }
  493. .el-upload__text{
  494. margin-top:20px;
  495. }
  496. }
  497. }
  498. .el-upload__tip{
  499. margin-left:60px;
  500. font-size:14px;
  501. margin-top:10px;
  502. }
  503. .el-upload-text-box{
  504. background: #F5F5F5;
  505. border-radius: 10px;
  506. margin:15px 30px 0;
  507. padding:0 20px 15px;
  508. overflow: hidden;
  509. *{
  510. margin:0;
  511. }
  512. .img-text-box{
  513. display: flex;
  514. margin-top:15px;
  515. img{
  516. width:16px;
  517. height:16px;
  518. margin-right:13px;
  519. }
  520. p{
  521. height:16px;
  522. line-height:16px;
  523. font-size:12px;
  524. }
  525. }
  526. .text-p{
  527. margin-top:15px;
  528. margin-left:29px;
  529. height:16px;
  530. line-height:16px;
  531. font-size:12px;
  532. }
  533. }
  534. }
  535. .teacher-import-dialog-button-box{
  536. display: flex;
  537. width:190px;
  538. margin:0 auto;
  539. p{
  540. width:70px;
  541. height:30px;
  542. line-height:30px;
  543. font-size:14px;
  544. margin:0 auto;
  545. }
  546. }
  547. .teacher-import-dialog-position-box{
  548. width:100%;
  549. height:100%;
  550. position: absolute;
  551. top:0;
  552. left:0;
  553. z-index: 999;
  554. background: rgba(255,255,255,0.4);
  555. border-radius:20px;
  556. }
  557. }
  558. </style>