AddCameraByRange.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div style="width: 100%">
  3. <div class="flex flex-col items-center add-body">
  4. <el-form
  5. class="range-form"
  6. :inline="true"
  7. :model="cameraRangeData"
  8. :rules="rules"
  9. label-width="84px"
  10. label-position="left"
  11. >
  12. <el-form-item
  13. v-for="item in cameraRangeAddForm"
  14. :key="item.prop"
  15. :label="item.label"
  16. :prop="item.prop"
  17. :label-width="item.labelWidth"
  18. >
  19. <el-input
  20. v-if="item.type === 'input'"
  21. v-model="cameraRangeData[item.prop]"
  22. :placeholder="item.placeholder"
  23. style="width: 200px"
  24. />
  25. <el-select
  26. v-if="item.type === 'select'"
  27. v-model="cameraRangeData[item.prop]"
  28. :placeholder="item.placeholder"
  29. style="width: 200px"
  30. >
  31. <el-option
  32. v-for="protocal in item.option"
  33. :key="protocal.value"
  34. :label="protocal.label"
  35. :value="protocal.value"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. </el-form>
  40. <div class="flex justify-end" style="width: 100%">
  41. <el-button type="primary" class="btn-r" @click="searchRangeCamera">搜索</el-button>
  42. </div>
  43. <div class="search-list">
  44. <BasicTable
  45. style="height: 274px"
  46. :columns="columns"
  47. :data-source="cameraItems"
  48. :row-key="(row) => row.name"
  49. :action-column="actionColumn"
  50. :pagination="false"
  51. :tableSetting="{
  52. size: false,
  53. redo: false,
  54. fullscreen: false,
  55. striped: false,
  56. setting: false,
  57. }"
  58. :row-class-name="getRowClassName"
  59. ref="tableRef"
  60. @order-change="orderByItem"
  61. @selection-change="handleSelectionChange"
  62. >
  63. <template #empty>
  64. <div class="empty-content flex flex-col items-center">
  65. <img :src="emptyImg" class="empty-img" />
  66. <span class="empty-text">目前无内容,请先添加相机</span>
  67. </div>
  68. </template>
  69. </BasicTable>
  70. </div>
  71. <EditCamera v-model="showEditPop" style="z-index: 9" :edit-data="editRow" />
  72. </div>
  73. <span class="pop-footer">
  74. <el-button @click="handleCancel">取消</el-button>
  75. <el-button type="primary" @click="handleConfirm">确定</el-button>
  76. </span>
  77. </div>
  78. </template>
  79. <script setup lang="ts">
  80. import { computed, h, reactive, ref } from 'vue';
  81. import { CameraRangeItem, CameraIPItem } from '../type';
  82. import { cameraRangeAddForm } from '../constant';
  83. import SearchCamerasAction from './SearchCamerasAction.vue';
  84. import { BasicTable } from '@/components/Table';
  85. import { BasicColumn } from '@/components/Table';
  86. import { columns } from '../searchRangeColumns';
  87. import emptyImg from '@/assets/images/table/table-empty.png';
  88. import editIcon from '@/assets/images/table/table-edit.png';
  89. import deleteIcon from '@/assets/images/table/table-delete.png';
  90. import EditCamera from './CameraEditPopover.vue';
  91. const emits = defineEmits(['cancel-execute', 'confirm-execute']);
  92. const cameraRangeData = ref<CameraRangeItem>({} as CameraRangeItem);
  93. const showEditPop = ref(false);
  94. const editRow = ref<CameraIPItem | null>(null);
  95. const rules = computed(() => {
  96. const newRule = {};
  97. cameraRangeAddForm.forEach((item) => {
  98. if (item.required) {
  99. newRule[item.prop] = item.rule;
  100. }
  101. });
  102. return newRule;
  103. });
  104. //操作列
  105. const actionColumn: BasicColumn = reactive({
  106. width: 150,
  107. title: '操作',
  108. prop: 'action',
  109. key: 'action',
  110. fixed: 'right',
  111. render(record) {
  112. return h(SearchCamerasAction as any, {
  113. activeColor: '#629bf9',
  114. unactiveColor: 'rgba(0,0,0,0.4)',
  115. tableTextActions: [
  116. {
  117. label: '添加',
  118. disabled: false,
  119. onclick: handleAdd.bind(null, record.row),
  120. },
  121. ],
  122. tableIconActions: {
  123. space: 10,
  124. color: '#629bf9',
  125. style: 'img',
  126. size: 16,
  127. actionIcons: [
  128. {
  129. label: '编辑',
  130. icon: editIcon,
  131. onClick: handleEdit.bind(null, record.row),
  132. },
  133. {
  134. label: '删除',
  135. icon: deleteIcon,
  136. onClick: handleDelete.bind(null, record.row),
  137. },
  138. ],
  139. },
  140. });
  141. },
  142. });
  143. const getRowClassName = (record) => {
  144. return record.row.name !== 'SHGD-XDJS-0003' ? 'warm-row' : '';
  145. };
  146. const cameraItems = reactive([
  147. {
  148. cameraIp: '10.10.10.10',
  149. protocal: '海康威视',
  150. cameraPort: '8080',
  151. mac: '255.255.255.255',
  152. name: 'SHGD-XDJS-0001',
  153. workshopId: 'ARJ21部装车间',
  154. workspaceId: '200工位',
  155. networkState: 1,
  156. status: 1,
  157. },
  158. {
  159. cameraIp: '10.10.10.10',
  160. protocal: '海康威视',
  161. cameraPort: '8080',
  162. mac: '255.255.255.255',
  163. name: 'SHGD-XDJS-0002',
  164. workshopId: 'ARJ21部装车间',
  165. workspaceId: '200工位',
  166. networkState: 1,
  167. status: 1,
  168. },
  169. {
  170. cameraIp: '10.10.10.10',
  171. protocal: '海康威视',
  172. cameraPort: '8080',
  173. mac: '255.255.255.255',
  174. name: 'SHGD-XDJS-0003',
  175. workshopId: 'ARJ21部装车间',
  176. workspaceId: '200工位',
  177. networkState: 1,
  178. status: 1,
  179. },
  180. {
  181. cameraIp: '10.10.10.10',
  182. protocal: '海康威视',
  183. cameraPort: '8080',
  184. mac: '255.255.255.255',
  185. name: 'SHGD-XDJS-0004',
  186. workshopId: 'ARJ21部装车间',
  187. workspaceId: '200工位',
  188. networkState: 1,
  189. status: 1,
  190. },
  191. {
  192. cameraIp: '10.10.10.10',
  193. protocal: '海康威视',
  194. cameraPort: '8080',
  195. mac: '255.255.255.255',
  196. name: 'SHGD-XDJS-0005',
  197. workshopId: 'ARJ21部装车间',
  198. workspaceId: '200工位',
  199. networkState: 1,
  200. status: 1,
  201. },
  202. ]);
  203. const searchRangeCamera = () => {};
  204. // 列排序操作
  205. const orderByItem = () => {};
  206. const handleSelectionChange = (val: any[]) => {
  207. console.log(val);
  208. };
  209. const handleAdd = () => {};
  210. const handleDelete = () => {};
  211. const handleEdit = (row) => {
  212. showEditPop.value = true;
  213. editRow.value = row;
  214. };
  215. const handleCancel = () => {
  216. emits('cancel-execute');
  217. };
  218. const handleConfirm = () => {};
  219. </script>
  220. <style scoped>
  221. .add-body {
  222. width: 100%;
  223. }
  224. .range-form {
  225. width: 1082px;
  226. display: flex;
  227. flex-wrap: wrap;
  228. justify-content: space-between;
  229. align-content: space-around;
  230. margin-bottom: -12px;
  231. }
  232. .btn-r {
  233. margin-right: 24px;
  234. }
  235. .search-list {
  236. width: 100%;
  237. height: 300px;
  238. padding: 0 28px;
  239. margin-bottom: 40px;
  240. }
  241. .pop-footer {
  242. position: absolute;
  243. right: 24px;
  244. bottom: 27px;
  245. display: flex;
  246. justify-content: flex-end;
  247. }
  248. :deep(.el-form-item__label) {
  249. font-size: 14px;
  250. color: #363636;
  251. padding: 0;
  252. }
  253. :deep(.el-form--inline .el-form-item) {
  254. display: flex;
  255. margin-right: 0;
  256. margin-bottom: 28px;
  257. }
  258. :deep(.el-table .warm-row) {
  259. background: #f9e6e5 !important;
  260. --el-table-row-hover-bg-color: none;
  261. --el-bg-color: none;
  262. }
  263. </style>