Prequalification.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="main-container">
  3. <div class="switch-container">
  4. <div class="prequal-container" v-if="hasDevModePermisson()">
  5. <div>预审后生效模式:</div>
  6. <el-tooltip :disabled="devMode" effect="light" placement="bottom-start">
  7. <template #content>
  8. 开启后,违规数据将不直接在前台展示<br />在下方问题管理列表中,操作生效后,推送到前台问题列表展示
  9. </template>
  10. <el-switch :model-value="devMode" @change="handelSwitchDevMode" />
  11. </el-tooltip>
  12. </div>
  13. <div style="display: flex" v-if="hasDataDelete()">
  14. <div>报警视频截取时长:</div>
  15. <el-select
  16. v-model="videoLength"
  17. style="width: 80px; margin: 0 10px"
  18. @change="updateNewVideoLength"
  19. >
  20. <el-option v-for="item in videoLengthOptions" :key="item" :label="item" :value="item" />
  21. </el-select>
  22. <div>s</div>
  23. </div>
  24. </div>
  25. <div class="options-container" v-if="hasDevModePermisson() && devMode">
  26. <div class="option-title">直接推送问题类型:</div>
  27. <div class="option-tags" :class="expandAll ? 'hide-style' : ''" id="option-id">
  28. <el-tag
  29. class="option-tag"
  30. v-for="item in tags"
  31. :key="item.id"
  32. type="info"
  33. closable
  34. @close="handleDeleteTag(item)"
  35. >{{ item.algoName }}</el-tag
  36. >
  37. <el-tooltip effect="light" placement="top-start">
  38. <template #content>
  39. 选择可直接推送到前台展示的违规问题类型<br />选择后检测到该类型问题发生时直接展示在前台问题列表
  40. </template>
  41. <span>
  42. <el-popover placement="bottom" trigger="click" :width="265">
  43. <template #reference>
  44. <div class="add-options">+</div>
  45. </template>
  46. <el-select
  47. v-model="optionValue"
  48. multiple
  49. collapse-tags
  50. placeholder="请选择问题类型"
  51. style="width: 240px"
  52. :teleported="false"
  53. >
  54. <el-option
  55. v-for="item in options"
  56. :key="item.id"
  57. :label="item.name"
  58. :value="item.id"
  59. />
  60. <template #footer>
  61. <el-button type="primary" @click="handleAddTags"> 确定 </el-button>
  62. </template>
  63. </el-select>
  64. </el-popover>
  65. </span>
  66. </el-tooltip>
  67. </div>
  68. <div class="option-expand" @click="expandAll = !expandAll" v-if="isExpandAllExist">
  69. <div v-if="expandAll"
  70. ><el-icon><ArrowDown /></el-icon>展开</div
  71. >
  72. <div v-if="!expandAll"
  73. ><el-icon><ArrowUp /></el-icon>收起</div
  74. >
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script setup lang="ts">
  80. import { nextTick, onMounted, ref, watch } from 'vue';
  81. import {
  82. ElMessage,
  83. ElSwitch,
  84. ElSelect,
  85. ElOption,
  86. ElTooltip,
  87. ElTag,
  88. ElPopover,
  89. ElIcon,
  90. } from 'element-plus';
  91. import { ArrowDown, ArrowUp } from '@element-plus/icons-vue';
  92. import { useUserStore } from '@/store/modules/user';
  93. import {
  94. getDevMode,
  95. switchDevMode,
  96. getVideoLength,
  97. updateVideoLength,
  98. DirectPushIssueType,
  99. getCurIssueTypeList,
  100. addCurIssueTypeList,
  101. deleteCurIssueTypeList,
  102. } from '@/api/datamanagement/getDevMode';
  103. import { AlgoItem, getAllAlgosApi } from '@/api/camera/camera-preview';
  104. const userStore = useUserStore();
  105. const hasDevModePermisson = () => {
  106. return userStore.checkPermission('control_activation');
  107. };
  108. const hasDataDelete = () => {
  109. return userStore.checkPermission('data_delete');
  110. };
  111. const devMode = ref(true);
  112. const videoLength = ref(10);
  113. const videoLengthOptions = [10, 20, 40, 60];
  114. const tags = ref<DirectPushIssueType[]>([]);
  115. const isExpandAllExist = ref(false);
  116. const expandAll = ref(false);
  117. const options = ref<AlgoItem[]>([]);
  118. const optionValue = ref<number[]>([]);
  119. const handelSwitchDevMode = () => {
  120. switchDevMode();
  121. devMode.value = !devMode.value;
  122. };
  123. const updateNewVideoLength = () => {
  124. updateVideoLength(videoLength.value).then(() => {
  125. ElMessage({
  126. message: '报警视频截取长度设置成功',
  127. type: 'success',
  128. });
  129. });
  130. };
  131. const handleAddTags = async () => {
  132. await addCurIssueTypeList({ algoInfoIdList: optionValue.value });
  133. getCurOptions();
  134. };
  135. const handleDeleteTag = async (tag) => {
  136. optionValue.value.splice(optionValue.value.indexOf(tag.algoInfoId), 1);
  137. await deleteCurIssueTypeList(tag.id);
  138. getCurOptions();
  139. };
  140. const getCurDevMode = () => {
  141. getDevMode().then((res) => {
  142. devMode.value = res;
  143. });
  144. };
  145. const getCurVideoLength = () => {
  146. getVideoLength().then((res) => {
  147. videoLength.value = res;
  148. });
  149. };
  150. const getCurOptions = async () => {
  151. await getCurIssueTypeList().then((res) => {
  152. tags.value = res;
  153. res.forEach((item) => {
  154. optionValue.value.push(item.algoInfoId);
  155. optionValue.value = [...new Set(optionValue.value)];
  156. });
  157. });
  158. };
  159. const getAllOptions = () => {
  160. getAllAlgosApi().then((res) => {
  161. options.value = res;
  162. });
  163. };
  164. watch(
  165. () => tags.value,
  166. () => {
  167. nextTick(() => {
  168. const objDivID = document.getElementById('option-id');
  169. if (objDivID && objDivID.clientHeight > 35) {
  170. isExpandAllExist.value = true;
  171. } else {
  172. isExpandAllExist.value = false;
  173. }
  174. });
  175. },
  176. { immediate: true },
  177. );
  178. onMounted(() => {
  179. getCurDevMode();
  180. getCurVideoLength();
  181. getAllOptions();
  182. getCurOptions();
  183. });
  184. </script>
  185. <style scoped lang="less">
  186. .main-container {
  187. margin-bottom: 20px;
  188. padding-bottom: 5px;
  189. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  190. }
  191. .switch-container {
  192. display: flex;
  193. line-height: 33px;
  194. margin-bottom: 10px;
  195. .prequal-container {
  196. display: flex;
  197. margin-right: 30px;
  198. }
  199. }
  200. .options-container {
  201. display: flex;
  202. margin-bottom: 10px;
  203. .option-title {
  204. width: 130px;
  205. padding-top: 7px;
  206. }
  207. .option-tags {
  208. height: 100%;
  209. flex: 1;
  210. .option-tag {
  211. height: 28px;
  212. border: none;
  213. border-radius: 5px;
  214. margin: 3px 5px 4px 0;
  215. }
  216. }
  217. .hide-style {
  218. height: 35px;
  219. overflow: hidden;
  220. }
  221. .add-options {
  222. width: 100px;
  223. height: 28px;
  224. border-radius: 5px;
  225. background: rgba(0, 0, 0, 0.05);
  226. color: rgba(0, 0, 0, 0.5);
  227. display: inline-flex;
  228. align-items: center;
  229. justify-content: center;
  230. cursor: pointer;
  231. transition: all 0.4s;
  232. }
  233. .add-options:hover {
  234. background: rgba(0, 0, 0, 0.15);
  235. transform: scale(1.05);
  236. }
  237. .option-expand {
  238. padding-top: 7px;
  239. color: #1890ff;
  240. cursor: pointer;
  241. }
  242. }
  243. :deep(.el-select-dropdown__footer) {
  244. display: flex;
  245. align-items: flex-end;
  246. }
  247. </style>