outfireDevice.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <!--智能灭火设备-->
  2. <template>
  3. <div class="app-container approval_handle">
  4. <div class="approval_handle-page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
  6. <el-form-item label="关键字" prop="name">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="设备名称\关联实验室"
  10. clearable
  11. maxLength="30"
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item>
  16. <p class="inquire-button-one" @click="handleQuery">查询</p>
  17. <p class="reset-button-one" @click="resetQuery">重置</p>
  18. </el-form-item>
  19. <el-form-item style="float: right;">
  20. <el-col :span="1.5">
  21. <el-button
  22. type="primary"
  23. plain
  24. icon="el-icon-plus"
  25. size="mini"
  26. @click="handleClick('','','add')"
  27. v-hasPermi="['algorithm:firedevice:add']"
  28. >新增</el-button>
  29. </el-col>
  30. </el-form-item>
  31. </el-form>
  32. <el-table border v-loading="loading" :data="tableData">
  33. <el-table-column label="设备名称" align="left" prop="deviceName"/>
  34. <el-table-column label="继电器编号" align="left" prop="deviceCode"/>
  35. <el-table-column label="设备地址" align="left" prop="deviceUrl"></el-table-column>
  36. <el-table-column label="关联实验室" align="left" prop="subjectName"></el-table-column>
  37. <el-table-column label="状态" align="left" prop="deviceStatus">
  38. <template slot-scope="scope">
  39. <span v-if="scope.row.deviceStatus==1">离线</span>
  40. <span v-if="scope.row.deviceStatus==2">在线</span>
  41. <span v-if="scope.row.deviceStatus==3">异常</span>
  42. <span v-if="scope.row.deviceStatus==3" style="color: #E6A23C"> {{'('+scope.row.describe+')'}}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="180">
  46. <template slot-scope="scope">
  47. <div class="table-button-box">
  48. <p class="table-button-null"></p>
  49. <p class="table-button-p" v-hasPermi="['algorithm:firedevice:edit']" @click="handleClick('',scope.row,'edit')">编辑</p>
  50. <p class="table-button-p" v-hasPermi="['algorithm:firedevice:remove']" @click="handleClick('',scope.row,'delete')">删除</p>
  51. <p class="table-button-null"></p>
  52. </div>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <pagination
  57. :total="total"
  58. layout="total, prev, pager, next, sizes, jumper"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getList"
  62. />
  63. </div>
  64. <!--弹框-->
  65. <el-dialog :title='dialogTitle' @close="handleClose" :visible.sync="dialogVisible" width="600px" append-to-body :close-on-click-modal="false">
  66. <el-form :model="dialogForm" ref="dialogForm" :rules="rules" :inline="true" label-width="140px">
  67. <el-form-item label="设备名称:" prop="deviceName" >
  68. <el-input
  69. style="width: 400px"
  70. v-model="dialogForm.deviceName"
  71. placeholder="请输入设备名称"
  72. maxLength="20"
  73. clearable
  74. size="small"
  75. />
  76. </el-form-item>
  77. <el-form-item label="继电器编号:" prop="relayCode" >
  78. <el-input
  79. style="width: 400px"
  80. v-model="dialogForm.relayCode"
  81. placeholder="请输入继电器编号"
  82. maxLength="20"
  83. clearable
  84. size="small"
  85. />
  86. </el-form-item>
  87. <el-form-item label="采集器编号:" prop="deviceCode" >
  88. <el-input
  89. style="width: 400px"
  90. v-model="dialogForm.deviceCode"
  91. placeholder="请输入采集器编号"
  92. maxLength="20"
  93. clearable
  94. size="small"
  95. />
  96. </el-form-item>
  97. <el-form-item label="设备地址:" prop="deviceUrl" >
  98. <el-input
  99. style="width: 400px"
  100. v-model="dialogForm.deviceUrl"
  101. placeholder="请输入设备地址"
  102. maxLength="3"
  103. clearable
  104. size="small"
  105. />
  106. </el-form-item>
  107. <el-form-item label="实验地点" prop="subjectId">
  108. <el-select
  109. style="width:400px;"
  110. v-model="dialogForm.location"
  111. filterable
  112. remote
  113. clearable
  114. reserve-keyword
  115. @focus="selectFocus"
  116. @change="selectChange"
  117. placeholder="请选择实验地点"
  118. :remote-method="userSelectList"
  119. :loading="loading">
  120. <el-option
  121. v-for="item in laboratoryOptions"
  122. :key="item.id"
  123. :label="item.name"
  124. :value="item.id">
  125. </el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="灭火倒计时:" prop="deviceCountDown" >
  129. <el-input
  130. :min="0"
  131. oninput="if(value<0 || value>30)value=0"
  132. style="width: 400px"
  133. v-model="dialogForm.deviceCountDown"
  134. placeholder="请输入倒计时秒数,仅能输入0-30之间的数字"
  135. clearable
  136. size="small"
  137. >
  138. <template slot="append">秒</template>
  139. </el-input>
  140. </el-form-item>
  141. </el-form>
  142. <div slot="footer" class="dialog-footer">
  143. <el-button @click="cancel">取 消</el-button>
  144. <el-button type="primary" @click="submitForm">确 定</el-button>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. import { subjectList, } from '@/api/gasManage3_0/gasManage'
  151. import { firedeviceAdd, firedeviceDle, firedeviceEdit, firedeviceList } from '@/api/laboratory/subject'
  152. export default {
  153. name: "Approval",
  154. components: {
  155. },
  156. data() {
  157. return {
  158. dialogVisible :false,
  159. //页面状态
  160. pageType:1,
  161. dialogTitle:'新增智能灭火设备',
  162. loading:false,
  163. // 查询参数
  164. queryParams: {
  165. pageNum: 1,
  166. pageSize:20,
  167. searchValue:'',
  168. },
  169. total:0,
  170. tableData:[],
  171. dialogForm:{
  172. id:'',
  173. deviceName:'',
  174. deviceCode:'',
  175. relayCode:'',
  176. deviceUrl:'',
  177. deviceCountDown:'',
  178. subjectId:'',
  179. location:'',
  180. },
  181. laboratoryOptions:[],
  182. // 表单校验
  183. rules: {
  184. deviceName: [
  185. { required: true, message: "请输入设备名称", trigger: "blur" }
  186. ],
  187. relayCode: [
  188. { required: true, message: "请输入继电器编号", trigger: "blur" }
  189. ],
  190. deviceCode: [
  191. { required: true, message: "请输入采集器编号", trigger: "blur" }
  192. ],
  193. deviceUrl: [
  194. { required: true, message: "请输入设备地址", trigger: "blur" }
  195. ],
  196. deviceCountDown: [
  197. { required: true, message: "请输入倒计时秒数", trigger: "blur" }
  198. ],
  199. subjectId: [
  200. { required: true, message: "请选择实验地点", trigger: "blur" }
  201. ],
  202. },
  203. };
  204. },
  205. methods: {
  206. //监听关联记录弹窗关闭
  207. handleClose(){
  208. },
  209. selectFocus(){
  210. if(!this.laboratoryOptions[0]){
  211. this.userSelectList("");
  212. }
  213. },
  214. //实验室选择
  215. selectChange(e){
  216. let self = this;
  217. for(let i=0;i<self.laboratoryOptions.length;i++){
  218. if(self.laboratoryOptions[i].id == e){
  219. //this.$set(this.dialogForm,"subject",self.laboratoryOptions[i]);
  220. this.$set(this.dialogForm,"location",self.laboratoryOptions[i].name);
  221. }
  222. }
  223. this.$set(this.dialogForm,"subjectId",e);
  224. },
  225. //懒加载实验室
  226. userSelectList(e){
  227. subjectList({name:e,deptId:this.dialogForm.deptId}).then(response => {
  228. this.laboratoryOptions = response.data;
  229. });
  230. },
  231. // 取消按钮
  232. cancel() {
  233. this.dialogVisible = false;
  234. },
  235. handleClick(index,row,doType){
  236. let _this=this;
  237. if(doType=='add'){//添加
  238. _this.dialogTitle='新增智能灭火设备';
  239. _this.dialogVisible=true;
  240. _this.dialogForm.deviceCountDown=30
  241. _this.dialogForm.id='';
  242. _this.dialogForm.deviceName='';
  243. _this.dialogForm.deviceCode='';
  244. _this.dialogForm.relayCode='';
  245. _this.dialogForm.deviceUrl='';
  246. _this.dialogForm.subjectId='';
  247. _this.dialogForm.location='';
  248. }else if(doType=='edit'){//编辑
  249. _this.dialogTitle='编辑智能灭火设备';
  250. _this.dialogVisible=true;
  251. _this.dialogForm.id=row.id;
  252. _this.dialogForm.deviceName=row.deviceName;
  253. _this.dialogForm.deviceCode=row.deviceCode;
  254. _this.dialogForm.relayCode=row.relayCode;
  255. _this.dialogForm.deviceUrl=row.deviceUrl
  256. _this.dialogForm.deviceCountDown=row.deviceCountDown;
  257. _this.dialogForm.subjectId=row.subjectId;
  258. _this.dialogForm.location=row.subjectName;
  259. }else if(doType=='delete'){//删除
  260. this.$confirm('是否确认删除当前数据项?', "警告", {
  261. confirmButtonText: "确定",
  262. cancelButtonText: "取消",
  263. type: "warning"
  264. }).then(function() {
  265. firedeviceDle(row.id).then( response => {
  266. if(response.code==200){
  267. _this.getList();
  268. _this.msgSuccess("删除成功");
  269. }
  270. });
  271. }).then(() => {
  272. }).catch(() => {});
  273. }
  274. },
  275. /** 搜索按钮操作 */
  276. handleQuery() {
  277. this.queryParams.pageNum = 1;
  278. this.getList();
  279. },
  280. /** 重置按钮操作 */
  281. resetQuery() {
  282. this.queryParams.searchValue = "";
  283. this.handleQuery();
  284. },
  285. getList(){
  286. let _this=this;
  287. firedeviceList(_this.queryParams).then( response => {
  288. let res=response.rows;
  289. _this.tableData=res;
  290. _this.total=response.total;
  291. });
  292. },
  293. //提交
  294. submitForm(){
  295. let _this = this;
  296. this.$refs['dialogForm'].validate((valid) => {
  297. if (valid) {
  298. _this.dialogForm.deviceUrl=Number( _this.dialogForm.deviceUrl)
  299. _this.dialogForm.deviceCountDown=Number( _this.dialogForm.deviceCountDown)
  300. if(!this.dialogForm.id){//新增
  301. firedeviceAdd(_this.dialogForm).then(res => {
  302. this.$message({
  303. type: 'success',
  304. message: '操作成功!',
  305. duration:2000,
  306. onClose:function(){
  307. _this.getList();
  308. _this.loading = false;
  309. _this.dialogVisible = false;
  310. }
  311. });
  312. });
  313. }else{//编辑
  314. firedeviceEdit(_this.dialogForm).then(res => {
  315. this.$message({
  316. type: 'success',
  317. message: '操作成功!',
  318. duration:2000,
  319. onClose:function(){
  320. _this.getList();
  321. _this.loading = false;
  322. _this.dialogVisible = false;
  323. }
  324. });
  325. });
  326. }
  327. } else {
  328. return false;
  329. }
  330. });
  331. },
  332. },
  333. mounted() {
  334. this.getList();
  335. }
  336. };
  337. </script>
  338. <style scoped lang="scss">
  339. .approval_handle {
  340. display: flex!important;
  341. flex-direction: column;
  342. overflow: hidden;
  343. .approval_handle-page{
  344. flex:1;
  345. display: flex!important;
  346. flex-direction: column;
  347. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  348. padding:20px 20px 20px!important;
  349. border-radius:10px;
  350. overflow: hidden;
  351. .button-box{
  352. width:200px;
  353. display: flex;
  354. }
  355. }
  356. .entering_t{
  357. font-size: 16px;
  358. font-family: Microsoft YaHei;
  359. font-weight: 400;
  360. color: #333333;
  361. line-height: 16px;
  362. margin: 36px auto 25px;
  363. text-align: center;
  364. }
  365. .entering_img{
  366. width: 288px;
  367. height: 140px;
  368. }
  369. .entering_input{
  370. width: 288px;
  371. }
  372. }
  373. </style>