algoManagement.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <PageWrapper>
  3. <div class="background">
  4. <div class="left">
  5. <el-input
  6. v-model="searchKey"
  7. placeholder="请输入算法信息搜索"
  8. style="margin-top: 24px; height: 32px; margin-bottom: 16px"
  9. :suffix-icon="Search"
  10. @change="searchItem"
  11. />
  12. <div class="algo-table">
  13. <el-table
  14. ref="singleTableRef"
  15. :data="algoList"
  16. highlight-current-row
  17. stripe
  18. style="width: 100%"
  19. height="100%"
  20. :row-style="{ height: '54px' }"
  21. :header-row-style="{ height: '54px' }"
  22. @row-click="handleRowClick"
  23. >
  24. <el-table-column property="id" label="序号" width="80" align="center" />
  25. <el-table-column property="code" label="算法编号" width="120" align="center" />
  26. <el-table-column property="name" label="算法名称" />
  27. </el-table>
  28. </div>
  29. <div style="display: flex; justify-content: flex-end">
  30. <el-pagination
  31. background
  32. layout="prev, pager, next"
  33. style="margin-top: 24px; height: 32px; margin-bottom: 34px"
  34. :total="total"
  35. v-model:current-page="curPage"
  36. @current-change="changePage"
  37. :page-size="pageSize"
  38. />
  39. </div>
  40. </div>
  41. <div class="right">
  42. <div class="right_top">
  43. <div class="top_left">
  44. <el-scrollbar height="100%">
  45. <div v-if="currentRow?.name == ''" class="details_title">请在左侧列表中选择算法</div>
  46. <div v-else class="details_title">{{ currentRow?.name }}检测算法展示</div>
  47. <div v-for="item in arrRemark" :key="item" class="textbox">
  48. <div class="item_title">{{ item }}</div>
  49. <!-- <div class="item_details">{{ currentRow?.remark }}</div> -->
  50. </div>
  51. <div class="textbox" style="justify-content: flex-start">
  52. <div class="item_title" style="width: auto">设置参数:</div>
  53. <ElTag v-for="tag in tags" :key="tag" class="mr-2">{{ labelNameMap[tag] }}</ElTag>
  54. </div>
  55. </el-scrollbar>
  56. </div>
  57. <div class="top_right">
  58. <video :src="currentRow?.url" controls autoplay muted style="width: 100%; height: 100%">
  59. </video>
  60. </div>
  61. </div>
  62. <div class="right_bottom">
  63. <div class="details_title" style="margin-bottom: 16px">报警推送编辑</div>
  64. <el-form :model="alarmConfig" size="default" :rules="rules" ref="ruleFormRef">
  65. <el-form-item label="语句编辑:" prop="pushStatement">
  66. <div class="pushStatement"
  67. >condition
  68. <div class="remark">时间:(示例:2023.10.23 10:55:28)</div>
  69. <div class="remark">地点:(示例:C919总装车间150A工位)</div>
  70. <el-input
  71. v-model="alarmConfig.pushStatement"
  72. style="width: 100%; height: 74px; margin-top: 4px"
  73. placeholder="示例:【异常类:未穿反光背心违规】您好,经安全管控平台分析,在该区域发现员工未穿反光背心或穿戴不规范的情况,请及时提醒。"
  74. />
  75. </div>
  76. </el-form-item>
  77. <el-form-item label="链接提示:" prop="pushLinkPrompt">
  78. <el-input
  79. v-model="alarmConfig.pushLinkPrompt"
  80. style="width: 100%"
  81. placeholder="示例:请点击商飞大脑-天眼APP查看。"
  82. />
  83. </el-form-item>
  84. <el-form-item>
  85. <el-button type="primary" :loading="isSending" @click="onSubmit"
  86. >保&nbsp;&nbsp;存</el-button
  87. >
  88. </el-form-item>
  89. </el-form>
  90. </div>
  91. </div>
  92. <!-- <video :src="address" controls autoplay muted style="width: 100%; height: 100%"> </video> -->
  93. </div>
  94. </PageWrapper>
  95. </template>
  96. <script lang="ts" setup>
  97. import { onMounted, ref, onUnmounted, reactive, watchEffect } from 'vue';
  98. import { PageWrapper } from '../../../components/Page';
  99. import useAlgo from './useAlgoData';
  100. import { Search } from '@element-plus/icons-vue';
  101. import type { FormInstance, FormRules } from 'element-plus';
  102. import { labelNameMap } from '../preview/components/AlgorithmsSetting/types';
  103. //调用后端数据
  104. const algoDatas = useAlgo();
  105. const {
  106. algoList,
  107. getAlgoDatas,
  108. page,
  109. total,
  110. pageSize,
  111. keyWord,
  112. searchAlgoDatas,
  113. algoId,
  114. pushLinkPrompt,
  115. pushStatement,
  116. modifyAlgoDatas,
  117. } = algoDatas;
  118. //将后端拉到的数据存到algoListUse数组中进行使用
  119. //刷新时从后端拉一次算法数组
  120. onMounted(() => {
  121. getAlgoDatas();
  122. });
  123. const changePage = () => {
  124. page.value = curPage.value;
  125. getAlgoDatas();
  126. };
  127. const searchItem = () => {
  128. keyWord.value = searchKey.value;
  129. curPage.value = 1;
  130. page.value = curPage.value;
  131. searchAlgoDatas();
  132. };
  133. const curPage = ref(1);
  134. const currentRow = ref({
  135. algoCode: '',
  136. name: '',
  137. remark: '',
  138. url: '',
  139. id: 0,
  140. pushLinkPrompt: '',
  141. pushStatement: '',
  142. extra: '',
  143. });
  144. interface User {
  145. algoCode: string;
  146. name: string;
  147. remark: string;
  148. url: string;
  149. id: number;
  150. pushLinkPrompt: string;
  151. pushStatement: string;
  152. extra: string;
  153. }
  154. const arrRemark = ref<string[]>([]);
  155. const tags = ref<string[]>([]);
  156. const handleRowClick = (val: User | undefined) => {
  157. tags.value = [];
  158. // console.log('xxxxxxxxxx', currentRow.value);
  159. currentRow.value = val || ({} as User);
  160. arrRemark.value = currentRow.value.remark.split('\r\n');
  161. // console.log('arrRemark', arrRemark.value);
  162. const extra = currentRow.value.extra;
  163. if (extra) {
  164. const extraObj = JSON.parse(extra);
  165. const params = extraObj?.inferParams;
  166. if (params && params.length > 0) {
  167. const metaObjs = params[0]?.metaObjs;
  168. if (metaObjs && metaObjs.length > 0) {
  169. tags.value = metaObjs.map((item) => item.label);
  170. }
  171. }
  172. }
  173. };
  174. const searchKey = ref('');
  175. interface SettingConfig {
  176. pushLinkPrompt: string;
  177. pushStatement: string;
  178. }
  179. const alarmConfig = ref<SettingConfig>({
  180. pushLinkPrompt: '',
  181. pushStatement: '',
  182. });
  183. const rules = ref<FormRules>({
  184. pushLinkPrompt: [{ required: true, message: '此处不可空缺' }],
  185. pushStatement: [{ required: true, message: '此处不可空缺' }],
  186. });
  187. const ruleFormRef = ref<FormInstance>();
  188. const isSending = ref(false);
  189. const onSubmit = async () => {
  190. if (!ruleFormRef.value) console.log('error submit!');
  191. await ruleFormRef.value?.validate((valid, fields) => {
  192. if (valid) {
  193. isSending.value = true;
  194. algoId.value = currentRow.value.id;
  195. pushLinkPrompt.value = alarmConfig.value.pushLinkPrompt;
  196. pushStatement.value = alarmConfig.value.pushStatement;
  197. // console.log('algoId', algoId.value);
  198. // console.log('pushStatement', pushStatement.value);
  199. // console.log('pushLinkPrompt', pushLinkPrompt.value);
  200. modifyAlgoDatas().finally(() => {
  201. isSending.value = false;
  202. });
  203. } else {
  204. console.log('error submit!', fields);
  205. }
  206. });
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. .background {
  211. position: relative;
  212. height: calc(100vh - 64px - 12px);
  213. background-color: #ffffff;
  214. display: flex;
  215. flex-direction: row;
  216. .left {
  217. position: relative;
  218. height: 100%;
  219. width: 31%;
  220. padding-left: 1.66%;
  221. padding-right: 1.33%;
  222. // background-color: green;
  223. border-right: #dddddd 1px solid;
  224. display: flex;
  225. flex-direction: column;
  226. .algo-table {
  227. position: relative;
  228. height: calc(100% - 72px - 90px);
  229. width: 100%;
  230. // background-color: red;
  231. // margin-top: 16px;
  232. }
  233. }
  234. .right {
  235. position: relative;
  236. height: 100%;
  237. width: 69%;
  238. display: flex;
  239. flex-direction: column;
  240. // background-color: yellow;
  241. .right_top {
  242. position: relative;
  243. height: 364px;
  244. width: 100%;
  245. display: flex;
  246. flex-direction: row;
  247. border-bottom: #dddddd 1px solid;
  248. // background-color: rebeccapurple;
  249. .top_left {
  250. position: relative;
  251. margin-top: 90px;
  252. margin-left: 4%;
  253. height: 234px;
  254. width: 42%;
  255. display: flex;
  256. flex-direction: column;
  257. // background-color: rebeccapurple;
  258. .details_title {
  259. position: relative;
  260. height: 22px;
  261. width: 100%;
  262. font-size: 14px;
  263. font-weight: 600;
  264. color: rgba(0, 0, 0, 0.85);
  265. line-height: 22px;
  266. }
  267. .textbox {
  268. position: relative;
  269. margin-top: 14px;
  270. width: 100%;
  271. display: flex;
  272. flex-direction: row;
  273. .item_title {
  274. position: relative;
  275. width: 100%;
  276. font-size: 14px;
  277. font-weight: 500;
  278. color: rgba(0, 0, 0, 0.85);
  279. line-height: 22px;
  280. }
  281. .item_details {
  282. position: relative;
  283. width: 79.8%;
  284. font-size: 14px;
  285. font-weight: 400;
  286. color: rgba(0, 0, 0, 0.85);
  287. line-height: 22px;
  288. }
  289. }
  290. }
  291. .top_right {
  292. position: relative;
  293. margin-top: 90px;
  294. margin-left: 4%;
  295. height: 234px;
  296. width: 45%;
  297. display: flex;
  298. flex-direction: row;
  299. // background-color: rebeccapurple;
  300. }
  301. }
  302. .right_bottom {
  303. position: relative;
  304. margin-left: 4%;
  305. margin-top: 24px;
  306. width: 91%;
  307. display: flex;
  308. flex-direction: column;
  309. .details_title {
  310. position: relative;
  311. height: 22px;
  312. width: 100%;
  313. font-size: 14px;
  314. font-weight: 600;
  315. color: rgba(0, 0, 0, 0.85);
  316. line-height: 22px;
  317. }
  318. }
  319. }
  320. }
  321. .pushStatement {
  322. position: relative;
  323. display: flex;
  324. flex-direction: column;
  325. height: 155px;
  326. width: 100%;
  327. // background-color: red;
  328. .remark {
  329. position: relative;
  330. height: 22px;
  331. width: 100%;
  332. margin-top: 4px;
  333. margin-left: 10px;
  334. margin-bottom: 12px;
  335. font-size: 16px;
  336. font-weight: 400;
  337. color: rgba(0, 0, 0, 0.42);
  338. line-height: 22px;
  339. }
  340. }
  341. :deep() {
  342. .el-input__wrapper {
  343. align-items: flex-start !important;
  344. }
  345. .el-form-item__content {
  346. justify-content: flex-end;
  347. }
  348. }
  349. </style>