sensorModel.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. ></model-list>
  12. <div class="contentPanel">
  13. <toolbarTab
  14. :isConnect="true"
  15. position="top"
  16. :subPageActiveName="subPageActiveName"
  17. :toolbarItem="subPageList"
  18. @toolbarClick="toolsControl"
  19. >
  20. </toolbarTab>
  21. <div class="tabContent">
  22. <form-camera
  23. v-show="subPageActiveName === 1"
  24. ref="form1"
  25. @getList="getList"
  26. @changeShare="changeShare"
  27. @clearForm="addOne"
  28. ></form-camera>
  29. <form-perfect-sensor
  30. v-show="subPageActiveName === 2"
  31. ref="form2"
  32. @getList="getList"
  33. @changeShare="changeShare"
  34. @clearForm="addOne"
  35. ></form-perfect-sensor>
  36. <form-laser-radar
  37. v-show="subPageActiveName === 3"
  38. ref="form3"
  39. @getList="getList"
  40. @changeShare="changeShare"
  41. @clearForm="addOne"
  42. ></form-laser-radar>
  43. <!-- <form-millimeter-wave-radar
  44. v-show="subPageActiveName === 4"
  45. ></form-millimeter-wave-radar> -->
  46. <form-gps
  47. v-show="subPageActiveName === 4"
  48. ref="form4"
  49. @getList="getList"
  50. @changeShare="changeShare"
  51. @clearForm="addOne"
  52. ></form-gps>
  53. <div class="model">
  54. <img :src="imgSrc" width="100%" />
  55. </div>
  56. </div>
  57. <div class="btns">
  58. <el-button
  59. type="primary"
  60. v-show="currentShare === '0' || currentShare === ''"
  61. @click="save(false)"
  62. >保存</el-button
  63. >
  64. <el-button
  65. type="primary"
  66. v-show="currentShare === '0'"
  67. @click="share"
  68. >分享</el-button
  69. >
  70. <el-button
  71. type="primary"
  72. v-show="currentShare === '0' || currentShare === '1'"
  73. @click="save(true)"
  74. >另存为</el-button
  75. >
  76. <el-button type="primary" plain @click="cancel">取消</el-button>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import modelList from "./components/modelList.vue";
  83. import toolbarTab from "@/components/toolbar/toolbarTab";
  84. import { mapState } from "vuex";
  85. import formCamera from "./components/formCamera.vue";
  86. import formPerfectSensor from "./components/formPerfectSensor.vue";
  87. import formLaserRadar from "./components/formLaserRadar.vue";
  88. import formMillimeterWaveRadar from "./components/formMillimeterWaveRadar.vue";
  89. import formGps from "./components/formGps.vue";
  90. export default {
  91. name: "sensorModel", // 传感器模型
  92. components: {
  93. modelList,
  94. toolbarTab,
  95. formCamera,
  96. formPerfectSensor,
  97. formLaserRadar,
  98. formMillimeterWaveRadar,
  99. formGps,
  100. },
  101. data() {
  102. return {
  103. getListApi: this.$api.modelLibrary.getCameraList,
  104. showName: "sensorName",
  105. subPageActiveName: 1,
  106. fromId: 1,
  107. imgSrc: require("@/assets/common/image/car.png"),
  108. currentShare: "",
  109. };
  110. },
  111. computed: {
  112. ...mapState(["configTitleList"]),
  113. subPageList() {
  114. return [
  115. {
  116. type: "primary",
  117. plain: true,
  118. title: this.configTitleList[0],
  119. disabled: false,
  120. api: this.$api.modelLibrary.getCameraList,
  121. fromId: 1,
  122. },
  123. {
  124. type: "primary",
  125. plain: true,
  126. title: this.configTitleList[1],
  127. disabled: false,
  128. api: this.$api.modelLibrary.getOgtList,
  129. fromId: 2,
  130. },
  131. {
  132. type: "primary",
  133. plain: true,
  134. title: this.configTitleList[2],
  135. disabled: false,
  136. api: this.$api.modelLibrary.getLidarList,
  137. fromId: 3,
  138. },
  139. {
  140. type: "primary",
  141. plain: true,
  142. title: this.configTitleList[3],
  143. disabled: false,
  144. api: this.$api.modelLibrary.getGpsList,
  145. fromId: 4,
  146. },
  147. // {
  148. // type: "primary",
  149. // plain: true,
  150. // title: this.configTitleList[4],
  151. // disabled: false,
  152. // fromId: 5,
  153. // },
  154. ];
  155. },
  156. },
  157. methods: {
  158. toolsControl(item) {
  159. this.addOne();
  160. this.getListApi = item.api;
  161. this.subPageActiveName = item.fromId;
  162. this.$nextTick(() => {
  163. this.getList();
  164. });
  165. },
  166. showInfo(id) {
  167. this.$refs[`form${this.subPageActiveName}`].showInfo(id);
  168. },
  169. getList() {
  170. this.$refs.modelList.getList();
  171. },
  172. save(isAdd) {
  173. this.$refs[`form${this.subPageActiveName}`].save(isAdd);
  174. },
  175. share() {
  176. this.$refs[`form${this.subPageActiveName}`].share();
  177. },
  178. cancel() {
  179. this.$refs[`form${this.subPageActiveName}`].cancel();
  180. },
  181. changeShare(share) {
  182. // 根据form传回的share进行按钮展示
  183. this.currentShare = share;
  184. },
  185. addOne() {
  186. this.$refs[
  187. `form${this.subPageActiveName}`
  188. ].$refs.form.resetFields();
  189. this.$refs[`form${this.subPageActiveName}`].form.sensorCode = "";
  190. this.$refs[`form${this.subPageActiveName}`].form.share = "";
  191. this.$refs[`form${this.subPageActiveName}`].form.id = "";
  192. this.currentShare = "";
  193. },
  194. delOne(id) {
  195. const delApis = [
  196. this.$api.modelLibrary.delCameraById,
  197. this.$api.modelLibrary.delOgtById,
  198. this.$api.modelLibrary.delLidarById,
  199. this.$api.modelLibrary.delGpsById,
  200. ];
  201. this.$axios({
  202. method: "post",
  203. url: delApis[this.subPageActiveName - 1],
  204. data: {
  205. id,
  206. },
  207. }).then((res) => {
  208. if (res.code == 200) {
  209. this.$message.success("删除成功");
  210. this.$refs.modelList.getList();
  211. } else {
  212. this.$message.error(res.message || "删除失败");
  213. }
  214. });
  215. },
  216. },
  217. // mounted() {},
  218. };
  219. </script>
  220. <style lang='less' scoped>
  221. .sensorModelPanel {
  222. display: flex;
  223. flex: 1;
  224. padding: 15px 30px 30px;
  225. .modelList /deep/ .listPanel {
  226. min-height: 400px;
  227. height: calc(100vh - 200px);
  228. }
  229. .contentPanel {
  230. flex: 1;
  231. padding-left: 30px;
  232. }
  233. .tabContent {
  234. display: flex;
  235. padding-top: 15px;
  236. .model {
  237. min-width: 300px;
  238. padding-left: 40px;
  239. }
  240. }
  241. .btns {
  242. padding-top: 30px;
  243. padding-left: 390px;
  244. }
  245. /deep/ .el-tabs__item {
  246. width: 150px;
  247. }
  248. }
  249. </style>