benchmarkEdit.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <el-dialog title="基准场景筛选编辑" :visible.sync="dialogVisible" width="700" @close="dialogClose">
  3. <h3>标签类型</h3>
  4. <el-radio-group v-model="radio" style="display: flex; flex-wrap: wrap; justify-content: flex-start;"
  5. @input="radioChange">
  6. <el-radio style="margin: 5px 5px" label="sceneLibrodeType" border>道路类型</el-radio>
  7. <el-radio style="margin: 5px 5px;" label="egoAction" border>主车行动</el-radio>
  8. <el-radio style="margin: 5px 5px;" label="targetAction" border>它车行动</el-radio>
  9. <el-radio style="margin: 5px 5px;" label="sceneLibWeather" border>天气</el-radio>
  10. <el-radio style="margin: 5px 5px;" label="roadPlaneGeometry" border>道路平面几何</el-radio>
  11. <el-radio style="margin: 5px 5px;" label="roadProfileGeometry" border>道路几何-纵断面</el-radio>
  12. <el-radio style="margin: 5px 5px;" label="rodeSection" border>运行区域</el-radio>
  13. <el-radio style="margin: 5px 5px;" label="supportedAdas" border>智能驾驶</el-radio>
  14. <el-radio style="margin: 5px 5px;" label="complexityLevel" border>复杂度等级</el-radio>
  15. <el-radio style="margin: 5px 5px;" label="riskLevel" border>危险度等级</el-radio>
  16. </el-radio-group>
  17. <h3>下拉内容编辑</h3>
  18. <div style="display: flex; margin-bottom: 30px;">
  19. <el-tag :key="tag.id" v-for="tag in dynamicTags" closable :disable-transitions="false"
  20. @close="handleClose(tag.id)">
  21. {{ tag.dictName }}
  22. </el-tag>
  23. <el-input placeholder="请输入新增内容" style="width: 150px; margin-left: 20px;" v-if="inputVisible"
  24. v-model="inputValue" ref="saveTagInput" size="small" @keyup.enter.native="handleInputConfirm"
  25. @blur="handleInputConfirm">
  26. </el-input>
  27. <el-button v-else class="button-new-tag" size="small" @click="showInput">新增数据+</el-button>
  28. </div>
  29. <!-- <span slot="footer" class="dialog-footer">
  30. <el-button @click="dialogVisible = false">取 消</el-button>
  31. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  32. </span> -->
  33. </el-dialog>
  34. </template>
  35. <script>
  36. const dictionaryMap = {
  37. sceneLibrodeType: '道路类型',
  38. egoAction: '主车动作',
  39. targetAction: '它车动作',
  40. sceneLibWeather: '天气',
  41. roadPlaneGeometry: '道路平面几何',
  42. roadProfileGeometry: '道路几何-纵断面',
  43. rodeSection: '运行区域',
  44. supportedAdas: '智能驾驶',
  45. complexityLevel: '复杂度等级',
  46. riskLevel: '危险度等级',
  47. }
  48. export default {
  49. name: "benchmarkEdit", // 基准场景筛选项编辑
  50. components: {},
  51. data() {
  52. return {
  53. radio: 'sceneLibrodeType',
  54. dialogVisible: true,
  55. dictionaryList: {}, // 字典对象
  56. dynamicTags: [{ label: 'xxx', value: '123' }],
  57. inputVisible: false,
  58. inputValue: '',
  59. }
  60. },
  61. props: {
  62. // content: {
  63. // type: String,
  64. // default: "",
  65. // },
  66. // isEdit: {
  67. // type: Boolean,
  68. // default: true,
  69. // },
  70. },
  71. methods: {
  72. init(defaultType = 'sceneLibrodeType') {
  73. this.$axios({
  74. method: 'post',
  75. url: this.$api.common.getDictListsByTypes,
  76. data: { dictTypes: "egoAction,targetAction,sceneLibWeather,sceneLibrodeType,roadPlaneGeometry,roadProfileGeometry,supportedAdas,rodeSection,complexityLevel,riskLevel" },
  77. }).then((res) => {
  78. if (res.code == 200) {
  79. this.dictionaryList = res.info
  80. // 默认加载道路类型数据
  81. this.dynamicTags = res.info[defaultType] || []
  82. } else {
  83. this.$message.error(res.message || '查询失败')
  84. }
  85. })
  86. },
  87. radioChange(type) {
  88. this.dynamicTags = this.dictionaryList[type] || []
  89. },
  90. handleClose(tag) {
  91. console.log(tag)
  92. // this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
  93. this.$axios({
  94. method: 'post',
  95. url: this.$api.sceneLibrary.benchmarkSearchDelete,
  96. data: {
  97. id: tag,
  98. dictType: this.radio
  99. },
  100. }).then((res) => {
  101. if (res.code == 200) {
  102. this.$message.success('数据删除成功')
  103. this.init(this.radio)
  104. } else {
  105. this.$message.error(res.message || '删除失败')
  106. }
  107. })
  108. },
  109. showInput() {
  110. this.inputVisible = true;
  111. this.$nextTick(() => {
  112. this.$refs.saveTagInput.$refs.input.focus();
  113. });
  114. },
  115. handleInputConfirm() {
  116. console.log(this.radio, dictionaryMap[this.radio])
  117. let inputValue = this.inputValue;
  118. if (inputValue) {
  119. this.$axios({
  120. method: 'post',
  121. url: this.$api.sceneLibrary.benchmarkSearchCreate,
  122. data: {
  123. dictType: this.radio,
  124. dictName: this.inputValue,
  125. dictCode: this.inputValue,
  126. dictComment: dictionaryMap[this.radio]
  127. },
  128. }).then((res) => {
  129. if (res.code == 200) {
  130. this.$message.success('数据新增成功')
  131. this.init(this.radio)
  132. } else {
  133. this.$message.error(res.message || '新增失败')
  134. }
  135. this.inputVisible = false;
  136. this.inputValue = '';
  137. })
  138. }
  139. },
  140. dialogClose(){
  141. console.log('关闭')
  142. this.$emit('closeHandle');
  143. }
  144. },
  145. mounted() {
  146. this.init()
  147. },
  148. beforeDestroy() {
  149. },
  150. };
  151. </script>
  152. <style lang='less' scoped>
  153. .el-tag+.el-tag {
  154. margin-left: 10px;
  155. }
  156. .button-new-tag {
  157. margin-left: 10px;
  158. height: 32px;
  159. line-height: 30px;
  160. padding-top: 0;
  161. padding-bottom: 0;
  162. }
  163. .input-new-tag {
  164. border: 2px solid red;
  165. width: 50px;
  166. margin-left: 10px;
  167. vertical-align: bottom;
  168. }
  169. h3 {
  170. font-size: 18px;
  171. margin: 20px 0 10px;
  172. }
  173. </style>