sensorModelCanvas.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. </div>
  73. </div>
  74. <div class="btns">
  75. <el-button
  76. type="primary"
  77. v-show="currentShare === '0' || currentShare === ''"
  78. @click="save(false)"
  79. >保存</el-button
  80. >
  81. <el-button
  82. type="primary"
  83. v-if="roleCode === '0' || roleCode === '1'"
  84. v-show="currentShare === '0'"
  85. @click="share"
  86. >分享</el-button
  87. >
  88. <el-button
  89. type="primary"
  90. v-show="currentShare === '0' || currentShare === '1'"
  91. @click="save(true)"
  92. >另存为</el-button
  93. >
  94. <el-button type="primary" plain @click="cancel">取消</el-button>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import modelList from "./components/modelList.vue";
  101. import toolbarTab from "@/components/toolbar/toolbarTab";
  102. import { mapState } from "vuex";
  103. import formCamera from "./components/formCamera.vue";
  104. import formPerfectSensor from "./components/formPerfectSensor.vue";
  105. import formLaserRadar from "./components/formLaserRadar.vue";
  106. import formMillimeterWaveRadar from "./components/formMillimeterWaveRadar.vue";
  107. import formGps from "./components/formGps.vue";
  108. import canvasSensor from "./components/canvasSensorModel.vue";
  109. import canvasSensorA from "./components/canvasSensorModelA.vue";
  110. export default {
  111. name: "sensorModel", // 传感器配置
  112. components: {
  113. modelList,
  114. toolbarTab,
  115. formCamera,
  116. formPerfectSensor,
  117. formLaserRadar,
  118. formMillimeterWaveRadar,
  119. formGps,
  120. canvasSensor,
  121. canvasSensorA,
  122. },
  123. data() {
  124. return {
  125. getListApi: this.$api.modelLibrary.getCameraList,
  126. showName: "sensorName",
  127. subPageActiveName: 1,
  128. fromId: 1,
  129. imgSrc: require("@/assets/common/image/others/carTopView.png"),
  130. currentShare: "",
  131. coordinate: { r: 0, h: 0, n: 0 }, // 存放传递给canvas的值
  132. coordinateA: { r: 0, n: 0, hl: 0, hr: 0 }, // 存放传递给完美传感器canvas的值
  133. // 用于当前选中项的展示
  134. curOne: {
  135. share: "",
  136. id: "",
  137. },
  138. };
  139. },
  140. computed: {
  141. ...mapState(["configTitleList", "roleCode"]),
  142. subPageList() {
  143. return [
  144. {
  145. type: "primary",
  146. plain: true,
  147. title: this.configTitleList[0],
  148. disabled: false,
  149. api: this.$api.modelLibrary.getCameraList,
  150. fromId: 1,
  151. },
  152. {
  153. type: "primary",
  154. plain: true,
  155. title: this.configTitleList[1],
  156. disabled: false,
  157. api: this.$api.modelLibrary.getOgtList,
  158. fromId: 2,
  159. },
  160. {
  161. type: "primary",
  162. plain: true,
  163. title: this.configTitleList[2],
  164. disabled: false,
  165. api: this.$api.modelLibrary.getLidarList,
  166. fromId: 3,
  167. },
  168. {
  169. type: "primary",
  170. plain: true,
  171. title: this.configTitleList[3],
  172. disabled: false,
  173. api: this.$api.modelLibrary.getGpsList,
  174. fromId: 4,
  175. },
  176. // {
  177. // type: "primary",
  178. // plain: true,
  179. // title: this.configTitleList[4],
  180. // disabled: false,
  181. // fromId: 5,
  182. // },
  183. ];
  184. },
  185. },
  186. methods: {
  187. toolsControl(item) {
  188. this.addOne();
  189. this.getListApi = item.api;
  190. this.subPageActiveName = item.fromId;
  191. this.$nextTick(() => {
  192. this.getList();
  193. });
  194. this.$refs.canvasSensor.clear();
  195. this.$refs.canvasSensorA.clear();
  196. this.curOne = {
  197. share: "",
  198. id: "",
  199. };
  200. },
  201. showInfo(id) {
  202. this.$refs[`form${this.subPageActiveName}`].showInfo(id);
  203. },
  204. getList() {
  205. this.$refs.modelList.getList();
  206. },
  207. save(isAdd) {
  208. this.$refs[`form${this.subPageActiveName}`].save(isAdd);
  209. },
  210. share() {
  211. this.$refs[`form${this.subPageActiveName}`].share();
  212. },
  213. cancel() {
  214. this.$refs[`form${this.subPageActiveName}`].cancel();
  215. this.$refs.canvasSensor.clear();
  216. this.$refs.canvasSensorA.clear();
  217. },
  218. changeShare(form) {
  219. // 根据form传回的share进行按钮展示
  220. this.currentShare = form.share;
  221. // 确定当前展示哪条数据
  222. this.curOne = {
  223. share: form.share,
  224. id: form.id,
  225. };
  226. },
  227. showDone() {
  228. this.$refs[`form${this.subPageActiveName}`].inputChange();
  229. },
  230. addOne() {
  231. this.$refs[
  232. `form${this.subPageActiveName}`
  233. ].$refs.form.resetFields();
  234. this.$refs[`form${this.subPageActiveName}`].form.sensorCode = "";
  235. this.$refs[`form${this.subPageActiveName}`].form.share = "";
  236. this.$refs[`form${this.subPageActiveName}`].form.id = "";
  237. this.currentShare = "";
  238. this.$refs.canvasSensor.clear();
  239. this.$refs.canvasSensorA.clear();
  240. this.curOne = {
  241. share: "",
  242. id: "",
  243. };
  244. },
  245. delOne(id) {
  246. const delApis = [
  247. this.$api.modelLibrary.delCameraById,
  248. this.$api.modelLibrary.delOgtById,
  249. this.$api.modelLibrary.delLidarById,
  250. this.$api.modelLibrary.delGpsById,
  251. ];
  252. this.$axios({
  253. method: "post",
  254. url: delApis[this.subPageActiveName - 1],
  255. data: {
  256. id,
  257. },
  258. }).then((res) => {
  259. if (res.code == 200) {
  260. this.$message.success("删除成功");
  261. this.$refs.modelList.getList();
  262. if (
  263. this.$refs[`form${this.subPageActiveName}`].form.id &&
  264. id ===
  265. this.$refs[`form${this.subPageActiveName}`].form.id
  266. ) {
  267. this.addOne();
  268. }
  269. if (id === this.curOne.id) {
  270. this.curOne = {
  271. share: "",
  272. id: "",
  273. };
  274. }
  275. } else {
  276. this.$message.error(res.message || "删除失败");
  277. }
  278. });
  279. },
  280. inputChange(data) {
  281. this.coordinate = data;
  282. },
  283. inputChangeA(data) {
  284. this.coordinateA = data;
  285. },
  286. },
  287. // mounted() {},
  288. };
  289. </script>
  290. <style lang='less' scoped>
  291. .sensorModelPanel {
  292. display: flex;
  293. flex: 1;
  294. padding: 15px 30px 30px;
  295. .modelList /deep/ .listPanel {
  296. min-height: 400px;
  297. height: calc(100vh - 200px);
  298. }
  299. .contentPanel {
  300. flex: 1;
  301. padding-left: 30px;
  302. }
  303. .tabContent {
  304. display: flex;
  305. padding-top: 15px;
  306. .model {
  307. flex: 1;
  308. min-width: 300px;
  309. // padding-left: 40px;
  310. padding-left: 6%;
  311. padding-right: 3%;
  312. }
  313. }
  314. .btns {
  315. padding-top: 30px;
  316. padding-left: 390px;
  317. }
  318. /deep/ .el-tabs__item {
  319. width: 150px;
  320. }
  321. }
  322. </style>