actionSerialItem.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="type-item">
  3. <div v-for="(item, index) in serial" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
  4. <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red"
  5. v-if="index > 0">
  6. <el-icon @click="delScene(index)">
  7. <CircleClose />
  8. </el-icon>
  9. </div>
  10. <div class="product flex flex-warp">
  11. <el-form-item label="动作类型:" prop="actionType">
  12. <el-select v-model="item.actionType" filterable clearable placeholder="请选择动作类型" @change="saveData">
  13. <el-option v-for="it in sence_action_type" :key="it.value" :label="it.label" :value="it.value">
  14. <span style="float: left">{{ it.label }}</span>
  15. <span style="float: right; font-size: 13px">{{ it.value }}</span>
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <DeviceOut :index="index" :data="serial[index]" :sourceData="sourceData" v-if="item.actionType==='deviceOutput' && serial[index] && sourceData.length>0" @SetSaveData="SetSaveData"></DeviceOut>
  20. <SendNotice :index="index" :data="serial[index]" v-if="item.actionType==='sendNotice' && serial[index]" @SetSaveData="SetSaveData"></SendNotice>
  21. <CallWebService :index="index" :data="serial[index]" v-if="item.actionType==='callWebService' && serial[index]" @SetSaveData="SetSaveData"></CallWebService>
  22. <TriggerAlarm :index="index" :data="serial[index]" v-if="item.actionType==='triggerAlarm' && serial[index]" @SetSaveData="SetSaveData"></TriggerAlarm>
  23. <DelayExecution :index="index" :data="serial[index]" v-if="item.actionType==='delayExecution' && serial[index]" @SetSaveData="SetSaveData"></DelayExecution>
  24. <TriggerCustomEvent :index="index" :data="serial[index]" v-if="item.actionType==='triggerCustomEvent' && serial[index]" @SetSaveData="SetSaveData"></TriggerCustomEvent>
  25. </div>
  26. </div>
  27. <div>
  28. <div class=" flex-center">
  29. <el-button :icon="DocumentAdd" @click="addScene()"
  30. style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script lang="ts" setup>
  36. import { PropType, ref, watch, getCurrentInstance } from 'vue'
  37. import { DocumentAdd, CircleClose } from '@element-plus/icons-vue';
  38. import DeviceOut from './actionType/deviceOut.vue';
  39. import SendNotice from './actionType/sendNotice.vue';
  40. import CallWebService from './actionType/callWebService.vue';
  41. import TriggerAlarm from './actionType/triggerAlarm.vue';
  42. import DelayExecution from './actionType/delayExecution.vue';
  43. import TriggerCustomEvent from './actionType/triggerCustomEvent.vue';
  44. const emit = defineEmits(['addScenesDetail', 'delData', 'saveData']);
  45. const { proxy } = getCurrentInstance() as any;
  46. const { sence_action_type } = proxy.useDict('sence_action_type');
  47. interface IValueType {
  48. actionType?:string;
  49. }
  50. interface testIValueType {
  51. key?: string;
  52. name?: string;
  53. }
  54. const props = defineProps({
  55. serial: {
  56. type: Array as PropType<IValueType[]>,
  57. default: () => []
  58. },
  59. sourceData: {
  60. type: Array as PropType<testIValueType[]>,
  61. default: () => []
  62. },
  63. index: {
  64. type: Number ,
  65. default: () => []
  66. }
  67. })
  68. const serialValue = ref(props.serial);
  69. const saveData=()=>{
  70. let newData={
  71. index:props.index,
  72. data:props.serial,
  73. }
  74. emit('saveData',newData);
  75. }
  76. watch(() => props.serial, (newSerial) => {
  77. serialValue.value = newSerial;
  78. });
  79. const SetSaveData = (data:any) => {
  80. serialValue.value[data.index] = data.data;
  81. let newData={
  82. index:props.index,
  83. data:serialValue.value,
  84. }
  85. emit('saveData', newData);
  86. }
  87. const addScene = () => {
  88. props.serial.push({
  89. 'actionType': '',
  90. });
  91. };
  92. const delScene = (index: number) => {
  93. props.serial.splice(index, 1);
  94. let newData={
  95. index:props.index,
  96. data:props.serial,
  97. }
  98. emit('saveData',newData);
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .type-item {
  103. width: 100%;
  104. .edit {
  105. margin-left: 10px;
  106. color: #2041d4;
  107. }
  108. .conicon {
  109. width: 55px;
  110. height: 25px;
  111. font-size: 28px;
  112. line-height: 28px;
  113. cursor: pointer;
  114. }
  115. .item {
  116. margin-bottom: 20px;
  117. }
  118. .biankang {
  119. border-top: 1px solid #d6d6d6;
  120. // border-radius: 10px;
  121. }
  122. .title {
  123. height: 40px;
  124. .icon {
  125. margin-left: 2px;
  126. margin-right: 10px;
  127. width: 5px;
  128. height: 20px;
  129. background-color: #315efb;
  130. }
  131. }
  132. .product {
  133. margin-bottom: 20px;
  134. :deep(.el-form-item) {
  135. margin-left: 30px;
  136. margin-bottom: 10px;
  137. }
  138. }
  139. }
  140. </style>