indexCamera.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="24" :xs="24">
  5. <div class="main-right-box">
  6. <div class="main-search-box">
  7. <el-form
  8. :model="queryParams"
  9. ref="queryForm"
  10. size="small"
  11. :inline="true"
  12. v-show="showSearch"
  13. >
  14. <el-form-item label="组织机构">
  15. <org-tree
  16. v-model="queryParams.orgId"
  17. @defaultKey="getDefaultKey"
  18. @defaultOrg="getDefaultOrg"
  19. @checkChange="checkChange"
  20. @click="clickTreeNode"
  21. ref="orgTree"
  22. ></org-tree>
  23. </el-form-item>
  24. <el-form-item label="设备名称" prop="deviceName">
  25. <el-input
  26. v-model="queryParams.deviceName"
  27. clearable
  28. placeholder="请输入关键字"
  29. @keyup.enter.native="handleQuery"/>
  30. </el-form-item>
  31. <el-form-item label="绑定任务" prop="state">
  32. <el-select
  33. v-model="queryParams.state" clearable
  34. label="绑定任务" placeholder="请选择绑定状态" prop="state">
  35. <el-option
  36. v-for="item in bindTypes"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value"/>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="任务名称" prop="missionCode">
  43. <el-select
  44. v-model="queryParams.missionCode"
  45. clearable
  46. label="任务名称"
  47. placeholder="请选择任务名称"
  48. prop="missionCode"
  49. >
  50. <el-option
  51. v-for="item in deviceTypes"
  52. :key="item.value"
  53. :label="item.label"
  54. :value="item.value">
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10">
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. icon="el-icon-search"
  64. size="mini"
  65. @click="handleQuery"
  66. >搜索
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="primary"
  72. icon="el-icon-refresh"
  73. size="mini"
  74. @click="resetQuery"
  75. >重置
  76. </el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="primary"
  81. icon="el-icon-refresh"
  82. size="mini"
  83. @click="unbindMission()"
  84. >解绑任务
  85. </el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. type="primary"
  90. icon="el-icon-refresh"
  91. size="mini"
  92. @click="bindMission()"
  93. >绑定任务
  94. </el-button>
  95. </el-col>
  96. <el-col :span="1.5">
  97. <el-button
  98. type="primary"
  99. icon="el-icon-download"
  100. size="mini"
  101. @click="handleExport"
  102. >导出数据
  103. </el-button>
  104. </el-col>
  105. <right-toolbar
  106. :showSearch.sync="showSearch"
  107. @queryTable="getList"
  108. ></right-toolbar>
  109. </el-row>
  110. </div>
  111. <el-table
  112. v-loading="loading"
  113. :data="dataList"
  114. border
  115. height="600"
  116. size="small"
  117. >
  118. <el-table-column label="序号" type="index" align="center" width="70">
  119. <template slot-scope="scope">
  120. {{
  121. (queryParams.pageNum - 1) * queryParams.pageSize +
  122. scope.$index +
  123. 1
  124. }}
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="地区" align="center" prop="firstOrgName" width="180"/>
  128. <el-table-column label="行社名称" align="center" prop="secondOrgName" width="220"/>
  129. <el-table-column label="所属机构" align="center" prop="orgName" width="220"/>
  130. <el-table-column label="设备名称" align="center" prop="deviceName" width="300"/>
  131. <el-table-column label="所属主机" align="center" prop="hostName" width="280"/>
  132. <el-table-column label="任务" align="center" prop="missionName" width="380"/>
  133. </el-table>
  134. <pagination
  135. v-show="total > 0"
  136. :total="total"
  137. :page.sync="queryParams.pageNum"
  138. :limit.sync="queryParams.pageSize"
  139. @pagination="getList"
  140. />
  141. </div>
  142. </el-col>
  143. </el-row>
  144. <dialog-bind-mission ref="bindMissionDialog" @success="getList()"></dialog-bind-mission>
  145. </div>
  146. </template>
  147. <script>
  148. import { cameraList,missionTypeList,unbindMission} from "@/api/iot/diagnoseMission";
  149. import DialogBindMission from "./dialog.bindMission.vue";
  150. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  151. import { mapGetters } from "vuex";
  152. import dayjs from "dayjs";
  153. export default {
  154. components: { OrgTree,DialogBindMission },
  155. name: "Task",
  156. dicts: ["sys_org_type",'sensor_alarm_status','sensor_device_type'],
  157. data() {
  158. return {
  159. bindTypes:[
  160. {
  161. value: '0',
  162. label: '未绑定'
  163. },
  164. {
  165. value: '1',
  166. label: '已绑定'
  167. }
  168. ],
  169. deviceTypes: [],
  170. // 遮罩层
  171. loading: false,
  172. // 选中数组
  173. ids: [],
  174. // 非单个停用
  175. single: true,
  176. // 非多个停用
  177. multiple: true,
  178. // 显示搜索条件
  179. showSearch: true,
  180. // 总条数
  181. total: 1,
  182. // 弹出层标题
  183. title: "",
  184. // 是否显示弹出层
  185. open: false,
  186. // 查询参数
  187. queryParams: {
  188. pageNum: 1,
  189. pageSize: 10,
  190. checkSub: true,
  191. missionCode: null,
  192. state: null,
  193. },
  194. // 表单参数
  195. form: {},
  196. // 表单校验
  197. rules: {},
  198. timeClearable: true,
  199. showOverflowTooltip:true,
  200. dataList:[],
  201. };
  202. },
  203. created() {
  204. this.queryParams.orgId = this.$store.getters.orgId;
  205. this.initDeviceTypeList();
  206. },
  207. computed: {
  208. ...mapGetters(["orgId"]),
  209. },
  210. methods: {
  211. initDeviceTypeList(){
  212. missionTypeList()
  213. .then((r) => {
  214. // 使用 map 而不是 filter 进行数据转换
  215. const transformedList = r.map((item) => ({
  216. value: item.value,
  217. label: item.label,
  218. type: item.type,
  219. }));
  220. // 将转换后的数据推送到 this.deviceTypeList
  221. this.deviceTypes.push(...transformedList);
  222. })
  223. .catch((error) => {
  224. // 处理错误
  225. console.error('Error fetching device type list:', error);
  226. });
  227. },
  228. /** 查询列表 */
  229. getList() {
  230. this.loading = true;
  231. cameraList(this.queryParams).then((response) => {
  232. this.dataList = response.rows;
  233. this.total = response.total;
  234. this.loading = false;
  235. });
  236. },
  237. // 取消弹框
  238. closeHandler() {
  239. this.reset();
  240. },
  241. handleImport() {},
  242. getDefaultOrg(org) {
  243. this.orgName = org.name;
  244. this.selectedOrgName = org.shortName;
  245. },
  246. getDefaultKey(key) {
  247. this.queryParams.orgId = key;
  248. this.getList();
  249. },
  250. checkChange(state) {
  251. this.queryParams.checkSub = state;
  252. this.handleQuery();
  253. },
  254. // 节点单击事件
  255. clickTreeNode(data) {
  256. this.queryParams.orgId = data.id;
  257. this.orgName = data.name;
  258. this.selectedOrgName = data.shortName;
  259. this.handleQuery();
  260. },
  261. /** 下穿状态改变*/
  262. changeCheckBox() {
  263. this.getList();
  264. },
  265. // 取消按钮
  266. cancel() {
  267. this.open = false;
  268. this.reset();
  269. },
  270. // 表单重置
  271. reset() {
  272. this.form = {
  273. id: null,
  274. orgId: null,
  275. orgPath: null,
  276. orgName: null
  277. };
  278. this.resetForm("form");
  279. },
  280. /** 搜索按钮操作 */
  281. handleQuery() {
  282. this.queryParams.pageNum = 1;
  283. this.getList();
  284. },
  285. /** 重置按钮操作 */
  286. resetQuery() {
  287. this.resetForm("queryForm");
  288. this.queryParams.orgId = this.orgId;
  289. this.selectedOrgName = this.orgName;
  290. this.queryParams.checkSub = true;
  291. this.queryParams.planStartTime = null;
  292. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
  293. this.handleQuery();
  294. },
  295. /** 绑定任务 */
  296. bindMission() {
  297. this.$refs["bindMissionDialog"].show(this.queryParams, this.deviceTypes);
  298. },
  299. /** 解绑任务 */
  300. unbindMission() {
  301. this.loading = true;
  302. unbindMission(this.queryParams).then((response) => {
  303. this.loading = false;
  304. this.getList();
  305. });
  306. },
  307. /** 导出按钮操作 */
  308. handleExport() {
  309. if (this.total==null || this.total===0){
  310. this.$modal.alert("暂无可用数据导出");
  311. return;
  312. }
  313. if (this.total>50000){
  314. this.$modal.alert("导出数据超过5万条,请缩小查询范围后重试");
  315. return;
  316. }
  317. this.download(
  318. "iot/sensor/export",
  319. {
  320. ...this.queryParams,
  321. },
  322. `${
  323. this.selectedOrgName
  324. }-${this.$tab.getCurrentTabName()}-${dayjs().format("YYYYMMDD")}.xlsx`
  325. );
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang="scss" scoped></style>