trap.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  1. <!-- -->
  2. <template>
  3. <div class="cbdbox">
  4. <div class="cbdboxs_search">
  5. <el-input
  6. v-model="idinput"
  7. placeholder="请输入诱捕器编号"
  8. size="mini"
  9. ></el-input>
  10. <el-select v-model="trapvalue" placeholder="请选择所在监测点" size="mini">
  11. <el-option
  12. v-for="item in traponsoptions"
  13. :key="item.point_id"
  14. :label="item.point_name"
  15. :value="item.point_id"
  16. >
  17. </el-option>
  18. </el-select>
  19. <el-select
  20. v-model="versionsvalue2"
  21. placeholder="请选择隶属海关"
  22. size="mini"
  23. >
  24. <el-option
  25. v-for="item in versionsoptions2"
  26. :key="item.org_id"
  27. :label="item.org_name"
  28. :value="item.org_id"
  29. >
  30. </el-option>
  31. </el-select>
  32. <!-- <el-cascader
  33. :change-on-select="true"
  34. :options="versionsoptions"
  35. v-model="versionsvalue"
  36. :props="defaultParams"
  37. :clearable="true"
  38. @change="cascaderchange"
  39. size="mini"
  40. placeholder="请选择隶属海关"
  41. ></el-cascader> -->
  42. <el-select
  43. v-model="inoffvalue"
  44. placeholder="请选择诱捕器状态"
  45. size="mini"
  46. >
  47. <el-option
  48. v-for="item in inoffoptions"
  49. :key="item.value"
  50. :label="item.label"
  51. :value="item.value"
  52. >
  53. </el-option>
  54. </el-select>
  55. <el-button type="info" @click="search" size="mini">搜索</el-button>
  56. <el-button size="mini" @click="reset">重置</el-button>
  57. <el-button
  58. type="info"
  59. @click="
  60. addtraptf = true;
  61. parameter = 'add';
  62. "
  63. size="mini"
  64. >添加诱捕器</el-button
  65. >
  66. <el-button type="info" @click="downloadtf = true" size="mini"
  67. >批量导入诱捕器</el-button
  68. >
  69. <el-button type="info" size="mini" @click="deriveVisible = true"
  70. >导出数据</el-button
  71. >
  72. </div>
  73. <el-card class="box-card" style="margin-top: 15px">
  74. <div class="cbdboxs_table" v-loading="loading">
  75. <el-table
  76. :data="tableData"
  77. style="width: 100%; overflow-y: auto"
  78. :stripe="true"
  79. :height="48 * 13"
  80. >
  81. <el-table-column
  82. prop="index"
  83. label="序号"
  84. width="60px"
  85. ></el-table-column>
  86. <el-table-column prop="trap_number" label="编号"></el-table-column>
  87. <el-table-column prop="lng" label="经度">
  88. <template slot-scope="scope">
  89. <span>{{ ToDegrees(scope.row.lng, "lng") }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="lat" label="纬度">
  93. <template slot-scope="scope">
  94. <span>{{ ToDegrees(scope.row.lat, "lat") }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column prop="org_list" label="组织">
  98. <template slot-scope="scope">
  99. <span v-if="scope.row.org_list.length == 1">{{
  100. scope.row.org_list[0].org_name
  101. }}</span>
  102. <el-popover
  103. ref="popover"
  104. placement="right"
  105. title=""
  106. width="150"
  107. trigger="hover"
  108. v-else
  109. >
  110. <div class="popover-content" v-html="content"></div>
  111. <span @mouseover="orglisthover(scope.row)" slot="reference"
  112. >{{ scope.row.org_list[0].org_name }}...</span
  113. >
  114. </el-popover>
  115. </template>
  116. </el-table-column>
  117. <el-table-column prop="point_name" label="监测点"> </el-table-column>
  118. <el-table-column prop="inducer_name" label="诱剂"> </el-table-column>
  119. <el-table-column prop="create_time" label="添加时间" width="200">
  120. </el-table-column>
  121. <el-table-column prop="is_online" label="状态">
  122. <template slot-scope="scope">
  123. <div class="state">
  124. <p
  125. :style="{
  126. color: scope.row.trap_status == '1' ? '#30A031 ' : 'red',
  127. }"
  128. >
  129. ·
  130. </p>
  131. <p
  132. :style="{
  133. color: scope.row.trap_status == '1' ? '#30A031 ' : 'red',
  134. }"
  135. >
  136. {{ scope.row.trap_status == "1" ? "正常" : "停用" }}
  137. </p>
  138. </div>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="操作" width="200">
  142. <template slot-scope="scope">
  143. <span
  144. style="color: #409eff; margin-right: 5px; cursor: pointer"
  145. @click="addtrap(scope.row)"
  146. >编辑</span
  147. >
  148. <span
  149. style="color: #409eff; margin-right: 5px; cursor: pointer"
  150. @click="deletes(scope.row)"
  151. >删除</span
  152. >
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. <el-pagination
  158. background
  159. layout="prev, pager, next,jumper"
  160. :total="total"
  161. :page-size="20"
  162. @current-change="pageChange"
  163. >
  164. </el-pagination>
  165. </el-card>
  166. <el-dialog
  167. :title="addtitle"
  168. :visible.sync="addtraptf"
  169. width="30%"
  170. @close="resetForm('ruleForm')"
  171. >
  172. <div>
  173. <el-form
  174. :model="ruleForm"
  175. :rules="rules"
  176. ref="ruleForm"
  177. label-width="100px"
  178. class="demo-ruleForm"
  179. >
  180. <el-form-item label="诱捕器编号" prop="trap_number">
  181. <el-input v-model="ruleForm.trap_number"></el-input>
  182. </el-form-item>
  183. <div class="addtrapbox">
  184. <el-form-item label="所在纬度" prop="lng">
  185. <el-input v-model="ruleForm.lng"></el-input>
  186. <p style="height: 24px; padding-left: 16px">
  187. {{ ToDegrees(ruleForm.lng, "lng") }}
  188. </p>
  189. </el-form-item>
  190. <el-form-item label="所在纬度" prop="lat">
  191. <el-input v-model="ruleForm.lat"></el-input>
  192. <p style="height: 24px; padding-left: 16px">
  193. {{ ToDegrees(ruleForm.lat, "lat") }}
  194. </p>
  195. </el-form-item>
  196. </div>
  197. <div class="buttonbox">
  198. <el-button type="info" size="mini" @click="dingwei"
  199. >地图选点</el-button
  200. >
  201. </div>
  202. <el-form-item label="隶属海关" prop="org_id">
  203. <!-- <el-select v-model="ruleForm.org_id" placeholder="请选择隶属海关">
  204. <el-option
  205. v-for="item in versionsoptions"
  206. :label="item.org_name"
  207. :value="item.org_id"
  208. :key="item.org_id"
  209. ></el-option>
  210. </el-select> -->
  211. <el-cascader
  212. :change-on-select="true"
  213. v-model="ruleForm.org_id"
  214. :options="versionsoptions"
  215. :props="defaultParams"
  216. :clearable="true"
  217. placeholder="请选择隶属海关"
  218. ></el-cascader>
  219. </el-form-item>
  220. <el-form-item label="所在监测点" prop="point_id">
  221. <el-select
  222. v-model="ruleForm.point_id"
  223. placeholder="请选择所在监测点"
  224. >
  225. <el-option
  226. v-for="item in traponsoptions"
  227. :label="item.point_name"
  228. :value="item.point_id"
  229. :key="item.point_id"
  230. ></el-option>
  231. </el-select>
  232. </el-form-item>
  233. <el-form-item label="诱剂名称" prop="inducer_id">
  234. <el-select
  235. v-model="ruleForm.inducer_id"
  236. placeholder="请选择诱剂名称"
  237. >
  238. <el-option
  239. v-for="item in inducer_data"
  240. :label="item.inducer_name"
  241. :value="item.inducer"
  242. :key="item.inducer"
  243. ></el-option>
  244. </el-select>
  245. </el-form-item>
  246. <el-form-item label="设备状态" prop="trap_status">
  247. <el-radio-group
  248. v-model="ruleForm.trap_status"
  249. placeholder="请选择设备状态"
  250. >
  251. <el-radio label="1">正常</el-radio>
  252. <el-radio label="0">停用</el-radio>
  253. </el-radio-group>
  254. </el-form-item>
  255. </el-form>
  256. </div>
  257. <span slot="footer" class="dialog-footer">
  258. <el-button @click="resetForm('ruleForm')" size="mini">取 消</el-button>
  259. <el-button
  260. type="primary"
  261. @click="submitForm('ruleForm')"
  262. size="mini"
  263. :disabled="releaseTF"
  264. >{{ releaseTF ? "发布中..." : "确 定" }}</el-button
  265. >
  266. </span>
  267. </el-dialog>
  268. <el-dialog title="导入诱捕器" :visible.sync="downloadtf" width="25%">
  269. <div class="downloadbox">
  270. <div class="downloadbox_item">
  271. <p class="title">导入诱捕器</p>
  272. <!-- <el-input placeholder="请输入内容" v-model="input1">
  273. <template slot="prepend">Http://</template>
  274. </el-input> -->
  275. <el-upload
  276. action=""
  277. :auto-upload="false"
  278. accept=".xlsx, .xls"
  279. :show-file-list="false"
  280. :on-change="handle"
  281. >
  282. <el-button type="success" size="mini">点击上传</el-button>
  283. </el-upload>
  284. <el-input
  285. v-model="downloadinput"
  286. placeholder="请输入内容"
  287. :disabled="true"
  288. size="mini"
  289. ></el-input>
  290. </div>
  291. <p class="tishi">
  292. <span>注:请先下模板,在模板中填入数据上传</span
  293. ><span @click="download">下载模板</span>
  294. </p>
  295. </div>
  296. <!-- <span slot="footer" class="dialog-footer">
  297. <el-button @click="downloadtf = false">取 消</el-button>
  298. <el-button type="primary" @click="downloadtf = false">确 定</el-button>
  299. </span> -->
  300. </el-dialog>
  301. <el-dialog title="导出数据" :visible.sync="deriveVisible" width="30%">
  302. <div class="derivebox">
  303. <p><span>*</span>文件名称:</p>
  304. <el-input
  305. v-model="derivefilename"
  306. placeholder="请输入文件名称"
  307. size="mini"
  308. ></el-input>
  309. </div>
  310. <span slot="footer" class="dialog-footer">
  311. <el-button @click="deriveVisible = false" size="mini">取 消</el-button>
  312. <el-button type="primary" @click="deriveclick" size="mini"
  313. :disabled="deriveTF"
  314. >{{deriveTF?"导出中...":"确 定"}}</el-button
  315. >
  316. </span>
  317. </el-dialog>
  318. <el-dialog
  319. class="map_dialog"
  320. title="地图选点"
  321. :visible.sync="addLocationDialogVisible"
  322. width="820px"
  323. @closed="addLocationDialogClosed"
  324. >
  325. <el-form
  326. :inline="true"
  327. :model="locationForm"
  328. class="demo-form-inline"
  329. size="mini"
  330. >
  331. <el-form-item label="经度">
  332. <el-input clearable v-model="locationForm.lng"></el-input>
  333. </el-form-item>
  334. <el-form-item label="纬度">
  335. <el-input clearable v-model="locationForm.lat"></el-input>
  336. </el-form-item>
  337. <el-form-item>
  338. <el-button type="primary" size="mini" @click="locationSearch"
  339. >定位</el-button
  340. >
  341. </el-form-item>
  342. <el-form-item label="">
  343. <el-input
  344. placeholder="请输入地区检索"
  345. v-model="addr"
  346. clearable
  347. @change="addrChange()"
  348. ></el-input>
  349. </el-form-item>
  350. </el-form>
  351. <div class="amap-demo" id="mapContainer2" style="height: 400px"></div>
  352. <span slot="footer" class="dialog-footer">
  353. <el-button @click="addLocationDialogVisible = false" size="mini"
  354. >取 消</el-button
  355. >
  356. <el-button type="primary" @click="addLocationSubm" size="mini"
  357. >确 定</el-button
  358. >
  359. </span>
  360. </el-dialog>
  361. </div>
  362. </template>
  363. <script>
  364. import { isArray } from "highcharts";
  365. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  366. export default {
  367. //import引入的组件需要注入到对象中才能使用
  368. components: {},
  369. data() {
  370. //这里存放数据
  371. var checkname = (rule, value, callback) => {
  372. if (/^[A-Za-z0-9\u4e00-\u9fa5]+$/.test(value)) {
  373. callback();
  374. } else {
  375. callback(new Error("请输入非中文格式"));
  376. }
  377. };
  378. var checklnglat = (rule, value, callback) => {
  379. if (isNaN(value)) {
  380. callback(new Error("请输入数字"));
  381. } else {
  382. callback();
  383. }
  384. };
  385. return {
  386. idinput: "",
  387. inoffvalue: "",
  388. inoffoptions: [
  389. { label: "停用", value: "0" },
  390. { label: "正常", value: "1" },
  391. ],
  392. versionsvalue: "",
  393. versionsvalue1: "", //组织id
  394. versionsoptions: [], //组织
  395. versionsvalue2: "", //组织id 用于搜索
  396. versionsoptions2: [], //组织 用于搜索
  397. defaultParams: {
  398. label: "org_name",
  399. value: "id",
  400. children: "childrens",
  401. multiple: true,
  402. checkStrictly: true,
  403. },
  404. trapvalue: "",
  405. traponsoptions: [], //监测点
  406. inducer_data: [],
  407. queryInfo: {
  408. page: 1,
  409. point_id: "", //监测点id
  410. trap_number: "", //设备id
  411. org_id: "", //组织id
  412. trap_status: "", //状态
  413. },
  414. tableData: [],
  415. device_id: "",
  416. total: 10,
  417. loading: false,
  418. addtraptf: false, //增加诱捕器弹框
  419. ruleForm: {
  420. trap_id: "", //诱捕器id 修改时用到
  421. trap_number: "", //诱捕器编号
  422. lat: "", // 必传(string) 纬度
  423. lng: "", // 必传(string) 经度
  424. org_id: "", // 必传(string) 所属海关id
  425. inducer_id: "", // 必传(string) 诱剂id
  426. point_id: "", // 必传(string) 所属监测点id
  427. trap_status: "", // 必传(string) 设备状态0停用 1正常
  428. },
  429. rules: {
  430. trap_number: [
  431. { required: true, message: "请输入诱捕器编号", trigger: "blur" },
  432. { validator: checkname, trigger: "blur" },
  433. ],
  434. lng: [
  435. { required: true, message: "请输入经度", trigger: "blur" },
  436. // { validator: checklnglat, trigger: "blur" },
  437. ],
  438. lat: [
  439. { required: true, message: "请输入纬度", trigger: "blur" },
  440. // { validator: checklnglat, trigger: "blur" },
  441. ],
  442. org_id: [
  443. { required: true, message: "请选择隶属海关", trigger: "change" },
  444. ],
  445. point_id: [
  446. { required: true, message: "请选择所在监测点", trigger: "change" },
  447. ],
  448. inducer_id: [
  449. { required: true, message: "请选择诱剂名称", trigger: "change" },
  450. ],
  451. trap_status: [
  452. { required: true, message: "请选择设备状态", trigger: "change" },
  453. ],
  454. },
  455. parameter: "",
  456. addtitle: "新增诱捕器",
  457. downloadtf: false,
  458. downloadinput: "", //上传的文件名
  459. deriveVisible: false, //导出弹框
  460. derivefilename: "", //导出文件名称
  461. //地图属性
  462. addLocationDialogVisible: false,
  463. locationForm: {
  464. lng: "",
  465. lat: "",
  466. },
  467. addr: "", //搜索栏地址
  468. address: "", //地图上标签地址
  469. center: [114.05, 22.55],
  470. content: "", //设备列表组织列表
  471. releaseTF: false,
  472. deriveTF:false
  473. };
  474. },
  475. //监听属性 类似于data概念
  476. computed: {},
  477. //监控data中的数据变化
  478. watch: {
  479. parameter: function (e) {
  480. // console.log(e);
  481. if (e == "add") {
  482. // console.log(this.$data.addtitle)
  483. this.$data.addtitle = "新增诱捕器";
  484. } else if (e == "modify") {
  485. this.$data.addtitle = "修改诱捕器";
  486. }
  487. },
  488. },
  489. //方法集合
  490. methods: {
  491. getcbdlist() {
  492. //获取设备列表
  493. this.loading = true;
  494. this.$axios({
  495. method: "POST",
  496. url: "/api/api_gateway?method=monitor_manage.trap_manage.trap_list",
  497. data: this.qs.stringify({
  498. page_size: 20,
  499. page: this.queryInfo.page,
  500. trap_number: this.queryInfo.trap_number,
  501. point_id: this.queryInfo.point_id,
  502. org_id: this.queryInfo.org_id,
  503. trap_status: this.queryInfo.trap_status,
  504. }),
  505. }).then((res) => {
  506. this.loading = false;
  507. console.log(res.data.data);
  508. this.total = res.data.data.total_item;
  509. this.tableData = res.data.data.page_list;
  510. for (var i = 0; i < this.tableData.length; i++) {
  511. this.tableData[i]["index"] = i + 1;
  512. }
  513. });
  514. },
  515. getmon() {
  516. //获取监测点列表 组织列表
  517. this.$axios({
  518. method: "POST",
  519. url: "/api/api_gateway?method=sysmenage.usermanager.org_list",
  520. data: this.qs.stringify({
  521. page_item: "100000000",
  522. }),
  523. }).then((res) => {
  524. console.log(res.data.data);
  525. this.versionsoptions = res.data.data.page_list; //组织
  526. this.traponsoptions = res.data.data.point_data;
  527. this.inducer_data = res.data.data.inducer_data;
  528. });
  529. },
  530. getmon2() {
  531. this.$axios({
  532. method: "POST",
  533. url: "/api/api_gateway?method=monitor_manage.trap_manage.trap_org",
  534. data: this.qs.stringify({
  535. page_item: "10000000",
  536. }),
  537. }).then((res) => {
  538. console.log(res.data.data);
  539. this.versionsoptions2 = res.data.data.org_data; //组织
  540. // this.inoffoptions = res.data.data.point_data;
  541. });
  542. },
  543. cascaderchange(e) {
  544. // console.log(this.versionsvalue, e);
  545. console.log(e[e.length - 1]);
  546. this.versionsvalue1 = e[e.length - 1];
  547. },
  548. search() {
  549. this.queryInfo.point_id = this.trapvalue;
  550. this.queryInfo.trap_number = this.idinput;
  551. this.queryInfo.org_id = this.versionsvalue2;
  552. this.queryInfo.trap_status = this.inoffvalue;
  553. // console.log(this.inoffvalue, this.versionsvalue, this.inoffvalue);
  554. this.getcbdlist();
  555. },
  556. pageChange(e) {
  557. // console.log(e)
  558. this.queryInfo.page = e;
  559. this.getcbdlist();
  560. },
  561. submitForm(formName) {
  562. console.log(this.ruleForm);
  563. var org_id = [];
  564. if (Array.isArray(this.ruleForm.org_id)) {
  565. for (var i = 0; i < this.ruleForm.org_id.length; i++) {
  566. org_id.push(
  567. this.ruleForm.org_id[i][this.ruleForm.org_id[i].length - 1]
  568. );
  569. }
  570. } else {
  571. org_id = this.ruleForm.org_id;
  572. }
  573. if (org_id.length > 0) {
  574. org_id = org_id.join("/");
  575. }
  576. console.log(org_id);
  577. this.releaseTF = true;
  578. this.$refs[formName].validate((valid) => {
  579. if (valid) {
  580. this.$axios({
  581. method: "POST",
  582. url: "/api/api_gateway?method=monitor_manage.trap_manage.add_trap",
  583. data: this.qs.stringify({
  584. trap_id: this.ruleForm.trap_id, // 非必传(num) 诱捕器id 修改项
  585. trap_number: this.ruleForm.trap_number, // 必传(string) 设备编号
  586. lat: this.ToDigital(this.ruleForm.lat), // 必传(string) 纬度
  587. lng: this.ToDigital(this.ruleForm.lng), // 必传(string) 经度
  588. org_id: org_id, // 必传(string) 所属海关id
  589. inducer_id: this.ruleForm.inducer_id, // 必传(string) 诱剂id
  590. point_id: this.ruleForm.point_id, // 必传(string) 所属监测点id
  591. trap_status: this.ruleForm.trap_status, // 必传(string) 设备状态0停用 1正常
  592. parameter: this.parameter,
  593. }),
  594. }).then((res) => {
  595. console.log(res);
  596. if (res.data.data) {
  597. var message = "";
  598. if (this.parameter == "add") {
  599. // console.log(this.$data.addtitle)
  600. message = "添加成功!";
  601. } else if (this.parameter == "modify") {
  602. message = "修改成功!";
  603. }
  604. this.$message({
  605. showClose: true,
  606. message: message,
  607. type: "success",
  608. });
  609. this.addtraptf = false;
  610. this.getcbdlist();
  611. } else {
  612. this.$message({
  613. showClose: true,
  614. message: "添加失败" + res.data.message,
  615. type: "warning",
  616. });
  617. }
  618. this.releaseTF = false;
  619. });
  620. } else {
  621. if (document.getElementsByClassName("el-message").length == 0) {
  622. this.$message({
  623. message: "请将信息填写完全",
  624. type: "warning",
  625. });
  626. }
  627. return false;
  628. }
  629. });
  630. },
  631. resetForm(formName) {
  632. this.addtraptf = false;
  633. this.$refs[formName].resetFields();
  634. for (var key in this.ruleForm) {
  635. this.ruleForm[key] = "";
  636. }
  637. },
  638. addtrap(e) {
  639. //增加诱捕器
  640. console.log(e);
  641. // this.
  642. for (var key in this.ruleForm) {
  643. this.ruleForm[key] = e[key];
  644. }
  645. // console.log(this.ruleForm.org_id);
  646. this.ruleForm.trap_status = this.ruleForm.trap_status.toString();
  647. this.parameter = "modify";
  648. this.ruleForm.org_id = [];
  649. for (var i = 0; i < e.org_list.length; i++) {
  650. var arr = [e.org_list[i].org_id];
  651. this.ruleForm.org_id.push(arr);
  652. }
  653. this.getmon3(e.trap_id);
  654. },
  655. getmon3(trap_id) {
  656. this.$axios({
  657. method: "POST",
  658. url: "/api/api_gateway?method=sysmenage.usermanager.get_parent_org_list;",
  659. data: this.qs.stringify({
  660. device_id: trap_id,
  661. }),
  662. }).then((res) => {
  663. // console.log(res.data.data);
  664. var orgdatas = res.data.data;
  665. if (orgdatas.length != 0) {
  666. for (var i = 0; i < orgdatas.length; i++) {
  667. if (orgdatas[i].lenngth != 0) {
  668. for (var j = 0; j < orgdatas[i].length; j++) {
  669. this.ruleForm.org_id[i].unshift(orgdatas[i][j].org_id);
  670. }
  671. }
  672. }
  673. }
  674. console.log(this.ruleForm.org_id);
  675. this.addtraptf = true;
  676. });
  677. },
  678. deletes(events) {
  679. //删除诱捕器
  680. console.log(events);
  681. var str = "您确定删除编号为<" + events.trap_number + ">的诱捕器吗?";
  682. this.$confirm(str, "删除诱捕器", {
  683. confirmButtonText: "确定",
  684. cancelButtonText: "取消",
  685. })
  686. .then(() => {
  687. this.$axios({
  688. method: "POST",
  689. url: "/api/api_gateway?method=monitor_manage.trap_manage.add_trap",
  690. data: this.qs.stringify({
  691. trap_id: events.trap_id,
  692. parameter: "del",
  693. }),
  694. }).then((res) => {
  695. console.log(res);
  696. if (res.data.data) {
  697. this.$message({
  698. showClose: true,
  699. message: "删除成功!",
  700. type: "success",
  701. });
  702. this.getcbdlist();
  703. } else {
  704. this.$message({
  705. showClose: true,
  706. message: "删除失败," + res.data.message,
  707. type: "warning",
  708. });
  709. }
  710. });
  711. })
  712. .catch(() => {
  713. this.$message({
  714. type: "info",
  715. message: "已取消删除",
  716. });
  717. });
  718. },
  719. handle(ev) {
  720. this.downloadinput = ev.name;
  721. var datas = new FormData();
  722. datas.append("username", localStorage.getItem("usernme"));
  723. datas.append("file", ev.raw);
  724. this.$axios({
  725. method: "POST",
  726. url: "/api/trap_export",
  727. data: datas,
  728. responseType: "blob",
  729. }).then((res) => {
  730. console.log(res);
  731. this.downloadFile(res, "allot_result.xls");
  732. });
  733. },
  734. download() {
  735. //下载模板
  736. console.log(22222);
  737. window.location.href =
  738. // this.$deriveData +
  739. // "http://192.168.1.77:12345/api/trap_export";1
  740. this.$deriveData + "/api/trap_export";
  741. },
  742. downloadFile(res, name) {
  743. let link = document.createElement("a");
  744. link.href = window.URL.createObjectURL(new Blob([res.data]));
  745. link.target = "_blank";
  746. //文件名和格式
  747. link.download = name;
  748. document.body.appendChild(link);
  749. link.click();
  750. document.body.removeChild(link);
  751. this.deriveTF = false
  752. },
  753. deriveclick() {
  754. // this.deriveVisible = false;
  755. if (this.derivefilename == "") {
  756. this.$message({
  757. showClose: true,
  758. message: "请输入文件名称",
  759. type: "warning",
  760. });
  761. } else {
  762. this.deriveTF = true
  763. this.$axios({
  764. method: "POST",
  765. url: "api/trap_list_export",
  766. data: this.qs.stringify({
  767. trap_number: this.ruleForm.trap_number,
  768. point_id: this.ruleForm.point_id,
  769. org_id: this.ruleForm.org_id,
  770. trap_status: this.ruleForm.trap_status,
  771. file_name: this.derivefilename,
  772. user: localStorage.getItem("usernme"),
  773. }),
  774. responseType: "blob",
  775. }).then((res) => {
  776. console.log(res);
  777. this.downloadFile(res, this.derivefilename + ".xls");
  778. });
  779. }
  780. },
  781. reset() {
  782. //重置
  783. this.idinput = "";
  784. this.trapvalue = "";
  785. this.inoffvalue = "";
  786. this.queryInfo.trap_number = "";
  787. this.queryInfo.point_id = "";
  788. this.queryInfo.org_id = "";
  789. this.queryInfo.trap_status = "";
  790. this.versionsvalue2 = "";
  791. this.versionsvalue = [];
  792. this.getcbdlist();
  793. },
  794. init() {
  795. console.log(document.getElementById("mapContainer2"));
  796. var map = new AMap.Map("mapContainer2", {
  797. center: this.center,
  798. resizeEnable: true,
  799. zoom: 10,
  800. lang: "en",
  801. });
  802. AMap.plugin(["AMap.ToolBar", "AMap.Geocoder"], () => {
  803. map.addControl(new AMap.ToolBar());
  804. this.geocoder = new AMap.Geocoder({
  805. city: "全国",
  806. radius: 1000,
  807. });
  808. });
  809. setTimeout(() => {
  810. var marker = new AMap.Marker({
  811. position: this.center,
  812. });
  813. console.log(this.center);
  814. marker.setMap(map);
  815. }, 1000);
  816. this.map = map;
  817. this.testevent();
  818. },
  819. addrChange() {
  820. //位置搜索
  821. var marker = new AMap.Marker();
  822. this.geocoder.getLocation(this.addr, (status, result) => {
  823. if (status === "complete" && result.geocodes.length) {
  824. var lnglat = result.geocodes[0].location;
  825. marker.setPosition(lnglat);
  826. this.map.add(marker);
  827. this.map.setFitView(marker);
  828. this.locationForm = {
  829. lat: lnglat.lat,
  830. lng: lnglat.lng,
  831. };
  832. } else {
  833. this.$message.error("根据地址查询位置失败");
  834. }
  835. });
  836. },
  837. // 地图点击事件
  838. testevent() {
  839. this.map.on("click", (ev) => {
  840. var lnglat = [ev.lnglat.lng, ev.lnglat.lat];
  841. this.locationForm = { lng: lnglat[0], lat: lnglat[1] };
  842. this.map.clearMap();
  843. var marker = new AMap.Marker({
  844. position: lnglat,
  845. });
  846. marker.setMap(this.map);
  847. this.getAddress(lnglat);
  848. setTimeout(() => {
  849. new AMap.InfoWindow({
  850. content: "<h5>" + "当前选中地址" + "</h5>" + this.address,
  851. offset: new AMap.Pixel(0, -32),
  852. }).open(this.map, lnglat);
  853. }, 100);
  854. });
  855. },
  856. getAddress(lnglat) {
  857. AMap.plugin("AMap.Geocoder", () => {
  858. this.geocoder.getAddress(lnglat, (status, result) => {
  859. if (status === "complete" && result.info === "OK") {
  860. this.address = result.regeocode.formattedAddress;
  861. }
  862. });
  863. });
  864. },
  865. addLocationSubm() {
  866. //点击确定
  867. this.ruleForm.lng = this.locationForm.lng;
  868. this.ruleForm.lat = this.locationForm.lat;
  869. this.addLocationDialogVisible = false;
  870. },
  871. addLocationDialogClosed() {
  872. //弹框关闭时
  873. this.locationForm = { lat: "", lng: "" };
  874. this.center = [];
  875. this.map = null;
  876. },
  877. locationSearch() {
  878. if (this.locationForm.lat && this.locationForm.lng) {
  879. let lnglat = [this.locationForm.lng, this.locationForm.lat];
  880. var marker = new AMap.Marker({
  881. position: lnglat,
  882. });
  883. marker.setMap(this.map);
  884. } else {
  885. this.$message.warning("请输入经纬度!");
  886. // return fasle;
  887. }
  888. },
  889. dingwei() {
  890. console.log(this.ruleForm);
  891. if (this.ruleForm.lng != "" && this.ruleForm.lng != 0) {
  892. this.center[0] = this.ruleForm.lng;
  893. } else {
  894. this.center = [114.05, 22.55];
  895. }
  896. if (this.ruleForm.lat != "" && this.ruleForm.lat != 0) {
  897. this.center[1] = this.ruleForm.lat;
  898. } else {
  899. this.center = [114.05, 22.55];
  900. }
  901. this.addLocationDialogVisible = true;
  902. setTimeout(() => {
  903. this.init();
  904. }, 500);
  905. },
  906. //度转度°分′秒″
  907. ToDegrees(val, type) {
  908. if (typeof val == "undefined" || val == "" || isNaN(val)) {
  909. return val;
  910. }
  911. val = val.toString();
  912. var A = "";
  913. if (type == "lng") {
  914. A = val > 0 ? "E" : "W";
  915. } else if (type == "lat") {
  916. A = val > 0 ? "N" : "S";
  917. }
  918. var i = val.indexOf(".");
  919. var strDu = i < 0 ? val : val.substring(0, i); //获取度
  920. var strFen = 0;
  921. var strMiao = 0;
  922. if (i > 0) {
  923. var strFen = "0" + val.substring(i);
  924. strFen = strFen * 60 + "";
  925. i = strFen.indexOf(".");
  926. if (i > 0) {
  927. strMiao = "0" + strFen.substring(i);
  928. strFen = strFen.substring(0, i); //获取分
  929. strMiao = strMiao * 60 + "";
  930. i = strMiao.indexOf(".");
  931. strMiao = strMiao.substring(0, i + 4); //取到小数点后面三位
  932. strMiao = parseFloat(strMiao).toFixed(2); //精确小数点后面两位
  933. }
  934. }
  935. // console.log(strDu, strFen, strMiao);
  936. return strDu + "°" + strFen + "′" + strMiao + "″" + A;
  937. },
  938. //度°分′秒″转度
  939. ToDigital(lnglat) {
  940. if (!isNaN(lnglat)) {
  941. return lnglat;
  942. }
  943. console.log(lnglat);
  944. lnglat = lnglat.toString();
  945. var strDu, strFen, strMiao;
  946. var duindex = lnglat.indexOf("°"); //字符度的下标
  947. var fenindex = lnglat.indexOf("′"); //字符分的下标
  948. var miaoindex = lnglat.indexOf("″"); //字符秒的下标
  949. strDu = lnglat.slice(0, duindex);
  950. strFen = lnglat.slice(duindex + 1, fenindex);
  951. strMiao = lnglat.slice(fenindex + 1, miaoindex);
  952. // len = len > 6 || typeof len == "undefined" ? 6 : len; //精确到小数点后最多六位
  953. strDu =
  954. typeof strDu == "undefined" || strDu == "" ? 0 : parseFloat(strDu);
  955. strFen =
  956. typeof strFen == "undefined" || strFen == ""
  957. ? 0
  958. : parseFloat(strFen) / 60;
  959. strMiao =
  960. typeof strMiao == "undefined" || strMiao == ""
  961. ? 0
  962. : parseFloat(strMiao) / 3600;
  963. var digital = strDu + strFen + strMiao;
  964. if (digital == 0) {
  965. return "";
  966. } else {
  967. return digital.toFixed(6);
  968. }
  969. },
  970. orglisthover(e) {
  971. console.log(e);
  972. var str = ``;
  973. for (var i = 0; i < e.org_list.length; i++) {
  974. str += `<p>` + e.org_list[i].org_name + `</p>`;
  975. }
  976. this.content = str;
  977. },
  978. },
  979. beforeCreate() {}, //生命周期 - 创建之前
  980. //生命周期 - 创建完成(可以访问当前this实例)
  981. created() {},
  982. beforeMount() {}, //生命周期 - 挂载之前
  983. //生命周期 - 挂载完成(可以访问DOM元素)
  984. mounted() {
  985. this.getmon();
  986. this.getmon2();
  987. this.getcbdlist();
  988. },
  989. beforeUpdate() {}, //生命周期 - 更新之前
  990. updated() {}, //生命周期 - 更新之后
  991. beforeDestroy() {}, //生命周期 - 销毁之前
  992. destroyed() {}, //生命周期 - 销毁完成
  993. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  994. };
  995. </script>
  996. <style scoped lang="less">
  997. .cbdbox {
  998. height: 100%;
  999. }
  1000. .cbdboxs_search {
  1001. display: flex;
  1002. justify-content: flex-start;
  1003. // height: 40px;
  1004. .el-select {
  1005. width: 250px;
  1006. margin-right: 15px;
  1007. }
  1008. .el-input {
  1009. width: 250px;
  1010. margin-right: 15px;
  1011. }
  1012. .el-cascader {
  1013. width: 250px;
  1014. margin-right: 15px;
  1015. }
  1016. }
  1017. .cbdboxs_table {
  1018. margin-top: 15px;
  1019. /deep/.el-table__header-wrapper {
  1020. th {
  1021. background-color: #fafafa;
  1022. }
  1023. }
  1024. .state {
  1025. display: flex;
  1026. p:first-child {
  1027. font-size: 40px;
  1028. }
  1029. }
  1030. }
  1031. .addtrapbox {
  1032. display: flex;
  1033. }
  1034. .buttonbox {
  1035. margin-bottom: 23px;
  1036. padding-left: 100px;
  1037. }
  1038. .downloadbox {
  1039. .downloadbox_item {
  1040. display: flex;
  1041. .title {
  1042. width: 100px;
  1043. line-height: 28px;
  1044. }
  1045. .el-input {
  1046. width: 250px;
  1047. margin-left: 15px;
  1048. }
  1049. }
  1050. .tishi {
  1051. padding-left: 100px;
  1052. margin-top: 15px;
  1053. display: flex;
  1054. justify-content: space-between;
  1055. color: #409eff;
  1056. span:last-child {
  1057. cursor: pointer;
  1058. }
  1059. }
  1060. }
  1061. .derivebox {
  1062. display: flex;
  1063. p {
  1064. width: 100px;
  1065. line-height: 28px;
  1066. span {
  1067. color: red;
  1068. }
  1069. }
  1070. .el-input {
  1071. width: 250px;
  1072. }
  1073. }
  1074. /deep/.el-button--info {
  1075. background-color: #409eff;
  1076. border-color: #409eff;
  1077. }
  1078. /deep/.el-date-editor {
  1079. cursor: pointer;
  1080. .el-range-input {
  1081. cursor: pointer;
  1082. }
  1083. }
  1084. </style>