index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <!--蓝牙网关-->
  2. <template>
  3. <div class="app-container bluetoothGateway">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" class="form-box">
  5. <el-form-item label="关键字" prop="searchValue">
  6. <el-input
  7. maxlength="10"
  8. v-model="queryParams.searchValue"
  9. placeholder="实验室"
  10. clearable
  11. />
  12. </el-form-item>
  13. <el-form-item label="学院" prop="deptId">
  14. <el-select v-model="queryParams.deptId" clearable placeholder="请选择学院">
  15. <el-option
  16. v-for="dict in deptOptions"
  17. :key="dict.deptId"
  18. :label="dict.deptName"
  19. :value="dict.deptId"
  20. ></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="状态" prop="gatewayOnline">
  24. <el-select v-model="queryParams.gatewayOnline" clearable placeholder="请选择状态">
  25. <el-option label="离线" value="0" />
  26. <el-option label="在线" value="1" />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item style="float: right;">
  30. <el-col :span="1.5">
  31. <p class="page-add-common-style-button"
  32. @click="tableButton(1)"
  33. v-hasPermi="['demo:demo:demo']"
  34. >+ 新增蓝牙网关</p>
  35. </el-col>
  36. </el-form-item>
  37. <el-form-item>
  38. <p class="inquire-button-one" @click="handleQuery">查询</p>
  39. <p class="reset-button-one" @click="resetQuery">重置</p>
  40. </el-form-item>
  41. </el-form>
  42. <el-table v-loading="loading" border :data="dataList">
  43. <el-table-column label="名称" align="left" prop="gatewayName"/>
  44. <el-table-column label="网关" align="left" prop="gatewayMac" width="249" show-overflow-tooltip/>
  45. <el-table-column label="状态" align="left" prop="gatewayOnline" width="200" show-overflow-tooltip>
  46. <template slot-scope="scope">{{scope.row.gatewayOnline==0?'离线':'在线'}}</template>
  47. </el-table-column>
  48. <el-table-column label="学院" align="left" prop="deptName" width="300" show-overflow-tooltip/>
  49. <el-table-column label="实验室名称" align="left" prop="subName" width="350" show-overflow-tooltip/>
  50. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  51. <template slot-scope="scope">
  52. <div class="table-button-box">
  53. <p class="table-button-null"></p>
  54. <p class="table-button-p" @click="tableButton(2,scope.row)" v-hasPermiAnd="['demo:demo:demo','demo:demo:demo']">编辑</p>
  55. <p class="table-button-p" @click="tableButton(3,scope.row)" v-hasPermi="['demo:demo:demo']">删除</p>
  56. <p class="table-button-null"></p>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <pagination :page-sizes="[20, 30, 40, 50]"
  62. v-show="total>0"
  63. :total="total"
  64. layout="total, prev, pager, next, sizes, jumper"
  65. :page.sync="queryParams.pageNum"
  66. :limit.sync="queryParams.pageSize"
  67. @pagination="getList"
  68. />
  69. <el-dialog :title="dialogTitle" :visible.sync="dialogType" v-if="dialogType"
  70. :close-on-click-modal="false" width="600px" append-to-body>
  71. <el-form ref="dialogForm" :model="dialogForm" :rules="rules" label-width="80px">
  72. <el-form-item label="名称" prop="gatewayName">
  73. <el-input v-model="dialogForm.gatewayName" placeholder="请输入名称" maxLength="20" style="width:450px;"/>
  74. </el-form-item>
  75. <el-form-item label="网关" prop="gatewayMac">
  76. <el-input v-model="dialogForm.gatewayMac" placeholder="请输入网关" maxLength="20" style="width:450px;"/>
  77. </el-form-item>
  78. <el-form-item label="实验室" prop="subId">
  79. <el-select
  80. style="width:450px;"
  81. v-model="dialogForm.subId"
  82. filterable
  83. remote
  84. clearable
  85. reserve-keyword
  86. @focus="selectFocus"
  87. @change="selectChange"
  88. placeholder="请选择实验室"
  89. :remote-method="getSub"
  90. :loading="loading">
  91. <el-option
  92. v-for="item in laboratoryOptions"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-form>
  100. <div slot="footer" class="dialog-footer">
  101. <p class="dialog-footer-null-p"></p>
  102. <el-button @click="cancel">取 消</el-button>
  103. <el-button type="primary" @click="submit">确 定</el-button>
  104. <p class="dialog-footer-null-p"></p>
  105. </div>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. import { airbottleBluetoothList, airbottleBluetoothInfo,
  111. airbottleBluetoothAdd, laboratoryBuildingPut,
  112. laboratoryBuildingDel } from '@/api/lanyadingwei/index'
  113. import {listDepartments} from "@/api/system/dept";
  114. import { subjectList } from '@/api/gasManage3_0/gasManage'
  115. export default {
  116. name: 'index',
  117. data(){
  118. return{
  119. tableButtonType:this.hasPermiDom(['demo:demo:demo','demo:demo:demo']),
  120. loading:false,
  121. queryParams:{
  122. pageNum:1,
  123. pageSize:20,
  124. searchValue:"",
  125. deptId:"",
  126. gatewayOnline:"",
  127. },
  128. deptOptions:{},
  129. dataList:[],
  130. total:0,
  131. dialogTitle:"",
  132. dialogType:false,
  133. dialogLookType:false,
  134. dialogForm:{
  135. gatewayName:"",
  136. gatewayMac:"",
  137. subName:"",
  138. subId:"",
  139. deptId:"",
  140. deptName:"",
  141. },
  142. laboratoryOptions:[],
  143. // 表单校验
  144. rules: {
  145. gatewayName: [
  146. { required: true, message: "请输入名称", trigger: "change" },
  147. { required: true, message: "请输入名称", validator: this.spaceJudgment, trigger: "blur" }
  148. ],
  149. gatewayMac: [
  150. { required: true, message: "请输入网关", trigger: "change" },
  151. { required: true, message: "请输入网关", validator: this.spaceJudgment, trigger: "blur" }
  152. ],
  153. subId: [
  154. { required: true, message: "请选择实验室", trigger: "change" },
  155. ],
  156. },
  157. }
  158. },
  159. created(){
  160. },
  161. mounted(){
  162. this.listDepartments();
  163. this.getList();
  164. },
  165. methods:{
  166. cancel(){
  167. this.$set(this,'dialogType',false);
  168. },
  169. submit(){
  170. this.$refs["dialogForm"].validate((valid) => {
  171. if (valid) {
  172. if(!this.dialogForm.id){
  173. //新增
  174. airbottleBluetoothAdd(this.dialogForm).then(response => {
  175. this.msgSuccess(response.msg)
  176. this.getList();
  177. this.$set(this,'dialogType',false);
  178. });
  179. }else{
  180. //修改
  181. laboratoryBuildingPut(this.dialogForm).then(response => {
  182. this.msgSuccess(response.msg)
  183. this.getList();
  184. this.$set(this,'dialogType',false);
  185. });
  186. }
  187. }
  188. })
  189. },
  190. selectChange(val){
  191. let self = this;
  192. for(let i=0;i<self.laboratoryOptions.length;i++){
  193. if(val == self.laboratoryOptions[i].id){
  194. this.$set(this.dialogForm,'subName',self.laboratoryOptions[i].name);
  195. this.$set(this.dialogForm,'deptId',self.laboratoryOptions[i].deptId);
  196. this.$set(this.dialogForm,'deptName',self.laboratoryOptions[i].deptName);
  197. }
  198. }
  199. },
  200. selectFocus(){
  201. if(!this.laboratoryOptions[0]){
  202. this.getSub("");
  203. }
  204. },
  205. //懒加载实验室
  206. getSub(e){
  207. subjectList({name:e}).then(response => {
  208. this.$set(this,'laboratoryOptions',response.data);
  209. });
  210. },
  211. //学院
  212. listDepartments(){
  213. listDepartments({}).then(response => {
  214. this.$set(this, 'deptOptions', response.data)
  215. });
  216. },
  217. // 列表
  218. getList(){
  219. airbottleBluetoothList(this.queryParams).then(response => {
  220. this.$set(this, 'dataList', response.rows)
  221. this.$set(this, 'total', response.total)
  222. });
  223. },
  224. //表格按钮
  225. tableButton(type,row){
  226. let self = this;
  227. if (type == 1){
  228. this.$set(this,'dialogForm',{
  229. gatewayName:"",
  230. gatewayMac:"",
  231. subName:"",
  232. subId:"",
  233. deptId:"",
  234. deptName:"",
  235. });
  236. this.$set(this,'dialogType',true);
  237. } else if(type == 2){
  238. this.$set(this,'dialogForm',{
  239. id:row.id,
  240. gatewayName:row.gatewayName,
  241. gatewayMac:row.gatewayMac,
  242. subName:row.subName,
  243. subId:row.subId,
  244. deptId:row.deptId,
  245. deptName:row.deptName,
  246. });
  247. this.getSub(row.subName);
  248. this.$set(this,'dialogType',true);
  249. } else if(type == 3){
  250. this.$confirm('是否确认删除?', "警告", {
  251. confirmButtonText: "确定",
  252. cancelButtonText: "取消",
  253. type: "warning"
  254. }).then(function() {
  255. laboratoryBuildingDel(row.id).then(response => {
  256. self.msgSuccess(response.msg)
  257. self.getList();
  258. });
  259. }).then(() => {
  260. }).catch(() => {});
  261. }
  262. },
  263. /** 搜索按钮操作 */
  264. handleQuery() {
  265. this.queryParams.pageNum = 1;
  266. this.queryParams.pageSize = 20;
  267. this.getList();
  268. },
  269. /** 重置按钮操作 */
  270. resetQuery() {
  271. this.$set(this,'queryParams',{
  272. searchValue:"",
  273. deptId:"",
  274. gatewayOnline:"",
  275. });
  276. this.handleQuery();
  277. },
  278. }
  279. }
  280. </script>
  281. <style scoped lang="scss">
  282. .bluetoothGateway{
  283. display: flex!important;
  284. flex-direction: column;
  285. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  286. padding:20px!important;
  287. }
  288. </style>