door-content-r.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div class="door-content-r">
  3. <div class="content-r-btn">
  4. <a-button type="primary" @click="handlerOpenOrClose('open')">
  5. <SvgIcon class="icon-style" size="14" color="#30b3fc" name="open-door" />
  6. 同步开启
  7. </a-button>
  8. <a-button type="primary" style="margin: 0px 10px" @click="handlerOpenOrClose('close')">
  9. <SvgIcon class="icon-style" size="14" color="#30b3fc" name="close-door" />
  10. 同步关闭
  11. </a-button>
  12. <a-button type="primary" @click="handlerTimeSet">
  13. <SvgIcon class="icon-style" size="14" color="#30b3fc" name="time-setting-door" />
  14. 定时设置
  15. </a-button>
  16. <a-button style="margin: 0px 10px" type="primary" @click="handlerOperation">操作日志</a-button>
  17. </div>
  18. <div class="content-r-container">
  19. <div class="content-r-box" v-for="(item, index) in infoDatas" :key="index">
  20. <div class="box-title">
  21. <div class="title-text">{{ item.strinstallpos }}</div>
  22. <div class="title-detail" @click="handlerDetail(item.deviceID)">详情</div>
  23. </div>
  24. <div class="box-content">
  25. <!-- 二三维信息 -->
  26. <!-- <gateDualSVG v-if="item.ndoorcount == '2'" :ref="`modelRef${index}`" :indexCode="index"></gateDualSVG>
  27. <gateSVG v-if="item.ndoorcount == '1'" :ref="`modelRef${index}`" :indexCode="index"></gateSVG> -->
  28. <!-- <component :ref="`modelRef${index}`" :indexCode="index"
  29. :is="getModelComponent(globalConfig.is2DModel, item.deviceType)" /> -->
  30. <gateDualSVG v-if="item.ndoorcount == '2'" :ref="(el) => setChildRef(el, index)" :indexCode="index">
  31. </gateDualSVG>
  32. <gateSVG v-if="item.ndoorcount == '1'" :ref="(el) => setChildRef(el, index)" :indexCode="index"></gateSVG>
  33. </div>
  34. <img src="@/assets/images/camera.png" alt="" @click="handlerCamera(item, index)" />
  35. </div>
  36. </div>
  37. <!-- 同步开启/关闭弹窗 -->
  38. <syncModal :visible="visible" @handleCancel="handleCancel" @handleOk="handleOk"></syncModal>
  39. <!-- 定时设置弹窗 -->
  40. <timeSetModal :visibleTime="visibleTime" @handleCancelTime="handleCancelTime" @handleOk="handleOkTime">
  41. </timeSetModal>
  42. <!--30s延时提示弹窗-->
  43. <tipModal></tipModal>
  44. <!-- 摄像头信息 -->
  45. <Modal :visible="modalVisible" :centered="true" :destroyOnClose="true" @cancel="handleCancelCamera">
  46. <CameraModal :cameraData="cameraData"></CameraModal>
  47. </Modal>
  48. <!-- 操作日志 -->
  49. <operationModal :visible="visibleOperation" @handleCancel="handleCancelOperation">
  50. </operationModal>
  51. </div>
  52. </template>
  53. <script setup lang="ts">
  54. import { reactive, ref, inject, watch, nextTick } from 'vue';
  55. import syncModal from './syncModal.vue';
  56. import timeSetModal from './timeSetModal.vue';
  57. import CameraModal from './cameraModal.vue';
  58. import Modal from './Modal.vue';
  59. import tipModal from './tipModal.vue'
  60. import gateDualSVG from './gateDualSVG.vue'
  61. import gateSVG from './gateSVG.vue'
  62. import operationModal from './operationModal.vue'
  63. import { useRouter } from 'vue-router';
  64. import { devicecontrol, insertSyncRule, GetSyncRule } from '../airdoor.api'
  65. // import { getModelComponent } from '../airdoor.data'
  66. import { useMessage } from '/@/hooks/web/useMessage';
  67. import { SvgIcon } from '/@/components/Icon';
  68. import { getDictItemsByCode } from '/@/utils/dict';
  69. let props = defineProps({
  70. infoData: {
  71. type: Array,
  72. default: () => {
  73. return [];
  74. },
  75. },
  76. });
  77. const { createMessage } = useMessage();
  78. const globalConfig = inject<any>('globalConfig');
  79. let router = useRouter();
  80. let infoDatas = ref<any[]>([])
  81. //同步开启/关闭弹窗-控制显示与隐藏
  82. let visible = ref(false);
  83. let visibleStatus = ref('')
  84. //设置定时弹窗-控制显示与影藏
  85. let visibleTime = ref(false);
  86. let Ids = ref('')
  87. //摄像头-控制显示与隐藏
  88. let modalVisible = ref(false);
  89. let cameraData = reactive({})
  90. //操作日志弹窗显示/关闭
  91. let visibleOperation = ref(false)
  92. const childRefs = ref<any[]>([])
  93. const setChildRef = (el, index) => {
  94. childRefs.value[index] = el
  95. }
  96. //同步开启/关闭--弹窗
  97. function handlerOpenOrClose(data) {
  98. visible.value = true;
  99. visibleStatus.value = data
  100. }
  101. //确定
  102. async function handleOk(param) {
  103. let deviceStr = infoDatas.value.map(v => v.deviceID).join(',')
  104. let paramcode = visibleStatus.value == 'open' ? 'sameTimeOpen' : 'sameTimeClose'
  105. let res = await devicecontrol({ deviceids: deviceStr, paramcode: paramcode, password: param.pass || globalConfig?.simulatedPassword })
  106. if (res) {
  107. visible.value = param.visib
  108. visibleStatus.value = ''
  109. }
  110. }
  111. //取消
  112. function handleCancel(param) {
  113. visible.value = param;
  114. visibleStatus.value = ''
  115. }
  116. //定时设置
  117. async function handlerTimeSet() {
  118. visibleTime.value = true;
  119. let res = await GetSyncRule({})
  120. Ids.value = res[0]['id'] || ''
  121. console.log(res, '读取规则')
  122. }
  123. //确定
  124. async function handleOkTime(param) {
  125. console.log(param, '定时参数---')
  126. let start_time = `${param.formState.hourS}:${param.formState.minuteS}:${param.formState.secondS}`
  127. let end_time = `${param.formState.hourE}:${param.formState.minuteE}:${param.formState.secondE}`
  128. let enabled = param.formState.checked ? '1' : '0'
  129. let res = await insertSyncRule({ startTime: start_time, endTime: end_time, enabled: enabled, id: Ids.value, password: param.formState.passWord })
  130. console.log(res, '设置定时---')
  131. if (res) {
  132. visibleTime.value = param.visib
  133. Ids.value = ''
  134. createMessage.success('设置定时成功!');
  135. }
  136. }
  137. //取消
  138. function handleCancelTime(param) {
  139. visibleTime.value = param;
  140. }
  141. //详情跳转
  142. function handlerDetail(id) {
  143. router.push(`/monitorChannel/monitor-gate?id=${id}&deviceType=gate`);
  144. }
  145. //摄像头切换
  146. function handlerCamera(item, index) {
  147. modalVisible.value = true;
  148. cameraData = Object.assign({}, item)
  149. }
  150. //摄像头弹窗关闭
  151. function handleCancelCamera(param) {
  152. modalVisible.value = param;
  153. }
  154. //操作日志弹窗-打开
  155. function handlerOperation() {
  156. visibleOperation.value = true
  157. }
  158. //操作日志弹窗-关闭
  159. function handleCancelOperation(param) {
  160. visibleOperation.value = param
  161. }
  162. //模型动画
  163. function monitorAnimation(selectData, index) {
  164. childRefs.value[index]?.animate?.(selectData.frontGateOpen == '1', selectData.midGateOpen == '1', selectData.rearGateOpen == '1');
  165. }
  166. function getInitSvg() {
  167. const dictCodes = getDictItemsByCode('gateStyle');
  168. console.log(dictCodes, 'dictCodes---')
  169. }
  170. watch(() => props.infoData, (newV, oldV) => {
  171. console.log(newV, 'new---')
  172. infoDatas.value = newV
  173. if (newV.length) {
  174. getInitSvg()
  175. nextTick(() => {
  176. newV.forEach((el: any, index: number) => {
  177. el = Object.assign(el, el.readData)
  178. monitorAnimation(el, index);
  179. })
  180. })
  181. }
  182. })
  183. </script>
  184. <style lang="less" scoped>
  185. @import '/@/design/theme.less';
  186. @{theme-deepblue} {
  187. .door-content-r {
  188. --image-camera_bg: url('/@/assets/images/themify/deepblue/vent/camera_bg.png');
  189. --image-btn: url(/@/assets/images/themify/deepblue/files/details/btn.png);
  190. }
  191. }
  192. .door-content-r {
  193. --image-camera_bg: url('/@/assets/images/vent/camera_bg.png');
  194. --image-btn: url(/@/assets/images/files/details/btn.png);
  195. width: 100%;
  196. height: 100%;
  197. .icon-style {
  198. margin-right: 5px;
  199. }
  200. .content-r-btn {
  201. width: 100%;
  202. height: 40px;
  203. padding: 0px 10px;
  204. display: flex;
  205. // align-items: center;
  206. }
  207. .content-r-container {
  208. width: 100%;
  209. height: calc(100% - 40px);
  210. display: flex;
  211. justify-content: flex-start;
  212. flex-wrap: wrap;
  213. .content-r-box {
  214. position: relative;
  215. width: 376px;
  216. height: 270px;
  217. margin: 10px 5px;
  218. background: var(--image-camera_bg);
  219. background-size: 100% 100%;
  220. .box-title {
  221. position: absolute;
  222. left: 50%;
  223. top: 12px;
  224. transform: translate(-50%, 0);
  225. width: 95%;
  226. height: 28px;
  227. line-height: 28px;
  228. text-align: center;
  229. color: #fff;
  230. background-color: rgba(51, 211, 255, 0.2);
  231. }
  232. .title-detail {
  233. position: absolute;
  234. right: 12px;
  235. top: 0px;
  236. color: rgba(60, 242, 255);
  237. font-size: 12px;
  238. cursor: pointer;
  239. }
  240. .box-content {
  241. position: absolute;
  242. left: 50%;
  243. top: 40px;
  244. transform: translate(-50%, 0);
  245. width: 95%;
  246. height: calc(100% - 40px);
  247. }
  248. img {
  249. position: absolute;
  250. right: 20px;
  251. bottom: 15px;
  252. width: 20px;
  253. height: 20px;
  254. cursor: pointer;
  255. }
  256. }
  257. }
  258. }
  259. ::v-deep .zxm-btn-primary {
  260. background-color: transparent;
  261. border: none;
  262. background: var(--image-btn) no-repeat !important;
  263. background-size: 100% 100% !important;
  264. }
  265. </style>