sensorModel.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div class="sensorModelPanel">
  3. <model-list
  4. ref="modelList"
  5. class="modelList"
  6. :getListApi="getListApi"
  7. :showName="showName"
  8. @showInfo="showInfo"
  9. @addOne="addOne"
  10. @delOne="delOne"
  11. :curOne="curOne"
  12. ></model-list>
  13. <div class="contentPanel">
  14. <toolbarTab
  15. :isConnect="true"
  16. position="top"
  17. :subPageActiveName="subPageActiveName"
  18. :toolbarItem="subPageList"
  19. @toolbarClick="toolsControl"
  20. >
  21. </toolbarTab>
  22. <div class="tabContent">
  23. <form-camera
  24. v-show="subPageActiveName === 1"
  25. ref="form1"
  26. @getList="getList"
  27. @changeShare="changeShare"
  28. @showDone="showDone"
  29. @clearForm="addOne"
  30. @inputChange="inputChange"
  31. ></form-camera>
  32. <form-perfect-sensor
  33. v-show="subPageActiveName === 2"
  34. ref="form2"
  35. @getList="getList"
  36. @changeShare="changeShare"
  37. @showDone="showDone"
  38. @clearForm="addOne"
  39. @inputChange="inputChangeA"
  40. ></form-perfect-sensor>
  41. <form-laser-radar
  42. v-show="subPageActiveName === 3"
  43. ref="form3"
  44. @getList="getList"
  45. @changeShare="changeShare"
  46. @showDone="showDone"
  47. @clearForm="addOne"
  48. @inputChange="inputChange"
  49. ></form-laser-radar>
  50. <!-- <form-millimeter-wave-radar
  51. v-show="subPageActiveName === 4"
  52. ></form-millimeter-wave-radar> -->
  53. <form-gps
  54. v-show="subPageActiveName === 4"
  55. ref="form4"
  56. @getList="getList"
  57. @changeShare="changeShare"
  58. @clearForm="addOne"
  59. ></form-gps>
  60. <div class="model">
  61. <!-- <img :src="imgSrc" width="100%" /> -->
  62. <!-- <canvas-sensor
  63. v-show="subPageActiveName != 2"
  64. ref="canvasSensor"
  65. :coordinate="coordinate"
  66. ></canvas-sensor>
  67. <canvas-sensorA
  68. v-show="subPageActiveName === 2"
  69. ref="canvasSensorA"
  70. :coordinate="coordinateA"
  71. ></canvas-sensorA> -->
  72. <three-show
  73. v-loading="loading"
  74. @loadingDone="loadingDone"
  75. ref="threeShow"
  76. :coordinate="coordinate"
  77. :coordinateA="coordinateA"
  78. :type="subPageActiveName"
  79. ></three-show>
  80. </div>
  81. </div>
  82. <div class="btns">
  83. <el-button
  84. type="primary"
  85. v-show="currentShare === '0' || currentShare === ''"
  86. @click="save(false)"
  87. >保存</el-button
  88. >
  89. <el-button
  90. type="primary"
  91. v-if="roleCode === '0' || roleCode === '1'"
  92. v-show="currentShare === '0'"
  93. @click="share"
  94. >分享</el-button
  95. >
  96. <el-button
  97. type="primary"
  98. v-show="currentShare === '0' || currentShare === '1'"
  99. @click="save(true)"
  100. >另存为</el-button
  101. >
  102. <el-button type="primary" plain @click="cancel">取消</el-button>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import modelList from "./components/modelList.vue";
  109. import toolbarTab from "@/components/toolbar/toolbarTab";
  110. import { mapState } from "vuex";
  111. import formCamera from "./components/formCamera.vue";
  112. import formPerfectSensor from "./components/formPerfectSensor.vue";
  113. import formLaserRadar from "./components/formLaserRadar.vue";
  114. import formMillimeterWaveRadar from "./components/formMillimeterWaveRadar.vue";
  115. import formGps from "./components/formGps.vue";
  116. import canvasSensor from "./components/canvasSensorModel.vue";
  117. import canvasSensorA from "./components/canvasSensorModelA.vue";
  118. import threeShow from "./components/threeSensorModel.vue";
  119. export default {
  120. name: "sensorModel", // 传感器配置
  121. components: {
  122. modelList,
  123. toolbarTab,
  124. formCamera,
  125. formPerfectSensor,
  126. formLaserRadar,
  127. formMillimeterWaveRadar,
  128. formGps,
  129. canvasSensor,
  130. canvasSensorA,
  131. threeShow,
  132. },
  133. data() {
  134. return {
  135. getListApi: this.$api.modelLibrary.getCameraList,
  136. showName: "sensorName",
  137. subPageActiveName: 1,
  138. fromId: 1,
  139. imgSrc: require("@/assets/common/image/others/carTopView.png"),
  140. currentShare: "",
  141. coordinate: { f: 0, n: 0, h: 0, v: 0 }, // 存放传递给three的值
  142. coordinateA: { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 }, // 存放传递给three的值
  143. // coordinate: { r: 0, h: 0, n: 0 }, // 存放传递给canvas的值
  144. // coordinateA: { r: 0, n: 0, hl: 0, hr: 0 }, // 存放传递给完美传感器canvas的值
  145. // 用于当前选中项的展示
  146. curOne: {
  147. share: "",
  148. id: "",
  149. },
  150. loading: true,
  151. };
  152. },
  153. computed: {
  154. ...mapState(["configTitleList", "roleCode"]),
  155. subPageList() {
  156. return [
  157. {
  158. type: "primary",
  159. plain: true,
  160. title: this.configTitleList[0],
  161. disabled: false,
  162. api: this.$api.modelLibrary.getCameraList,
  163. fromId: 1,
  164. },
  165. {
  166. type: "primary",
  167. plain: true,
  168. title: this.configTitleList[1],
  169. disabled: false,
  170. api: this.$api.modelLibrary.getOgtList,
  171. fromId: 2,
  172. },
  173. {
  174. type: "primary",
  175. plain: true,
  176. title: this.configTitleList[2],
  177. disabled: false,
  178. api: this.$api.modelLibrary.getLidarList,
  179. fromId: 3,
  180. },
  181. {
  182. type: "primary",
  183. plain: true,
  184. title: this.configTitleList[3],
  185. disabled: false,
  186. api: this.$api.modelLibrary.getGpsList,
  187. fromId: 4,
  188. },
  189. // {
  190. // type: "primary",
  191. // plain: true,
  192. // title: this.configTitleList[4],
  193. // disabled: false,
  194. // fromId: 5,
  195. // },
  196. ];
  197. },
  198. },
  199. methods: {
  200. toolsControl(item) {
  201. this.addOne();
  202. this.getListApi = item.api;
  203. this.subPageActiveName = item.fromId;
  204. this.$nextTick(() => {
  205. this.getList();
  206. });
  207. // this.$refs.canvasSensor.clear();
  208. // this.$refs.canvasSensorA.clear();
  209. this.coordinate = { f: 0, n: 0, h: 0, v: 0 };
  210. this.coordinateA = { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 };
  211. setTimeout(() => {
  212. this.$refs.threeShow.initContent();
  213. }, 0);
  214. this.curOne = {
  215. share: "",
  216. id: "",
  217. };
  218. },
  219. showInfo(id) {
  220. this.$refs[`form${this.subPageActiveName}`].showInfo(id);
  221. },
  222. getList() {
  223. this.$refs.modelList.getList();
  224. },
  225. save(isAdd) {
  226. this.$refs[`form${this.subPageActiveName}`].save(isAdd);
  227. },
  228. share() {
  229. this.$refs[`form${this.subPageActiveName}`].share();
  230. },
  231. cancel() {
  232. this.$refs[`form${this.subPageActiveName}`].cancel();
  233. // this.$refs.canvasSensor.clear();
  234. // this.$refs.canvasSensorA.clear();
  235. this.coordinate = { f: 0, n: 0, h: 0, v: 0 };
  236. this.coordinateA = { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 };
  237. setTimeout(() => {
  238. this.$refs.threeShow.initContent();
  239. }, 0);
  240. },
  241. changeShare(form) {
  242. // 根据form传回的share进行按钮展示
  243. this.currentShare = form.share;
  244. // 确定当前展示哪条数据
  245. this.curOne = {
  246. share: form.share,
  247. id: form.id,
  248. };
  249. },
  250. showDone() {
  251. this.$refs[`form${this.subPageActiveName}`].inputChange();
  252. },
  253. addOne() {
  254. this.$refs[
  255. `form${this.subPageActiveName}`
  256. ].$refs.form.resetFields();
  257. this.$refs[`form${this.subPageActiveName}`].form.sensorCode = "";
  258. this.$refs[`form${this.subPageActiveName}`].form.share = "";
  259. this.$refs[`form${this.subPageActiveName}`].form.id = "";
  260. this.currentShare = "";
  261. // this.$refs.canvasSensor.clear();
  262. // this.$refs.canvasSensorA.clear();
  263. this.coordinate = { f: 0, n: 0, h: 0, v: 0 };
  264. this.coordinateA = { f: 0, n: 0, hl: 0, hr: 0, vt: 0, vb: 0 };
  265. setTimeout(() => {
  266. this.$refs.threeShow.initContent();
  267. }, 0);
  268. this.curOne = {
  269. share: "",
  270. id: "",
  271. };
  272. },
  273. delOne(id) {
  274. const delApis = [
  275. this.$api.modelLibrary.delCameraById,
  276. this.$api.modelLibrary.delOgtById,
  277. this.$api.modelLibrary.delLidarById,
  278. this.$api.modelLibrary.delGpsById,
  279. ];
  280. this.$axios({
  281. method: "post",
  282. url: delApis[this.subPageActiveName - 1],
  283. data: {
  284. id,
  285. },
  286. }).then((res) => {
  287. if (res.code == 200) {
  288. this.$message.success("删除成功");
  289. this.$refs.modelList.getList();
  290. if (
  291. this.$refs[`form${this.subPageActiveName}`].form.id &&
  292. id ===
  293. this.$refs[`form${this.subPageActiveName}`].form.id
  294. ) {
  295. this.addOne();
  296. }
  297. if (id === this.curOne.id) {
  298. this.curOne = {
  299. share: "",
  300. id: "",
  301. };
  302. }
  303. } else {
  304. this.$message.error(res.message || "删除失败");
  305. }
  306. });
  307. },
  308. inputChange(data) {
  309. this.coordinate = data;
  310. setTimeout(() => {
  311. this.$refs.threeShow.initContent();
  312. }, 0);
  313. },
  314. inputChangeA(data) {
  315. this.coordinateA = data;
  316. setTimeout(() => {
  317. this.$refs.threeShow.initContent();
  318. }, 0);
  319. },
  320. loadingDone(done) {
  321. if (done === 'carDone') {
  322. this.loading = false;
  323. }else {
  324. this.loading = true;
  325. }
  326. },
  327. },
  328. // mounted() {},
  329. };
  330. </script>
  331. <style lang='less' scoped>
  332. .sensorModelPanel {
  333. display: flex;
  334. flex: 1;
  335. padding: 15px 30px 30px 363px;
  336. .modelList {
  337. position: fixed;
  338. top: 65px;
  339. left: 180px;
  340. z-index: 6;
  341. background: #ffffff;
  342. }
  343. .modelList /deep/ .listPanel {
  344. min-height: 400px;
  345. height: calc(100vh - 150px);
  346. }
  347. .contentPanel {
  348. flex: 1;
  349. padding-left: 30px;
  350. }
  351. .tabContent {
  352. display: flex;
  353. padding-top: 15px;
  354. .model {
  355. flex: 1;
  356. min-width: 300px;
  357. // padding-left: 40px;
  358. padding-left: 6%;
  359. // padding-right: 3%;
  360. }
  361. }
  362. .btns {
  363. padding-top: 30px;
  364. padding-left: 390px;
  365. }
  366. /deep/ .el-tabs__item {
  367. width: 150px;
  368. }
  369. }
  370. </style>