batchUpDialog.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="applyList-batchUpDialog">
  3. <el-dialog class="batchUpDialog" :title="batchUpDialogTitle"
  4. :visible.sync="batchUpDialogType" v-if="batchUpDialogType" width="1240px" height="700"
  5. append-to-body :close-on-click-modal="false" @close="dialogOff()">
  6. <div class="page-form-title-box" style="border:none;padding:0;height:60px;">
  7. <el-form :model="queryParams" class="form-box" ref="queryForm"
  8. :inline="true" style="width:100%;">
  9. <el-form-item label="" prop="schoolId">
  10. <el-select v-model="queryParams.schoolId" @change="changeSchool"
  11. placeholder="请选择校区" style="width: 150px">
  12. <el-option v-for="(item,index) in schoolOption"
  13. :key="item.id"
  14. :label="item.name"
  15. :value="item.id"/>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="" prop="buildId">
  19. <el-select v-model="queryParams.buildId" @change="buildSchool"
  20. placeholder="请选择楼栋" style="width: 150px">
  21. <el-option v-for="(item,index) in buildOption"
  22. :key="item.id"
  23. :label="item.name"
  24. :value="item.id"/>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="" prop="subjectId">
  28. <el-select v-model="queryParams.subjectId"
  29. placeholder="请选择实验室" style="width: 150px">
  30. <el-option v-for="(item,index) in subjectOption"
  31. :key="item.subId"
  32. :label="item.subName"
  33. :value="item.subId"/>
  34. </el-select>
  35. </el-form-item>
  36. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  37. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  38. </el-form>
  39. </div>
  40. <div class="page-content-box" style="padding:0;height:500px;">
  41. <el-table class="table-box" border :data="tableList" ref="multipleTable" :row-key="getRowKeys"
  42. tooltip-effect="dark" @selection-change="handleSelectionChange">
  43. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  44. <el-table-column label="名称" align="center" prop="deviceName" show-overflow-tooltip/>
  45. <el-table-column label="编号" align="center" prop="deviceNo" show-overflow-tooltip width="300"/>
  46. <el-table-column label="类型" align="center" prop="name" show-overflow-tooltip width="200"/>
  47. <el-table-column label="位置" align="center" prop="subjectName" show-overflow-tooltip width="200">
  48. <template slot-scope="scope">
  49. <span>{{scope.row.subjectName?scope.row.subjectName:'--'}}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="当前版本" align="center" prop="appName" show-overflow-tooltip width="200">
  53. <template slot-scope="scope">
  54. <span>{{scope.row.appName}} {{scope.row.version?' ('+scope.row.version+')':''}}</span>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <div class="selected-num-box" v-show="total>0">
  59. <p class="selected-num-p">
  60. <i class="el-icon-warning"></i>
  61. 已选择 {{selectedNum}} 项
  62. </p>
  63. <pagination :page-sizes="[20, 30, 40, 50]"
  64. :total="total"
  65. :page.sync="queryParams.page"
  66. :limit.sync="queryParams.pageSize"
  67. @pagination="getList"
  68. />
  69. </div>
  70. </div>
  71. <div slot="footer" class="dialog-footer dialog-footer-box">
  72. <p class="dialog-footer-button-null"></p>
  73. <p class="dialog-footer-button-info" @click="dialogOff">取消</p>
  74. <p class="dialog-footer-button-primary" @click="dialogSubmit">提交</p>
  75. <p class="dialog-footer-button-null"></p>
  76. </div>
  77. </el-dialog>
  78. </div>
  79. </template>
  80. <script>
  81. import { iotAppInfoUpgradeDevices,iotAppInfoBatchUpgrade, } from "@/api/iotDevice/index";
  82. import { systemBuildingGetTreeList,laboratorySubRelInfoGetListByFloor } from "@/api/commonality/permission";
  83. export default {
  84. name: 'batchUpDialog',
  85. data(){
  86. return{
  87. typeId:null,
  88. batchUpDialogTitle:'',
  89. batchUpDialogType:false,
  90. //校区楼栋原始数据
  91. addressList:[],
  92. //校区下拉列表
  93. schoolOption:[],
  94. //楼栋下拉列表
  95. buildOption:[],
  96. //实验室下拉列表
  97. subjectOption:[],
  98. //列表相关
  99. optionList:[],
  100. queryParams:{
  101. page:1,
  102. pageSize:20,
  103. schoolId:null,
  104. buildId:null,
  105. subjectId :null,
  106. },
  107. tableList:[],
  108. total:0,
  109. //勾选相关
  110. selectedNum:0,
  111. ids:[],
  112. }
  113. },
  114. created(){
  115. },
  116. mounted(){
  117. this.systemBuildingGetTreeList();
  118. },
  119. methods:{
  120. //提交
  121. dialogSubmit(){
  122. if(!this.ids[0]){
  123. this.msgError('请勾选设备')
  124. }else{
  125. let obj = {
  126. id:this.typeId,
  127. isAll:false, // true.全部升级 false.勾选升级
  128. ids:this.ids
  129. }
  130. iotAppInfoBatchUpgrade(obj).then(response => {
  131. this.msgSuccess(response.message)
  132. this.dialogOff();
  133. });
  134. }
  135. },
  136. //开启
  137. dialogOpen(row){
  138. this.$set(this,'batchUpDialogTitle',row.name+' ('+row.info+') '+'- 批量升级');
  139. this.$set(this,'typeId',row.id);
  140. this.$set(this,'batchUpDialogType',true);
  141. this.$nextTick(()=>{
  142. this.resetQuery();
  143. })
  144. },
  145. //关闭
  146. dialogOff(){
  147. this.$set(this,'batchUpDialogType',false);
  148. this.$set(this,'batchUpDialogTitle','');
  149. },
  150. //查询
  151. handleQuery(){
  152. this.$refs.multipleTable.clearSelection();
  153. this.$set(this.queryParams,'page',1);
  154. this.$set(this,'selectedNum',0);
  155. this.$set(this,'ids',[]);
  156. this.getList();
  157. },
  158. //重置
  159. resetQuery(){
  160. //清除选中
  161. this.$refs.multipleTable.clearSelection();
  162. this.$set(this,'queryParams',{
  163. page:1,
  164. pageSize:20,
  165. schoolId:null,
  166. buildId:null,
  167. subjectId :null,
  168. });
  169. this.$set(this,'selectedNum',0);
  170. this.$set(this,'ids',[]);
  171. this.getList();
  172. },
  173. getList(){
  174. let obj = JSON.parse(JSON.stringify(this.queryParams))
  175. obj.id = this.typeId;
  176. iotAppInfoUpgradeDevices(obj).then(response => {
  177. this.$set(this,'tableList',response.data.records);
  178. this.$set(this,'total',response.data.total);
  179. });
  180. },
  181. //获取校区
  182. systemBuildingGetTreeList(){
  183. systemBuildingGetTreeList({}).then(response => {
  184. let list = [];
  185. for(let i=0;i<response.data.length;i++){
  186. list.push({
  187. id:response.data[i].id,
  188. name:response.data[i].name,
  189. })
  190. }
  191. this.$set(this,'schoolOption',list);
  192. this.$set(this,'addressList',response.data);
  193. })
  194. },
  195. //校区选中
  196. changeSchool(val){
  197. let self = this;
  198. let list = [];
  199. for(let i=0;i<self.addressList.length;i++){
  200. if(val == self.addressList[i].id && self.addressList[i].buildFloorVoList[0]){
  201. for(let o=0;o<self.addressList[i].buildFloorVoList.length;o++){
  202. list.push({
  203. id:self.addressList[i].buildFloorVoList[o].id,
  204. name:self.addressList[i].buildFloorVoList[o].name,
  205. })
  206. }
  207. }
  208. }
  209. this.$set(this.queryParams,'buildId',null);
  210. this.$set(this.queryParams,'subjectId',null);
  211. this.$set(this,'buildOption',list);
  212. this.$set(this,'subjectOption',[]);
  213. },
  214. //楼栋选中
  215. buildSchool(val){
  216. laboratorySubRelInfoGetListByFloor({buildId:val}).then(response => {
  217. this.$set(this.queryParams,'subjectId',null);
  218. this.$set(this,'subjectOption',response.data);
  219. })
  220. },
  221. /*===记录勾选数据===
  222. 需要再el-table 添加 :row-key="getRowKeys"
  223. 需要在selection 添加 :reserve-selection="true"
  224. */
  225. getRowKeys(row) {
  226. return row.deviceId
  227. },
  228. //多选框选中数据
  229. handleSelectionChange(selection) {
  230. this.selectedNum = selection.length;
  231. this.ids = selection.map(item => item.deviceId)
  232. },
  233. },
  234. }
  235. </script>
  236. <style scoped lang="scss">
  237. .applyList-batchUpDialog{
  238. .content-box{
  239. flex:1;
  240. display: flex;
  241. padding:20px;
  242. }
  243. }
  244. </style>