algoManagement.vue 9.9 KB

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